Module target - #465
Open
Neargye wants to merge 12 commits into
Open
Conversation
|
LGTM: tested only with But IMHO I should not needed in this case. I would change a view points and the test script: diff --git a/CMakeLists.txt b/CMakeLists.txt
index 76f3056..c6b365b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,7 +102,7 @@ if(MAGIC_ENUM_OPT_VERIFY_INTERFACE_HEADER_SETS)
if(CMAKE_VERSION VERSION_LESS "3.24")
message(FATAL_ERROR "MAGIC_ENUM_OPT_VERIFY_INTERFACE_HEADER_SETS requires CMake >= 3.24")
endif()
- set_property(TARGET ${PROJECT_NAME} PROPERTY VERIFY_INTERFACE_HEADER_SETS ON)
+ set_property(TARGET ${PROJECT_NAME} PROPERTY VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL})
endif()
function(magic_enum_make_module_library name)
@@ -124,13 +124,18 @@ function(magic_enum_make_module_library name)
if(NOT TARGET fmt::fmt)
find_package(fmt CONFIG REQUIRED)
endif()
- target_link_libraries(${name} PUBLIC fmt::fmt)
- target_compile_definitions(${name} PRIVATE MAGIC_ENUM_MODULE_WITH_FMT)
+ if(MAGIC_ENUM_USE_MODULES AND TARGET fmt::fmt-module)
+ # FIXME: this does not compile! CK
+ target_link_libraries(${name} PUBLIC fmt::fmt-module)
+ else()
+ target_link_libraries(${name} PUBLIC fmt::fmt)
+ endif()
+ target_compile_definitions(${name} PUBLIC MAGIC_ENUM_MODULE_WITH_FMT)
endif()
if(MAGIC_ENUM_MODULE_IMPORT_STD)
- if(CMAKE_VERSION VERSION_LESS "3.30")
- message(FATAL_ERROR "MAGIC_ENUM_MODULE_IMPORT_STD requires CMake >= 3.30")
+ if(CMAKE_VERSION VERSION_LESS "3.31")
+ message(FATAL_ERROR "MAGIC_ENUM_MODULE_IMPORT_STD requires CMake >= 3.31")
endif()
if(CMAKE_CXX_STANDARD LESS 23)
message(FATAL_ERROR "MAGIC_ENUM_MODULE_IMPORT_STD requires CMAKE_CXX_STANDARD >= 23")
@@ -143,7 +148,7 @@ function(magic_enum_make_module_library name)
endif()
message(STATUS "${name}: using import std")
set_property(TARGET ${name} PROPERTY CXX_MODULE_STD ON)
- target_compile_definitions(${name} PRIVATE MAGIC_ENUM_USE_STD_MODULE)
+ target_compile_definitions(${name} PUBLIC MAGIC_ENUM_USE_STD_MODULE)
elseif(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30")
set_property(TARGET ${name} PROPERTY CXX_MODULE_STD OFF)
endif()
diff --git a/test_installed_version.bash b/test_installed_version.bash
index 8c3705e..6444962 100644
--- a/test_installed_version.bash
+++ b/test_installed_version.bash
@@ -9,33 +9,53 @@ install_dir="${build_root}/install"
consumer_prefix="${build_root}/relocated-install"
cmake_consumer_build_dir="${build_root}/cmake-consumer"
pkgconfig_consumer_build_dir="${build_root}/pkgconfig-consumer"
+cxx_modules_consumer_build_dir="${build_root}/cxx_modules-consumer"
test_installed_consumer() {
local build_dir="$1"
shift
CMAKE_PREFIX_PATH="${consumer_prefix}" cmake -S "${repo_root}" -B "${build_dir}" \
+ -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
"$@"
cmake --build "${build_dir}" --parallel
ctest --test-dir "${build_dir}" --output-on-failure --no-tests=error
}
+cmake --version
cmake -E remove_directory "${build_root}"
-cmake -S "${repo_root}" -B "${source_build_dir}" \
+cmake -S "${repo_root}" -B "${source_build_dir}" -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_CXX_STANDARD=23 \
+ -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=f35a9ac6-8463-4d38-8eec-5d6008153e7d \
-DCMAKE_INSTALL_PREFIX="${configured_install_dir}" \
+ -DMAGIC_ENUM_MODULE_IMPORT_STD=ON \
+ -DMAGIC_ENUM_MODULE_WITH_FMT=OFF \
-DMAGIC_ENUM_OPT_BUILD_EXAMPLES=OFF \
-DMAGIC_ENUM_OPT_BUILD_TESTS=OFF \
-DMAGIC_ENUM_OPT_INSTALL=ON \
- -DMAGIC_ENUM_OPT_VERIFY_INTERFACE_HEADER_SETS=ON
+ -DMAGIC_ENUM_OPT_VERIFY_INTERFACE_HEADER_SETS=ON \
+ -DMAGIC_ENUM_USE_MODULES=ON
cmake --build "${source_build_dir}" \
--target magic_enum_verify_interface_header_sets \
--parallel
+cmake --build "${source_build_dir}" \
+ --target all \
+ --parallel
cmake --install "${source_build_dir}" --prefix "${install_dir}"
cmake -E copy_directory "${install_dir}" "${consumer_prefix}"
+test_installed_consumer "${cxx_modules_consumer_build_dir}" \
+ -DCMAKE_CXX_STANDARD=23 \
+ -DCMAKE_EXPERIMENTAL_CXX_IMPORT_STD=f35a9ac6-8463-4d38-8eec-5d6008153e7d \
+ -DMAGIC_ENUM_MODULE_IMPORT_STD=ON \
+ -DMAGIC_ENUM_MODULE_WITH_FMT=OFF \
+ -DMAGIC_ENUM_OPT_TEST_INSTALLED_VERSION=ON \
+ -DMAGIC_ENUM_USE_MODULES=ON \
+ -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=OFF --fresh
+
test_installed_consumer "${cmake_consumer_build_dir}" \
-DMAGIC_ENUM_OPT_TEST_INSTALLED_VERSION=ON
|
ClausKlein
reviewed
Aug 6, 2026
ClausKlein
reviewed
Aug 6, 2026
ClausKlein
reviewed
Aug 6, 2026
ClausKlein
reviewed
Aug 6, 2026
ClausKlein
reviewed
Aug 6, 2026
|
Please note: I opened a bunch of issues, but they are all ignored and closed at fmt lib?IMHO: if you build with bash-5.3$ builddriver ninja
builddriver executing: 'ninja'
Compilation FAILED in 1.714425 seconds
Number of warnings: 0
Number of errors: 1914
Last Error:
Message: "template constraint failure for 'template<class _It> requires input_iterator<_It> using std::const_iterator = std::__conditional_t<__constant_iterator<_It>, _It, std::basic_const_iterator<_It> >'"
Path: /usr/local/Cellar/gcc/16.1.0/include/c++/16/span
Line Number: 166
Column: 13
For full log, please open: /var/folders/wb/ckvxxgls5db7qyhqq4y5_l1c0000gq/T/build-mocbts17.log
bash-5.3$ cmake -L .
-- magic_enum module: using fmt::fmt
-- Configuring done (0.1s)
CMake Warning (experimental) in CMakeLists.txt:
CMake's support for `import std;` in C++23 and newer is experimental. It
is meant only for experimentation and feedback to CMake developers.
This warning is for project developers. Use -Wno-author or -Wno-experimental
to suppress it.
-- Generating done (0.0s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/magic_enum/build-installed-version/source
-- Cache values
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache
CMAKE_INSTALL_PREFIX:PATH=/Users/clausklein/Workspace/cpp/magic_enum/build-installed-version/configured-install
CMAKE_OSX_ARCHITECTURES:STRING=
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=
CMAKE_OSX_SYSROOT:STRING=
MAGIC_ENUM_MODULE_IMPORT_STD:BOOL=OFF
MAGIC_ENUM_MODULE_WITH_FMT:BOOL=ON
MAGIC_ENUM_OPT_BUILD_EXAMPLES:BOOL=OFF
MAGIC_ENUM_OPT_BUILD_TESTS:BOOL=OFF
MAGIC_ENUM_OPT_INSTALL:BOOL=ON
MAGIC_ENUM_OPT_INSTALL_PACKAGE_XML:BOOL=ON
MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION:BOOL=OFF
MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG:BOOL=OFF
MAGIC_ENUM_OPT_VERIFY_INTERFACE_HEADER_SETS:BOOL=ON
MAGIC_ENUM_USE_MODULES:BOOL=ON
fmt_DIR:PATH=/Users/clausklein/.local/lib/cmake/fmt
bash-5.3$ pwd
/Users/clausklein/Workspace/cpp/magic_enum/build-installed-version/source
bash-5.3$ echo $CXX
g++-16
bash-5.3$ |
|
Sorry to bother you, but if
[1/7] /Users/clausklein/.local/bin/cmake -E cmake_ninja_dyndep --tdi=CMakeFiles/@cmake_cxx_std.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc --dd='CMakeFiles/@cmake_cxx_std.dir/CXX.dd' @'CMakeFiles/@cmake_cxx_std.dir/CXX.dd'.rsp
[2/7] /Users/clausklein/.local/bin/cmake -E cmake_ninja_dyndep --tdi=CMakeFiles/@cmake_cxx_std@synth_0.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc --dd='CMakeFiles/@cmake_cxx_std@synth_0.dir/CXX.dd' @'CMakeFiles/@cmake_cxx_std@synth_0.dir/CXX.dd'.rsp
[3/6] /Users/clausklein/.local/bin/cmake -E cmake_ninja_dyndep --tdi=CMakeFiles/fmt__fmt@synth_0.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc --dd='CMakeFiles/fmt__fmt@synth_0.dir/CXX.dd' @'CMakeFiles/fmt__fmt@synth_0.dir/CXX.dd'.rsp
[4/6] /Users/clausklein/.local/bin/cmake -E cmake_ninja_dyndep --tdi=CMakeFiles/magic_enum_module.dir/CXXDependInfo.json --lang=CXX --modmapfmt=gcc --dd=CMakeFiles/magic_enum_module.dir/CXX.dd @CMakeFiles/magic_enum_module.dir/CXX.dd.rsp
[5/6] ccache /usr/local/bin/g++-16 -DFMT_IMPORT_STD -DFMT_MODULE
-DMAGIC_ENUM_USE_FMT_HEADER -I/Users/clausklein/Workspace/cpp/magic_enum/include
-isystem /Users/clausklein/.local/include -O3 -DNDEBUG -std=c++26 -MD -MT
CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o -MF
CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o.d -fmodules-ts
-fmodule-mapper=CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o.modmap
-MD -fdeps-format=p1689r5 -x c++ -o
CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o -c
/Users/clausklein/Workspace/cpp/magic_enum/module/magic_enum.cppm
FAILED: [code=1] CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o CMakeFiles/magic_enum_module.dir/magic_enum.gcm
ccache /usr/local/bin/g++-16 -DFMT_IMPORT_STD -DFMT_MODULE -DMAGIC_ENUM_USE_FMT_HEADER -I/Users/clausklein/Workspace/cpp/magic_enum/include -isystem /Users/clausklein/.local/include -O3 -DNDEBUG -std=c++26 -MD -MT CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o -MF CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/magic_enum_module.dir/module/magic_enum.cppm.o -c /Users/clausklein/Workspace/cpp/magic_enum/module/magic_enum.cppm
In file included from /Users/clausklein/.local/include/fmt/format.h:41,
from /Users/clausklein/Workspace/cpp/magic_enum/module/magic_enum.cppm:5:
/Users/clausklein/.local/include/fmt/base.h:312:35: error: 'enable_if' in namespace 'std' does not name a template type
312 | using enable_if_t = typename std::enable_if<B, T>::type;
| ^~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:1:1: note: 'std::enable_if' is defined in header '<type_traits>'; this is probably fixable by adding '#include <type_traits>'
+++ |+#include <type_traits>
1 | // Formatting library for C++ - the base API for char/UTF-8
/Users/clausklein/.local/include/fmt/base.h:314:37: error: 'conditional' in namespace 'std' does not name a template type
314 | using conditional_t = typename std::conditional<B, T, F>::type;
| ^~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:315:46: error: 'integral_constant' in namespace 'std' does not name a template type
315 | template <bool B> using bool_constant = std::integral_constant<bool, B>;
| ^~~~~~~~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:317:42: error: 'remove_reference' in namespace 'std' does not name a template type
317 | using remove_reference_t = typename std::remove_reference<T>::type;
| ^~~~~~~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:319:38: error: 'remove_const' in namespace 'std' does not name a template type
319 | using remove_const_t = typename std::remove_const<T>::type;
| ^~~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:321:38: error: 'remove_cv' in namespace 'std' does not name a template type
321 | using remove_cvref_t = typename std::remove_cv<remove_reference_t<T>>::type;
| ^~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:323:39: error: 'make_unsigned' in namespace 'std' does not name a template type
323 | using make_unsigned_t = typename std::make_unsigned<T>::type;
| ^~~~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:325:36: error: 'underlying_type' in namespace 'std' does not name a template type
325 | using underlying_t = typename std::underlying_type<T>::type;
| ^~~~~~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:326:53: error: 'decay' in namespace 'std' does not name a template type
326 | template <typename T> using decay_t = typename std::decay<T>::type;
| ^~~~~
/Users/clausklein/.local/include/fmt/base.h: In function 'constexpr bool fmt::v12::detail::is_constant_evaluated(bool)':
/Users/clausklein/.local/include/fmt/base.h:380:15: error: 'is_constant_evaluated' is not a member of 'std'
380 | return std::is_constant_evaluated();
| ^~~~~~~~~~~~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h: At global scope:
/Users/clausklein/.local/include/fmt/base.h:421:46: error: 'make_unsigned_t' does not name a type
421 | FMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t<Int> {
| ^~~~~~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:421:61: error: expected initializer before '<' token
421 | FMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t<Int> {
| ^
/Users/clausklein/.local/include/fmt/base.h:427:23: error: 'conditional_t' does not name a type
427 | using unsigned_char = conditional_t<sizeof(Char) == 1, unsigned char, unsigned>;
| ^~~~~~~~~~~~~
/Users/clausklein/.local/include/fmt/base.h:432:45: error: expected class-name before '{' token [-Wtemplate-body]
432 | struct is_std_string_like : std::false_type {};
| ^
/Users/clausklein/.local/include/fmt/base.h:434:51: error: 'declval' is not a member of 'std'
434 | struct is_std_string_like<T, void_t<decltype(std::declval<T>().find_first_of(
| ^~~~~~~
/Users/clausklein/.local/include/fmt/base.h:1:1: note: 'std::declval' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
+++ |+#include <utility>
1 | // Formatting library for C++ - the base API for char/UTF-8
/Users/clausklein/.local/include/fmt/base.h:434:51: error: 'declval' is not a member of 'std'
434 | struct is_std_string_like<T, void_t<decltype(std::declval<T>().find_first_of(
| ^~~~~~~
/Users/clausklein/.local/include/fmt/base.h:434:51: note: 'std::declval' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
/Users/clausklein/.local/include/fmt/base.h:434:60: error: expected primary-expression before '>' token
434 | struct is_std_string_like<T, void_t<decltype(std::declval<T>().find_first_of(
| ^
/Users/clausklein/.local/include/fmt/base.h:434:62: error: expected primary-expression before ')' token
434 | struct is_std_string_like<T, void_t<decltype(std::declval<T>().find_first_of(
| ^
/Users/clausklein/.local/include/fmt/base.h:434:37: error: template argument 1 is invalid
. . .
ninja: build stopped: subcommand failed.
bash-5.3$ cmake -L .
-- The CXX compiler identification is GNU 16.1.0
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - no
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - no
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/g++-16 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test MAGIC_ENUM_HAS_CPP20_FLAG
-- Performing Test MAGIC_ENUM_HAS_CPP20_FLAG - Success
-- Performing Test MAGIC_ENUM_HAS_CPP23_FLAG
-- Performing Test MAGIC_ENUM_HAS_CPP23_FLAG - Success
-- Performing Test MAGIC_ENUM_HAS_CPP26_FLAG
-- Performing Test MAGIC_ENUM_HAS_CPP26_FLAG - Success
-- Configuring done (1.9s)
-- Generating done (0.1s)
-- Build files have been written to: /Users/clausklein/Workspace/cpp/magic_enum
-- Cache values
CMAKE_BUILD_TYPE:STRING=
CMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache
CMAKE_INSTALL_PREFIX:PATH=/Users/clausklein/.local
CMAKE_OSX_ARCHITECTURES:STRING=
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=
CMAKE_OSX_SYSROOT:STRING=
MAGIC_ENUM_MODULE_IMPORT_STD:BOOL=OFF
MAGIC_ENUM_MODULE_WITH_FMT:BOOL=OFF
MAGIC_ENUM_OPT_BUILD_EXAMPLES:BOOL=ON
MAGIC_ENUM_OPT_BUILD_TESTS:BOOL=ON
MAGIC_ENUM_OPT_INSTALL:BOOL=ON
MAGIC_ENUM_OPT_INSTALL_PACKAGE_XML:BOOL=ON
MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION:BOOL=OFF
MAGIC_ENUM_OPT_TEST_INSTALLED_VERSION_PKGCONFIG:BOOL=OFF
MAGIC_ENUM_OPT_VERIFY_INTERFACE_HEADER_SETS:BOOL=ON
MAGIC_ENUM_USE_MODULES:BOOL=OFF
bash-5.3$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.