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

Add a CMake option BUILD_TESTS to decide whether to build S2 unit tests #333

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

acelyc111
Copy link
Contributor

@acelyc111 acelyc111 commented Nov 21, 2023

In the use case of using s2geometry as a thirdparty library of a project, it's not needed to build S2 unit tests, but it's possible to use test utilities in src/s2/s2testing.
In this case, s2testing has to be exported, but unit tests are not necessary to build.
This patch adds an option BUILD_TESTS to decide whether to build S2 unit tests.

Copy link

google-cla bot commented Nov 21, 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.

@acelyc111 acelyc111 changed the title Add an option BUILD_TESTS to decide whether to build S2 unit tests Add a CMake option BUILD_TESTS to decide whether to build S2 unit tests Nov 21, 2023
@smcallis
Copy link
Collaborator

Is the intention to not build the unit tests themselves or just not build the google test/google mock subdirectories? I think this would only do the latter.

@acelyc111
Copy link
Contributor Author

Is the intention to not build the unit tests themselves or just not build the google test/google mock subdirectories? I think this would only do the latter.

@smcallis Both of them will not be built. As the code shows in:
https://github.com/google/s2geometry/pull/333/files#diff-1e7de1ae2d059d21e1dd75d5812d5a34b0222cef273b7c3a2af62eb747f9d20aR441, the unit tests will not be added.

CMakeLists.txt Outdated
@@ -432,7 +433,7 @@ install(TARGETS ${S2_TARGETS}
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

message("GOOGLETEST_ROOT: ${GOOGLETEST_ROOT}")
if (GOOGLETEST_ROOT)
if (GOOGLETEST_ROOT AND BUILD_TESTS)
Copy link
Member

Choose a reason for hiding this comment

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

Depending on only GOOGLETEST_ROOT was a mistake.

How about something like

if (BUILD_TESTS)
  if (NOT GOOGLETEST_ROOT)
    message(FATAL_ERROR "BUILD_TESTS requires GOOGLETEST_ROOT")
  endif()
  message("GOOGLETEST_ROOT: ${GOOGLETEST_ROOT}")
  ...

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done.

@jmr jmr merged commit fadf458 into google:master Nov 22, 2023
1 check passed
@jmr
Copy link
Member

jmr commented Nov 22, 2023

Thanks!

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.

3 participants