View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015943CMakeCMakepublic2016-01-29 12:242016-06-10 14:31
Assigned ToKitware Robot 
PlatformMACOSOSXOS Version10.11.3
Product VersionCMake 3.4.3 
Target VersionFixed in Version 
Summary0015943: CMAKE_CXX_STANDARD not working on non-apple clang++
Descriptioncmake does not set standard related flags on non-apple clang++ ignoring CMAKE_CXX_STANDARD var or/and CXX_STANDARD propery.
Steps To Reproduce# brew install llvm --with-clang --with-libcxx --with-rtti
# export PATH=/usr/local/opt/llvm/bin:$PATH
# export CXX=/usr/local/opt/llvm/bin/clang++
# export CC=/usr/local/opt/llvm/bin/clang

cmake project with

# make VERBOSE=1
no -std=c++14 flag
TagsNo tags attached.
Attached Files

related to 0015897closedBrad King Clang CXX feature detection disabled on WIN32 platforms 
related to 0015544closedKitware Robot Policy to require cmake_minimum_required() before project() 

Brad King (manager)
2016-01-29 13:26

This may be due to the code here:;a=blob;f=Modules/Compiler/Clang-CXX.cmake;hb=v3.4.3#l8 [^]
 cmake_policy(GET CMP0025 appleClangPolicy)
 if(WIN32 OR (APPLE AND NOT appleClangPolicy STREQUAL NEW))

Check that the top-level CMakeLists.txt file starts with

 cmake_minimum_required(VERSION 3.0) # or higher

before the project() command.
senz (reporter)
2016-01-29 13:28
edited on: 2016-01-29 13:34

First line is cmake_minimum_required(VERSION 3.4) - no effect

Brad King (manager)
2016-01-29 13:36

$ export PATH=/usr/local/opt/llvm/bin:$PATH
$ export CXX=/usr/local/opt/llvm/bin/clang++
$ export CC=/usr/local/opt/llvm/bin/clang
$ cmake --version
cmake version 3.4.1
$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.3)
add_executable(foo foo.cxx)
$ cmake ..
-- The C compiler identification is Clang 3.6.2
-- The CXX compiler identification is Clang 3.6.2
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang -- works
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++
-- Check for working CXX compiler: /usr/local/opt/llvm/bin/clang++ -- works
$ make VERBOSE=1 | grep std=
/usr/local/opt/llvm/bin/clang++ ... -std=gnu++14 ...
senz (reporter)
2016-01-29 14:03

Found the difference.
In faulty file project() command was never called, but it was set with set( PROJECT foo )
If calling project() flags are fine on both clangs. That is a very strange behavior
senz (reporter)
2016-01-29 14:06

cmake_minimum_required(VERSION 3.4)
set (PROJECT Issue15943)

add_executable(foo foo.cxx)
Brad King (manager)
2016-01-29 14:11

The project() command is required and is inserted on line 0 if not present: [^]
 "The top-level CMakeLists.txt file for a project must contain a literal,
  direct call to the project() command; loading one through the include()
  command is not sufficient. If no such call exists CMake will implicitly
  add one to the top that enables the default languages (C and CXX)."

The implied call was originally meant to make hello-world projects shorter (e.g. just add_executable). Since it is inserted on line 0 that is before the cmake_minimum_required(VERSION) call sets CMP0025 to NEW so the code mentioned in 0015943:0040364 triggers. The reason is that without CMP0025 we don't know whether the Clang version number corresponds to upstream or Apple's fork.
senz (reporter)
2016-01-29 14:16

Tricky, thanks. Mb emit warning about implicit insert? At least in verbose mode
Stephen Kelly (developer)
2016-01-30 01:49

If cmake_minimum_required() is required before project(), then users can't have this bug. [^]
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2016-01-29 12:24 senz New Issue
2016-01-29 13:26 Brad King Note Added: 0040364
2016-01-29 13:27 Brad King Relationship added related to 0015897
2016-01-29 13:28 senz Note Added: 0040365
2016-01-29 13:34 senz Note Edited: 0040365
2016-01-29 13:36 Brad King Note Added: 0040366
2016-01-29 14:03 senz Note Added: 0040371
2016-01-29 14:06 senz Note Added: 0040372
2016-01-29 14:11 Brad King Note Added: 0040374
2016-01-29 14:16 senz Note Added: 0040375
2016-01-30 01:49 Stephen Kelly Note Added: 0040380
2016-02-01 08:46 Brad King Relationship added related to 0015544
2016-06-10 14:29 Kitware Robot Note Added: 0042928
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed

Copyright © 2000 - 2018 MantisBT Team