-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
188 lines (154 loc) · 5.89 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
###
# Copyright (c) 2012-2018, University of Strathclyde
# License: BSD-3-Clause
# 25.6.2015 Jonathan Smith - CMake lists for PUFFIN Project
###
cmake_minimum_required (VERSION 2.8.10)
project (puffin)
cmake_policy(SET CMP0054 NEW)
enable_language (Fortran)
# The version number.
set (Puffin_VERSION_MAJOR 1)
set (Puffin_VERSION_MINOR 9)
set (Puffin_VERSION_PATCH 0)
include(${CMAKE_SOURCE_DIR}/scimake/SciInit.cmake)
#option(ENABLE_PARALLEL "whether to build parallel PUFFIN" ON)
######################################################################
#
# Find packages
#
######################################################################
if(ENABLE_PARALLEL)
find_package(SciMpi REQUIRED)
set(USE_MPI 1 CACHE BOOL "setting USE_MPI to 1" FORCE)
endif()
if (USE_MKL)
find_package(SciMkl)
else()
find_package(SciFftw3 REQUIRED)
endif()
find_package(SciHdf5)
find_package(OpenMP)
find_package(SciDoxygen)
if (DOXYGEN_FOUND)
message(STATUS "Doxygen FOUND!!")
message(STATUS "DOXYGEN IS : ${DOXYGEN_PROGRAM}")
endif()
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
endif()
## FFLAGS depend on the compiler
#get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)#
#
#if (Fortran_COMPILER_NAME MATCHES "gfortran.*")
# # gfortran
# set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3")
# set (CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g")
#elseif (Fortran_COMPILER_NAME MATCHES "ifort.*")
# # ifort (untested)
# set (CMAKE_Fortran_FLAGS_RELEASE "-f77rtl -O3")
# set (CMAKE_Fortran_FLAGS_DEBUG "-f77rtl -O0 -g")
#elseif (Fortran_COMPILER_NAME MATCHES "g77")
# # g77
# set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-all-loops -fno-f2c -O3 -m32")
# set (CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g -m32")
#else (Fortran_COMPILER_NAME MATCHES "gfortran.*")
# message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
# message ("Fortran compiler: " ${Fortran_COMPILER_NAME})
# message ("No optimized Fortran compiler flags are known, we just try -O2...")
# set (CMAKE_Fortran_FLAGS_RELEASE "-O2")
# set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g")
#endif (Fortran_COMPILER_NAME MATCHES "gfortran.*")
#message ("-- FFTW_LIB: " ${FFTW_LIB})
#message ("-- FFTW_MPI_LIB: " ${FFTW_MPI_LIB})
#message ("-- FFTW_LIB_DIR: " ${FFTW_LIB_DIR})
#find_package(MPI REQUIRED)
set(ENV{GIT_DIR} ${CMAKE_SOURCE_DIR}/.git)
#set(GIT_GET_BRANCH "git rev-parse --abbrev-ref HEAD")
execute_process(COMMAND git --work-tree=${CMAKE_SOURCE_DIR} rev-parse --abbrev-ref HEAD
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE GIT_BRANCH
)
if (GIT_BRANCH)
STRING(REPLACE "\n" "" GIT_BRANCH ${GIT_BRANCH})
else()
set(GIT_BRANCH "unknown branch, not in git")
endif()
execute_process(COMMAND git --work-tree=${CMAKE_SOURCE_DIR} rev-parse HEAD
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE GIT_REVISION
)
if (GIT_REVISION)
STRING(REPLACE "\n" "" GIT_REVISION ${GIT_REVISION})
else()
set(GIT_REVISION "unknown revision, not in git")
endif()
message(STATUS "git branch : ${GIT_BRANCH} ${GIT_REVISION}")
string(TIMESTAMP CONFIGURE_TIME_STAMP "%Y-%m-%d %H:%M")
######################################################################
#
# Variables for inclusion in config.h
#
######################################################################
set(CXX ${CMAKE_CXX_COMPILER})
set(CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CBT_UC}}")
set(CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CBT_UC}}")
set(HAVE_CMAKE 1 CACHE STRING "Whether built with CMake")
enable_testing()
######################################################################
#
# Create the configure file
#
######################################################################
configure_file(config-cmake.h.in config.h)
configure_file(source/puffProvenance.f90.in source/puffProvenance.f90)
configure_file(doc/fortran.dxg.in doc/fortran.dxg)
add_subdirectory(source)
set(PFUNIT_INSTALL $ENV{PFUNIT_INSTALL})
if (ENABLE_TESTING)
if(DEFINED PFUNIT_INSTALL)
message(STATUS "PFUNIT_INSTALL: ${PFUNIT_INSTALL}")
set(PFUNIT_DIR ${PFUNIT_INSTALL})
add_subdirectory(test)
else()
message(STATUS "Tests requested, but need PFUNIT_INSTALL specified...")
message(STATUS "...so skipping tests. Define top level PFUNIT_INSTALL.")
endif (DEFINED PFUNIT_INSTALL)
endif (ENABLE_TESTING)
if (DOXYGEN_FOUND)
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/doc/fortran.dxg
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/doc
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
#add_custom_command(COMMAND ${DOXYGEN_PROGRAM} ${PROJECT_BINARY_DIR}/doc/fortran.dxg
# COMMENT "Generating doxygen dev docs"
# VERBATIM
# )
endif()
install (DIRECTORY utilities/post DESTINATION bin)
install (DIRECTORY utilities/pyPlotting DESTINATION bin)
install (DIRECTORY utilities/setup DESTINATION bin)
install (DIRECTORY utilities/visit-scripts DESTINATION bin)
install (DIRECTORY inputs/ DESTINATION examples)
# install (DIRECTORY inputs/gen/ DESTINATION python)
install (DIRECTORY scripts/ DESTINATION examples/job-submission-scripts)
######################################################################
#
# Finalize (installation, packaging)
#
######################################################################
set(COMMON_INSTALL TRUE)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Puffin")
set(CONFIG_FILES) # Clear out
include(${CMAKE_SOURCE_DIR}/scimake/SciFinalize.cmake)
# build a CPack driven installer package
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set (CPACK_PACKAGE_VERSION_MAJOR "${Puffin_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${Puffin_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${Puffin_VERSION_PATCH}")
include (CPack)