-
Notifications
You must be signed in to change notification settings - Fork 249
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
Skip building tests by default when included in other projects #931
Conversation
When the changes are merged, the test code that was previously built in the subproject will no longer be built. |
It's not clear to me why the tests break on this PR, but at any rate I'm not confident yet that I get this idea. Also, it relies on a string comparison and I'd like to be sure that that check is robust in the face of soft links, unicode normalisation, etc. if possible. |
See also:
In libpqxx, CMakeLists.txt is the top of the project. CMAKE_SOURCE_DIR: path/to/libpqxx/CMakeLists.txt
CMAKE_CURRENT_SOURCE_DIR: path/to/libpqxx/CMakeLists.txt From CMakeLists.txt, test/CMakeLists.txt is imported by Line 35 in d280c6c
At this time test/CMakeLists.txt is evaluated, but at this time -CMAKE_SOURCE_DIR: path/to/libpqxx/CMakeLists.txt
+CMAKE_CURRENT_SOURCE_DIR: path/to/libpqxx/test/CMakeLists.txt
These two variables are generated by CMake, so there is no need to worry about them. |
Trying to figure out why the CircleCI test is failing... It doesn't look related but it's entirely unclear. :-( Thanks @tt4g for the explanation. I'm warming to the idea. On the one hand the tests even when they don't actually run may expose some compile problems on other systems out there before they actually hit any users. On the other hand, the tests take up most of the compile time and most portability problems and such will show up soon enough as people build applications. |
@ankane it looks like the build is failing because you're not logged into CircleCI. |
@ankane I've merged it anyway — bit silly that the test pipeline gets run under your identity but does not check that this is in fact possible. A local build still works. Thanks for the contribution, it'll save a lot of people some time. |
Thanks @jtv! Another method I've seen is |
Hi, I think it'd be nice to skip building tests by default when libpqxx is included in other projects. For instance, with FetchContent:
Currently, projects need to set:
nlohmann/json is one project that does this.