-
Notifications
You must be signed in to change notification settings - Fork 50
Feature/use file set headers #46
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,5 @@ doc/html | |
| build* | ||
| .cache | ||
| .vscode | ||
| compile_commands.json | ||
| GNUmakefile | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,135 @@ | ||
| # Generated by `boostdep --cmake type_index` | ||
| # ----------------------------------------------------------------------------- | ||
| # Boost.type_index CMake | ||
| # Handles: no modules, modules, modules + import std; | ||
| # ----------------------------------------------------------------------------- | ||
| # Copyright 2020, 2021 Peter Dimov | ||
| # Copyright 2026 Fedor Osetrov | ||
| # Distributed under the Boost Software License, Version 1.0. | ||
| # https://www.boost.org/LICENSE_1_0.txt | ||
|
|
||
| cmake_minimum_required(VERSION 3.5...4.20) | ||
| cmake_minimum_required(VERSION 3.28...4.4) | ||
|
|
||
| project(boost_type_index VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) | ||
|
|
||
| if (BOOST_USE_MODULES) | ||
| if(PROJECT_IS_TOP_LEVEL) | ||
| set(BUILD_TESTING ON) | ||
| enable_testing() | ||
| find_package(Threads) | ||
| find_package(Boost 1.91.0 CONFIG REQUIRED) | ||
| endif() | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # User option: enable C++ modules | ||
| # ----------------------------------------------------------------------------- | ||
| option(BOOST_USE_MODULES "Build Boost using C++ modules" OFF) | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Determine target type and sources | ||
| # ----------------------------------------------------------------------------- | ||
| if(BOOST_USE_MODULES) | ||
|
|
||
| # Ensure CMAKE_CXX_STANDARD is set for module detection | ||
| if(NOT DEFINED CMAKE_CXX_STANDARD) | ||
| set(CMAKE_CXX_STANDARD 20) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it right to set this variable from CMakeLists? Can we stick to using feature flags only? |
||
| endif() | ||
|
|
||
| add_library(boost_type_index) | ||
| target_sources(boost_type_index | ||
| PUBLIC | ||
| FILE_SET CXX_MODULES | ||
| BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" | ||
| FILES "${CMAKE_CURRENT_SOURCE_DIR}/modules/boost_type_index.cppm" | ||
| target_sources( | ||
| boost_type_index | ||
| PUBLIC | ||
| FILE_SET modules_public | ||
| TYPE CXX_MODULES | ||
| FILES modules/boost_type_index.cppm | ||
| ) | ||
|
|
||
| target_compile_features(boost_type_index PUBLIC cxx_std_20) | ||
| # Require C++20 for modules | ||
| target_compile_features(boost_type_index PUBLIC cxx_std_${CMAKE_CXX_STANDARD}) | ||
| # Define macro indicating modules usage | ||
| target_compile_definitions(boost_type_index PUBLIC BOOST_USE_MODULES) | ||
| if ((CMAKE_CXX_STANDARD IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) AND CMAKE_CXX_MODULE_STD) | ||
| target_compile_features(boost_type_index PRIVATE cxx_std_23) | ||
| target_compile_definitions(boost_type_index PRIVATE BOOST_TYPE_INDEX_USE_STD_MODULE) | ||
| message(STATUS "Using `import std;`") | ||
|
|
||
| # Check if import std; is available for the current standard | ||
| if(${CMAKE_CXX_STANDARD} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) | ||
| target_compile_definitions(boost_type_index PUBLIC BOOST_TYPE_INDEX_USE_STD_MODULE) | ||
| set_property(TARGET boost_type_index PROPERTY CXX_MODULE_STD ON) | ||
| message(STATUS "Boost.type_index: Using `import std;`") | ||
| else() | ||
| message(STATUS "`import std;` is not available") | ||
| message(WARNING "Boost.type_index: `import std;` is not available for C++${CMAKE_CXX_STANDARD}") | ||
| endif() | ||
|
|
||
| set(__scope PUBLIC) | ||
|
|
||
| else() | ||
|
|
||
| # Verify interface headers only at top level | ||
| if(PROJECT_IS_TOP_LEVEL) | ||
| set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON) | ||
| endif() | ||
|
|
||
| # Modules disabled -> INTERFACE library | ||
| 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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a really historic C++ std? |
||
|
|
||
| set(__scope INTERFACE) | ||
|
|
||
| endif() | ||
|
|
||
| target_include_directories(boost_type_index ${__scope} include) | ||
| add_library(Boost::type_index ALIAS boost_type_index) | ||
| # ----------------------------------------------------------------------------- | ||
| # Include headers | ||
| # ----------------------------------------------------------------------------- | ||
| # Note: usable starting with cmake v3.23 | ||
| if(NOT CMAKE_VERSION VERSION_LESS 3.23) | ||
| target_sources( | ||
| boost_type_index | ||
| PUBLIC | ||
| FILE_SET headers_public | ||
| TYPE HEADERS | ||
| BASE_DIRS include | ||
| FILES | ||
| include/boost/type_index.hpp | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about searching the files via GLOB?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using of GLOB is not recommended for stable projects. |
||
| include/boost/type_index/runtime_cast.hpp | ||
| include/boost/type_index/stl_type_index.hpp | ||
| include/boost/type_index/detail/compile_time_type_info.hpp | ||
| include/boost/type_index/detail/stl_register_class.hpp | ||
| include/boost/type_index/detail/config.hpp | ||
| include/boost/type_index/detail/ctti_register_class.hpp | ||
| include/boost/type_index/ctti_type_index.hpp | ||
| include/boost/type_index/runtime_cast/std_shared_ptr_cast.hpp | ||
| include/boost/type_index/runtime_cast/detail/runtime_cast_impl.hpp | ||
| include/boost/type_index/runtime_cast/register_runtime_class.hpp | ||
| include/boost/type_index/runtime_cast/pointer_cast.hpp | ||
| include/boost/type_index/runtime_cast/reference_cast.hpp | ||
| include/boost/type_index/runtime_cast/boost_shared_ptr_cast.hpp | ||
| include/boost/type_index/type_index_facade.hpp | ||
| ) | ||
| else() | ||
| target_include_directories(boost_type_index ${__scope} include) | ||
| endif() | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Link dependencies | ||
| # ----------------------------------------------------------------------------- | ||
| if(PROJECT_IS_TOP_LEVEL) | ||
| target_link_libraries(boost_type_index ${__scope} Boost::headers) | ||
| else() | ||
| target_link_libraries(boost_type_index | ||
| ${__scope} | ||
| Boost::config | ||
| Boost::container_hash | ||
| Boost::core | ||
| Boost::smart_ptr | ||
| Boost::throw_exception | ||
| Boost::unordered | ||
| ) | ||
| endif() | ||
|
|
||
| target_link_libraries(boost_type_index | ||
| ${__scope} | ||
| Boost::config | ||
| Boost::container_hash | ||
| Boost::throw_exception | ||
| ) | ||
| # Alias for convenient import | ||
| add_library(Boost::type_index ALIAS boost_type_index) | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # Testing | ||
| # ----------------------------------------------------------------------------- | ||
| if(BUILD_TESTING) | ||
| add_subdirectory(test) | ||
| add_subdirectory(test) | ||
| endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,28 +2,31 @@ | |
| # Distributed under the Boost Software License, Version 1.0. | ||
| # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt | ||
|
|
||
| cmake_minimum_required(VERSION 3.5...4.0) | ||
| cmake_minimum_required(VERSION 3.28...4.4) | ||
|
|
||
| set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "451f2fe2-a8a2-47c3-bc32-94786d8fc91b") | ||
|
|
||
| project(type_index_subdir_test LANGUAGES CXX) | ||
|
|
||
| foreach(dep IN ITEMS | ||
| assert | ||
| config | ||
| core | ||
| container_hash | ||
| describe | ||
| mp11 | ||
| smart_ptr | ||
| throw_exception | ||
| unordered | ||
| predef) | ||
| assert | ||
| config | ||
| core | ||
| container_hash | ||
| describe | ||
| mp11 | ||
| smart_ptr | ||
| throw_exception | ||
| unordered | ||
| predef | ||
| ) | ||
| add_subdirectory(../../../${dep} boostorg/${dep}) | ||
| endforeach() | ||
|
|
||
| enable_testing() | ||
| add_subdirectory(../../ boostorg/type_index) | ||
|
|
||
| if (BOOST_USE_MODULES) | ||
| if(BOOST_USE_MODULES) | ||
| add_executable(boost_type_index_module_usage ../../modules/usage_sample.cpp) | ||
| target_link_libraries(boost_type_index_module_usage PRIVATE Boost::type_index) | ||
| add_test(NAME boost_type_index_module_usage COMMAND boost_type_index_module_usage) | ||
|
|
@@ -32,4 +35,19 @@ if (BOOST_USE_MODULES) | |
| add_executable(boost_type_index_module_usage_mu ../../modules/usage_test_mu1.cpp ../../modules/usage_test_mu2.cpp) | ||
| 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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it in the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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$ |
||
| compare_ctti_stl.cpp | ||
| ctti_print_name.cpp | ||
| track_13621.cpp | ||
| type_index_runtime_cast_test.cpp | ||
| type_index_test.cpp | ||
| ) | ||
| endif() | ||
|
|
||
| foreach(testsourcefile ${RUN_TESTS_SOURCES}) | ||
| get_filename_component(testname ../${testsourcefile} NAME_WLE) | ||
| add_executable(${PROJECT_NAME}_${testname} ../${testsourcefile}) | ||
| target_link_libraries(${PROJECT_NAME}_${testname} Boost::type_index) | ||
| add_test(NAME ${PROJECT_NAME}_${testname} COMMAND ${PROJECT_NAME}_${testname}) | ||
| endforeach() | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ?