-
Notifications
You must be signed in to change notification settings - Fork 51
/
CMakeLists.txt
201 lines (163 loc) · 6.86 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
189
190
191
192
193
194
195
196
197
198
199
200
201
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4 FATAL_ERROR)
PROJECT(FoX Fortran)
SET(CMAKE_VERBOSE_MAKEFILE FALSE)
#======================#
# Enable testing
#======================#
ENABLE_TESTING()
INCLUDE(CTest)
#======================#
# Build paths
#======================#
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules)
INCLUDE_DIRECTORIES(${CMAKE_Fortran_MODULE_DIRECTORY})
#======================#
# Enable/disable libraries
#======================#
OPTION(${PROJECT_NAME}_ENABLE_WXML "Enable/disable general Fortran XML output library" ON)
OPTION(${PROJECT_NAME}_ENABLE_WCML "Enable/disable Chemical Markup Language output library" ON)
OPTION(${PROJECT_NAME}_ENABLE_WKML "Enable/disable Keyhole Markup Language output library" ON)
OPTION(${PROJECT_NAME}_ENABLE_DOM "Enable/disable Document Object Model input library" ON)
OPTION(${PROJECT_NAME}_ENABLE_EXAMPLES "Build examples" ON)
OPTION(${PROJECT_NAME}_SUPPRESS_WARNINGS "Supress non-fatal warnings" OFF)
OPTION(BUILD_SHARED_LIBS, OFF)
#======================#
# set another compiler #
#======================#
# to set another compiler than the default,
# do the usual from within the build directory:
# $ FC=g95
# $ rm -rf * && cmake ../
# $ make
#=====================#
# verbose make output #
#=====================#
# to see out all commands used during building,
# do as follows:
# $ rm -rf * && cmake ../
# $ make VERBOSE=1
#======================#
# speed up compilation #
#======================#
# to speed up compilation by using multiple cores/processors,
# do the following:
# $ rm -rf * && cmake ../
# $ make -j
#==============================#
# get the machine architecture #
#==============================#
SET(OS ${CMAKE_SYSTEM})
SET(MACHINE_ARCH ${CMAKE_SYSTEM_PROCESSOR})
MESSAGE(STATUS "determining operating system and architecture:")
MESSAGE(" -> your operating system is : ${OS}")
MESSAGE(" -> your architecture is : ${MACHINE_ARCH}")
#==========================#
# check if m4 is available #
#==========================#
MESSAGE(STATUS "Searching for m4 scripting language")
FIND_PROGRAM(M4_PROGRAM m4)
IF(${M4_PROGRAM} MATCHES "NOTFOUND")
MESSAGE(" -> WARNING : could not find m4, cannot generate fortran files from m4 sources")
ELSE(${M4_PROGRAM} MATCHES "NOTFOUND")
MESSAGE(" -> ${M4_PROGRAM}")
ENDIF(${M4_PROGRAM} MATCHES "NOTFOUND")
#============================#
# set some other definitions #
#============================#
# file name extensions
SET(m4_ext .m4)
SET(f90pp_ext .F90)
SET(f90_ext .f90)
###===================================###
###===================================###
### determine some preprocessor flags ###
###===================================###
###===================================###
#===========================================================#
# determine end-of-line character based on operating system #
#===========================================================#
INCLUDE(${${PROJECT_NAME}_SOURCE_DIR}/cmake/DetermineEOL.cmake)
#============================================#
# determine if and how FLUSH intrinsic works #
#============================================#
INCLUDE(${${PROJECT_NAME}_SOURCE_DIR}/cmake/CheckFlushIntrinsic.cmake)
#=====================================================#
# check for 'associated in restricted expression' bug #
#=====================================================#
INCLUDE(${${PROJECT_NAME}_SOURCE_DIR}/cmake/CheckAssociatedBug.cmake)
#============================================#
# determine if and how ABORT intrinsic works #
#============================================#
INCLUDE(${${PROJECT_NAME}_SOURCE_DIR}/cmake/CheckAbortIntrinsic.cmake)
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FPPFLAGS}")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
MACRO(MK_LIBS _NAME)
ADD_LIBRARY(
${PROJECT_NAME}_${_NAME}
${fox_${_NAME}_srcs}
${fox_${_NAME}_srcs_pp}
)
SET_PROPERTY(TARGET ${PROJECT_NAME}_${_NAME} PROPERTY POSITION_INDEPENDENT_CODE 1)
FOREACH(ARG IN ITEMS ${ARGN})
TARGET_LINK_LIBRARIES(
${PROJECT_NAME}_${_NAME}
${PROJECT_NAME}_${ARG}
)
ENDFOREACH()
INSTALL (TARGETS ${PROJECT_NAME}_${_NAME} DESTINATION lib)
ENDMACRO(MK_LIBS)
# Base library directories
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/fsys)
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/utils)
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/common)
# wxml directory
IF(${PROJECT_NAME}_ENABLE_WXML OR ${PROJECT_NAME}_ENABLE_WCML OR ${PROJECT_NAME}_ENABLE_WKML OR ${PROJECT_NAME}_ENABLE_DOM OR ${PROJECT_NAME}_ENABLE_EXAMPLES)
SET(${PROJECT_NAME}_ENABLE_WXML ON)
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/wxml)
ELSE()
GET_PROPERTY(THE_INCLUDE_DIRS GLOBAL PROPERTY INCLUDE_DIRECTORIES)
STRING(REPLACE ${${PROJECT_NAME}_SOURCE_DIR}/wxml "" NEW_INCLUDE_DIRS "${THE_INCLUDE_DIRS}")
SET_PROPERTY(GLOBAL PROPERTY INCLUDE_DIRECTORIES ${NEW_INCLUDE_DIRS})
ENDIF()
# wkml directory
IF(${PROJECT_NAME}_ENABLE_WKML OR ${PROJECT_NAME}_ENABLE_EXAMPLES)
SET(${PROJECT_NAME}_ENABLE_WKML ON)
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/wkml)
ELSE()
GET_PROPERTY(THE_INCLUDE_DIRS GLOBAL PROPERTY INCLUDE_DIRECTORIES)
STRING(REPLACE ${${PROJECT_NAME}_SOURCE_DIR}/wkml "" NEW_INCLUDE_DIRS "${THE_INCLUDE_DIRS}")
SET_PROPERTY(GLOBAL PROPERTY INCLUDE_DIRECTORIES ${NEW_INCLUDE_DIRS})
ENDIF()
# wcml directory
IF(${PROJECT_NAME}_ENABLE_WCML OR ${PROJECT_NAME}_ENABLE_EXAMPLES)
SET(${PROJECT_NAME}_ENABLE_WCML ON)
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/wcml)
ELSE()
GET_PROPERTY(THE_INCLUDE_DIRS GLOBAL PROPERTY INCLUDE_DIRECTORIES)
STRING(REPLACE ${${PROJECT_NAME}_SOURCE_DIR}/wcml "" NEW_INCLUDE_DIRS "${THE_INCLUDE_DIRS}")
SET_PROPERTY(GLOBAL PROPERTY INCLUDE_DIRECTORIES ${NEW_INCLUDE_DIRS})
ENDIF()
# dom and sax directories
IF(${PROJECT_NAME}_ENABLE_DOM OR ${PROJECT_NAME}_ENABLE_EXAMPLES)
SET(${PROJECT_NAME}_ENABLE_DOM ON)
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/sax)
ADD_SUBDIRECTORY(${${PROJECT_NAME}_SOURCE_DIR}/dom)
ELSE()
GET_PROPERTY(THE_INCLUDE_DIRS GLOBAL PROPERTY INCLUDE_DIRECTORIES)
STRING(REPLACE ${${PROJECT_NAME}_SOURCE_DIR}/sax "" TEMP_DIRS "${THE_INCLUDE_DIRS}")
STRING(REPLACE ${${PROJECT_NAME}_SOURCE_DIR}/dom "" NEW_INCLUDE_DIRS "${TEMP_DIRS}")
SET_PROPERTY(GLOBAL PROPERTY INCLUDE_DIRECTORIES ${NEW_INCLUDE_DIRS})
ENDIF()
# examples directory
IF(${PROJECT_NAME}_ENABLE_EXAMPLES OR ${PROJECT_NAME}_ENABLE_EXAMPLES)
SET(${PROJECT_NAME}_ENABLE_WCML ON)
ADD_SUBDIRECTORY(examples)
ELSE()
GET_PROPERTY(THE_INCLUDE_DIRS GLOBAL PROPERTY INCLUDE_DIRECTORIES)
STRING(REPLACE "${${PROJECT_NAME}_SOURCE_DIR}/examples" "" NEW_INCLUDE_DIRS "${THE_INCLUDE_DIRS}")
SET_PROPERTY(GLOBAL PROPERTY INCLUDE_DIRECTORIES ${NEW_INCLUDE_DIRS})
ENDIF()
# install modules
INSTALL(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION include)