add support to build without modules
some compilers don't fully support modules with the way cmake does them. it seems like only Clang 16 supports them which is not in the arch repos yet.
This commit is contained in:
parent
678b854b74
commit
eb6fa7a104
2 changed files with 26 additions and 16 deletions
|
@ -1,7 +1,11 @@
|
||||||
cmake_minimum_required(VERSION 3.26)
|
cmake_minimum_required(VERSION 3.26)
|
||||||
project(LearningProject CXX)
|
project(LearningProject CXX)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
option(BUILD_WITH_MODULES "Build with C++ Modules" ON)
|
||||||
|
|
||||||
|
if(BUILD_WITH_MODULES)
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE
|
string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE
|
||||||
"<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> <SOURCE>"
|
"<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> <SOURCE>"
|
||||||
|
@ -14,10 +18,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
"${compiler_flags_for_module_map} -fmodule-mapper=<MODULE_MAP_FILE>")
|
"${compiler_flags_for_module_map} -fmodule-mapper=<MODULE_MAP_FILE>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
|
||||||
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1)
|
||||||
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
|
set(CMAKE_EXPERIMENTAL_CXX_MODULE_CMAKE_API "2182bf5c-ef0d-489a-91da-49dbc3090d2a")
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
if (BUILD_WITH_MODULES)
|
||||||
add_subdirectory(math)
|
add_subdirectory(math)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(hello hello.cc)
|
add_executable(hello hello.cc)
|
||||||
|
if (BUILD_WITH_MODULES)
|
||||||
add_executable(sqrt sqrt.cc)
|
add_executable(sqrt sqrt.cc)
|
||||||
target_link_libraries(sqrt PRIVATE Math)
|
target_link_libraries(sqrt PRIVATE Math)
|
||||||
|
endif()
|
||||||
add_executable(inheritance inheritance.cc)
|
add_executable(inheritance inheritance.cc)
|
||||||
add_executable(enumerations enumerations.cc)
|
add_executable(enumerations enumerations.cc)
|
||||||
add_executable(namespaces namespaces.cc)
|
add_executable(namespaces namespaces.cc)
|
||||||
|
|
Loading…
Reference in a new issue