From 88e07bc4f029a98524ac4a78e3ddd75ac1f329b6 Mon Sep 17 00:00:00 2001 From: Hannes Kofler Date: Fri, 26 Jun 2026 11:18:46 +0200 Subject: [PATCH 1/2] cmake: fix module-tests naming conflicts all oatpp modules name their test executable module-tests. So when you use multiple modules their names conflict. --- azure-pipelines.yml | 2 +- test/CMakeLists.txt | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8b3abdb..ad8b306 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -88,6 +88,6 @@ jobs: displayName: 'Build - module' workingDirectory: build - script: | - module-tests.exe + oatpp-sqlite-tests.exe displayName: 'Test' workingDirectory: build\test\Debug\ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index be10c0d..a7eb359 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,7 +3,7 @@ add_definitions ( -DTEST_DB_MIGRATION="${CMAKE_CURRENT_SOURCE_DIR}/oatpp-sqlite/migration/" ) -add_executable(module-tests +add_executable(oatpp-sqlite-tests oatpp-sqlite/ql_template/ParserTest.cpp oatpp-sqlite/ql_template/ParserTest.hpp oatpp-sqlite/types/BlobTest.cpp @@ -16,28 +16,28 @@ add_executable(module-tests oatpp-sqlite/types/NumericTest.hpp oatpp-sqlite/tests.cpp) -set_target_properties(module-tests PROPERTIES +set_target_properties(oatpp-sqlite-tests PROPERTIES CXX_STANDARD 17 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON ) -target_include_directories(module-tests +target_include_directories(oatpp-sqlite-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) if(OATPP_MODULES_LOCATION STREQUAL OATPP_MODULES_LOCATION_EXTERNAL) - add_dependencies(module-tests ${LIB_OATPP_EXTERNAL}) + add_dependencies(oatpp-sqlite-tests ${LIB_OATPP_EXTERNAL}) endif() -add_dependencies(module-tests ${OATPP_THIS_MODULE_NAME}) +add_dependencies(oatpp-sqlite-tests ${OATPP_THIS_MODULE_NAME}) -target_link_oatpp(module-tests) +target_link_oatpp(oatpp-sqlite-tests) -target_link_libraries(module-tests +target_link_libraries(oatpp-sqlite-tests PRIVATE ${OATPP_THIS_MODULE_NAME} ) ## TODO link dependencies here (if some) -add_test(module-tests module-tests) \ No newline at end of file +add_test(oatpp-sqlite-tests oatpp-sqlite-tests) From da3e9e474a7f7d761a9812418f067fe67ff0ec70 Mon Sep 17 00:00:00 2001 From: Hannes Kofler Date: Fri, 26 Jun 2026 11:14:48 +0200 Subject: [PATCH 2/2] cmake: respect OATPP_LINK_TEST_LIBRARY variable integrate https://github.com/oatpp/oatpp/pull/542 into the sqlite module --- CMakeLists.txt | 7 +++++-- cmake/module-utils.cmake | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d7d497..d76bf31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(OATPP_DIR_SRC "Path to oatpp module directory (sources)") option(OATPP_DIR_LIB "Path to directory with liboatpp (directory containing ex: liboatpp.so or liboatpp.dynlib)") option(OATPP_BUILD_TESTS "Build tests for this module" ON) +option(OATPP_LINK_TEST_LIBRARY "Link oat++ test library" ON) option(OATPP_INSTALL "Install module binaries" ON) set(OATPP_MODULES_LOCATION "INSTALLED" CACHE STRING "Location where to find oatpp modules. can be [INSTALLED|EXTERNAL|CUSTOM]") @@ -54,8 +55,10 @@ if(OATPP_MODULES_LOCATION STREQUAL OATPP_MODULES_LOCATION_INSTALLED) get_target_property(OATPP_INCLUDE oatpp::oatpp INTERFACE_INCLUDE_DIRECTORIES) message("OATPP_INCLUDE=${OATPP_INCLUDE}") - get_target_property(OATPP_TEST_INCLUDE oatpp::oatpp-test INTERFACE_INCLUDE_DIRECTORIES) - message("OATPP_TEST_INCLUDE=${OATPP_TEST_INCLUDE}") + if (OATPP_BUILD_TESTS) + get_target_property(OATPP_TEST_INCLUDE oatpp::oatpp-test INTERFACE_INCLUDE_DIRECTORIES) + message("OATPP_TEST_INCLUDE=${OATPP_TEST_INCLUDE}") + endif() elseif(OATPP_MODULES_LOCATION STREQUAL OATPP_MODULES_LOCATION_EXTERNAL) diff --git a/cmake/module-utils.cmake b/cmake/module-utils.cmake index 8f1d35a..b562a07 100644 --- a/cmake/module-utils.cmake +++ b/cmake/module-utils.cmake @@ -6,9 +6,14 @@ macro(target_link_oatpp target) target_link_libraries(${target} PRIVATE oatpp::oatpp - PRIVATE oatpp::oatpp-test ) + if(OATPP_LINK_TEST_LIBRARY) + target_link_libraries(${target} + PRIVATE oatpp::oatpp-test + ) + endif() + else() message("target_link_oatpp(${target}) to found in provided path oatpp lib") @@ -17,9 +22,14 @@ macro(target_link_oatpp target) #target_link_directories(${target} PRIVATE ${OATPP_DIR_LIB}) target_link_libraries(${target} PRIVATE oatpp - PRIVATE oatpp-test ) + if(OATPP_LINK_TEST_LIBRARY) + target_link_libraries(${target} + PRIVATE oatpp-test + ) + endif() + endif() endmacro()