mirror of
https://github.com/void-linux/void-packages.git
synced 2025-06-05 06:33:50 +02:00
cppdap: fix gtest patch to fix build with gcc14
This commit is contained in:
parent
4e73161431
commit
a2c9d8ac07
1 changed files with 83 additions and 14 deletions
|
@ -1,32 +1,101 @@
|
||||||
|
From ae76a3888e273c662c7bc7f8f5eaca6a2f6774ca Mon Sep 17 00:00:00 2001
|
||||||
|
From: topazus <topazus@outlook.com>
|
||||||
|
Date: Wed, 27 Dec 2023 19:56:49 +0800
|
||||||
|
Subject: [PATCH] CMake: add CPPDAP_USE_EXTERNAL_GTEST_PACKAGE option
|
||||||
|
|
||||||
|
---
|
||||||
|
CMakeLists.txt | 35 +++++++++++++++++++++++++----------
|
||||||
|
1 file changed, 25 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||||
|
index 1b3c321..7292f3c 100644
|
||||||
--- a/CMakeLists.txt
|
--- a/CMakeLists.txt
|
||||||
+++ b/CMakeLists.txt
|
+++ b/CMakeLists.txt
|
||||||
@@ -59,13 +59,6 @@ set_if_not_defined(CPPDAP_GOOGLETEST_DIR
|
@@ -40,6 +40,7 @@ option_if_not_defined(CPPDAP_INSTALL_VSCODE_EXAMPLES "Build and install dap exam
|
||||||
|
option_if_not_defined(CPPDAP_USE_EXTERNAL_NLOHMANN_JSON_PACKAGE "Use nlohmann_json with find_package() instead of building internal submodule" OFF)
|
||||||
|
option_if_not_defined(CPPDAP_USE_EXTERNAL_RAPIDJSON_PACKAGE "Use RapidJSON with find_package()" OFF)
|
||||||
|
option_if_not_defined(CPPDAP_USE_EXTERNAL_JSONCPP_PACKAGE "Use JsonCpp with find_package()" OFF)
|
||||||
|
+option_if_not_defined(CPPDAP_USE_EXTERNAL_GTEST_PACKAGE "Use googletest with find_package()" OFF)
|
||||||
|
|
||||||
|
###########################################################
|
||||||
|
# Directories
|
||||||
|
@@ -59,7 +60,7 @@ set_if_not_defined(CPPDAP_GOOGLETEST_DIR ${CPPDAP_THIRD_PARTY_DIR}/googletest)
|
||||||
###########################################################
|
###########################################################
|
||||||
# Submodules
|
# Submodules
|
||||||
###########################################################
|
###########################################################
|
||||||
-if(CPPDAP_BUILD_TESTS)
|
-if(CPPDAP_BUILD_TESTS)
|
||||||
- if(NOT EXISTS ${CPPDAP_GOOGLETEST_DIR}/.git)
|
+if(CPPDAP_BUILD_TESTS AND NOT CPPDAP_USE_EXTERNAL_GTEST_PACKAGE)
|
||||||
- message(WARNING "third_party/googletest submodule missing.")
|
if(NOT EXISTS ${CPPDAP_GOOGLETEST_DIR}/.git)
|
||||||
- message(WARNING "Run: `git submodule update --init` to build tests.")
|
message(WARNING "third_party/googletest submodule missing.")
|
||||||
- set(CPPDAP_BUILD_TESTS OFF)
|
message(WARNING "Run: `git submodule update --init` to build tests.")
|
||||||
- endif()
|
@@ -161,7 +162,7 @@ function(cppdap_set_json_links target)
|
||||||
-endif(CPPDAP_BUILD_TESTS)
|
target_link_libraries(${target} PRIVATE JsonCpp::JsonCpp)
|
||||||
|
else()
|
||||||
|
target_include_directories(${target} PRIVATE "${CPPDAP_JSON_DIR}/include/")
|
||||||
|
- endif()
|
||||||
|
+ endif()
|
||||||
|
endfunction(cppdap_set_json_links)
|
||||||
|
|
||||||
###########################################################
|
function(cppdap_set_target_options target)
|
||||||
# JSON library
|
@@ -247,7 +248,7 @@ write_basic_package_version_file(
|
||||||
@@ -289,7 +282,6 @@ if(CPPDAP_BUILD_TESTS)
|
)
|
||||||
|
configure_package_config_file(
|
||||||
|
${CPPDAP_CMAKE_CONFIG_TEMPLATE}
|
||||||
|
- "${CPPDAP_CMAKE_PROJECT_CONFIG_FILE}"
|
||||||
|
+ "${CPPDAP_CMAKE_PROJECT_CONFIG_FILE}"
|
||||||
|
INSTALL_DESTINATION ${CPPDAP_CONFIG_INSTALL_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
@@ -276,6 +277,8 @@ DESTINATION ${CPPDAP_CONFIG_INSTALL_DIR})
|
||||||
|
|
||||||
|
# tests
|
||||||
|
if(CPPDAP_BUILD_TESTS)
|
||||||
|
+ enable_testing()
|
||||||
|
+
|
||||||
|
set(DAP_TEST_LIST
|
||||||
|
${CPPDAP_SRC_DIR}/any_test.cpp
|
||||||
|
${CPPDAP_SRC_DIR}/chan_test.cpp
|
||||||
|
@@ -290,16 +293,24 @@ if(CPPDAP_BUILD_TESTS)
|
||||||
${CPPDAP_SRC_DIR}/traits_test.cpp
|
${CPPDAP_SRC_DIR}/traits_test.cpp
|
||||||
${CPPDAP_SRC_DIR}/typeinfo_test.cpp
|
${CPPDAP_SRC_DIR}/typeinfo_test.cpp
|
||||||
${CPPDAP_SRC_DIR}/variant_test.cpp
|
${CPPDAP_SRC_DIR}/variant_test.cpp
|
||||||
- ${CPPDAP_GOOGLETEST_DIR}/googletest/src/gtest-all.cc
|
- ${CPPDAP_GOOGLETEST_DIR}/googletest/src/gtest-all.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(DAP_TEST_INCLUDE_DIR
|
- set(DAP_TEST_INCLUDE_DIR
|
||||||
@@ -312,6 +304,7 @@ if(CPPDAP_BUILD_TESTS)
|
- ${CPPDAP_GOOGLETEST_DIR}/googlemock/include/
|
||||||
|
- ${CPPDAP_GOOGLETEST_DIR}/googletest/
|
||||||
|
- ${CPPDAP_GOOGLETEST_DIR}/googletest/include/
|
||||||
|
- )
|
||||||
|
+ if(CPPDAP_USE_EXTERNAL_GTEST_PACKAGE)
|
||||||
|
+ find_package(GTest REQUIRED)
|
||||||
|
+ else()
|
||||||
|
+ list(APPEND DAP_TEST_LIST
|
||||||
|
+ ${CPPDAP_GOOGLETEST_DIR}/googletest/src/gtest-all.cc
|
||||||
|
+ )
|
||||||
|
+
|
||||||
|
+ set(DAP_TEST_INCLUDE_DIR
|
||||||
|
+ ${CPPDAP_GOOGLETEST_DIR}/googlemock/include/
|
||||||
|
+ ${CPPDAP_GOOGLETEST_DIR}/googletest/
|
||||||
|
+ ${CPPDAP_GOOGLETEST_DIR}/googletest/include/
|
||||||
|
+ )
|
||||||
|
+ endif()
|
||||||
|
|
||||||
|
add_executable(cppdap-unittests ${DAP_TEST_LIST})
|
||||||
|
+ add_test(NAME cppdap-unittests COMMAND cppdap-unittests)
|
||||||
|
|
||||||
|
target_include_directories(cppdap-unittests PUBLIC ${DAP_TEST_INCLUDE_DIR} )
|
||||||
|
set_target_properties(cppdap-unittests PROPERTIES
|
||||||
|
@@ -312,7 +323,11 @@ if(CPPDAP_BUILD_TESTS)
|
||||||
|
endif()
|
||||||
|
|
||||||
cppdap_set_target_options(cppdap-unittests)
|
cppdap_set_target_options(cppdap-unittests)
|
||||||
target_link_libraries(cppdap-unittests PRIVATE cppdap)
|
- target_link_libraries(cppdap-unittests PRIVATE cppdap)
|
||||||
+ target_link_libraries(cppdap-unittests PRIVATE gtest_main gtest)
|
+ if(CPPDAP_USE_EXTERNAL_GTEST_PACKAGE)
|
||||||
|
+ target_link_libraries(cppdap-unittests PRIVATE cppdap GTest::gtest)
|
||||||
|
+ else()
|
||||||
|
+ target_link_libraries(cppdap-unittests PRIVATE cppdap)
|
||||||
|
+ endif()
|
||||||
endif(CPPDAP_BUILD_TESTS)
|
endif(CPPDAP_BUILD_TESTS)
|
||||||
|
|
||||||
# fuzzer
|
# fuzzer
|
||||||
|
|
Loading…
Add table
Reference in a new issue