Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use system googletest dependency when available #304

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

topazus
Copy link

@topazus topazus commented Mar 29, 2023

No description provided.

@google-cla
Copy link

google-cla bot commented Mar 29, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gchatelet gchatelet requested a review from Mizux August 23, 2023 13:28
@gchatelet
Copy link
Collaborator

@Mizux does that look good to you?

@@ -184,7 +184,8 @@ if(BUILD_TESTING)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std14 instead of -gnustd14

if(NOT TARGET gtest OR NOT TARGET gmock_main)
find_package(GTest REQUIRED)
if(NOT TARGET GTest::gtest OR NOT TARGET GTest::gmock_main)
Copy link
Collaborator

@Mizux Mizux Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my 2 cents,

  1. GTest::gtest seems to be available only since CMake 3.5 (cpu_feature still use 3.0 as minimum requirement...)
    ref: https://cmake.org/cmake/help/v3.5/module/FindGTest.html
    ref: https://cmake.org/cmake/help/v3.4/module/FindGTest.html

  2. Googletest didn't provide these aliases until recently
    issue: Add CMake aliases googletest#2429
    PR: CMake: Add namespaced ALIAS library googletest#3155
    commit: google/googletest@6c5c455
    available in v1.14.0 … release-1.11.0

to compare with https://repology.org/project/gtest/badges (e.g. ubuntu 20.04 LTS => gtest 1.10.0)

  1. If your superbuild is using add_subdirectory() OR fetch_content() (without the new flag FIND_PACKAGE_ARGS NAMES ...) then you find_package() won't work as expected (i.e. ignore the call since your super already provide it)
    ref: https://cmake.org/cmake/help/latest/module/FetchContent.html#integrating-with-find-package

  2. Also in 3.24 we would be able to have FetchContent calling find_package() before sourcing if unavailable...
    ref: https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_TRY_FIND_PACKAGE_MODE

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EDIT:

  1. DONE (we now target cmake 3.13)
  2. googletest v1.11 (June 2021) should provide alias -> Can we suppose super build use at least googletest 1.11 ?

@@ -184,7 +184,8 @@ if(BUILD_TESTING)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # prefer use of -std14 instead of -gnustd14

if(NOT TARGET gtest OR NOT TARGET gmock_main)
find_package(GTest REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you add REQUIRED -> if not found the cmake configure will fail where instead you would like to fallback to "build googletest if not found in the system"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants