[cmake-developers] [CMake 0015361]: CHECK_CXX_SOURCE_COMPILES doesn't use c++11 flags specified

Mantis Bug Tracker mantis at public.kitware.com
Mon Jan 19 18:28:34 EST 2015


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15361 
====================================================================== 
Reported By:                Laurent Demailly
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15361
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2015-01-19 15:28 PST
Last Modified:              2015-01-19 15:28 PST
====================================================================== 
Summary:                    CHECK_CXX_SOURCE_COMPILES doesn't use c++11 flags
specified
Description: 
I have 

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)

in my cmake file - yet later when I try:

check_cxx_source_compiles(
"extern \"C\" void cmkcheckweak() __attribute__((weak));
int main(int argc, char** argv) {
  return cmkcheckweak == nullptr; // works with (void*)0;
}" HAVE_WEAK_SYMBOLS)

it fails incorrectly because it invokes the compiler without the  -std=gnu++11
it adds for regular files

(the goal/point of CMAKE_CXX_STANDARD_REQUIRED is to use that compiler for
everything and not me having to write code to guess the way to request c++11
compiler)

this is related to http://public.kitware.com/Bug/view.php?id=15359
but while here there is an easy work around (not use nullptr and use 0 instead)
that won't work for other tests I'm trying to do with CHECK_CXX_SOURCE_COMPILES

suggestions/workarounds on how to make CHECK_CXX_SOURCE_COMPILES use the same
compiler invocation as my other targets would be most welcome in the meantime


Steps to Reproduce: 
see above and below


Additional Information: 
Performing C++ SOURCE FILE Test HAVE_WEAK_SYMBOLS failed with the following
output:
Change Dir: /home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTryCompileExec1489303762/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec1489303762.dir/build.make
CMakeFiles/cmTryCompileExec1489303762.dir/build
make[1]: Entering directory
`/mnt/hgfs/ldemailly/wdt_ubuntu_build/CMakeFiles/CMakeTmp'
/usr/local/bin/cmake -E cmake_progress_report
/home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp/CMakeFiles 1
Building CXX object CMakeFiles/cmTryCompileExec1489303762.dir/src.cxx.o
/usr/bin/c++    -DHAVE_WEAK_SYMBOLS   -o
CMakeFiles/cmTryCompileExec1489303762.dir/src.cxx.o -c
/home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp/src.cxx
/home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp/src.cxx: In function
‘int main(int, char**)’:
/home/ldemailly/mac/wdt_ubuntu_build/CMakeFiles/CMakeTmp/src.cxx:3:26: error:
‘nullptr’ was not declared in this scope
   return cmkcheckweak == nullptr; // (void*)0; works
                          ^
make[1]: Leaving directory
`/mnt/hgfs/ldemailly/wdt_ubuntu_build/CMakeFiles/CMakeTmp'
make[1]: *** [CMakeFiles/cmTryCompileExec1489303762.dir/src.cxx.o] Error 1
make: *** [cmTryCompileExec1489303762/fast] Error 2

Source file was:
extern "C" void cmkcheckweak() __attribute__((weak));
int main(int argc, char** argv) {
  return cmkcheckweak == nullptr; // (void*)0; works
}

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2015-01-19 15:28 Laurent DemaillyNew Issue                                    
======================================================================



More information about the cmake-developers mailing list