more CML fixes for integration in super-project

This commit is contained in:
Jean-Louis Leroy
2025-10-27 14:10:16 -04:00
parent af52a803d6
commit 8617f71a05
4 changed files with 17 additions and 16 deletions

View File

@@ -178,6 +178,9 @@ endif()
if (BUILD_TESTING OR BOOST_OPENMETHOD_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
if (BOOST_OPENMETHOD_IS_ROOT)
add_custom_target(all_with_tests ALL DEPENDS tests)
endif()
endif ()
#-------------------------------------------------

View File

@@ -3,7 +3,7 @@
# See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
message(STATUS "Building examples")
message(STATUS "Boost.OpenMethod: building examples")
if (CMAKE_BUILD_TYPE STREQUAL "Release")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
@@ -18,10 +18,9 @@ endif()
file(GLOB cpp_files "*.cpp")
foreach (cpp ${cpp_files})
cmake_path(REMOVE_EXTENSION cpp LAST_ONLY OUTPUT_VARIABLE stem)
string(REGEX REPLACE ".*/" "" stem ${stem})
get_filename_component(stem ${cpp} NAME_WE)
add_executable(${stem} ${cpp})
target_link_libraries(${stem} PUBLIC Boost::openmethod Boost::unit_test_framework)
target_link_libraries(${stem} PRIVATE Boost::openmethod Boost::unit_test_framework)
add_test(NAME ${stem} COMMAND ${stem})
add_dependencies(tests ${stem})
endforeach()
@@ -40,8 +39,8 @@ function(add_step_by_step dir)
file(GLOB cpp_files "${subdir}/*.cpp")
set(target "${dir}_${subex}")
add_executable(${target} ${cpp_files})
target_link_libraries(${target} PUBLIC Boost::openmethod)
set(output_dir "${subdir}")
target_link_libraries(${target} PRIVATE Boost::openmethod)
set(output_dir openmethod/${dir}/${subex})
set_target_properties(${target} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${output_dir}"
LIBRARY_OUTPUT_DIRECTORY "${output_dir}"

View File

@@ -3,7 +3,7 @@
# See accompanying file LICENSE_1_0.txt
# or copy at http://www.boost.org/LICENSE_1_0.txt)
message(STATUS "Building shared library examples")
message(STATUS "Boost.OpenMethod: building shared library examples")
add_compile_definitions(BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS)
@@ -35,14 +35,14 @@ endif()
add_library(indirect_shared SHARED indirect_extensions.cpp)
target_compile_definitions(
indirect_shared PUBLIC BOOST_OPENMETHOD_DEFAULT_REGISTRY=indirect_registry)
target_link_libraries(indirect_shared Boost::openmethod Boost::dll)
target_link_libraries(indirect_shared PRIVATE Boost::openmethod Boost::dll)
set_target_properties(indirect_shared PROPERTIES ENABLE_EXPORTS ON)
add_executable(indirect indirect_main.cpp)
target_compile_definitions(
indirect PUBLIC BOOST_OPENMETHOD_DEFAULT_REGISTRY=indirect_registry)
set_target_properties(indirect PROPERTIES ENABLE_EXPORTS ON)
target_link_libraries(indirect Boost::openmethod Boost::dll)
target_link_libraries(indirect PRIVATE Boost::openmethod Boost::dll)
add_dependencies(indirect indirect_shared)
if (NOT WIN32)
add_test(NAME indirect_shared COMMAND indirect)

View File

@@ -8,7 +8,7 @@
# Official repository: https://github.com/boostorg/openmethod
#
message(STATUS "Building tests")
message(STATUS "Boost.OpenMethod: building tests")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS)
@@ -56,16 +56,15 @@ endif()
file(GLOB test_cpp_files "test_*.cpp")
foreach(test_cpp ${test_cpp_files})
cmake_path(REMOVE_EXTENSION test_cpp LAST_ONLY OUTPUT_VARIABLE test)
string(REGEX REPLACE ".*/" "" test ${test})
add_executable(${test} ${test_cpp})
target_link_libraries(${test} PUBLIC Boost::openmethod Boost::unit_test_framework)
get_filename_component(test ${test_cpp} NAME_WE)
add_executable(${test} EXCLUDE_FROM_ALL ${test_cpp})
target_link_libraries(${test} PRIVATE Boost::openmethod Boost::unit_test_framework)
add_test(NAME ${test} COMMAND ${test})
add_dependencies(tests ${test})
endforeach()
add_executable(test_mix_release_debug mix_release_debug/main.cpp mix_release_debug/lib.cpp)
target_link_libraries(test_mix_release_debug Boost::openmethod Boost::unit_test_framework)
add_executable(test_mix_release_debug EXCLUDE_FROM_ALL mix_release_debug/main.cpp mix_release_debug/lib.cpp)
target_link_libraries(test_mix_release_debug PRIVATE Boost::openmethod Boost::unit_test_framework)
add_test(NAME test_mix_release_debug COMMAND test_mix_release_debug)
add_dependencies(tests test_mix_release_debug)