Feature/use file set headers#46
Conversation
| # ----------------------------------------------------------------------------- | ||
| # User option: enable C++ modules | ||
| # ----------------------------------------------------------------------------- | ||
| option(BOOST_USE_MODULES "Build Boost using C++ modules" OFF) |
There was a problem hiding this comment.
This differs with boostorg/conversion boostorg/conversion@d324df9#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20a
Is that OK? Is there any conflict with https://github.com/boostorg/cmake/pull/105/changes#diff-362ae3918cd3ea347acb8663e39d697af2ec828794c33494e747ee3249dbde73R307 ?
|
|
||
| # Ensure CMAKE_CXX_STANDARD is set for module detection | ||
| if(NOT DEFINED CMAKE_CXX_STANDARD) | ||
| set(CMAKE_CXX_STANDARD 20) |
There was a problem hiding this comment.
Is it right to set this variable from CMakeLists? Can we stick to using feature flags only?
| add_library(boost_type_index INTERFACE) | ||
|
|
||
| # If modules are disabled, require C++17 for headers | ||
| target_compile_features(boost_type_index INTERFACE cxx_std_17) |
There was a problem hiding this comment.
cxx_std_11
Library supports C++11
|
|
||
| # Verify interface headers only at top level | ||
| if(PROJECT_IS_TOP_LEVEL) | ||
| set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON) |
There was a problem hiding this comment.
Projects should not normally set this variable, it is intended as a developer control to be set on the [cmake(1)](https://cmake.org/cmake/help/latest/manual/cmake.1.html#manual:cmake(1)) command line or other equivalent methods
Maybe we should set this variable in CI only?
There was a problem hiding this comment.
yes, but the generated target has to be explicit called:
bash-5.3$ ninja -C build/ all_verify_header_sets
ninja: Entering directory `build/'
[15/15] Building CXX object CMakeFiles/boost_type_index_verify_interface_header_sets.dir/bo...ype_index_verify_interface_header_sets/boost/type_index/detail/stl_register_class.hpp.cxx.
bash-5.3$ | TYPE HEADERS | ||
| BASE_DIRS include | ||
| FILES | ||
| include/boost/type_index.hpp |
There was a problem hiding this comment.
How about searching the files via GLOB?
There was a problem hiding this comment.
Using of GLOB is not recommended for stable projects.
| target_link_libraries(boost_type_index_module_usage_mu PRIVATE Boost::type_index) | ||
| add_test(NAME boost_type_index_module_usage_mu COMMAND boost_type_index_module_usage_mu) | ||
| else() | ||
| list(APPEND RUN_TESTS_SOURCES |
There was a problem hiding this comment.
build errors while dependency scan:
[1/5] Scanning /Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp for CXX dependencies
FAILED: [code=1] CMakeFiles/type_index_subdir_test_type_index_test.dir/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp.o.ddi
/usr/local/bin/g++-16 -DBOOST_USE_MODULES -I/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/include -I/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/config/include -I/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/container_hash/include -I/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/describe/include -I/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/mp11/include -I/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/throw_exception/include -I/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/assert/include -O3 -DNDEBUG -E -x c++ /Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp -MT CMakeFiles/type_index_subdir_test_type_index_test.dir/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp.o.ddi -MD -MF CMakeFiles/type_index_subdir_test_type_index_test.dir/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp.o.ddi.d -fmodules-ts -fdeps-file=CMakeFiles/type_index_subdir_test_type_index_test.dir/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp.o.ddi -fdeps-target=CMakeFiles/type_index_subdir_test_type_index_test.dir/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp.o -fdeps-format=p1689r5 -o CMakeFiles/type_index_subdir_test_type_index_test.dir/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp.o.ddi.i
/Users/clausklein/.cache/CPM/boost-1.91.0-1/libs/type_index/test/type_index_test.cpp:12:10: fatal error: boost/core/lightweight_test.hpp: No such file or directory
12 | #include <boost/core/lightweight_test.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
iMac:cmake_subdir_test clausklein$ |
@ClausKlein please check the current develop branch. I think the issue should have been fixed by now |
bash-5.3$ CXX=clang++ gmake
cmake --version
cmake version 4.3.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
cmake -S . -B build -G Ninja \
-D CMAKE_CXX_STDLIB_MODULES_JSON=/usr/local/Cellar/llvm/22.1.6/lib/c++/libc++.modules.json \
-D CMAKE_CXX_STANDARD=23 -D CMAKE_CXX_EXTENSIONS=YES -D CMAKE_CXX_STANDARD_REQUIRED=YES \
-D CMAKE_CXX_MODULE_STD=YES \
-D BOOST_USE_MODULES=YES \
-D BUILD_TESTING=YES \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_MESSAGE=LAZY \
-D CMAKE_SKIP_INSTALL_RULES=NO \
--log-level=VERBOSE --fresh \
# --trace-expand --trace-source=use-fetch-content.cmake \
# --debug-find-pkg=GTest
-- The CXX compiler identification is Clang 22.1.6
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/Cellar/llvm/22.1.6/bin/clang++ - skipped
-- Detecting CXX compile features
CMake Warning (dev) at /usr/local/share/cmake/Modules/Compiler/CMakeCommonCompilerMacros.cmake:226 (cmake_language):
CMake's support for `import std;` in C++23 and newer is experimental. It
is meant only for experimentation and feedback to CMake developers.
Call Stack (most recent call first):
/usr/local/share/cmake/Modules/CMakeDetermineCompilerSupport.cmake:110 (cmake_cxx_find_modules_json)
/usr/local/share/cmake/Modules/CMakeTestCXXCompiler.cmake:83 (CMAKE_DETERMINE_COMPILER_SUPPORT)
CMakeLists.txt:9 (project)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Detecting CXX compile features - done
-- Using `import std;`
-- Configuring done (1.7s)
-- Generating done (0.1s)
bash-5.3$ ninja -C build/ all -v
ninja: Entering directory `build/'
[0/2] /usr/local/bin/cmake -P /Users/clausklein/Workspace/cpp/boost-git/libs/type_index/test/cmake_subdir_test/build/CMakeFiles/VerifyGlobs.cmake
[1/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/CXX.dd.rsp
FAILED: [code=1] boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/CXX.dd boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/CXXModules.json boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/Users/clausklein/Workspace/cpp/boost-git/libs/type_index/modules/boost_type_index.cppm.o.modmap
/usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/boost_type_index_user_defined_typeinfo.dir/CXX.dd.rsp
CMake Error: Circular dependency detected in the C++ module import graph. See modules named: "boost.type_index"
[2/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_inheritance_example.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_inheritance_example.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_inheritance_example.dir/CXX.dd.rsp
[3/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_demangled_names_example.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_demangled_names_example.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_demangled_names_example.dir/CXX.dd.rsp
[4/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_constexpr14_sort_check_example.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_constexpr14_sort_check_example.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_constexpr14_sort_check_example.dir/CXX.dd.rsp
[5/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_exact_types_match_example.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_exact_types_match_example.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_exact_types_match_example.dir/CXX.dd.rsp
[6/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_ctti_alignment_test.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_ctti_alignment_test.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_ctti_alignment_test.dir/CXX.dd.rsp
[7/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_runtime_cast_example.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_runtime_cast_example.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_runtime_cast_example.dir/CXX.dd.rsp
[8/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_table_of_names_example.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_table_of_names_example.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_table_of_names_example.dir/CXX.dd.rsp
[9/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_constexpr14_namespace_check_example.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_constexpr14_namespace_check_example.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_constexpr14_namespace_check_example.dir/CXX.dd.rsp
[10/65] /usr/local/bin/cmake -E cmake_ninja_dyndep --tdi=boostorg/type_index/test/CMakeFiles/type_index_registry_example.dir/CXXDependInfo.json --lang=CXX --modmapfmt=clang --dd=boostorg/type_index/test/CMakeFiles/type_index_registry_example.dir/CXX.dd @boostorg/type_index/test/CMakeFiles/type_index_registry_example.dir/CXX.dd.rsp
[11/65] ccache /usr/local/Cellar/llvm/22.1.6/bin/clang++ -I/usr/local/Cellar/llvm/22.1.6/share/libc++/v1 -stdlib=libc++ --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -O3 -DNDEBUG -std=gnu++23 -MD -MT CMakeFiles/__cmake_cxx_std_23.dir/usr/local/Cellar/llvm/22.1.6/share/libc++/v1/std.compat.cppm.o -MF CMakeFiles/__cmake_cxx_std_23.dir/usr/local/Cellar/llvm/22.1.6/share/libc++/v1/std.compat.cppm.o.d @CMakeFiles/__cmake_cxx_std_23.dir/usr/local/Cellar/llvm/22.1.6/share/libc++/v1/std.compat.cppm.o.modmap -o CMakeFiles/__cmake_cxx_std_23.dir/usr/local/Cellar/llvm/22.1.6/share/libc++/v1/std.compat.cppm.o -c /usr/local/Cellar/llvm/22.1.6/share/libc++/v1/std.compat.cppm
/usr/local/Cellar/llvm/22.1.6/share/libc++/v1/std.compat.cppm:83:15: warning: 'std' is a reserved name for a module [-Wreserved-module-identifier]
83 | export module std.compat;
| ^
1 warning generated.
ninja: build stopped: subcommand failed.
bash-5.3$ |
Add FILE_SET HEADERS too support generic installation Prevent use of FILE_SET w/o modules Fix yamllint issues Fix typos Always use FILE_SET HEADERS if possible
1ee819f to
1d62158
Compare
Make
import std;usableAdd
FILE_SET HEADERStoo support generic module installation