-3
if (WITH_TEST)
    add_subdirectory(test/unitTesting)
endif(WITH_TEST)

How do you read the with_test variable in a .cpp file?

Kevin
  • 16,549
  • 8
  • 60
  • 74

1 Answers1

0

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
Badr El Hiouel
  • 281
  • 2
  • 10