From 471f60eaa0d3fb552834604cdc36aceb75e2da9d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Sat, 25 Nov 2023 18:58:02 +0100 Subject: [PATCH] autotest/cpp/CMakeLists.txt: avoid recompiling main_gtest.cpp multiple times --- autotest/cpp/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/autotest/cpp/CMakeLists.txt b/autotest/cpp/CMakeLists.txt index 795e1058fcdc..f764d3a4638b 100644 --- a/autotest/cpp/CMakeLists.txt +++ b/autotest/cpp/CMakeLists.txt @@ -174,9 +174,12 @@ register_test(test-unit gdal_unit_test) include(GdalTestTarget) +add_library(main_gtest OBJECT main_gtest.cpp) +target_include_directories(main_gtest PRIVATE $) +gdal_standard_includes(main_gtest) + gdal_test_target(testblockcache testblockcache.cpp) -target_sources(testblockcache PRIVATE main_gtest.cpp) -target_link_libraries(testblockcache PRIVATE gtest_for_gdal) +target_link_libraries(testblockcache PRIVATE gtest_for_gdal main_gtest) register_test( test-block-cache-1 @@ -273,8 +276,7 @@ endmacro () function (gdal_gtest_target _target testlabel _source) gdal_autotest_target(${_target} ${testlabel} ${_source} ${ARGN}) - target_sources(${_target} PRIVATE main_gtest.cpp) - target_link_libraries(${_target} PRIVATE gtest_for_gdal) + target_link_libraries(${_target} PRIVATE gtest_for_gdal main_gtest) endfunction () set(QUICKTEST_LIST