Skip to content

Commit 2c85225

Browse files
committed
factor out the cmake dependencies into a separate file.
1 parent b14cede commit 2c85225

File tree

2 files changed

+69
-66
lines changed

2 files changed

+69
-66
lines changed

CMakeLists.txt

+1-66
Original file line numberDiff line numberDiff line change
@@ -56,42 +56,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
5656
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
5757
endif()
5858

59-
find_package(Charm REQUIRED)
60-
# Link executables with the charmc wrapper
61-
STRING(REGEX REPLACE "<CMAKE_CXX_COMPILER>" "${CHARM_LINKER}"
62-
CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
63-
64-
65-
# Need to process Grackle here as both Cello and Enzo-E depend on it
66-
option(USE_GRACKLE "Use Grackle Chemistry" ON)
67-
# don't bother advertising the following option (but users can
68-
# overwrite it if they really want to - e.g. to reduce binary size)
69-
option(GRACKLE_USE_STATIC_LIBS "sets Grackle's lib-type if USE_GRACKLE=ON" ON)
70-
if (USE_GRACKLE)
71-
find_package(Grackle)
72-
if (Grackle_FOUND)
73-
# This really only needs to be defined for a relatively small subset of
74-
# files in the Enzo-layer
75-
add_compile_definitions(CONFIG_USE_GRACKLE)
76-
77-
else()
78-
message(FATAL_ERROR
79-
"Configured to use Grackle but Grackle library not found.\n"
80-
"Either disable grackle (e.g., `-DUSE_GRACKLE=OFF`) or provide path "
81-
"(e.g., `-DGrackle_ROOT=/PATH/TO/GRACKLE/INSTALL/DIRECTORY`).")
82-
endif()
83-
endif()
84-
85-
find_package(PNG REQUIRED)
86-
add_compile_definitions(NO_FREETYPE)
87-
88-
find_package(HDF5 REQUIRED COMPONENTS C)
89-
# HDF5 Interface library
90-
add_library(HDF5_C INTERFACE)
91-
target_link_libraries(HDF5_C INTERFACE ${HDF5_C_LIBRARIES})
92-
target_compile_definitions(HDF5_C INTERFACE ${HDF5_C_DEFINITIONS})
93-
target_include_directories(HDF5_C INTERFACE ${HDF5_C_INCLUDE_DIRS})
94-
59+
include("dependencies.cmake")
9560

9661
set(Cello_TARGET_LINK_OPTIONS "")
9762

@@ -245,22 +210,6 @@ if (have_git)
245210
)
246211
endif()
247212

248-
249-
option (use_jemalloc "Use the jemalloc library for memory allocation" OFF)
250-
if (use_jemalloc)
251-
find_package(jemalloc)
252-
if (jemalloc_FOUND)
253-
add_compile_definitions(CONFIG_USE_JEMALLOC)
254-
else()
255-
message(FATAL_ERROR
256-
"Requested to use the jemalloc library for memory allocation but jemalloc was not found. "
257-
"Try setting specific path via `-Djemalloc_ROOT=/PATH/TO/jemalloc/INSTALL` "
258-
" or disable jemalloc via `-Duse_jemalloc=OFF` (default)."
259-
)
260-
endif()
261-
endif()
262-
263-
264213
option (smp "Use Charm++ in SMP mode." OFF)
265214
if (smp)
266215
if (CHARM_SMP)
@@ -274,20 +223,6 @@ if (smp)
274223
endif()
275224

276225

277-
option(use_papi "Use the PAPI performance API" OFF)
278-
if (use_papi)
279-
find_package(PAPI)
280-
if (PAPI_FOUND)
281-
add_compile_definitions(CONFIG_USE_PAPI PAPI3)
282-
else()
283-
message(FATAL_ERROR
284-
"Requested to use PAPI performance API but PAPI was not found. "
285-
"Try setting specific path via `-DPAPI_ROOT=/PATH/TO/PAPI/INSTALL` "
286-
" or disable PAPI via `-Duse_papi=OFF` (default)."
287-
)
288-
endif()
289-
endif()
290-
291226
# define recipies for building external dependencies before we introduce
292227
# compiler flags specific to Enzo-E (and Cello)
293228
add_subdirectory(src/External)

dependencies.cmake

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Handle external dependencies
2+
# -> locate all existing prebuilt dependencies
3+
# -> in the future, we may also define the recipies for building dependencies
4+
# that are not pre-built
5+
6+
find_package(Charm REQUIRED)
7+
# Link executables with the charmc wrapper
8+
STRING(REGEX REPLACE "<CMAKE_CXX_COMPILER>" "${CHARM_LINKER}"
9+
CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
10+
11+
12+
# Need to process Grackle here as both Cello and Enzo-E depend on it
13+
option(USE_GRACKLE "Use Grackle Chemistry" ON)
14+
# don't bother advertising the following option (but users can
15+
# overwrite it if they really want to - e.g. to reduce binary size)
16+
option(GRACKLE_USE_STATIC_LIBS "sets Grackle's lib-type if USE_GRACKLE=ON" ON)
17+
if (USE_GRACKLE)
18+
find_package(Grackle)
19+
if (Grackle_FOUND)
20+
# This really only needs to be defined for a relatively small subset of
21+
# files in the Enzo-layer
22+
add_compile_definitions(CONFIG_USE_GRACKLE)
23+
24+
else()
25+
message(FATAL_ERROR
26+
"Configured to use Grackle but Grackle library not found.\n"
27+
"Either disable grackle (e.g., `-DUSE_GRACKLE=OFF`) or provide path "
28+
"(e.g., `-DGrackle_ROOT=/PATH/TO/GRACKLE/INSTALL/DIRECTORY`).")
29+
endif()
30+
endif()
31+
32+
find_package(PNG REQUIRED)
33+
add_compile_definitions(NO_FREETYPE)
34+
35+
find_package(HDF5 REQUIRED COMPONENTS C)
36+
# HDF5 Interface library
37+
add_library(HDF5_C INTERFACE)
38+
target_link_libraries(HDF5_C INTERFACE ${HDF5_C_LIBRARIES})
39+
target_compile_definitions(HDF5_C INTERFACE ${HDF5_C_DEFINITIONS})
40+
target_include_directories(HDF5_C INTERFACE ${HDF5_C_INCLUDE_DIRS})
41+
42+
option (use_jemalloc "Use the jemalloc library for memory allocation" OFF)
43+
if (use_jemalloc)
44+
find_package(jemalloc)
45+
if (jemalloc_FOUND)
46+
add_compile_definitions(CONFIG_USE_JEMALLOC)
47+
else()
48+
message(FATAL_ERROR
49+
"Requested to use the jemalloc library for memory allocation but jemalloc was not found. "
50+
"Try setting specific path via `-Djemalloc_ROOT=/PATH/TO/jemalloc/INSTALL` "
51+
" or disable jemalloc via `-Duse_jemalloc=OFF` (default)."
52+
)
53+
endif()
54+
endif()
55+
56+
option(use_papi "Use the PAPI performance API" OFF)
57+
if (use_papi)
58+
find_package(PAPI)
59+
if (PAPI_FOUND)
60+
add_compile_definitions(CONFIG_USE_PAPI PAPI3)
61+
else()
62+
message(FATAL_ERROR
63+
"Requested to use PAPI performance API but PAPI was not found. "
64+
"Try setting specific path via `-DPAPI_ROOT=/PATH/TO/PAPI/INSTALL` "
65+
" or disable PAPI via `-Duse_papi=OFF` (default)."
66+
)
67+
endif()
68+
endif()

0 commit comments

Comments
 (0)