From 340d4e278bff0152d9a41413e27ff785199c741c Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Wed, 22 Apr 2020 22:25:31 +0200 Subject: [PATCH] [CMake] Enabled Unity builds for the testrunner. NumLib tests are still not unity build. --- MathLib/KelvinVector-impl.h | 8 ++++---- Tests/CMakeLists.txt | 6 +++++- Tests/MathLib/TestODESolver.cpp | 4 ++++ Tests/NumLib/TestODEInt.cpp | 4 ++++ scripts/cmake/UnityBuildSettings.cmake | 4 +--- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/MathLib/KelvinVector-impl.h b/MathLib/KelvinVector-impl.h index 967149b8c77..7a860b8869d 100644 --- a/MathLib/KelvinVector-impl.h +++ b/MathLib/KelvinVector-impl.h @@ -69,7 +69,7 @@ double Invariants<KelvinVectorSize>::trace( // Initialization of static Invariant variables. // -namespace detail +namespace KelvinVector_detail { template <int KelvinVectorSize> Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize> @@ -108,17 +108,17 @@ Eigen::Matrix<double, KelvinVectorSize, 1> initIdentity2() template <int KelvinVectorSize> const Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize> Invariants<KelvinVectorSize>::deviatoric_projection = - detail::initDeviatoricProjection<KelvinVectorSize>(); + KelvinVector_detail::initDeviatoricProjection<KelvinVectorSize>(); template <int KelvinVectorSize> Eigen::Matrix<double, KelvinVectorSize, KelvinVectorSize> const Invariants<KelvinVectorSize>::spherical_projection = - detail::initSphericalProjection<KelvinVectorSize>(); + KelvinVector_detail::initSphericalProjection<KelvinVectorSize>(); template <int KelvinVectorSize> const Eigen::Matrix<double, KelvinVectorSize, 1> Invariants<KelvinVectorSize>::identity2 = - detail::initIdentity2<KelvinVectorSize>(); + KelvinVector_detail::initIdentity2<KelvinVectorSize>(); } // namespace KelvinVector } // namespace MathLib diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 46cb824af5a..546c2e2d20d 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -15,7 +15,11 @@ append_source_files(TEST_SOURCES MaterialLib) append_source_files(TEST_SOURCES MathLib) append_source_files(TEST_SOURCES MeshLib) append_source_files(TEST_SOURCES MeshGeoToolsLib) -append_source_files(TEST_SOURCES NumLib) +append_source_files(TEST_SOURCES_NUMLIB NumLib) +# Disable Unity build for NumLib tests +set_source_files_properties(${TEST_SOURCES_NUMLIB} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) +# Keep order of source files, otherwise PETSc non-MPI tests fail +set(TEST_SOURCES ${TEST_SOURCES} ${TEST_SOURCES_NUMLIB}) append_source_files(TEST_SOURCES ParameterLib) append_source_files(TEST_SOURCES ProcessLib) diff --git a/Tests/MathLib/TestODESolver.cpp b/Tests/MathLib/TestODESolver.cpp index d9d0ec8ae61..cf719b5025f 100644 --- a/Tests/MathLib/TestODESolver.cpp +++ b/Tests/MathLib/TestODESolver.cpp @@ -13,6 +13,8 @@ #include "BaseLib/ConfigTree.h" #include "MathLib/ODE/ODESolverBuilder.h" +namespace TestODESolver { + const double abs_tol = 1e-8; const double rel_tol = 1e-8; @@ -315,3 +317,5 @@ TEST(MathLibCVodeTest, ExponentialWithJacobianNewton) check(time_reached, y[0], y_dot[0], time, y_ana, y_dot_ana); } } + +} // end namespace diff --git a/Tests/NumLib/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp index aa91edc1529..5740221277d 100644 --- a/Tests/NumLib/TestODEInt.cpp +++ b/Tests/NumLib/TestODEInt.cpp @@ -25,6 +25,8 @@ #include "TimeLoopSingleODE.h" +namespace TestODEInt { + #ifndef USE_PETSC std::unique_ptr<GlobalLinearSolver> createLinearSolver() @@ -298,3 +300,5 @@ TYPED_TEST(NumLibODEIntTyped, DISABLED_T1) * * check that the order of time discretization scales correctly * with the timestep size */ + +} // end namespace diff --git a/scripts/cmake/UnityBuildSettings.cmake b/scripts/cmake/UnityBuildSettings.cmake index a88a922199e..c469531a0f3 100644 --- a/scripts/cmake/UnityBuildSettings.cmake +++ b/scripts/cmake/UnityBuildSettings.cmake @@ -10,7 +10,5 @@ set_target_properties(MeshLib PROPERTIES UNITY_BUILD_BATCH_SIZE 20) # set_target_properties(ProcessLib PROPERTIES UNITY_BUILD_BATCH_SIZE 80) # breaks! if(TARGET testrunner) - # breaks! - # set_target_properties(testrunner PROPERTIES UNITY_BUILD ON) - # set_target_properties(testrunner PROPERTIES UNITY_BUILD_BATCH_SIZE 2) + set_target_properties(testrunner PROPERTIES UNITY_BUILD ON) endif() -- GitLab