-
Notifications
You must be signed in to change notification settings - Fork 591
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
Compile tests only in top-level projects. #197
Conversation
an option to disable building of tests would be more generic |
Are the tests causing a problem? I agree in principle that there should be a general mechanism (e.g. (I just encountered a problem building the tests with a cross compiler because they weren't being linked by the C++ linker, but that is hopefully fixed by 6e7f31f.) |
I'm building my own code against nlopt, and I don't need to have both set of tests (the ones for nlopt and mine) in the same project, since I'm only interested in my own tests. Also, when a test in nlopt fails it shouldn't impact my own tests (e.g. right now I have an issue with the guile test that is not compiling). I can add an option if you prefer, and set its default value based on whether nlopt is a top-level project or not. |
Ok done! |
CMakeLists.txt
Outdated
@@ -31,6 +31,12 @@ option (NLOPT_GUILE "build guile bindings" ON) | |||
option (NLOPT_SWIG "use SWIG to build bindings" ON) | |||
option (NLOPT_LINK_PYTHON "link Python libs" ON) | |||
|
|||
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) | |||
option (NLOPT_BUILD_TESTS "build unit tests" ON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably just NLOPT_TESTS
to be shorter
LGTM, thanks! |
This is a small change, which basically means that tests won't be compiled when
nlopt
is used in another project viaadd_subdirectory()
. Please let me know if you have any question.