CMake add_definitions does not seem to work

Viewed 20936

I'm trying to define a preprocessor variable via CMake, but unfortunately it does not seem to work.

The following is my c++ code:

     #ifdef hehe_test
     #define it_exists "it_exists"
     #endif

     #ifndef hehe_test
     #define it_exists "it_doesnt_exist"
     #endif

     int main(int argc, char** argv)
     {
        printf("%s\n",it_exists);

        return 0;
    }

And this is my CMakeLists.txt:

    project(LibraryTester)

    add_definitions(hehe_test)

    file(GLOB src "*.h" "*.cpp")

    include_directories(${CMAKE_SOURCE_DIR}/include)

    add_executable( ${PROJECT_NAME} ${src})

When i run my program it outputs: it_doesnt_exist
indicating "hehe_test" has not been defined.

What am i doing wrong here?

2 Answers
Related