I was just starting to learn CMake and thought that I would understand the basic process of first writing CMakeLists.txt , and then the settings for creating CMakeCache.txt and finally generating Makefiles .
However, when I try to apply it to the next CMakeLists.txt, I do not get the expected results, and I'm not sure what is going wrong. The CMakeLists.txt part looks like this:
# compiler flags if (CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fpermissive -Wall -Wformat-security") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs") endif() endif()
Since I am using gcc / g ++ 4.7.3, the compiler flags from the first if-statement should be set. But if I configure this with CMake-Gui, the compiler flags will not be predefined. The same thing happens when I do not comment on if-statements and just save set(CMAKE_CXX_FLAGS ...) . When searching for CMakeCache.txt for any -std=c++11 flags, I also don't get any results.
Why is this happening? What is the point of indicating compiler flags inside CMakeLists.txt when not in use? Or I get something completely wrong and they are used, but then I donβt know why and how I could check.
When I create an actual project (Eclipse CDT) with make and import it into Eclipse, I get error messages that cannot be resolved with C ++ 11, the __cplusplus macro contains the value 199711 so the -std=c++11 flag is obviously not used.
c ++ gcc c ++ 11 cmake
Schnigges
source share