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 all 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 @@ -29,6 +29,7 @@ option(MORPHEUS_RENDER_SYSTEM_DIRECT_X12 "Build with support for the Dirext X 12
option(MORPHEUS_RENDER_SYSTEM_METAL "Build with support for the Metal render system" ON)
option(MORPHEUS_RENDER_SYSTEM_OPENGL "Build with support for the Open GL render system" ON)
option(MORPHEUS_RENDER_SYSTEM_VULKAN "Build with support for the Vulkan render system" ON)
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 @@ -98,8 +99,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 @@ -28,6 +28,7 @@ morpheus_add_library(
target_link_libraries(MorpheusConfig
INTERFACE
$<$<PLATFORM_ID:Linux>:dl>
std
)

target_compile_options(MorpheusConfig
Expand All @@ -37,3 +38,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 @@ -56,6 +56,7 @@ class Morpheus(ConanFile):
no_copy_source = True
options = {
"build_docs": [True, False],
"build_with_modules": [True, False],
"fPIC": [True, False],
"link_with_mold": [True, False],
"shared": [True, False],
Expand All @@ -67,6 +68,7 @@ class Morpheus(ConanFile):
}
default_options = {
"build_docs": False,
"build_with_modules": False,
"fPIC": True,
"link_with_mold": True,
"shared": False,
Expand Down Expand Up @@ -141,8 +143,8 @@ def build_requirements(self):
self.test_requires("catch2/3.5.3")
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 @@ -215,6 +217,7 @@ def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_SHARED_LIBS"] = self.options.shared
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.variables["MORPHEUS_RENDER_SYSTEM_DIRECT_X12"] = self.options.get_safe("with_rs_direct_x12", False)
tc.variables["MORPHEUS_RENDER_SYSTEM_METAL"] = self.options.get_safe("with_rs_metal", False)
Expand Down
14 changes: 9 additions & 5 deletions libraries/core/src/morpheus/core/base/assert.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#pragma once

#include <morpheus/core/base/assert.hpp>
#include <morpheus/core/base/assert_handler.hpp>
#include <morpheus/core/base/platform.hpp>
#include <morpheus/core/base/verify.hpp>
#include <morpheus/core/conformance/source_location.hpp>

#include <cstdint>
#include <functional>
#include <string>
#include <string_view>
//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#include <cstdint>
#include <functional>
#include <string>
#include <string_view>
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

namespace morpheus
{
Expand Down
14 changes: 12 additions & 2 deletions libraries/core/src/morpheus/core/base/assert_handler.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#if (MORPHEUS_MODULES_SUPPORT)
// import std;
#endif // #if (MORPHEUS_MODULES_SUPPORT)

#include "morpheus/core/base/assert_handler.hpp"
#include "morpheus/core/base/debugging.hpp"
#include "morpheus/core/conformance/format.hpp"
#include "morpheus/core/conformance/stacktrace.hpp"
#include "morpheus/core/conversion/adapters/std/stacktrace.hpp"

#include <iostream>
#include <utility>

//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#include <iostream>
#include <string_view>
#include <utility>
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

namespace morpheus
{
Expand Down
14 changes: 10 additions & 4 deletions libraries/core/src/morpheus/core/base/assert_handler.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#pragma once

//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

#include <morpheus/core/base/platform.hpp>
#include <morpheus/core/conformance/source_location.hpp>

#include <cstdint>
#include <functional>
#include <string>
#include <string_view>
//#if (!MORPHEUS_MODULES_SUPPORT)
#include <cstdint>
#include <functional>
#include <string>
#include <string_view>
//#endif // #if (!MORPHEUS_MODULES_SUPPORT)

namespace morpheus
{
Expand Down
8 changes: 6 additions & 2 deletions libraries/core/src/morpheus/core/base/debugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

#include <boost/test/debug.hpp>

#include <cstdio>
#include <iostream>
//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#include <cstdio>
#include <iostream>
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

namespace morpheus
{
Expand Down
6 changes: 5 additions & 1 deletion libraries/core/src/morpheus/core/base/debugging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include <morpheus/core/base/compiler.hpp>
#include <morpheus/core/base/platform.hpp>

#include <string_view>
//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#include <string_view>
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

namespace morpheus
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/core/src/morpheus/core/base/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace morpheus

using ExceptionInfo = boost::error_info<struct tag_stacktrace, st_ns::stacktrace>;

/// \group Exception Helpers
/// \defgroup Exception Helpers
/// Throwing of exceptions is moved to explicitly outlined functions to ensure code density around exception sites.
/// Additionally this allows to inform the compiler that exceptions are expected to be on the cold path to ensure
/// optimal code generation where exceptions are thrown.
Expand Down
8 changes: 7 additions & 1 deletion libraries/core/src/morpheus/core/base/platform.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#pragma once

#include <cstdint>
#include <morpheus/core/base/compiler.hpp>
#include <morpheus/core/morpheuscore_export.h>

//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#include <cstdint>
//#endif // #if (MORPHEUS_MODULES_SUPPORT)


/*! \defgroup Platform Morpheus Supported Platforms
The platform group of macros allow for compile time detection of the current platform.
@{
Expand Down
9 changes: 7 additions & 2 deletions libraries/core/src/morpheus/core/base/scoped_action.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#pragma once

#include <concepts>
#include <utility>
//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#include <concepts>
#include <utility>
//#endif // #if (MORPHEUS_MODULES_SUPPORT)


namespace morpheus
{
Expand Down
10 changes: 7 additions & 3 deletions libraries/core/src/morpheus/core/conformance/format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

#include <morpheus/core/conformance/version.hpp>

#if __has_include(<format>)
#include <format>
#endif
//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#if __has_include(<format>)
#include <format>
#endif
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

// clang-format off
#if (__cpp_lib_format >= 201907L)
Expand Down
10 changes: 7 additions & 3 deletions libraries/core/src/morpheus/core/conformance/source_location.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#pragma once

#if __has_include(<source_location>)
#include <source_location>
#endif
//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#if __has_include(<source_location>)
#include <source_location>
#endif
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

// clang-format off
#if (__cpp_lib_source_location >= 201907L)
Expand Down
10 changes: 7 additions & 3 deletions libraries/core/src/morpheus/core/conformance/stacktrace.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#pragma once

#if __has_include(<stacktrace>)
#include <stacktrace>
#endif
//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#if __has_include(<stacktrace>)
#include <stacktrace>
#endif
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

// clang-format off
#if (__cpp_lib_stacktrace >= 202011L)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
#include "morpheus/core/conformance/format.hpp"
#include "morpheus/core/conformance/stacktrace.hpp"

#include <string_view>
//#if (MORPHEUS_MODULES_SUPPORT)
// import std;
//#else
#include <string_view>
//#endif // #if (MORPHEUS_MODULES_SUPPORT)

// clang-format off
#if (__cpp_lib_formatters < 202302L)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include "morpheus/core/conformance/format.hpp"
#include "morpheus/core/conformance/format.hpp"

#include <thread>
Expand Down
4 changes: 4 additions & 0 deletions libraries/core/testing/morpheus/catch2/main.cpp.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#if (MORPHEUS_MODULES_SUPPORT)
// import std;
#endif // #if (MORPHEUS_MODULES_SUPPORT)

#include <morpheus/catch2/adapters/assert.hpp>
#include <morpheus/catch2/adapters/gmock.hpp>
#include <catch2/catch_all.hpp>
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)

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