I'm new to cmake, and I was building some c++11 code with it (notably a set of template aliases.) I want to use the CXX_STANDARD property to hopefully cover all platforms and problems introduced by simply adding -std=c++11 to cxxflags, which worked for me before:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
But when I change this to
set_property(GLOBAL PROPERTY CXX_STANDARD 11)
set_property(GLOBAL PROPERTY CXX_STANDARD_REQUIRED true)
cmake doesn't tell the compiler to use c++11. What am I doing wrong with the latter code?
I didn't have CMake updated to the latest version... I should have done that before posting a question. The code above only works for version > 3.1.
CMAKE_CXX_STANDARD is not a global property, but a variable. http://www.cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html#variable:CMAKE_CXX_STANDARD
So all you need is
before you define any targets.