CML: prefix targets with "boost_openmethod-"

This commit is contained in:
Jean-Louis Leroy
2025-10-27 20:57:43 -04:00
parent 36d88320ba
commit 0bda0fee49
3 changed files with 50 additions and 46 deletions

View File

@@ -19,25 +19,27 @@ file(GLOB cpp_files "*.cpp")
foreach (cpp ${cpp_files})
get_filename_component(stem ${cpp} NAME_WE)
add_executable(${stem} ${cpp})
target_link_libraries(${stem} PRIVATE Boost::openmethod Boost::unit_test_framework)
add_test(NAME ${stem} COMMAND ${stem})
add_dependencies(tests ${stem})
set(test_target "boost_openmethod-${stem}")
add_executable(${test_target} ${cpp})
target_link_libraries(${test_target} PRIVATE Boost::openmethod Boost::unit_test_framework)
add_test(NAME ${test_target} COMMAND ${test_target})
add_dependencies(tests ${test_target})
endforeach()
function(add_step_by_step dir)
function(boost_openmethod_add_step_by_step dir)
set(add_test "")
if(ARGC GREATER 1)
set(add_test "${ARGV1}")
else()
set(add_test "ON")
endif()
file(GLOB subdirs "${dir}/*")
foreach (subdir ${subdirs})
string(REGEX REPLACE ".*/" "" subex ${subdir})
file(GLOB cpp_files "${subdir}/*.cpp")
set(target "${dir}_${subex}")
set(target "boost_openmethod-${dir}_${subex}")
add_executable(${target} ${cpp_files})
target_link_libraries(${target} PRIVATE Boost::openmethod)
set(output_dir openmethod/${dir}/${subex})
@@ -53,11 +55,11 @@ function(add_step_by_step dir)
endforeach()
endfunction()
add_step_by_step(rolex)
add_step_by_step(ambiguities OFF)
add_step_by_step(core_api)
add_step_by_step(custom_rtti)
add_step_by_step(virtual_ptr_alt)
boost_openmethod_add_step_by_step(rolex)
boost_openmethod_add_step_by_step(ambiguities OFF)
boost_openmethod_add_step_by_step(core_api)
boost_openmethod_add_step_by_step(custom_rtti)
boost_openmethod_add_step_by_step(virtual_ptr_alt)
if (NOT WIN32)
add_subdirectory(shared_libs)

View File

