0

I am trying to build my C++17 project on Ubuntu using clang 7.0. I have build and installed llvm, clang, it's libcxx and libcxxabi. When I try to compile the code I see in log files that it still uses gnu 5.4.0 headers (they are default for Ubuntu). How to fix that issue?

Here is my how I am setting the toolchain in 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)

Additional information. CMake output:

-- 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

And make output with problem place:

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
  • Helpful CMake debugging techniques: add `message(FATAL_ERROR "${CMAKE_CXX_FLAGS}")` and see if the flags are what you expect them to be, run with `--trace`, run `make VERBOSE=1` and see the command used to invoke the compiler – Justin May 21 '18 at 05:19
  • @Justin: Important thing is to call `message()` **AFTER** the `project()` call. – Tsyvarev May 21 '18 at 10:27

0 Answers0