Solved QtCreator CMake and compier defines
-
In CmakeLists.txt i set the following define:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_DEFINE")
In my source code I have the following:
#ifdef TEST_DEFINE return 1; #else return 2; #endif
In Qt Creator, the coloring indicates that TEST_DEFINE is not defined, but when compiling it is defined. What is the proper way to make Qt Creator aware of the defines set in CMakeLists.txt
-
Hi,
After modifying your CMakeFile.txt did you re-run cmake ?
-
@SGaist Yes
-
Which version of Qt Creator are you using ?
-
Does it work correctly if you use add_definitions() instead?
https://cmake.org/cmake/help/v3.0/command/add_definitions.html
-