-
Notifications
You must be signed in to change notification settings - Fork 27
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
[cmake] Add detection of C++1x features, and store results in SiconosConfig.h #10
Conversation
@@ -28,7 +28,7 @@ | |||
#include <boost/serialization/serialization.hpp> | |||
#include <boost/serialization/nvp.hpp> | |||
|
|||
#if __cplusplus >= 201103L | |||
#if SICONOS_CXXVERSION >= 201103L |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: This was the only one I wasn't sure to do with in terms of feature detection, so I at least changed the comparison with __cplusplus for SICONOS_CXXVERSION.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this 3.5 years ago (thanks git blame for reminding me this), so I had to take a stab at it and try to remember ... So looking at the code, ser_shared_ptr.hpp does the serialization of the std shared_ptr. Hence, I would add
#if defined(SICONOS_STD_SHARED_PTR) && !defined(SICONOS_USE_BOOST_FOR_CXX11)
here.
00b86c4
to
85d6f51
Compare
@@ -7,7 +7,7 @@ | |||
|
|||
%import SiconosConfig.h | |||
|
|||
#if (SICONOS_CXXVERSION >= 201103L) && !defined(USE_BOOST_FOR_CXX11) | |||
#if defined(SICONOS_STD_TO_STRING) && !defined(SICONOS_USE_BOOST_FOR_CXX11) | |||
#define STD11 std |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant SICONOS_STD_SHARED_PTR: the following bits of code are from g++-v4/bits/shared_ptr.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, good catch! Must have done that one a little too quickly.
I like this new version. I just had 2 minors comments. If you think the proposed changes make sense, just commit an updated version to the main repo. |
…Config.h. The use of boost::shared_ptr or std::shared_ptr is detected by the preprocessor by checking against __cplusplus in some headers. So software including those headers when -std=c++11 was enabled would incorrectly choose the std:: namespace, when Siconos was compiled with the boost:: namespace. This caused linker errors. This patch: * Adds detection of individual C++11 features, such as std::shared_ptr, std::array, std::unordered_map, std::to_string, std::bind. * Detection variables are stored in SiconosConfig.h e.g., SICONOS_STD_SHARED_PTR, etc.. * Detection of individual features is only performed if CXXVERSION or CMAKE_CXX_STANDARD is changed. * User flags to turn off use of these features are also stored in SiconosConfig.h. They default to ON to keep compatibility with previous behaviour. - SICONOS_USE_BOOST_FOR_CXX11 - SICONOS_USE_MAP_FOR_HASH * Fixes some problematic areas in mechanics where boost::array or similar was used even when c++11 was enabled. * Replaces checks against __cplusplus in the headers with checks against specific feature variables. Note that CMake's own mechanism for setting the C++ standard must be used to select C++11 or C++14: cmake .. -DCMAKE_CXX_STANDARD=11 This option is explicitly passed on to the try_run() calls used for feature detection.
…h C++11. Full warning is, warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix] and in clang++, it is an error: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
85d6f51
to
19b3d91
Compare
Ok I updated the branch but apparently I don't have push access for the siconos repository. |
I added you to the siconos group. I think that's the way to go. |
Seems to have worked, thanks! |
This PR includes the changes from PR #9, but proposes a different approach for handling C++1x features. To summarize:
This patch:
Note that CMake's own mechanism for setting the C++ standard must be used to select C++11 or C++14:
This option is explicitly passed on to the detection try_run() calls.