-
Notifications
You must be signed in to change notification settings - Fork 93
/
CMakeLists.txt
executable file
·101 lines (87 loc) · 3.15 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
cmake_minimum_required (VERSION 3.0 FATAL_ERROR)
project(Iron VERSION 1.0 LANGUAGES C Fortran)
# Config
SET(CMAKE_NO_SYSTEM_FROM_IMPORTED YES)
SET(IRON_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules)
INCLUDE(${IRON_MODULES}/MacroDefinitions.cmake)
INCLUDE(${IRON_MODULES}/CompileFlags.cmake)
# External components
# MPI
find_package(MPI REQUIRED)
SET(LINK_LIBS )
# CellML
if (WITH_CELLML)
find_package(LIBCELLML CONFIG REQUIRED)
find_package(CELLML-API CONFIG REQUIRED)
LIST(APPEND LINK_LIBS cellml cellml_model_definition)
endif()
# FieldML
if (WITH_FIELDML)
find_package(FIELDML REQUIRED)
endif()
# Other Dependencies
include(Variables)
SET(DEPS PETSC SUNDIALS HYPRE MUMPS SCALAPACK) #BLACS
foreach(DEP ${DEPS})
# Look for config-aware implementations first
find_package(${DEP} CONFIG QUIET)
if (NOT ${DEP}_FOUND)
FIND_PACKAGE(${DEP} REQUIRED)
INCLUDE_DIRECTORIES(${${DEP}_INCLUDES})
else()
LIST(APPEND LINK_LIBS ${${DEP}_TARGETS})
endif()
endforeach()
message("Link libaries: ${LINK_LIBS}")
# Config
SET(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
SET(HEADER_INC_NAME opencmiss.h)
SET(HEADER_SOURCE_INC ${SOURCE_DIR}/${HEADER_INC_NAME})
SET(LIBRARY_INSTALL_TYPE ARCHIVE)
# Remove some source files from compilation
FILE(GLOB IRON_SOURCES ${SOURCE_DIR}/*.*)
INCLUDE(${IRON_MODULES}/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 IRON_SOURCES ${infileName})
ENDIF (infileName)
ENDFOREACH(infileName)
# Libraries / targets
IF(WIN32)
# Need separate C/Fortran code due to Project natures in VS
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(${IRON_MODULES}/Entries.cmake )
FOREACH(infileName ${EXCLUDED_ROUTINES})
LIST(REMOVE_ITEM OPENCMISS_FORTRAN_SRCS ${infileName})
LIST(REMOVE_ITEM OPENCMISS_C_SRCS ${infileName})
ENDFOREACH(infileName)
# ? maybe use object target an then combine to one target..
ADD_LIBRARY(iron_Fortran ${OPENCMISS_FORTRAN_SRCS})
target_include_directories(iron_Fortran PUBLIC ${MPI_Fortran_INCLUDE_PATH})
if (WITH_CELLML)
target_compile_definitions(iron_Fortran PUBLIC USECELLML)
endif()
ADD_LIBRARY(iron_C ${OPENCMISS_C_SRCS})
if (WITH_CELLML)
target_compile_definitions(iron_C PUBLIC USECELLML)
endif()
target_include_directories(iron_C PUBLIC ${MPI_C_INCLUDE_PATH})
ELSE()
ADD_LIBRARY(iron ${IRON_SOURCES})
if (WITH_CELLML)
target_compile_definitions(iron PUBLIC USECELLML)
endif()
target_include_directories(iron PUBLIC ${MPI_C_INCLUDE_PATH} ${MPI_Fortran_INCLUDE_PATH})
target_link_libraries(iron ${LINK_LIBS})
ENDIF()
# Install steps
INSTALL(TARGETS iron
DESTINATION iron
INCLUDES DESTINATION include)
INSTALL(FILES ${HEADER_SOURCE_INC} DESTINATION include)
FILE(GLOB OPENCMISS_MODS ${CMAKE_BINARY_DIR}/*.mod)
INSTALL(FILES ${OPENCMISS_MODS} DESTINATION include)