CMake add_definitions does not seem to work
The following form won't do what you expect in any case:
add_definitions(hehe_test)
According to the documentation the form is:
add_definitions(-DFOO -DBAR ...)
In your case it means:
add_definitions(-Dhehe_test)
You can also give them a value if required:
// statically defined
add_definitions(-Dfoo=bar)
// use a cmake or user-defined variable
add_definitions(-Dbar=${FOO})
// use "" if you intend to pass strings with spaces
add_definitions(-Dxxx="${YYY}")
Note that you can put all of them together in the same add_definitions
call.
In order to get the C/C++ effect of :
#define _MYSYMBOL
From the command line you can :
cmake . -DCMAKE_C_FLAGS=" -D_MYSYMBOL " -DCMAKE_CXX_FLAGS=" -D_MYSYMBOL "
From within CMakeLists.txt:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_MYSYMBOL")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_MYSYMBOL")
These add flags to the c/c++ compiler command directly. -D is define symbol
You can also use cmake's add_definitions
command
add_definitions ( -D_MYSYMBOL1 -D_MYSYMBOL2 )
add_definitions
makes some slight assumptions as described here