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} t and simplifies things. Reported by zimoun at <https://lists.gnu.org/archive/html/guix-devel/2021-02/msg00153.html>. * guix/profiles.scm (default-properties): New procedure. (package->manifest-entry): Use it for #:properties. * guix/scripts/pack.scm (guix-pack)[with-transformations]: Remove. Remove caller. * guix/scripts/package.scm (transaction-upgrade-entry): Remove calls to 'manifest-entry-with-transformations'. * tests/guix-package.sh: Add test. * tests/transformations.scm ("options->transformation + package->manifest-entry"): New test. Ludovic Courtès 2021-01-19transformations: Add '--with-latest'....* guix/upstream.scm (upstream-source-compiler): New procedure. (%updaters): Set! it. * guix/transformations.scm (transform-package-latest): New procedure. (%transformations): Add 'with-latest'. (%transformation-options, show-transformation-options-help/detailed): Add '--with-latest'. * tests/transformations.scm ("options->transformation, with-latest"): New test. * doc/guix.texi (Package Transformation Options): Document it. Ludovic Courtès 2020-12-27transformations: Add '--with-patch'....Suggested by Philippe Swartvagher <philippe.swartvagher@inria.fr>. * guix/transformations.scm (transform-package-patches): New procedure. (%transformations): Add it as 'with-patch'. (%transformation-options, show-transformation-options-help/detailed): Add '--with-patch'. * tests/transformations.scm ("options->transformation, with-patch"): New test. * doc/guix.texi (Package Transformation Options): Document it. Ludovic Courtès 2020-12-21tests: Check the effect of '--without-tests' on implicit inputs....* tests/transformations.scm ("options->transformation, without-tests"): Ensure TAR has #:tests? #f. Ludovic Courtès 2020-10-31guix build: Move transformation options to (guix transformations)....* guix/transformations.scm: New file. * tests/scripts-build.scm: Rename to... * tests/transformations.scm: ... this. * Makefile.am (MODULES): Add 'guix/transformations.scm'. (SCM_TESTS): Adjust to rename. * guix/scripts/build.scm (numeric-extension?) (tarball-base-name, <downloaded-file>, download-to-store*) (compile-downloaded-file, package-with-source) (transform-package-source, evaluate-replacement-specs) (transform-package-inputs, transform-package-inputs/graft) (%not-equal, package-git-url, evaluate-git-replacement-specs) (transform-package-source-branch, transform-package-source-commit) (transform-package-source-git-url, package-dependents/spec) (package-toolchain-rewriting, transform-package-toolchain) (transform-package-with-debug-info, transform-package-tests) (%transformations, transformation-procedure, %transformation-options) (show-transformation-options-help, options->transformation) (package-transformations): Move to (guix transformations). * guix/scripts/environment.scm: Adjust accordingly. * guix/scripts/graph.scm: Likewise. * guix/scripts/install.scm: Likewise. * guix/scripts/pack.scm: Likewise. * guix/scripts/package.scm: Likewise. * guix/scripts/upgrade.scm: Likewise. * po/guix/POTFILES.in: Add 'guix/transformations.scm'. Ludovic Courtès