-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
96 lines (78 loc) · 3.19 KB
/
CMakeLists.txt
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
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.10.0 FATAL_ERROR)
project(NaluWindUtils CXX C Fortran)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
set(CMAKE_PREFIX_PATH ${Trilinos_DIR} ${CMAKE_PREFIX_PATH})
option(ENABLE_WRFTONALU "Enable WRF to Nalu Fortran conversion utility" off)
option(ENABLE_SPHINX_DOCS "Enable Sphinx-based user/developer manual" off)
option(ENABLE_DOXYGEN_DOCS "Enable API documentation using Doxygen" off)
option(ENABLE_SPHINX_API_DOCS "Enable linking Doxygen API documentation to Sphinx" off)
option(ENABLE_HYPRE "Enable HYPRE solver interface" off)
option(ENABLE_WARNINGS "Enable warnings during build" on)
option(ENABLE_REGTESTS "Enable regression tests" off)
find_package(MPI REQUIRED)
find_package(Trilinos REQUIRED)
find_package(OpenMP)
############################ YAML ######################################
set(CMAKE_PREFIX_PATH ${YAML_DIR} ${CMAKE_PREFIX_PATH})
find_package(YAML-CPP 0.6.2 QUIET REQUIRED)
message(STATUS "Found YAML-CPP = ${YAML_CPP_CMAKE_DIR}")
if (ENABLE_HYPRE)
find_package(HYPRE REQUIRED)
endif()
if (CMAKE_VERSION VERSION_LESS "3.1")
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
include_directories(SYSTEM ${MPI_INCLUDE_PATH})
include_directories(SYSTEM ${Trilinos_INCLUDE_DIRS})
include_directories(SYSTEM ${Trilinos_TPL_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
if (HYPRE_FOUND)
include_directories(SYSTEM ${HYPRE_INCLUDE_DIRS})
add_definitions(-DENABLE_HYPRE)
endif()
if (OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
endif()
if (ENABLE_WARNINGS)
list(APPEND WIND_UTILS_WARN_FLAGS "-Wall" "-Wextra" "-pedantic")
endif()
add_subdirectory(src)
if (ENABLE_SPHINX_DOCS OR ENABLE_DOXYGEN_DOCS)
add_subdirectory(doc)
endif()
if (ENABLE_REGTESTS)
include(CTest)
add_subdirectory(tests)
endif()
# Install library dependency information
install(EXPORT ${PROJECT_NAME}Libraries
DESTINATION lib/cmake/${PROJECT_NAME}
FILE ${PROJECT_NAME}Libraries.cmake)
# Create NaluWindUtils config so that other codes can find NaluWindUtils
include(CMakePackageConfigHelpers)
set(INCLUDE_INSTALL_DIR include/)
set(LIB_INSTALL_DIR lib/)
configure_package_config_file(
cmake/${PROJECT_NAME}.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.cmake
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.cmake
DESTINATION lib/cmake/${PROJECT_NAME})