Skip to content

Commit 6bac451

Browse files
committed
automatic detection of required packages, such as Threads or TBB
1 parent 984f73e commit 6bac451

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

cmake/modules/clang.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ if(enable-parallel-stl-algorithms)
8484
if(UNIX AND NOT APPLE)
8585
if(NOT enable-libcxx)
8686
find_package(TBB REQUIRED)
87+
list(APPEND MGIS_REQUIRED_ADDITIONAL_PACKAGES "TBB")
8788
list(APPEND MGIS_ADDITIONAL_LIBRARIES "TBB::tbb")
8889
endif(NOT enable-libcxx)
8990
endif(UNIX AND NOT APPLE)

cmake/modules/compiler.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# MGIS_CMAKE_REQUIRED_INCLUDES = list of include directories
1212
# MGIS_CMAKE_REQUIRED_LIBRARIES = list of libraries to link
1313
# MGIS_ADDITIONAL_LINK_FLAGS = additional flags for the MFrontGenericInterface library
14+
# MGIS_REQUIRED_ADDITIONAL_PACKAGES = additional required packages for the MFrontGenericInterface library
1415
#
1516
# This macro is a copy of CheckCXXSourceCompiles.cmake
1617
# Copyright 2005-2009 Kitware, Inc.
@@ -128,6 +129,7 @@ set(OPTIMISATION_FLAGS "")
128129
set(COMPILER_WARNINGS "")
129130
set(MGIS_ADDITIONAL_LIBRARIES "")
130131
set(MGIS_ADDITIONAL_LINK_FLAGS "")
132+
set(MGIS_REQUIRED_ADDITIONAL_PACKAGES "")
131133

132134
option(enable-gpu-offloading "enable offloading on GPUS. Support of offloading depends on compiler support" OFF)
133135
option(enable-fast-math "enable -ffast-math compiler flag" OFF)

cmake/modules/gcc.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ set(COMPILER_C_WARNINGS "-Wall -W -pedantic")
112112

113113
if(enable-parallel-stl-algorithms)
114114
find_package(TBB REQUIRED)
115+
list(APPEND MGIS_REQUIRED_ADDITIONAL_PACKAGES "TBB")
115116
list(APPEND MGIS_ADDITIONAL_LIBRARIES "TBB::tbb")
116117
endif(enable-parallel-stl-algorithms)
117118

src/MFrontGenericInterfaceConfig.cmake.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,16 @@ if(MGIS_HAVE_TFEL)
2626

2727
endif(MGIS_HAVE_TFEL)
2828

29+
if(UNIX)
30+
set(Threads_FOUND @Threads_FOUND@)
31+
if(Threads_FOUND)
32+
find_package(Threads REQUIRED)
33+
endif(Threads_FOUND)
34+
endif(UNIX)
35+
36+
set(MGIS_REQUIRED_ADDITIONAL_PACKAGES "@MGIS_REQUIRED_ADDITIONAL_PACKAGES@")
37+
foreach(_package ${MGIS_REQUIRED_ADDITIONAL_PACKAGES})
38+
find_package(${_package} REQUIRED)
39+
endforeach()
40+
2941
include("${CMAKE_CURRENT_LIST_DIR}/MFrontGenericInterfaceTargets.cmake")

0 commit comments

Comments
 (0)