Hi! I've just installed cmake 3.8.0 using ports tree with default options (sudo make -DBATCH install clean). Then I tried to build a simple project that uses C++17 features: ``` git clone https://github.com/afiskon/cpp-multithreading.git cd cpp-multithreading mkdir build cd build cmake .. ``` Here is the output: ``` -- The C compiler identification is Clang 3.8.0 -- The CXX compiler identification is Clang 3.8.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- 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/bin/CC -- Check for working CXX compiler: /usr/bin/CC -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done CMake Error in CMakeLists.txt: Target "atomic_example" requires the language dialect "CXX17" (with compiler extensions), but CMake does not know the compile flags to use to enable it. CMake Error in CMakeLists.txt: Target "shared_mutex_example" requires the language dialect "CXX17" (with compiler extensions), but CMake does not know the compile flags to use to enable it. CMake Error in CMakeLists.txt: Target "mutex_example" requires the language dialect "CXX17" (with compiler extensions), but CMake does not know the compile flags to use to enable it. -- Generating done -- Build files have been written to: /home/eax/cpp-multithreading/build ``` This looks like a bug since CMake 3.8.0 on Linux (tested on Ubuntu 16.04 and Arch Linux, on GCC and Clang) builds the same project without problems.
(commenting for kde@ -- I'll take this one, I have the cmake 3.8.2 update lined up anyway and VMs with also Linux versions of everything set up)
I don't think this is an issue with cmake-3.8.0 but with clang-3.8.0 :) Please try to install a newer clang, say clang3.9, and re-run with env CC=/usr/local/bin/clang39 CXX=/usr/local/bin/clang++39 cmake ..
What base system are you using? On 10.3, any of the versioned clangs I have -- clang++36, clang++37, clang++38 and clang++40 -- work. The unversioned clang, /usr/bin/c++, does not. But clang 3.8 works for me (while it doesn't in the OP), so I don't think it's the compiler version. The clang site reports C++1z (i.e. C++17) support is available from 3.5 onwards. All use flag -std=c++1z. Note that the cpp-multithreading repo builds fine with C++14.
Created attachment 183379 [details] Test for C++17 detection Here's a simple C++17 program, a CMakeLists.txt that demands C++17, and a Makefile that tries building the program with base-c++ and clang++3* and clang++40 (what succeeds depends on what is installed on your system). On FreeBSD 11.0, base-c++ gives me thie same output as the OP: ### /usr/bin/c++ ### ### /usr/bin/c++ --version FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0) Target: x86_64-unknown-freebsd11.0 Thread model: posix InstalledDir: /usr/bin ( cd mbuild/build-base && cmake ../.. && make && ./example ) -- The C compiler identification is Clang 3.8.0 -- The CXX compiler identification is Clang 3.8.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- 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/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done CMake Error in CMakeLists.txt: Target "example" requires the language dialect "CXX17" (with compiler extensions), but CMake does not know the compile flags to use to enable it. While on FreeBSD 10.3, the same compiler (roughly .. ports is different from 11.0's base) does work: ### /usr/local/bin/clang++38 ### ### /usr/local/bin/clang++38 --version clang version 3.8.1 (tags/RELEASE_381/final) Target: x86_64-unknown-freebsd10.3 Thread model: posix InstalledDir: /usr/local/llvm38/bin ( cd mbuild/build-38 && cmake ../.. && make && ./example ) -- The C compiler identification is Clang 3.8.1 -- The CXX compiler identification is Clang 3.8.1 -- Check for working C compiler: /usr/local/bin/clang38 -- Check for working C compiler: /usr/local/bin/clang38 -- 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++38 -- Check for working CXX compiler: /usr/local/bin/clang++38 -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done
How to use the test-case: - untar it (it goes to cmake-c++17/) - cd cmake-c++17 - make Then watch as it tries all kinds of different compilers as CC / CXX for CMake.
The problem is that you have updated CMake to 3.8.0, but not cmake-modules. So you're getting older compiler-detection code, alongside a newer CMake. I don't know why those two ports are disconnected. In any case, updating cmake-modules to 3.8.0 will fix this.
Original problem was discovered on FreeBSD 11, just installed from the .iso. No clang or llvm updates were made. ``` $ cc --version FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0) Target: x86_64-unknown-freebsd11.0 Thread model: posix InstalledDir: /usr/bin ``` > In any case, updating cmake-modules to 3.8.0 will fix this. OK, I've installed cmake-modules 3.8.0 using ports tree and it fixed the problem. However, from user perspective being unable to compile a program despite the fact that compiler and cmake versions are correct looks like a bug. If it's not too much trouble I would recommend to install cmake-mudules as a dependency of cmake package.
It already is a dependency.
We will most likely merge devel/cmake-modules back into devel/cmake in the future.