Skip to content

Commit

Permalink
Fixup CMake files
Browse files Browse the repository at this point in the history
  • Loading branch information
z4kn4fein committed Jul 27, 2024
1 parent 72346ac commit 512375c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
34 changes: 17 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ endif()

option(SEMVER_BUILD_TESTS "Enable builds of tests" ${TOP_PROJECT})
option(SEMVER_INSTALL "Enable install target" ${TOP_PROJECT})
option(SEMVER_CPP20_MODULE "Build as C++20 module" ${TOP_PROJECT})
option(SEMVER_BUILD_MODULE "Build as C++20 module" ${TOP_PROJECT})

if (SEMVER_CPP20_MODULES)
if (SEMVER_BUILD_MODULE)
cmake_minimum_required(VERSION 3.28)
else()
cmake_minimum_required(VERSION 3.14)
Expand All @@ -26,30 +26,30 @@ message(VERBOSE " CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
message(VERBOSE " CMAKE_CXX_COMPILER_VERSION: ${CMAKE_CXX_COMPILER_VERSION}")
message(VERBOSE " CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")

add_library(${PROJECT_NAME} INTERFACE)
add_library (${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(
${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)

if(SEMVER_CPP20_MODULE)
add_library(${PROJECT_NAME}-module)
set_target_properties(${PROJECT_NAME}-module PROPERTIES
if(SEMVER_BUILD_MODULE)
add_library(${PROJECT_NAME})
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF)
target_compile_features(${PROJECT_NAME}-module PUBLIC cxx_std_20)
target_sources(${PROJECT_NAME}-module
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
target_sources(${PROJECT_NAME}
PUBLIC
FILE_SET CXX_MODULES FILES module/semver.cppm)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
else()
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(
${PROJECT_NAME}-module PUBLIC
${PROJECT_NAME} INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
endif()

add_library (${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

## --------------------------------------------------------------------
## TESTS
## --------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ catch_discover_tests(${PROJECT_NAME}-tests-17)

# add c++20 tests
set(TARGET_LIBS Catch2::Catch2WithMain ${PROJECT_NAME})
if(SEMVER_CPP20_MODULE)
if(SEMVER_BUILD_MODULE)
list(APPEND TEST_SRC module/module_tests.cpp)
list(APPEND TARGET_LIBS ${PROJECT_NAME}-module)
list(APPEND TARGET_LIBS ${PROJECT_NAME})
endif()
add_executable(${PROJECT_NAME}-tests-20 ${TEST_SRC})
set_target_properties(${PROJECT_NAME}-tests-20 PROPERTIES CXX_STANDARD 20)
Expand Down

0 comments on commit 512375c

Please # to comment.