forked from OpenCMISS/cm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
161 lines (139 loc) · 6.85 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
cmake_minimum_required (VERSION 2.8)
project (OpenCMISS C Fortran)
#################Define OPENCMISS_ROOT & OPENCMISSEXTRAS_ROOT##################
# Set OPENCMISS_ROOT
IF(NOT DEFINED OPENCMISS_ROOT)
IF(DEFINED ENV{OPENCMISS_ROOT})
SET(OPENCMISS_ROOT $ENV{OPENCMISS_ROOT})
ELSE(DEFINED ENV{OPENCMISS_ROOT})
SET(OPENCMISS_ROOT ..)
ENDIF(DEFINED ENV{OPENCMISS_ROOT})
ENDIF(NOT DEFINED OPENCMISS_ROOT)
SET(GLOBAL_CM_ROOT ${OPENCMISS_ROOT}/cm)
SET(GLOBAL_CELLML_ROOT ${OPENCMISS_ROOT}/cellml)
# Need some way of getting OPENCMISSEXTRAS_ROOT defined.
IF(NOT DEFINED OPENCMISSEXTRAS_ROOT)
IF(DEFINED ENV{OPENCMISSEXTRAS_ROOT})
set (OPENCMISSEXTRAS_ROOT $ENV{OPENCMISSEXTRAS_ROOT})
ELSE(DEFINED ENV{OPENCMISSEXTRAS_ROOT})
set (OPENCMISSEXTRAS_ROOT ${OPENCMISS_ROOT}/../opencmissextras)
ENDIF(DEFINED ENV{OPENCMISSEXTRAS_ROOT})
ENDIF(NOT DEFINED OPENCMISSEXTRAS_ROOT)
set (EXTERNAL_CM_ROOT ${OPENCMISSEXTRAS_ROOT}/cm/external)
SET(GLOBAL_FIELDML_ROOT ${OPENCMISSEXTRAS_ROOT}/fieldml)
SET(CMAKE_MODULE_PATH "${GLOBAL_CM_ROOT}/cmake_modules")
INCLUDE( ${CMAKE_MODULE_PATH}/GeneralConfiguration.cmake )
INCLUDE( ${CMAKE_MODULE_PATH}/MacroDefinitions.cmake )
INCLUDE( ${CMAKE_MODULE_PATH}/CompileFlags.cmake )
########################Include opencmissextras libraries#############################################
IF(${OPERATING_SYSTEM} STREQUAL win32)
#TODO This is to be removed while new opencmissextras is available.
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${EXTERNAL_CM_ROOT}/i386-win32-debug)
ELSE(${OPERATING_SYSTEM} STREQUAL win32)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${EXTERNAL_CM_ROOT}/${LIB_ARCH_DIR}${DEBUG_SUFFIX}${PROF_SUFFIX}/${MPI}/${COMPILER})
ENDIF(${OPERATING_SYSTEM} STREQUAL win32)
# MPI
IF(NOT ${OPERATING_SYSTEM} STREQUAL aix)
FIND_PACKAGE(MPI REQUIRED)
INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
ENDIF(NOT ${OPERATING_SYSTEM} STREQUAL aix)
#PETSC
FIND_PACKAGE(PETSC REQUIRED)
INCLUDE_DIRECTORIES(${PETSC_INCLUDES})
#TAO
FIND_PACKAGE(TAO)
INCLUDE_DIRECTORIES(${TAO_INCLUDES})
#SUNDIALS
FIND_PACKAGE(SUNDIALS)
INCLUDE_DIRECTORIES(${SUNDIALS_INCLUDES})
#HYPRE
FIND_PACKAGE(HYPRE)
INCLUDE_DIRECTORIES(${HYPRE_INCLUDES})
#MUMPS
FIND_PACKAGE(MUMPS)
INCLUDE_DIRECTORIES(${MUMPS_INCLUDES})
#SCALAPACK
FIND_PACKAGE(SCALAPACK)
INCLUDE_DIRECTORIES(${SCALAPACK_INCLUDES})
#BLACS
FIND_PACKAGE(BLACS)
INCLUDE_DIRECTORIES(${BLACS_INCLUDES})
IF(USECELLML)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSECELLML ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSECELLML ")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DUSECELLML ")
INCLUDE_DIRECTORIES(${GLOBAL_CELLMLML_ROOT}/${LIB_ARCH_DIR}${MT_SUFFIX}${DEBUG_SUFFIX}${PROF_SUFFIX}/${COMPILER}/include)
ENDIF(USECELLML)
IF(USEFIELDML)
INCLUDE_DIRECTORIES(${GLOBAL_FIELDML_ROOT}/${LIB_ARCH_DIR}${MT_SUFFIX}${DEBUG_SUFFIX}${PROF_SUFFIX}/include)
INCLUDE_DIRECTORIES(${GLOBAL_FIELDML_ROOT}/${LIB_ARCH_DIR}${MT_SUFFIX}${DEBUG_SUFFIX}${PROF_SUFFIX}/${COMPILER}/include)
ENDIF(USEFIELDML)
SET(SOURCE_DIR ${GLOBAL_CM_ROOT}/src)
SET(CMAKE_INSTALL_PREFIX ${GLOBAL_CM_ROOT})
SET(OBJECT_DIR object/${LIB_ARCH_DIR}${MY_SUFFIX}${DEBUG_SUFFIX}${PROF_SUFFIX}/${MPI}/${COMPILER})
SET(MODULE_DIR ${OBJECT_DIR})
SET(INC_DIR include/${BIN_ARCH_DIR}/${MPI}/${COMPILER})
SET(MOD_INC_NAME opencmiss.mod)
SET(MOD_SOURCE_INC ${CMAKE_BINARY_DIR}/${MOD_INC_NAME})
SET(HEADER_INC_NAME opencmiss.h)
SET(HEADER_SOURCE_INC ${SOURCE_DIR}/${HEADER_INC_NAME})
SET(LIB_DIR lib/${BIN_ARCH_DIR}/${MPI}/${COMPILER})
SET(LIBRARY_TARGET_NAME ${CMAKE_PROJECT_NAME}${EXE_ABI_SUFFIX}${MT_SUFFIX}${DEBUG_SUFFIX}${PRO_SUFFIX})
SET(LIBRARY_BUILD_TYPE STATIC)
SET(LIBRARY_INSTALL_TYPE ARCHIVE)
FILE(GLOB OPENCMISS_SRCS ${SOURCE_DIR}/*.*)
INCLUDE( ${CMAKE_MODULE_PATH}/Entries.cmake )
FOREACH(infileName ${EXCLUDED_ROUTINES})
FILE(GLOB infileName ${infileName}) # necessary to get an exact match of the filename in the list (for out-of-source builds)
IF (infileName) # if file was found
LIST(REMOVE_ITEM OPENCMISS_SRCS ${infileName})
ENDIF (infileName)
ENDFOREACH(infileName)
# Preprocess files mentioned in "PreprocessedSources.cmake"
INCLUDE( ${CMAKE_MODULE_PATH}/PreprocessedSources.cmake )
FOREACH(filenameSrc ${PREPROCESSED_SRCS})
# Get full filename of raw, unexpanded src file
SET(fullFilenameSrc "${SOURCE_DIR}/${filenameSrc}")
# Generate filename for expanded (intermediate) file
GET_FILENAME_COMPONENT(filenameBase ${filenameSrc} NAME_WE)
GET_FILENAME_COMPONENT(filenameExtension ${filenameSrc} EXT)
SET(fullFilenameExpanded "${OBJECT_DIR}/${filenameBase}-expanded${filenameExtension}")
# Don't compile the raw, unexpanded source file...
FILE(GLOB fullFilenameSrc ${fullFilenameSrc}) # necessary to get an exact match of the filename in the list (for out-of-source builds)
LIST(REMOVE_ITEM OPENCMISS_SRCS ${fullFilenameSrc})
# ...but compile the preprocessed (expanded) intermediate file instead!
LIST(APPEND OPENCMISS_SRCS ${fullFilenameExpanded})
# Add rule that tells cmake how to create the intermediate file
ADD_CUSTOM_COMMAND(OUTPUT ${fullFilenameExpanded}
COMMAND mkdir
ARGS -p ${OBJECT_DIR}
VERBATIM
COMMAND m4
ARGS --prefix-builtins ${fullFilenameSrc} > ${fullFilenameExpanded}
VERBATIM
DEPENDS ${fullFilenameSrc}
)
ENDFOREACH(filenameSrc)
IF(${OPERATING_SYSTEM} STREQUAL win32)
FILE(GLOB OPENCMISS_FORTRAN_SRCS ${SOURCE_DIR}/*.f90)
FILE(GLOB OPENCMISS_C_SRCS ${SOURCE_DIR}/*.c)
FILE(GLOB OPENCMISS_C_HEADER ${SOURCE_DIR}/*.h)
LIST(APPEND OPENCMISS_C_SRCS ${OPENCMISS_C_HEADER})
INCLUDE( ${CMAKE_MODULE_PATH}/Entries.cmake )
FOREACH(infileName ${EXCLUDED_ROUTINES})
LIST(REMOVE_ITEM OPENCMISS_FORTRAN_SRCS ${infileName})
LIST(REMOVE_ITEM OPENCMISS_C_SRCS ${infileName})
ENDFOREACH(infileName)
ADD_LIBRARY(${LIBRARY_TARGET_NAME}_Fortran ${LIBRARY_BUILD_TYPE} ${OPENCMISS_FORTRAN_SRCS} ${PUBLIC_HDRS} ${PRIVATE_HDRS})
ADD_LIBRARY(${LIBRARY_TARGET_NAME}_C ${LIBRARY_BUILD_TYPE} ${OPENCMISS_C_SRCS} ${PUBLIC_HDRS} ${PRIVATE_HDRS})
ELSE(${OPERATING_SYSTEM} STREQUAL win32)
ADD_LIBRARY(${LIBRARY_TARGET_NAME} ${LIBRARY_BUILD_TYPE} ${OPENCMISS_SRCS} ${PUBLIC_HDRS} ${PRIVATE_HDRS})
ENDIF(${OPERATING_SYSTEM} STREQUAL win32)
IF(${OPERATING_SYSTEM} STREQUAL linux)
INSTALL(TARGETS ${LIBRARY_TARGET_NAME} ${LIBRARY_INSTALL_TYPE} DESTINATION lib/x86_64-linux/mpich2/gnu)
INSTALL(FILES ${MOD_SOURCE_INC} ${HEADER_SOURCE_INC} DESTINATION ${INC_DIR})
FILE(GLOB OPENCMISS_MODS ${CMAKE_BINARY_DIR}/*.mod)
INSTALL(FILES ${OPENCMISS_MODS} DESTINATION ${MODULE_DIR})
FILE(GLOB OPENCMISS_OBJS ${CMAKE_BINARY_DIR}/CMakeFiles/${CMAKE_PROJECT_NAME}${EXE_ABI_SUFFIX}${MT_SUFFIX}${DEBUG_SUFFIX}${PRO_SUFFIX}.dir/src/*.o)
INSTALL(FILES ${OPENCMISS_OBJS} DESTINATION ${OBJECT_DIR})
ENDIF(${OPERATING_SYSTEM} STREQUAL linux)