From 2c3fc1250da5fdb2b781bcf0371014cd9f698933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org> Date: Wed, 8 May 2024 06:50:19 +0200 Subject: [PATCH] [cmake] Update build system The creation of the library needs to be updated, because otherwise the library is not found by downstream modules. --- CMakeLists.txt | 18 +++++++++++++++--- dune/solvers/CMakeLists.txt | 10 ++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae563f91..cc7637f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,8 @@ -cmake_minimum_required(VERSION 2.8.6) +if(dune-common_VERSION VERSION_GREATER_EQUAL 2.10.0) + cmake_minimum_required(VERSION 3.16) +else() + cmake_minimum_required(VERSION 3.13) +endif() project(dune-solvers CXX) if(NOT (dune-common_DIR OR dune-common_ROOT OR @@ -22,9 +26,17 @@ dune_project() find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK) include(AddSuiteSparseFlags) +# Create library target and export it as Dune::Solvers +dune_add_library(dunesolvers EXPORT_NAME Solvers LINK_LIBRARIES ${DUNE_LIBS}) + +dune_register_package_flags(LIBRARIES dunesolvers) + add_subdirectory("dune") add_subdirectory("doc") add_subdirectory("cmake/modules") -# finalize the dune project, e.g. generating config.h etc. -finalize_dune_project(GENERATE_CONFIG_H_CMAKE) +if(dune-common_VERSION VERSION_GREATER_EQUAL 2.10.0) + finalize_dune_project() +else() + finalize_dune_project(GENERATE_CONFIG_H_CMAKE) +endif() diff --git a/dune/solvers/CMakeLists.txt b/dune/solvers/CMakeLists.txt index f79381dc..05ebea6d 100644 --- a/dune/solvers/CMakeLists.txt +++ b/dune/solvers/CMakeLists.txt @@ -1,9 +1,3 @@ -dune_add_library("dunesolvers" - iterationsteps/blockgssteps.cc - solvers/criterion.cc) - -dune_register_package_flags(LIBRARIES dunesolvers) - add_subdirectory("common") add_subdirectory("iterationsteps") add_subdirectory("norms") @@ -12,6 +6,10 @@ add_subdirectory("solvers") add_subdirectory("test") add_subdirectory("transferoperators") +target_sources(dunesolvers PRIVATE + iterationsteps/blockgssteps.cc + solvers/criterion.cc) + install(FILES computeenergy.hh DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dune/solvers) -- GitLab