File tree Expand file tree Collapse file tree 5 files changed +68
-42
lines changed Expand file tree Collapse file tree 5 files changed +68
-42
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,6 @@ endif()
56
56
cmake_policy (SET CMP0074 NEW )
57
57
find_package (HDF5 COMPONENTS C Fortran HL REQUIRED )
58
58
find_package (Boost 1.74 REQUIRED )
59
- find_package (FFTW REQUIRED )
60
59
find_package (GSL REQUIRED )
61
60
62
61
### NetCDF
@@ -90,9 +89,10 @@ add_link_options(${NETCDF_FLIBS})
90
89
91
90
include (ExternalProject )
92
91
include (SetupCODE )
93
- include (SetupLIBNEO )
94
92
include (SetupTriangle )
95
93
include (SetupMFEM )
94
+ include (Util )
95
+ find_or_fetch (libneo )
96
96
97
97
### Project source files
98
98
# SuiteSparse
@@ -157,7 +157,7 @@ add_library(mephit SHARED
157
157
${MEPHIT_C_SRC_FILES}
158
158
${MEPHIT_CPP_SRC_FILES}
159
159
)
160
- add_dependencies (mephit LIBNEO MFEM TRIANGLE )
160
+ add_dependencies (mephit MFEM TRIANGLE )
161
161
target_include_directories (mephit PUBLIC
162
162
${magfie_include_dir}
163
163
${NETCDF_INCLUDES}
@@ -176,9 +176,9 @@ set(MEPHIT_LIBS
176
176
LAPACK::LAPACK
177
177
${FFTW_LIBRARIES}
178
178
${triangle_lib}
179
- ${magfie_lib}
180
- ${neo_lib}
181
- ${hdf5_tools_lib}
179
+ LIBNEO::magfie
180
+ LIBNEO::neo
181
+ LIBNEO::hdf5_tools
182
182
)
183
183
target_link_libraries (mephit ${MEPHIT_LIBS} )
184
184
if (LEGACY_SUITESPARSE )
Original file line number Diff line number Diff line change 1
1
if (DEFINED ENV{CODE} )
2
2
message (STATUS "External libraries prebuilt in $CODE=" $ENV{CODE} )
3
- set (LIBNEO_DIR $ENV{CODE} /libneo/build/ CACHE STRING "libneo directory" )
4
- set (FGSL_DIR $ENV{CODE} /external/fgsl-1.6.0/ CACHE STRING "FGSL directory" )
5
- set (TRIANGLE_DIR $ENV{CODE} /external/triangle/ CACHE STRING "TRIANGLE directory" )
6
- set (MFEM_DIR $ENV{CODE} /external/mfem-4.7/build/ CACHE STRING "MFEM directory" )
3
+ if (EXISTS $ENV{CODE} /libneo/build/ )
4
+ set (LIBNEO_DIR $ENV{CODE} /libneo/build/ CACHE STRING "libneo directory" )
5
+ endif ()
6
+ if (EXISTS $ENV{CODE} /external/fgsl-1.6.0/ )
7
+ set (FGSL_DIR $ENV{CODE} /external/fgsl-1.6.0/ CACHE STRING "FGSL directory" )
8
+ endif ()
9
+ if (EXISTS $ENV{CODE} /external/triangle/ )
10
+ set (TRIANGLE_DIR $ENV{CODE} /external/triangle/ CACHE STRING "TRIANGLE directory" )
11
+ endif ()
12
+ if (EXISTS $ENV{CODE} /external/mfem-4.7/build/ )
13
+ set (MFEM_DIR $ENV{CODE} /external/mfem-4.7/build/ CACHE STRING "MFEM directory" )
14
+ endif ()
7
15
else ()
8
16
message (STATUS "Downloading and building external libraries" )
9
17
endif ()
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -17,12 +17,12 @@ else()# Define Triangle repository
17
17
BUILD_COMMAND /bin/bash ${CMAKE_SOURCE_DIR} /cmake/setup_triangle.sh <SOURCE_DIR>
18
18
INSTALL_COMMAND ""
19
19
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
20
- BUILD_BYPRODUCTS <SOURCE_DIR>/libtriangle${CMAKE_SHARED_LIBRARY_SUFFIX}
20
+ BUILD_BYPRODUCTS <SOURCE_DIR>/libtriangle.so
21
21
)
22
22
set (TRIANGLE_DIR ${CMAKE_BINARY_DIR} /triangle/src/TRIANGLE )
23
23
endif ()
24
24
25
25
set (TRIANGLE_INCLUDE_DIR ${TRIANGLE_DIR} CACHE STRING "Path to triangle include" )
26
26
set (TRIANGLE_LIB_DIR ${TRIANGLE_DIR} CACHE STRING "Path to triangle lib" )
27
27
28
- set (triangle_lib ${TRIANGLE_LIB_DIR} /libtriangle${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE STRING "TRIANGLE lib" )
28
+ set (triangle_lib ${TRIANGLE_LIB_DIR} /libtriangle.so CACHE STRING "TRIANGLE lib" )
Original file line number Diff line number Diff line change
1
+ include (FetchContent )
2
+
3
+ function (find_or_fetch DEPENDENCY )
4
+ if (DEFINED ENV{CODE} AND EXISTS $ENV{CODE} /${DEPENDENCY} )
5
+ set (${DEPENDENCY} _SOURCE_DIR $ENV{CODE} /${DEPENDENCY} )
6
+ message (STATUS "Using ${DEPENDENCY} in $ENV{CODE} /${DEPENDENCY} " )
7
+ else ()
8
+ set (REPO_URL https://github.com/itpplasma/${DEPENDENCY}.git )
9
+ get_branch_or_main (${REPO_URL} REMOTE_BRANCH )
10
+ message (STATUS "Using ${DEPENDENCY} branch ${REMOTE_BRANCH} from ${REPO_URL} " )
11
+
12
+ FetchContent_Declare (
13
+ ${DEPENDENCY}
14
+ DOWNLOAD_EXTRACT_TIMESTAMP TRUE
15
+ GIT_REPOSITORY ${REPO_URL}
16
+ GIT_TAG ${REMOTE_BRANCH}
17
+ )
18
+ FetchContent_Populate (${DEPENDENCY} )
19
+ endif ()
20
+
21
+ add_subdirectory (${${DEPENDENCY}_SOURCE_DIR}
22
+ ${CMAKE_CURRENT_BINARY_DIR} /${DEPENDENCY}
23
+ EXCLUDE_FROM_ALL
24
+ )
25
+ endfunction ()
26
+
27
+
28
+ function (get_branch_or_main REPO_URL REMOTE_BRANCH )
29
+ execute_process (
30
+ COMMAND git rev-parse --abbrev-ref HEAD
31
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
32
+ OUTPUT_VARIABLE BRANCH
33
+ OUTPUT_STRIP_TRAILING_WHITESPACE
34
+ )
35
+
36
+ execute_process (
37
+ COMMAND git ls-remote --heads ${REPO_URL} ${BRANCH}
38
+ OUTPUT_VARIABLE BRANCH_EXISTS
39
+ ERROR_VARIABLE GIT_ERROR
40
+ OUTPUT_STRIP_TRAILING_WHITESPACE
41
+ )
42
+
43
+ if (BRANCH_EXISTS )
44
+ set (${REMOTE_BRANCH} ${BRANCH} PARENT_SCOPE )
45
+ else ()
46
+ set (${REMOTE_BRANCH} "main" PARENT_SCOPE )
47
+ endif ()
48
+ endfunction ()
You can’t perform that action at this time.
0 commit comments