I'm building a project using cmake which uses Google's dense hash maps. I need to check that the corresponding header file is present. I therefore added
set (CMAKE_CXX_STANDARD 11)
INCLUDE (CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX("sparsehash/dense_hash_map" HAVE_SPARSEHASH)
to my CMakeLists.txt
. However, it fails to find the header when I compile
on some old compiler. The problem is that the header must be compiled in
C++11 and these compiler are not C++11 by default:
/usr/bin/clang++ -o CMakeFiles/cmTC_4186d.dir/CheckIncludeFile.cxx.o -c /home/florent/src/IVMPG/HPCombi/build/CMakeFiles/CMakeTmp/CheckIncludeFile.cxx
In file included from /home/florent/src/IVMPG/HPCombi/build/CMakeFiles/CMakeTmp/CheckIncludeFile.cxx:1:
In file included from /usr/local/include/sparsehash/dense_hash_map:102:
In file included from /usr/bin/../lib64/gcc/x86_64-suse-linux/7/../../../../include/c++/7/type_traits:35:
/usr/bin/../lib64/gcc/x86_64-suse-linux/7/../../../../include/c++/7/bits/c++0x_warning.h:32:2: 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 \
^
As a consequence CMake think the file is not present.
So the question is: How do I ensure that I'm using c++11
(or even c++14
)
when I'm testing some include or symbols ?