diff --git a/cmake/clang_warnings.cmake b/cmake/clang_warnings.cmake index 0843707..b8a8171 100644 --- a/cmake/clang_warnings.cmake +++ b/cmake/clang_warnings.cmake @@ -28,7 +28,7 @@ # * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # */ -set(MCC_WARNING_FLAGS +set(WARNING_FLAGS # From Xcode default project # -Wno-sign-conversion diff --git a/cmake/doxygen.cmake b/cmake/doxygen.cmake index fc5dff8..525230f 100644 --- a/cmake/doxygen.cmake +++ b/cmake/doxygen.cmake @@ -51,4 +51,3 @@ if (DOXYGEN_FOUND) else (DOXYGEN_FOUND) message("Doxygen need to be installed to generate the doxygen documentation") endif (DOXYGEN_FOUND) - diff --git a/cmake/env.cmake b/cmake/env.cmake index 0b263ec..e8a54b7 100644 --- a/cmake/env.cmake +++ b/cmake/env.cmake @@ -32,11 +32,11 @@ #set(CMAKE_VERBOSE_MAKEFILE ON) # Pathes -if(NOT MCC_DEV) - get_filename_component(MCC_DEV "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +if(NOT DEV) + get_filename_component(DEV "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) endif() -set(MCC_CMAKE ${MCC_DEV}/cmake) +set(CMAKE ${DEV}/cmake) # Force C++17 set(CMAKE_CXX_STANDARD 17) @@ -45,46 +45,31 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(USE_CLANG false) -if (CMAKE_CXX_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]") #Case insensitive match - set(USE_CLANG true) -else() - set(USE_CLANG false) -endif() - -set(USE_GCC false) -if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set(USE_GCC true) -else() - set(USE_GCC false) -endif() - # Warning flags -if(USE_CLANG) -include(${MCC_CMAKE}/clang_warnings.cmake) +# Case insensitive match +if(CMAKE_CXX_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]") + include(${CMAKE}/clang_warnings.cmake) -set(MCC_WARNING_FLAGS_SPACED "") - foreach(MCC_WARNING_FLAG ${MCC_WARNING_FLAGS}) - set(MCC_WARNING_FLAGS_SPACED "${MCC_WARNING_FLAGS_SPACED} ${MCC_WARNING_FLAG}") -endforeach() + set(WARNING_FLAGS_SPACED "") + foreach(WARNING_FLAG ${WARNING_FLAGS}) + set(WARNING_FLAGS_SPACED "${WARNING_FLAGS_SPACED} ${WARNING_FLAG}") + endforeach() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Werror") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MCC_WARNING_FLAGS_SPACED}") -endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_SPACED}") -if(USE_GCC) - include(${MCC_CMAKE}/gcc_warnings.cmake) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + include(${CMAKE}/gcc_warnings.cmake) -set(MCC_WARNING_FLAGS_SPACED "") - foreach(MCC_WARNING_FLAG ${MCC_WARNING_FLAGS}) - set(MCC_WARNING_FLAGS_SPACED "${MCC_WARNING_FLAGS_SPACED} ${MCC_WARNING_FLAG}") -endforeach() + set(WARNING_FLAGS_SPACED "") + foreach(WARNING_FLAG ${WARNING_FLAGS}) + set(WARNING_FLAGS_SPACED "${WARNING_FLAGS_SPACED} ${WARNING_FLAG}") + endforeach() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MCC_WARNING_FLAGS_SPACED}") -endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS_SPACED}") -if(MSVC) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # Force to always compile with W4 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX") if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") @@ -97,7 +82,7 @@ add_compile_options("$<$:-DDEBUG>") set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Project modules/variables -set(CMAKE_MODULE_PATH ${MCC_CMAKE}/modules) +set(CMAKE_MODULE_PATH ${CMAKE}/modules) # Includes -include(${MCC_CMAKE}/find_package.cmake) +include(${CMAKE}/find_package.cmake) diff --git a/cmake/gcc_warnings.cmake b/cmake/gcc_warnings.cmake index f514510..49fb40b 100644 --- a/cmake/gcc_warnings.cmake +++ b/cmake/gcc_warnings.cmake @@ -28,7 +28,7 @@ # * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # */ -set(MCC_WARNING_FLAGS +set(WARNING_FLAGS # -Wno-unknown-pragmas ) diff --git a/examples/cpuinfo/CMakeLists.txt b/examples/cpuinfo/CMakeLists.txt index 4c70d65..a063946 100644 --- a/examples/cpuinfo/CMakeLists.txt +++ b/examples/cpuinfo/CMakeLists.txt @@ -30,10 +30,8 @@ project(cpuinfo) -include_directories(../../source) - -add_executable(cpuinfo +add_executable(${PROJECT_NAME} main.cpp ) -target_link_libraries(cpuinfo PRIVATE modern.cpp.core) +target_link_libraries(${PROJECT_NAME} PRIVATE modern.cpp.core) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 45544bd..680cfc1 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -30,7 +30,7 @@ project(modern.cpp.core) -add_library(modern.cpp.core +add_library(${PROJECT_NAME} ../README.md CPU.cpp CPU.h @@ -45,3 +45,5 @@ add_library(modern.cpp.core templates/CSVWriter.h templates/Timer.h ) + +target_include_directories(${PROJECT_NAME} PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/templates)