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
823 stars 161 forks source link

CMake: Support UNITY_BUILD #564

Closed jschueller closed 7 months ago

jschueller commented 8 months ago

xref https://cmake.org/cmake/help/latest/prop_tgt/UNITY_BUILD.html

bluescarni commented 7 months ago

Hi @jschueller

Am I understanding right that the goal here is to skip big .cpp files when doing jumbo builds?

jschueller commented 7 months ago

hi, it's the contrary: assemble several sources into big files to speed up compilation

bluescarni commented 7 months ago

hi, it's the contrary: assemble several sources into big files to speed up compilation

I understand this is what a jumbo build is, but isn't this PR explicitly disabling the jumbo feature on a very specific cpp file?

jschueller commented 7 months ago

oh, indeed, this excludes one file from jumbo build because it contains a conflicting declaration (cec2013.cpp & cec2014.cpp):

In file included from /home/schueller/projects/pagmo2/build/CMakeFiles/pagmo.dir/Unity/unity_4_cxx.cxx:9:
/home/schueller/projects/pagmo2/src/problems/cec2014.cpp:51:18: error: redefinition of ‘constexpr const double pagmo::{anonymous}::E’
   51 | constexpr double E = 2.7182818284590452353602874713526625;
      |                  ^
In file included from /home/schueller/projects/pagmo2/build/CMakeFiles/pagmo.dir/Unity/unity_4_cxx.cxx:5:
/home/schueller/projects/pagmo2/src/problems/cec2013.cpp:51:18: note: ‘constexpr const double pagmo::{anonymous}::E’ previously defined here
   51 | constexpr double E = 2.7182818284590452353602874713526625;
bluescarni commented 7 months ago

oh, indeed, this excludes one file from jumbo build because it contains a conflicting declaration (cec2013.cpp & cec2014.cpp):

In file included from /home/schueller/projects/pagmo2/build/CMakeFiles/pagmo.dir/Unity/unity_4_cxx.cxx:9:
/home/schueller/projects/pagmo2/src/problems/cec2014.cpp:51:18: error: redefinition of ‘constexpr const double pagmo::{anonymous}::E’
   51 | constexpr double E = 2.7182818284590452353602874713526625;
      |                  ^
In file included from /home/schueller/projects/pagmo2/build/CMakeFiles/pagmo.dir/Unity/unity_4_cxx.cxx:5:
/home/schueller/projects/pagmo2/src/problems/cec2013.cpp:51:18: note: ‘constexpr const double pagmo::{anonymous}::E’ previously defined here
   51 | constexpr double E = 2.7182818284590452353602874713526625;

Oh I see, thanks for reporting the error message.

In this specific case we should really be defining constants once and for all, avoiding needless repetitions. I'll open a report about this. I am ok with merging this PR as is for the time being.