@@ -10,40 +10,40 @@ add_compile_definitions(BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS)
# ------------------------------------------------------------------------------
# static linking
add_library(shared SHARED extensions.cpp)
target_link_libraries(shared Boost::openmethod)
set_target_properties(shared PROPERTIES ENABLE_EXPORTS ON)
add_library(boost_openmethod-shared SHARED extensions.cpp)
target_link_libraries(boost_openmethod-shared Boost::openmethod)
set_target_properties(boost_openmethod-shared PROPERTIES ENABLE_EXPORTS ON)
add_executable(static static_main.cpp)
target_link_libraries(static Boost::openmethod Boost::dll shared)
add_test(NAME static_shared COMMAND static)
add_executable(boost_openmethod-static static_main.cpp)
target_link_libraries(boost_openmethod-static Boost::openmethod Boost::dll boost_openmethod-shared)
add_test(NAME boost_openmethod-static COMMAND boost_openmethod-static)
# ------------------------------------------------------------------------------
# dynamic loading, direct virtual_ptrs
add_executable(dynamic dynamic_main.cpp)
set_target_properties(dynamic PROPERTIES ENABLE_EXPORTS ON)
target_link_libraries(dynamic Boost::openmethod Boost::dll)
add_dependencies(dynamic shared)
add_executable(boost_openmethod-dynamic dynamic_main.cpp)
set_target_properties(boost_openmethod-dynamic PROPERTIES ENABLE_EXPORTS ON)
target_link_libraries(boost_openmethod-dynamic Boost::openmethod Boost::dll)
add_dependencies(boost_openmethod-dynamic boost_openmethod-shared)
if (NOT WIN32)
add_test(NAME dynamic_shared COMMAND dynamic)
add_test(NAME boost_openmethod-dynamic COMMAND boost_openmethod-dynamic)
endif()
# ------------------------------------------------------------------------------
# dynamic loading, indirect virtual_ptrs
add_library(indirect_shared SHARED indirect_extensions.cpp)
add_library(boost_openmethod-indirect_shared SHARED indirect_extensions.cpp)
target_compile_definitions(
indirect_shared PUBLIC BOOST_OPENMETHOD_DEFAULT_REGISTRY=indirect_registry)
target_link_libraries(indirect_shared PRIVATE Boost::openmethod Boost::dll)
set_target_properties(indirect_shared PROPERTIES ENABLE_EXPORTS ON)
boost_openmethod-indirect_shared PUBLIC BOOST_OPENMETHOD_DEFAULT_REGISTRY=indirect_registry)
target_link_libraries(boost_openmethod-indirect_shared PRIVATE Boost::openmethod Boost::dll)
set_target_properties(boost_openmethod-indirect_shared PROPERTIES ENABLE_EXPORTS ON)
add_executable(indirect indirect_main.cpp)
add_executable(boost_openmethod-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 PRIVATE Boost::openmethod Boost::dll)
add_dependencies(indirect indirect_shared)
boost_openmethod-indirect PUBLIC BOOST_OPENMETHOD_DEFAULT_REGISTRY=indirect_registry)
set_target_properties(boost_openmethod-indirect PROPERTIES ENABLE_EXPORTS ON)
target_link_libraries(boost_openmethod-indirect PRIVATE Boost::openmethod Boost::dll)
add_dependencies(boost_openmethod-indirect boost_openmethod-indirect_shared)
if (NOT WIN32)
add_test(NAME indirect_shared COMMAND indirect)
add_test(NAME boost_openmethod-indirect COMMAND boost_openmethod-indirect)
endif()

View File

@@ -57,24 +57,26 @@ file(GLOB test_cpp_files "test_*.cpp")
foreach(test_cpp ${test_cpp_files})
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})
set(test_target "boost_openmethod-${test}")
add_executable(${test_target} EXCLUDE_FROM_ALL ${test_cpp})
target_link_libraries(${test_target} PRIVATE Boost::openmethod Boost::unit_test_framework)
add_test(NAME ${test_target} COMMAND ${test_target})
add_dependencies(tests ${test_target})
endforeach()
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)
add_executable(boost_openmethod-test_mix_release_debug EXCLUDE_FROM_ALL mix_release_debug/main.cpp mix_release_debug/lib.cpp)
target_link_libraries(boost_openmethod-test_mix_release_debug PRIVATE Boost::openmethod Boost::unit_test_framework)
add_test(NAME boost_openmethod-test_mix_release_debug COMMAND boost_openmethod-test_mix_release_debug)
add_dependencies(tests boost_openmethod-test_mix_release_debug)
function(openmethod_compile_fail_test testname fail_regex)
add_library("compile-fail-${testname}" STATIC EXCLUDE_FROM_ALL "${testname}.cpp")
target_link_libraries("compile-fail-${testname}" PRIVATE Boost::openmethod)
add_test(
NAME "openmethod-${testname}"
COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target "compile-fail-${testname}" --config $<CONFIG>)
set_property(TEST "openmethod-${testname}" PROPERTY PASS_REGULAR_EXPRESSION "${fail_regex}")
set(test_target "boost_openmethod-${testname}")
add_library(${test_target} STATIC EXCLUDE_FROM_ALL "${testname}.cpp")
target_link_libraries(${test_target} PRIVATE Boost::openmethod)
add_test(
NAME "${test_target}"
COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target "${test_target}" --config $<CONFIG>)
set_property(TEST "${test_target}" PROPERTY PASS_REGULAR_EXPRESSION "${fail_regex}")
endfunction()
openmethod_compile_fail_test(