if (WITH_TEST)
add_subdirectory(test/unitTesting)
endif(WITH_TEST)
How do you read the with_test
variable in a .cpp
file?
if (WITH_TEST)
add_subdirectory(test/unitTesting)
endif(WITH_TEST)
How do you read the with_test
variable in a .cpp
file?
A solution could be to add preprocessor definition.
in your CMakeLists :
add_definitions(-DWITH_TEST_VALUE ="${WITH_TEST}")
And in you source code you could do something like this :
#ifdef WITH_TEST_VALUE
constexpr auto WITH_TEST = WITH_TEST_VALUE;
#else
// something
#endif