forked from ESCOMP/CDEPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindPIO.cmake
103 lines (84 loc) · 3.59 KB
/
FindPIO.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# - Try to find PIO
#
# This can be controled by setting PIO_PATH or PIO_<lang>_PATH Cmake variables,
# where <lang> is the COMPONENT language one needs.
#
# Once done, this will define:
#
# PIO_<lang>_FOUND (BOOL) - system has PIO
# PIO_<lang>_IS_SHARED (BOOL) - whether the library is shared/dynamic
# PIO_<lang>_INCLUDE_DIR (PATH) - Location of the header files and modules
# PIO_<lang>_LIBRARY (File) - Path to the <lang> library files
# PIO_<lang>_LIBRARIES (List) - link these to use PIO
#
# Available COMPONENTS are: C Fortran
# If no components are specified only C is assumed
include (LibFind)
include (LibCheck)
# Define PIO C Component
define_package_component(PIO DEFAULT
COMPONENT C
INCLUDE_NAMES pio.h
LIBRARY_NAMES pioc)
# Define PIO Fortran Component
define_package_component(PIO
COMPONENT Fortran
INCLUDE_NAMES pio.mod pio.inc
LIBRARY_NAMES piof)
# Search for list of valid components requested
find_valid_components(PIO)
#==============================================================================
# SEARCH FOR VALIDATED COMPONENTS
foreach (pcomp IN LISTS PIO_FIND_VALID_COMPONENTS)
# If not found already, search...
if (NOT PIO_${pcomp}_FOUND)
# Manually add the MPI include and library dirs to search paths
# and search for the package component
if (MPI_${pcomp}_FOUND)
initialize_paths (PIO_${pcomp}_PATHS
INCLUDE_DIRECTORIES ${MPI_${pcomp}_INCLUDE_PATH}
LIBRARIES ${MPI_${pcomp}_LIBRARIES})
find_package_component(PIO COMPONENT ${pcomp}
PATHS ${PIO_${pcomp}_PATHS})
else ()
find_package_component(PIO COMPONENT ${pcomp} HINT PIO_${pcomp}_PATH=${PIO_PATH})
endif ()
# Continue only if component found
if (PIO_${pcomp}_FOUND)
# Checks
if (pcomp STREQUAL C)
# Check version
check_version (PIO
NAME "pio_meta.h"
HINTS ${PIO_C_INCLUDE_DIRS}
MACRO_REGEX "PIO_VERSION_")
endif ()
# Dependencies
if (pcomp STREQUAL C AND NOT PIO_C_IS_SHARED)
# DEPENDENCY: PnetCDF (if PnetCDF enabled)
check_macro (PIO_HAS_PNETCDF
NAME TryPIO_PNETCDF.c
HINTS ${CMAKE_MODULE_PATH}
DEFINITIONS -I${PIO_C_INCLUDE_DIR}
COMMENT "whether PIO has PnetCDF support")
if (PIO_HAS_PNETCDF)
find_package (PnetCDF COMPONENTS C)
endif ()
elseif (pcomp STREQUAL Fortran AND NOT PIO_Fortran_IS_SHARED)
# DEPENDENCY: PIO
set (orig_comp ${pcomp})
set (orig_comps ${PIO_FIND_VALID_COMPONENTS})
find_package (PIO COMPONENTS C)
set (PIO_FIND_VALID_COMPONENTS ${orig_comps})
set (pcomp ${orig_comp})
if (PIO_C_FOUND)
list (APPEND PIO_Fortran_INCLUDE_DIRS ${PIO_C_INCLUDE_DIRS})
list (APPEND PIO_Fortran_LIBRARIES ${PIO_C_LIBRARIES})
endif ()
endif ()
endif ()
endif ()
endforeach ()
message("PIO_C_FOUND ${PIO_C_FOUND}")
message("PIO_Fortran_FOUND ${PIO_Fortran_FOUND}")
message("PIO_Fortran_INCLUDE_DIR ${PIO_Fortran_INCLUDE_DIR}")