Clang stdlib heades和cmake

时间:2018-05-20 16:37:24

标签: ubuntu cmake clang libc++

我正在尝试使用clang 7.0在Ubuntu上构建我的C ++ 17项目。 我已经构建并安装了llvm,clang,它的libcxx和libcxxabi。 当我尝试编译我在日志文件中看到的代码时,它仍然使用gnu 5.4.0头文件(它们是Ubuntu的默认代码)。如何解决这个问题?

以下是我在cmake中设置工具链的方法:

set(CMAKE_C_COMPILER             "clang")
set(CMAKE_C_FLAGS                "-Wall -std=c99")
set(CMAKE_CXX_COMPILER           "clang++")
set(CMAKE_CXX_FLAGS              "-Wall -stdlib=libc++")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

其他信息。 CMake输出:

-- The C compiler identification is Clang 7.0.0
-- The CXX compiler identification is Clang 7.0.0
-- Check for working C compiler: /usr/local/bin/clang
-- Check for working C compiler: /usr/local/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/local/bin/clang++
-- Check for working CXX compiler: /usr/local/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.12")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/c/Projects/EverydayToolsTestsLinux/build

并输出有问题的地方:

Scanning dependencies of target EverydayToolsTest
[ 69%] Building CXX object submodules/edttests/CMakeFiles/EverydayToolsTest.dir/Code/Array/ArrayView/CastAndConversion.cpp.o
[ 76%] Building CXX object submodules/edttests/CMakeFiles/EverydayToolsTest.dir/Code/Array/ArrayView/Constructors.cpp.o
[ 84%] Building CXX object submodules/edttests/CMakeFiles/EverydayToolsTest.dir/Code/Array/ArrayView/Iteration.cpp.o
[ 92%] Building CXX object submodules/edttests/CMakeFiles/EverydayToolsTest.dir/Code/Geom/Matrix/Matrix.cpp.o
In file included from /mnt/c/Projects/EverydayToolsTestsLinux/submodules/edttests/Code/Geom/Matrix/Matrix.cpp:2:
In file included from /mnt/c/Projects/EverydayToolsTestsLinux/submodules/edt/include/EverydayTools/Geom/Matrix.h:8:
/mnt/c/Projects/EverydayToolsTestsLinux/submodules/edt/include/EverydayTools/Geom/Details/Mixins/Cast.h:20:46: error: no template named 'is_convertible_v' in namespace 'std'; did you mean 'is_convertible'?
            typename = std::enable_if_t<std::is_convertible_v<T, U>>>
                                        ~~~~~^~~~~~~~~~~~~~~~
                                             is_convertible
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/type_traits:1491:12: note: 'is_convertible' declared here
    struct is_convertible
           ^
In file included from /mnt/c/Projects/EverydayToolsTestsLinux/submodules/edttests/Code/Geom/Matrix/Matrix.cpp:2:
In file included from /mnt/c/Projects/EverydayToolsTestsLinux/submodules/edt/include/EverydayTools/Geom/Matrix.h:8:
/mnt/c/Projects/EverydayToolsTestsLinux/submodules/edt/include/EverydayTools/Geom/Details/Mixins/Cast.h:20:41: error: template argument for non-type template parameter must be an expression
            typename = std::enable_if_t<std::is_convertible_v<T, U>>>
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/type_traits:2387:17: note: template parameter is declared here
  template<bool _Cond, typename _Tp = void>
                ^
2 errors generated.
submodules/edttests/CMakeFiles/EverydayToolsTest.dir/build.make:134: recipe for target 'submodules/edttests/CMakeFiles/EverydayToolsTest.dir/Code/Geom/Matrix/Matrix.cpp.o' failed
make[2]: *** [submodules/edttests/CMakeFiles/EverydayToolsTest.dir/Code/Geom/Matrix/Matrix.cpp.o] Error 1
CMakeFiles/Makefile2:337: recipe for target 'submodules/edttests/CMakeFiles/EverydayToolsTest.dir/all' failed
make[1]: *** [submodules/edttests/CMakeFiles/EverydayToolsTest.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

0 个答案:

没有答案