I'm trying to set multiple compile definitions for one of the executables I'm trying to compile in CMake (in order to activate macros used for debugging). Here's what I tried:
add_executable (trie_io_test trie_io_test.c trie.c word_list.c)
set_target_properties(
trie_io_test
PROPERTIES
COMPILE_DEFINITIONS UNIT_TESTING=1)
set_target_properties(
trie_io_test
PROPERTIES
COMPILE_DEFINITIONS IO_TEST=1)
Unfortunately this causes only the IO_TEST to be defined.
I also tried the following:
add_executable (trie_io_test trie_io_test.c trie.c word_list.c)
set_target_properties(
trie_io_test
PROPERTIES
COMPILE_DEFINITIONS UNIT_TESTING=1 IO_TEST=1)
But this, on the other hand, causes CMake error.
How to set both of these definitions for the executable I'm trying to build?
You want
target_compile_definitions
instead ofset_target_properties
: