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

add c++11 flags in cmake build system #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

weatherhead99
Copy link
Contributor

This patch enforces needing a c++11 compiler from within the CMake build system. Also adds appropriate c++11 flags in a cross platform way (e.g. if building on gcc < 5.0)

@coveralls
Copy link

coveralls commented Apr 14, 2018

Coverage Status

Coverage remained the same at 93.149% when pulling 99f23e9 on weatherhead99:require_cxx_11 into 07c3c94 on rttrorg:master.

@acki-m
Copy link
Contributor

acki-m commented Apr 15, 2018

@weatherhead99
There is already code for this, see here:
https://github.com/rttrorg/rttr/blob/master/CMake/config.cmake#L121
And this function to retrieve the latest supported CXX:
https://github.com/rttrorg/rttr/blob/master/CMake/utility.cmake#L529

Does this fix anything? Because, I am setting: set(CMAKE_CXX_STANDARD 14)
When this not works, I will set C++11

The only thing worth adding, would be a cmake error, when even c++11 is not supported. But I have never tested this, whether this works or not.

@weatherhead99
Copy link
Contributor Author

weatherhead99 commented Apr 15, 2018

hmmm, I do see your point. I encountered this the other day when building against GCC 4.8. The library works, all unit tests pass and my project using it has no issues, but it won't built because unless you pass -std=c++11, gcc 4.8 will not compile c++11 constructs. setting CMAKE_CXX_STANDARD will add these flags to compilers where c++11 is not the default. Note, however, your detection of maximum available c++ standard will still report 11 on gcc 4.8, because it is available. It just doesn't add the flags to compiling.

@acki-m
Copy link
Contributor

acki-m commented Apr 15, 2018

GCC 4.8, should also use the flag in c++11
See the CI build in travis with GCC 4.9:
https://travis-ci.org/rttrorg/rttr/jobs/358614015#L842
What do you see in cmake when configure your project?
Does it print: "using C++: 11" ?

PS: What about your PR with conan?

@weatherhead99
Copy link
Contributor Author

weatherhead99 commented Apr 15, 2018

it does print Using c++: 11, but does not append -std=c++11 to the build (NOTE: this is gcc 4.8 , not 4.9, where it works without this flag).

Re; Conan, work on the released 0.9.6 has started here: https://github.com/weatherhead99/conan-rttr/tree/v0.9.6 still have some issues with building on some versions of apple-clang and MSVC. As soon as those are fixed, will PR against your repo :-)

@acki-m
Copy link
Contributor

acki-m commented Apr 16, 2018

It seems to be not implemented for older compilers, so a CMake issue.
What you have to do is something like this:
guilhermeferreira/paho.mqtt.cpp@eac8a6f

eclipse-paho/paho.mqtt.cpp#70

@acki-m
Copy link
Contributor

acki-m commented May 23, 2018

@weatherhead99
Any update here?

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

Successfully merging this pull request may close these issues.

3 participants