diff --git a/CMakeLists.txt b/CMakeLists.txt index 5600684859c3d6bf96c56a122f08922a774b9b70..0e2579388ffa7425cbcbb8ca59e40f1abbc46582 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ endif() # make sure our own modules are found list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) +set(THREADS_PREFER_PTHREAD_FLAG TRUE CACHE BOOL "Prefer -pthread compiler and linker flag") + #include the dune macros include(DuneMacros) @@ -35,7 +37,8 @@ add_dune_blas_lapack_flags(dunecommon) add_dune_tbb_flags(dunecommon) # collect dependencies to be added into the dune-common-config.cmake files -set(DUNE_COMMON_PACKAGE_DEPENDENCIES) +set(DUNE_COMMON_PACKAGE_DEPENDENCIES + [[set(THREADS_PREFER_PTHREAD_FLAG TRUE CACHE BOOL "Prefer -pthread compiler and linker flag")]]) # since dunecommon is exported its linked libs must be provided downstream too if (LAPACK_FOUND) @@ -43,6 +46,9 @@ if (LAPACK_FOUND) elseif (BLAS_FOUND) list(APPEND DUNE_COMMON_PACKAGE_DEPENDENCIES "find_dependency(BLAS)") endif() +if (Threads_FOUND) + list(APPEND DUNE_COMMON_PACKAGE_DEPENDENCIES "find_dependency(Threads)") +endif() if (TBB_FOUND) list(APPEND DUNE_COMMON_PACKAGE_DEPENDENCIES "find_dependency(TBB)") endif() @@ -60,14 +66,12 @@ if(DUNE_ENABLE_PYTHONBINDINGS) add_subdirectory(python) endif() -if(DUNE_COMMON_PACKAGE_DEPENDENCIES) - # write contents into DUNE_CUSTOM_PKG_CONFIG_SECTION, which will be injected into dune-common-config.cmake - string(JOIN "\n" DUNE_CUSTOM_PKG_CONFIG_SECTION - # make sure that Find<module>.cmake provided by dune-common can be found by cmake - [[list(APPEND CMAKE_MODULE_PATH "${dune-common_MODULE_PATH}")]] - ${DUNE_COMMON_PACKAGE_DEPENDENCIES} - ) -endif() +# write contents into DUNE_CUSTOM_PKG_CONFIG_SECTION, which will be injected into dune-common-config.cmake +string(JOIN "\n" DUNE_CUSTOM_PKG_CONFIG_SECTION + # make sure that Find<module>.cmake provided by dune-common can be found by cmake + [[list(APPEND CMAKE_MODULE_PATH "${dune-common_MODULE_PATH}")]] + ${DUNE_COMMON_PACKAGE_DEPENDENCIES} +) # finalize the dune project, e.g. generating config.h, dune-common-config.cmake, etc. finalize_dune_project() diff --git a/cmake/modules/DuneMacros.cmake b/cmake/modules/DuneMacros.cmake index 8e44df783259086de5781bc6ee2621a673a8359a..7cfe6956d20461685eeff05fa7a9d3952d1adc34 100644 --- a/cmake/modules/DuneMacros.cmake +++ b/cmake/modules/DuneMacros.cmake @@ -30,10 +30,6 @@ include_guard(GLOBAL) enable_language(C) # Enable C to skip CXX bindings for some tests. -# By default use -pthread flag. This option is set at the beginning to enforce it for -# find_package(Threads) everywhere -set(THREADS_PREFER_PTHREAD_FLAG TRUE CACHE BOOL "Prefer -pthread compiler and linker flag") - include(DuneAddLibrary) include(DuneDefaultIncludeDirectories) include(DuneEnableAllPackages)