Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faulty detection of C++11 support. #55

Closed
elfprince13 opened this issue Jun 20, 2017 · 8 comments
Closed

Faulty detection of C++11 support. #55

elfprince13 opened this issue Jun 20, 2017 · 8 comments

Comments

@elfprince13
Copy link
Contributor

elfprince13 commented Jun 20, 2017

if (NOT WIN32)
#http://www.guyrutenberg.com/2014/01/05/enabling-c11-c0x-in-cmake/
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    message("-- C++11 Enabled")
elseif(COMPILER_SUPPORTS_CXX0X)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
    message("-- C++0x Enabled")
else()
        message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
endif()

This snippet causes configuration to abort on my Linux machine when using clang (clang --version returns the following:

clang version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

).

However Clang is absolutely a C++11 compliant compiler, and I can manually pass it the -std=c++11 flag without incident.

@pjcozzi
Copy link
Member

pjcozzi commented Jun 20, 2017

@elfprince13 thanks for the report, any chance you would be able to contribute a pull request with a fix?

@elfprince13
Copy link
Contributor Author

I've just commented them out in our fork (https://github.com/Geopipe/COLLADA2GLTF), because it's pretty easy to identify by inspection of error messages when compilation fails due to C++11 not being supported. I suspect you guys will want a more user-friendly fix.

@javagl
Copy link
Contributor

javagl commented Jun 20, 2017

Instead of manually setting the (compiler-specific) flags, it should be possible to just use

set(CMAKE_CXX_STANDARD 11)

(with 98, 11 or 17).

(This might need a CMake version newer than 2.8, though, and .... I cannot test it appropriately right now, so no PR from me here, just as a hint)

@elfprince13
Copy link
Contributor Author

elfprince13 commented Jun 20, 2017 via email

@javagl
Copy link
Contributor

javagl commented Jun 21, 2017

Given that the required version (which I think is 3.1) is out for more than a year now (according to https://cmake.org/files/ ), requiring it should be fine, but the decision has to be made by the main maintainers here.

@lasalvavida lasalvavida mentioned this issue Aug 14, 2017
8 tasks
@lasalvavida
Copy link
Contributor

set(CMAKE_CXX_STANDARD 11) is the preferred fix

@elfprince13
Copy link
Contributor Author

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS OFF)

Is more comprehensive, and standards-enforcing. CMAKE_CXX_STANDARD_REQUIRED is intended to provide the same behavior as the message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") in the existing code.

@lasalvavida
Copy link
Contributor

This was done in #74.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants