CMake - how to set multiple compile definitions for target executable?

You want target_compile_definitions instead of set_target_properties:

target_compile_definitions(trie_io_test PRIVATE UNIT_TESTING=1 IO_TEST=1)

I find this can work for you:

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
    COMPILE_DEFINITIONS IO_TEST=1
   )

Just by adding another COMPILE_DEFINITIONS :P

Tags:

Cmake