Skip to content

Commit d7859d7

Browse files
authored
Merge pull request #57 from dengwirda/cmake-paths
Add support to build with user-defined dependencies
2 parents a3afb93 + e2d9a88 commit d7859d7

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/CMakeLists.txt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@ function (cfg_compile_options OPT CFG)
44
endfunction ()
55

66
include (CheckCXXCompilerFlag)
7+
include (CheckIPOSupported)
78

89
set (CMAKE_CXX_STANDARD 17)
9-
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
10+
11+
check_ipo_supported (RESULT IPO OUTPUT IPO_ERR LANGUAGES C CXX)
12+
13+
if (IPO)
14+
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
15+
endif ()
1016

1117
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
1218
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
@@ -59,7 +65,13 @@ endif ()
5965

6066
# try to find netcdf support
6167

62-
find_library (NETCDF_LIBRARY NAMES netcdf)
68+
if (DEFINED NETCDF_USER_PATH)
69+
message (STATUS "Testing user NetCDF path")
70+
find_library (NETCDF_LIBRARY NAMES netcdf
71+
PATHS ${NETCDF_USER_PATH} NO_DEFAULT_PATH)
72+
else ()
73+
find_library (NETCDF_LIBRARY NAMES netcdf)
74+
endif ()
6375

6476
if (NETCDF_LIBRARY)
6577
message (STATUS "NetCDF library found")
@@ -70,7 +82,14 @@ endif ()
7082

7183
# try to find openmp support
7284

73-
find_package (OpenMP)
85+
if (DEFINED OPENMP_USER_PATH)
86+
message (STATUS "Testing user OpenMP path")
87+
set ( OpenMP_C_INCLUDE_DIR ${OPENMP_USER_PATH})
88+
set (OpenMP_CXX_INCLUDE_DIR ${OPENMP_USER_PATH})
89+
find_package (OpenMP)
90+
else ()
91+
find_package (OpenMP)
92+
endif ()
7493

7594
if (OpenMP_CXX_FOUND AND (OpenMP_CXX_VERSION LESS 3))
7695
set (OpenMP_CXX_FOUND FALSE)
@@ -80,6 +99,7 @@ endif ()
8099
if (OpenMP_CXX_FOUND)
81100
message (STATUS "OpenMP library found")
82101
message (STATUS "OpenMP inc. lib: ${OpenMP_CXX_LIB_NAMES}")
102+
message (STATUS "OpenMP inc. lib: ${OpenMP_CXX_LIBRARIES}")
83103
else ()
84104
message (STATUS "OpenMP library not found")
85105
endif ()

0 commit comments

Comments
 (0)