我想介紹使用CMake來構建我的C++項目。當我運行使我得到一個錯誤:CMake target_compile_features unordered_map
[ 11%] Building CXX object CMakeFiles/game.dir/InputHandler.cpp.o
In file included from /usr/include/c++/5/unordered_map:35:0,
...
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support...
我意識到這是因爲CMake的不調用C++ 11時,它需要以使使用unordered_map的。谷歌搜索後,我知道我需要在我的CMakeLists.txt中使用target_compile_features()。但是我找不到任何給我提供我需要使用的語法/參數的地方,這裏只是一些例子。 CMake的頁面上它給:
add_library(mylib requires_constexpr.cpp)
target_compile_features(mylib PRIVATE cxx_constexpr)
但我不需要cxx_constexpr,我甚至不知道那是什麼。我需要unordered_map。
任何人都可以告訴我我需要使用的語法,最好給我一些參考有效值傳遞到該函數。