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

cmake: add testing.cc to colmap_util only if TESTS_ENABLED=ON #2102

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

NeroBurner
Copy link
Contributor

Conditionally add the files testing.h and testing.cc to the library target colmap_util only if TESTS_ENABLED=ON.

Otherwise one needs the gtest/gtest.h header available, for example by installing the Debian package libgtest-dev, even though no tests are actually built.

Using the target_sources() function (Introduced with CMake 3.1`) to conditionally add the two testing files to the util target.

https://cmake.org/cmake/help/latest/command/target_sources.html

Fixes: #2101

Conditionally add the files `testing.h` and `testing.cc` to the library
target `colmap_util` only if `TESTS_ENABLED=ON`.

Otherwise one needs the `gtest/gtest.h` header available, for example by
installing the Debian package `libgtest-dev`, even though no tests are
actually built.

Using the `target_sources()` function (Introduced with CMake 3.1`) to
conditionally add the two testing files to the util target.

https://cmake.org/cmake/help/latest/command/target_sources.html

Fixes: colmap#2101
@ahojnnes ahojnnes merged commit f2255fe into colmap:dev Aug 8, 2023
11 checks passed
@ahojnnes
Copy link
Contributor

ahojnnes commented Aug 8, 2023

Thanks, LGTM.

@NeroBurner NeroBurner deleted the gtest_optional branch August 8, 2023 13:21
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.

gtest/gtest.h needed even though TESTS_ENABLED=NO
2 participants