-
Notifications
You must be signed in to change notification settings - Fork 3
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
Disable tests by default #4
Comments
For CMake-based projects, I usually check if my lib is being used as a sub-project with this hack: if(NOT DEFINED PROJECT_NAME)
set(LIB_IS_SUBPROJECT OFF)
else()
set(LIB_IS_SUBPROJECT ON)
endif()
# call to project() MUST come after!
project(...) and just use an implicit option if(ENABLE_TESTS AND NOT LIB_IS_SUBPROJECT)
message(STATUS "Unit Tests Enabled")
add_subdirectory(tests)
enable_testing()
endif() One can then enable the tests explicitly by passing Personally, I go a step further and detect when in debug mode and enable tests automatically in that case, disable them automatically in release mode (but they can be manually reënabled by passing the flag as mentioned above). |
@saxbophone, OK, Great! |
I could. What behaviour do you want?
|
The case is the following: What do you think? |
This is what I use for my own projects and it works well for me, is very convenient for CI and for manually building the tests in release mode if one's ever worried about compiler optimisations breaking them. I can do this no problem! |
@saxbophone , |
No, I've just been busy doing other stuff and haven't got round to it yet. You will be able to see when I start working on it as I will fork your project. |
OK. |
Somebody lies on the Internet again... |
You know, I really was going to do this for you when I found the time for it, but if that's your attitude then you know what, never mind. You can do it yourself. The code samples I've already given in comments here should be a good enough starting point for you. |
(from PR#3)
The text was updated successfully, but these errors were encountered: