esa / pagmo2

A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
https://esa.github.io/pagmo2/
GNU General Public License v3.0
808 stars 160 forks source link

[BUG] Pagmo needs C++17 compiler features but this is not reflected when using pagmo-config.cmake #456

Closed Bidski closed 3 years ago

Bidski commented 3 years ago

Describe the bug std::conjunction, std::disjunction, and std::negation are all only available in C++17. When including pagmo from a third-party application via CMake compilation will fail unless the third-party app also sets C++17. However, pagmo-config.cmake or pagmo_export.cmake should be setting the required compiler standard so that third-party apps don't need to be concerned with this detail.

To Reproduce

  1. In CMakeLists.txt find_package(pagmo CONFIG)
  2. In C++ file #include <pagmo/pagmo.hpp>
  3. Compile
  4. See error
    /usr/include/pagmo/type_traits.hpp:72:26: error: ‘conjunction’ in namespace ‘std’ does not name a template type
    72 | using conjunction = std::conjunction<Args...>;
      |                          ^~~~~~~~~~~
    /usr/include/pagmo/type_traits.hpp:72:21: note: ‘std::conjunction’ is only available from C++17 onwards
    72 | using conjunction = std::conjunction<Args...>;
      |                     ^~~
    /usr/include/pagmo/type_traits.hpp:75:26: error: ‘disjunction’ in namespace ‘std’ does not name a template type
    75 | using disjunction = std::disjunction<Args...>;
      |                          ^~~~~~~~~~~
    /usr/include/pagmo/type_traits.hpp:75:21: note: ‘std::disjunction’ is only available from C++17 onwards
    75 | using disjunction = std::disjunction<Args...>;
      |                     ^~~
    /usr/include/pagmo/type_traits.hpp:78:23: error: ‘negation’ in namespace ‘std’ does not name a template type
    78 | using negation = std::negation<T>;
      |                       ^~~~~~~~
    /usr/include/pagmo/type_traits.hpp:78:18: note: ‘std::negation’ is only available from C++17 onwards
    78 | using negation = std::negation<T>;

Environment (please complete the following information):

bluescarni commented 3 years ago

@Bidski thanks for the report.

pagmo is a C++17 library, so the assumption is that packages depending on pagmo are also accepting that they need to be compiled in C++17 mode.

Of course it would be better if somehow we could convey this information also in the CMake machinery, but at this time it is unclear to me how to do it. I remember looking into this some (a long?) time ago and concluding that there was no clean way to do this via CMake, but perhaps I did not look hard enough. Do you have concrete pointers/suggestions on how to do it?

Note that we do not want to force people to use C++17 when depending on pagmo - we want people to have the option to use C++20 as well. So the constraint should be something like C++ >= 17.

bluescarni commented 3 years ago

@Bidski can we consider this fixed by #458?

Bidski commented 3 years ago

@bluescarni yes, I think this is fixed now