Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules support #293

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ include(GNUInstallDirs)
include(CMakeDependentOption)
include(CMakePackageConfigHelpers)

cmake_dependent_option(MORPHEUS_MODULES_SUPPORT "Enable building with support for modules" ON "\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"MSVC\"" OFF)
cmake_dependent_option(MORPHEUS_LINK_WITH_MOLD "Enable the mold linker" ON "LINUX OR APPLE" OFF)
cmake_dependent_option(MORPHEUS_CODE_COVERAGE "Enable code coverage" ON "\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"Clang\" OR \"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\"" OFF)
cmake_dependent_option(MORPHEUS_INCLUDE_NATVIS "Enable inclusion of a natvis files for debugging" ON "\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"MSVC\"" OFF)
Expand Down Expand Up @@ -93,8 +94,9 @@ if(IS_MULTI_CONFIG)
endif()
#------------------------------------------------------------------------------------------------------------------------------------------

add_subdirectory(libraries)
add_subdirectory(examples)
add_subdirectory(modules)
add_subdirectory(libraries)

if (ENABLE_CODE_COVERAGE)
enable_code_coverage()
Expand Down
6 changes: 6 additions & 0 deletions cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add_library(morpheus::config ALIAS MorpheusConfig)
target_link_libraries(MorpheusConfig
INTERFACE
$<$<PLATFORM_ID:Linux>:dl>
std
)

target_compile_options(MorpheusConfig
Expand All @@ -35,3 +36,8 @@ target_compile_options(MorpheusConfig
$<$<CXX_COMPILER_ID:GNU>:${GCC_WARNINGS}>
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:${CLANG_WARNINGS}>
)

target_compile_definitions(MorpheusConfig
INTERFACE
MORPHEUS_MODULES_SUPPORT=$<BOOL:${MORPHEUS_MODULES_SUPPORT}>
)
7 changes: 5 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ class Morpheus(ConanFile):
"fPIC": [True, False],
"tools": [True, False],
"build_docs": [True, False],
"build_with_modules": [True, False],
"link_with_mold": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"tools": True,
"build_docs": False,
"build_with_modules": False,
"link_with_mold": True
}
exports_sources = ["CMakeLists.txt", "LICENSE", "version.txt", "cmake/*", "examples/*" "libraries/*"]
Expand Down Expand Up @@ -130,8 +132,8 @@ def build_requirements(self):
self.test_requires("catch2/3.4.0")
self.test_requires("gtest/1.14.0")

if get_cmake_version() < Version("3.28.1"):
self.tool_requires("cmake/3.28.1")
if get_cmake_version() < Version("3.29.0"):
self.tool_requires("cmake/3.29.0")

if self.options.build_docs:
self.build_requires("doxygen/1.9.4") # doxygen/1.9.5 will update dependency on zlib/1.2.12 to zlib/1.2.13
Expand Down Expand Up @@ -195,6 +197,7 @@ def configure(self):
def generate(self):
tc = CMakeToolchain(self)
tc.variables["MORPHEUS_BUILD_DOCS"] = self.options.build_docs
tc.variables["MORPHEUS_MODULES_SUPPORT"] = self.options.build_with_modules
tc.variables["MORPHEUS_LINK_WITH_MOLD"] = self.options.get_safe("link_with_mold", False)
tc.generate()
deps = CMakeDeps(self)
Expand Down
7 changes: 7 additions & 0 deletions modules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if (${MORPHEUS_MODULES_SUPPORT})

set(CMAKE_CXX_SCAN_FOR_MODULES ON)

add_subdirectory(std)
Twon marked this conversation as resolved.
Show resolved Hide resolved

endif (${MORPHEUS_MODULES_SUPPORT})
1 change: 1 addition & 0 deletions modules/std/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(std)
Empty file.
9 changes: 9 additions & 0 deletions modules/std/std/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
add_library(std)
target_sources(std
PUBLIC
FILE_SET CXX_MODULES TYPE CXX_MODULES
FILES
"std.ixx"
)

target_compile_features(std PUBLIC cxx_std_23)
Loading
Loading