clean-up cmake:
* formating * remove set(CMAKE_VERBOSE_MAKEFILE * use function to simplify test
This commit is contained in:
parent
0639b4b0c4
commit
cb08b67e9d
3 changed files with 26 additions and 37 deletions
|
@ -8,12 +8,12 @@ option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" OFF)
|
|||
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" OFF)
|
||||
|
||||
if(NAMEOF_OPT_BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
if(NAMEOF_OPT_BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
@ -22,23 +22,23 @@ add_library(${PROJECT_NAME} INTERFACE)
|
|||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>)
|
||||
|
||||
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion)
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY AnyNewerVersion)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
EXPORT ${PROJECT_NAME}Config)
|
||||
EXPORT ${PROJECT_NAME}Config)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||
|
||||
install(EXPORT ${PROJECT_NAME}Config
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||
NAMESPACE ${PROJECT_NAME}::
|
||||
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
DESTINATION .)
|
||||
DESTINATION .)
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
add_executable(example example.cpp)
|
||||
add_executable(example example.cpp)
|
||||
target_link_libraries(example PRIVATE nameof::nameof)
|
||||
set_target_properties(example PROPERTIES CXX_EXTENSIONS OFF)
|
||||
|
||||
|
|
|
@ -3,34 +3,25 @@
|
|||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag(-std=c++20 HAS_GNU_CPP20_FLAG)
|
||||
check_cxx_compiler_flag(/std:c++20 HAS_MSVC_CPP20_FLAG)
|
||||
|
||||
set(HAS_CPP20 (HAS_GNU_CPP20_FLAG OR HAS_MSVC_CPP20_FLAG))
|
||||
|
||||
function(make_test target std)
|
||||
add_executable(${target} test.cpp)
|
||||
target_link_libraries(${target} PRIVATE Catch2::Catch2 nameof::nameof)
|
||||
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_features(${target} PRIVATE ${std})
|
||||
|
||||
add_executable(test-17 test.cpp)
|
||||
target_link_libraries(test-17 PRIVATE Catch2::Catch2 nameof::nameof)
|
||||
set_target_properties(test-17 PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_features(test-17 PRIVATE cxx_std_17)
|
||||
|
||||
target_compile_options(test-17
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Wall -Wextra -pedantic-errors -Werror>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/W4 /WX>
|
||||
)
|
||||
|
||||
if(HAS_CPP20 AND (cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES))
|
||||
add_executable(test-20 test.cpp)
|
||||
target_link_libraries(test-20 PRIVATE Catch2::Catch2 nameof::nameof)
|
||||
set_target_properties(test-20 PROPERTIES CXX_EXTENSIONS OFF)
|
||||
target_compile_features(test-20 PRIVATE cxx_std_20)
|
||||
|
||||
target_compile_options(test-20
|
||||
target_compile_options(${target}
|
||||
PRIVATE
|
||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
|
||||
-Wall -Wextra -pedantic-errors -Werror>
|
||||
$<$<CXX_COMPILER_ID:MSVC>:
|
||||
/W4 /WX>
|
||||
)
|
||||
endfunction()
|
||||
|
||||
make_test(nameof-cpp17.t cxx_std_17)
|
||||
|
||||
if(HAS_CPP20 AND (cxx_std_20 IN_LIST CMAKE_CXX_COMPILE_FEATURES))
|
||||
make_test(nameof-cpp20.t cxx_std_20)
|
||||
endif()
|
||||
|
|
Loading…
Reference in a new issue