update cmake
This commit is contained in:
parent
9faad26eb1
commit
09864fe578
3 changed files with 32 additions and 33 deletions
|
@ -1,18 +1,10 @@
|
||||||
cmake_minimum_required(VERSION 3.2)
|
cmake_minimum_required(VERSION 3.6)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
project(nameof VERSION "0.3.0" LANGUAGES CXX)
|
||||||
|
|
||||||
project(nameof LANGUAGES CXX)
|
|
||||||
set(${PROJECT_NAME}_version "0.5.0")
|
|
||||||
set(package_name ${PROJECT_NAME})
|
|
||||||
set(include_source_dir "${CMAKE_SOURCE_DIR}/include")
|
|
||||||
|
|
||||||
option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" ON)
|
option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" ON)
|
||||||
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" ON)
|
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" ON)
|
||||||
|
|
||||||
add_library(${package_name} INTERFACE)
|
|
||||||
target_include_directories(${package_name} INTERFACE "$<BUILD_INTERFACE:${include_source_dir}>")
|
|
||||||
|
|
||||||
if(NAMEOF_OPT_BUILD_EXAMPLES)
|
if(NAMEOF_OPT_BUILD_EXAMPLES)
|
||||||
add_subdirectory(example)
|
add_subdirectory(example)
|
||||||
endif()
|
endif()
|
||||||
|
@ -21,5 +13,3 @@ if(NAMEOF_OPT_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
set(SOURCES example.cpp ${CMAKE_SOURCE_DIR}/include/nameof.hpp)
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
set(OPTIONS "")
|
||||||
|
|
||||||
add_executable(example ${SOURCES})
|
|
||||||
|
|
||||||
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
target_compile_options(example PRIVATE -Wall -Wextra -pedantic-errors)
|
set(OPTIONS -Wall -Wextra -pedantic-errors)
|
||||||
target_compile_options(example PRIVATE -std=c++11)
|
set(OPTIONS ${OPTIONS} -std=c++11)
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
target_compile_options(example PRIVATE /W4)
|
set(OPTIONS /W4)
|
||||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.11)
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.11)
|
||||||
target_compile_options(example PRIVATE /permissive-)
|
set(OPTIONS ${OPTIONS} /permissive-)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_executable(example
|
||||||
|
example.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/include/nameof.hpp)
|
||||||
|
target_compile_options(example PRIVATE ${OPTIONS})
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
set(SOURCES test.cpp)
|
include_directories(3rdparty/Catch2)
|
||||||
|
|
||||||
include_directories(3rdparty/Catch2)
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
set(SOURCES test.cpp)
|
||||||
|
|
||||||
set(OPTIONS "")
|
set(OPTIONS "")
|
||||||
|
|
||||||
set(HAS_CPP11_FLAG FALSE)
|
set(HAS_CPP11_FLAG FALSE)
|
||||||
|
@ -14,6 +14,8 @@ set(HAS_CPPLATEST_FLAG FALSE)
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
set(OPTIONS /W4)
|
set(OPTIONS /W4)
|
||||||
|
|
||||||
|
set(HAS_CPP11_FLAG TRUE)
|
||||||
|
|
||||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.00)
|
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.00)
|
||||||
set(HAS_CPP14_FLAG TRUE)
|
set(HAS_CPP14_FLAG TRUE)
|
||||||
set(HAS_CPPLATEST_FLAG TRUE)
|
set(HAS_CPPLATEST_FLAG TRUE)
|
||||||
|
@ -23,6 +25,8 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
set(HAS_CPP17_FLAG TRUE)
|
set(HAS_CPP17_FLAG TRUE)
|
||||||
set(OPTIONS ${OPTIONS} /permissive-)
|
set(OPTIONS ${OPTIONS} /permissive-)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(OPTIONS ${OPTIONS} /wd4702) # Disable warning C4702: unreachable code
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
set(OPTIONS -Wall -Wextra -pedantic-errors)
|
set(OPTIONS -Wall -Wextra -pedantic-errors)
|
||||||
|
@ -65,15 +69,17 @@ function(make_target target std)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
if(HAS_CPP11_FLAG)
|
if(HAS_CPP11_FLAG)
|
||||||
make_target(nameof-cpp11.t c++11)
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
make_target(${CMAKE_PROJECT_NAME}-cpp11.t "")
|
||||||
make_target(nameof-cpp11.t "")
|
else()
|
||||||
|
make_target(${CMAKE_PROJECT_NAME}-cpp11.t c++11)
|
||||||
|
endif()
|
||||||
|
add_test(NAME ${CMAKE_PROJECT_NAME}-cpp11.t COMMAND ${CMAKE_PROJECT_NAME}-cpp11.t)
|
||||||
endif()
|
endif()
|
||||||
add_test(NAME nameof-cpp11.t COMMAND nameof-cpp11.t)
|
|
||||||
|
|
||||||
if(HAS_CPP14_FLAG)
|
if(HAS_CPP14_FLAG)
|
||||||
make_target(nameof-cpp14.t c++14)
|
make_target(${CMAKE_PROJECT_NAME}-cpp14.t c++14)
|
||||||
add_test(NAME nameof-cpp14.t COMMAND nameof-cpp14.t)
|
add_test(NAME ${CMAKE_PROJECT_NAME}-cpp14.t COMMAND ${CMAKE_PROJECT_NAME}-cpp14.t)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAS_CPP17_FLAG)
|
if(HAS_CPP17_FLAG)
|
||||||
|
@ -81,11 +87,11 @@ if(HAS_CPP17_FLAG)
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
||||||
set(std17 c++1z)
|
set(std17 c++1z)
|
||||||
endif()
|
endif()
|
||||||
make_target(nameof-cpp17.t ${std17})
|
make_target(${CMAKE_PROJECT_NAME}-cpp17.t ${std17})
|
||||||
add_test(NAME nameof-cpp17.t COMMAND nameof-cpp17.t)
|
add_test(NAME ${CMAKE_PROJECT_NAME}-cpp17.t COMMAND ${CMAKE_PROJECT_NAME}-cpp17.t)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAS_CPPLATEST_FLAG)
|
if(HAS_CPPLATEST_FLAG)
|
||||||
make_target(nameof-cpplatest.t c++latest)
|
make_target(${CMAKE_PROJECT_NAME}-cpplatest.t c++latest)
|
||||||
add_test(NAME nameof-cpplatest.t COMMAND nameof-cpplatest.t)
|
add_test(NAME ${CMAKE_PROJECT_NAME}-cpplatest.t COMMAND ${CMAKE_PROJECT_NAME}-cpplatest.t)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in a new issue