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
Removed the explicit '-std=c++14' compile flag; set the CMake STANDAR… #119
Conversation
@svwilliams I think you could have reverted 9933456 as I do in #120 and then do the rest of the changes. As I mention in the description of that PR there are still two instances of fuse_constraints/CMakeLists.txt
219: target_compile_features(test_marginal_constraint PRIVATE cxx_generic_lambdas)
237: target_compile_features(test_marginalize_variables PRIVATE cxx_generic_lambdas) |
BTW I'm still not sure that not using That should allow the building infrastructure to easily switch to a newer version of the standard w/o making any changes to the source code. For example, if we ever switch to C++17, do we have to update the I'm also afraid that |
While I like the theory behind specifying the features you need and letting the build system select the correct compile flags, in practice I found the system to be cumbersome and incomplete. Here's my rant: First, not all C++11/C++14 standard features have a corresponding CMake The fuse code uses many C++11/C++14 features. To be a good and proper code maintainer, you need to specify each one, and determine if it is a public or private build requirement. Since this is done per-target, the list must be generated for each library, executable and test target separately. Having to track each standard feature that is used increases the maintenance burden quite a bit. And since this list is defined at the CMake level and not the compiler level, it is nearly impossible to tell if you have correctly captured all of the used features -- the compiler will not warn you if you are missing something. The odds of this list being maintained during refactors is slim. For reference, here is the branch where I was trying to get the per-feature list working before I decided the whole thing was too much trouble. I never got it quite working correctly, and I didn't even attempt to get the unit tests configured. The benefit of tracking each feature is marginal. In practice, fuse will only be compiled using gcc version 5.3 or later (Xenial/Kinetic or later). This means all of this work tracking individual language features is largely wasted, since only features supported by gcc 5.3 or later are used inside of fuse, and non-gcc compilers are definitely not tested, and will probably never be used. In the end, all of this extra work is roughly equivalent to just setting the I do take the "polluting the CMake settings for other projects" bit seriously, but I'm not sure what the solution is. If I could use the CMake My understanding of What I could do is set the
This avoids setting the global Regarding the two existing instances of
I'm assuming these are not needed if we are setting the target C++ standard to C++14 explicitly. I believe those were removed in the branch you tested, and Ceres and fuse still compiled correctly? |
10acccb
to
56039e8
Compare
@svwilliams I think you're right when you say things would be hard to maintain if you use Regarding Finally, the two existing instances of |
56039e8
to
633acf6
Compare
Suggestion: for CMake To force C++14 on a target: Advantage of doing it this way is that if/when targets are properly exported, consumers will automatically require these compile features as well (CMake takes care of transitively managing these).
Edit: if Kinetic+Xenial should also be supported, the following trick could perhaps be used to spec C++14 for both CMake target_compile_features(<TARGET> ...
# on CMake 3.8+ use meta-feature
$<$<NOT:$<VERSION_LESS:$CMAKE_VERSION,3.8>>:cxx_std_14>
# the following should get us C++14 on older versions of CMake
$<$<VERSION_LESS:$CMAKE_VERSION,3.8>:cxx_decltype_auto>) |
What I should do is drop support for Xenial/Kinetic since Xenial has reached end of life, but Xenial has a strangely long life in the robotics community. I will switch over to the |
C++14 is not the problem. That's supported on Xenial. It's CMake that is a bit old (on Xenial). But with the generator expression I showed in my previous comment everything should work on all CMake versions (on Xenial and newer). |
Well, yes and no. It is abusing the design intent of the named-feature |
Seeing as N3638 was only accepted into C++14 and is on GCC, Clang, Intel and MSVC only supported in versions that actually support C++14, it would seem like an acceptable work-around to having to list each and every feature. But it's all up to you. I just wanted to make you aware of something that seems to tick all the boxes without requiring anything special or manual maintenance. |
Yep. Definitely appreciated. Keep the suggestions coming. At this time I'm not personally comfortable maintaining complicated CMake expressions, but it is nice to have a solution ready if this becomes issue for users. |
Addendum to PR #112