Bug 219862 - devel/cmake: Cmake 3.8.0 somehow is unaware about CXX17 dialect (upd: make cmake-modules a dependency of cmake?)
Summary: devel/cmake: Cmake 3.8.0 somehow is unaware about CXX17 dialect (upd: make cm...
Status: Closed Works As Intended
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: kde
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-08 15:41 UTC by Aleksander Alekseev
Modified: 2017-06-13 08:45 UTC (History)
2 users (show)

See Also:
tcberner: maintainer-feedback+


Attachments
Test for C++17 detection (717 bytes, application/gzip)
2017-06-10 12:15 UTC, groot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksander Alekseev 2017-06-08 15:41:36 UTC
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.
Comment 1 groot 2017-06-08 21:47:56 UTC
(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)
Comment 2 Tobias C. Berner freebsd_committer 2017-06-09 18:31:12 UTC
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 ..
Comment 3 groot 2017-06-09 22:48:05 UTC
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.
Comment 4 groot 2017-06-10 12:15:27 UTC
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
Comment 5 groot 2017-06-10 12:18:35 UTC
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.
Comment 6 groot 2017-06-10 13:03:32 UTC
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.
Comment 7 Aleksander Alekseev 2017-06-13 08:31:26 UTC
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.
Comment 8 Tobias C. Berner freebsd_committer 2017-06-13 08:41:45 UTC
It already is a dependency.
Comment 9 Tobias C. Berner freebsd_committer 2017-06-13 08:45:45 UTC
We will most likely merge devel/cmake-modules back into devel/cmake in the future.