I'm having some trouble compiling a C++11/SDL 2.0 code with CMake. The CMakeLists is pretty simple:
cmake_minimum_required(VERSION 2.6)
project(Test)
include(FindPkgConfig)
pkg_search_module(SDL2 REQUIRED sdl2)
include_directories(${SDL2_INCLUDE_DIRS})
target_link_libraries(sdl2test ${SDL2_LIBRARIES})
add_definitions(-std=c++0x)
add_executable(Test src/main.cpp)
However, when compiling, i receive this error:
Scanning dependencies of target Test
[100%] Building CXX object CMakeFiles/Test.dir/src/main.cpp.o
/var/dev/cmake/src/main.cpp: In function ‘int main(int, char**)’:
/var/dev/cmake/src/main.cpp:11:16: error: ‘nullptr’ was not declared in this scope
/var/dev/cmake/src/main.cpp:17:16: error: ‘nullptr’ was not declared in this scope
make[2]: *** [CMakeFiles/Test.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Test.dir/all] Error 2
make: *** [all] Error 2
cmake version 2.8.9 and gcc 4.7.2. Any ideas on how to properly make usage of C++11 features with CMake?
ps: I have also tried -std=c++11
add_definitions
is really for setting preprocessor definitions. You need to set the CMAKE_CXX_FLAGS
here:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With