From f5cf01083baf7e8dc8318db3648bc6098dc32d67 Mon Sep 17 00:00:00 2001 From: Nicholas Guriev Date: Sat, 18 Apr 2020 13:30:17 +0300 Subject: [PATCH] Search for GoogleTest via pkg-config first --- tests/CMakeLists.txt | 55 ++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 02193197..53d475c2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,36 +1,41 @@ cmake_minimum_required(VERSION 3.0.2) project(GSLTests CXX) +include(FindPkgConfig) # will make visual studio generated project group files set_property(GLOBAL PROPERTY USE_FOLDERS ON) -configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) -execute_process( - COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download -) -if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") -endif() +pkg_search_module(GTestMain gtest_main) +if (NOT GTestMain_FOUND) + configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) + execute_process( + COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download + ) + if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") + endif() -execute_process( - COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download -) -if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") -endif() + execute_process( + COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download + ) + if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") + endif() -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + set(GTestMain_LIBRARIES gtest_main) -add_subdirectory( - ${CMAKE_CURRENT_BINARY_DIR}/googletest-src - ${CMAKE_CURRENT_BINARY_DIR}/googletest-build - EXCLUDE_FROM_ALL -) + add_subdirectory( + ${CMAKE_CURRENT_BINARY_DIR}/googletest-src + ${CMAKE_CURRENT_BINARY_DIR}/googletest-build + EXCLUDE_FROM_ALL + ) +endif() if (MSVC AND (GSL_CXX_STANDARD EQUAL 17)) set(GSL_CPLUSPLUS_OPT -Zc:__cplusplus -permissive-) @@ -149,7 +154,7 @@ function(add_gsl_test name) target_link_libraries(${name} GSL gsl_tests_config - gtest_main + ${GTestMain_LIBRARIES} ) add_test( ${name} @@ -254,7 +259,7 @@ function(add_gsl_test_noexcept name) target_link_libraries(${name} GSL gsl_tests_config_noexcept - gtest_main + ${GTestMain_LIBRARIES} ) add_test( ${name} loader): Delete variable. * gnu/machine/ssh.scm (deploy-managed-host): Rewrite procedure. * gnu/services/herd.scm (live-service): Export variable. * gnu/services/herd.scm (live-service-canonical-name): New variable. * tests/services.scm (live-service): Delete variable. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Jakob L. Kreuze 2019-01-24tests: Remove duplicate field initializers....Fixes a regression introduced in c2dcff41c2e47f5f978f467864d5ed7829939884, whereby many tests in 'tests/packages.scm' would trigger a syntax error due to duplicate field intializers in forms like: (dummy-package "foo" (version "0")) * guix/tests.scm (dummy-package, dummy-origin): Rewrite to inherit from a base record. This restores the semantics from before c2dcff41c2e47f5f978f467864d5ed7829939884. * tests/services.scm ("instantiate-missing-services, indirect"): Remove duplicate 'extensions' field. Ludovic Courtès 2018-09-27tests: Adjust services tests to new 'shepherd-service-upgrade'....This is a followup to 4245ddcbc9f935804c17c97872b90ec1050c2d75. * tests/services.scm ("shepherd-service-upgrade: one unchanged, one upgraded, one new") ("shepherd-service-upgrade: service depended on is not unloaded") ("shepherd-service-upgrade: obsolete services that depend on each other"): Adjust to changes in 'shepherd-service-upgrade'. Ludovic Courtès 2018-09-07services: 'instantiate-missing-services' reaches fixed point....Fixes a bug whereby services indirectly depended on would not be automatically instantiated. * gnu/services.scm (instantiate-missing-services): Loop back when the length of ADJUSTED is greater than that of INSTANCES. * tests/services.scm ("instantiate-missing-services, indirect"): New test. Ludovic Courtès 2018-01-21services: Missing services are automatically instantiated....This simplifies OS configuration: users no longer need to be aware of what a given service depends on. See the discussion at <https://lists.gnu.org/archive/html/guix-devel/2018-01/msg00114.html>. * gnu/services.scm (missing-target-error): New procedure. (service-back-edges): Use it. (instantiate-missing-services): New procedure. * gnu/system.scm (operating-system-services): Call 'instantiate-missing-services'. * tests/services.scm ("instantiate-missing-services") ("instantiate-missing-services, no default value"): New tests. * gnu/services/version-control.scm (cgit-service-type)[extensions]: Add FCGIWRAP-SERVICE-TYPE. * gnu/tests/version-control.scm (%cgit-os): Remove NGINX-SERVICE-TYPE and FCGIWRAP-SERVICE-TYPE instances. * doc/guix.texi (Log Rotation): Remove 'mcron-service-type' in example. (Miscellaneous Services): Remove 'nginx-service-type' and 'fcgiwrap-service-type' in Cgit example. Ludovic Courtès 2017-11-08services: Add 'lookup-service-types'....* gnu/services.scm (lookup-service-types): New procedure. * tests/services.scm ("lookup-service-types"): New test. Ludovic Courtès