-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
186 lines (151 loc) · 6.67 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
cmake_minimum_required (VERSION 2.8)
project (jemris)
set (jemris_VERSION_MAJOR 2)
set (jemris_VERSION_MINOR 9)
set (jemris_VERSION_PATCH 1)
set (jemris_VERSION "${jemris_VERSION_MAJOR}.${jemris_VERSION_MINOR}.${jemris_VERSION_PATCH}")
set(CMAKE_BUILD_TYPE "Release")
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
macro(set_config_option VARNAME STRING)
set(${VARNAME} TRUE)
list(APPEND CONFIG_OPTIONS ${STRING})
message(STATUS "Found " ${STRING})
endmacro(set_config_option)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
include(ConfigureChecks.cmake)
add_definitions(-DHAVE_CONFIG_H)
# OS type -----------------------------------------------------------------------
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS TRUE)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
endif()
# Architecture ------------------------------------------------------------------
# include (VcMacros) DB: not needed, right?
include (OptimizeForArchitecture)
#find_package (OpenMP)
#if(OPENMP_FOUND)
#message("-- Found OpenMP")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
#endif()
# C++ flags ---------------------------------------------------------------------
# THis should be highly discouraged as it directly sets the compiler flags - this should be handled by cmake to allow
# proper RELEASE, DEBUG, ... builds
set(CMAKE_CXX_COMPILER "mpicxx")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi -DTIXML_USE_STL -fPIC -O3")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTIXML_USE_STL -O3 -Itr1 -std=c++0x -stdlib=libc++")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DTIXML_USE_STL /EHsc /Ox
/nologo /MT /wd4267 /wd4244 /wd4190 /wd4996 /LD /MD /DEXP_STL")
set (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:LIBCMT")
endif()
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
enable_testing()
include (VcMacros)
include (OptimizeForArchitecture)
check_type_size("void*" SIZEOF_VOID_P)
if(SIZEOF_VOID_P EQUAL 8)
set_config_option(HAVE_64BIT_SIZE_T "Have64BitSizeT")
endif(SIZEOF_VOID_P EQUAL 8)
find_package(Boost)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
set (HAVE_BOOST ON CACHE BOOL "Found boost")
endif()
find_package(Xerces 1.3.0 REQUIRED)
include_directories (${Xerces_INCLUDE_DIRS})
find_package(GiNaC REQUIRED)
include_directories (${GINAC_INCLUDE_DIRS})
# Hmm does not support components...
find_package(Sundials REQUIRED)
include_directories (${SUNDIALS_INCLUDE_DIR})
# Handle Nvector stuff... here we need to deal with the actual version
if (SUNDIALS_FOUND)
add_definitions(-DHAVE_CVODE_CVODE_H)
add_definitions(-DHAVE_NVECTOR_NVECTOR_SERIAL_H)
add_definitions(-DHAVE_CVODE_CVODE_DIAG_H)
endif(SUNDIALS_FOUND)
find_package(MPI)
if(MPI_C_FOUND)
include_directories (${MPI_INCLUDE_PATH})
set (HAVE_MPI_THREADS ON CACHE BOOL "Found MPI with threads")
elseif(MPI_C_FOUND)
set(MPIRUN "MPIRUN-UNAVAILABLE")
endif()
find_package(HDF5 COMPONENTS C CXX REQUIRED)
if (NOT DEFINED HDF5_CXX_LIBRARIES)
MESSAGE(STATUS "HDF5 CXX Libraries not set but library present... using alternative! Probably everything is fine!")
LIST(APPEND HDF5_CXX_LIBRARIES ${HDF5_hdf5_cpp_LIBRARY})
LIST(APPEND HDF5_CXX_LIBRARIES ${HDF5_hdf5_LIBRARY})
LIST(APPEND HDF5_CXX_LIBRARIES ${HDF5_z_LIBRARY})
LIST(APPEND HDF5_CXX_LIBRARIES ${HDF5_sz_LIBRARY})
LIST(APPEND HDF5_CXX_LIBRARIES ${HDF5_m_LIBRARY})
LIST(APPEND HDF5_CXX_LIBRARIES ${HDF5_hdf5_hl_LIBRARY})
endif(NOT DEFINED HDF5_CXX_LIBRARIES)
include_directories (${HDF5_INCLUDE_DIR})
# ISMRMRD
find_package(ISMRMRD REQUIRED)
link_directories(${ISMRMRD_LIBRARY_DIRS})
include_directories(${ISMRMRD_INCLUDE_DIRS})
# Docker image
message( NOTICE "pulling docker image for reconstruction server...")
execute_process(COMMAND "docker" "pull" "mavel101/bart-reco-server" RESULT_VARIABLE ret OUTPUT_FILE CMD_OUTPUT)
if(ret EQUAL "1")
message( WARNING "Docker image for reconstruction server cannot be pulled. Docker may not be installed.")
else()
message( NOTICE "Succesfully pulled Docker image.")
endif()
# Client conda environment
message( NOTICE "creating conda environment for reconstruction client.")
configure_file(${CMAKE_SOURCE_DIR}/ismrmrd_client.yml ${CMAKE_CURRENT_BINARY_DIR}/ismrmrd_client.yml)
execute_process(COMMAND "conda" "list" "-n" "ismrmrd_client" RESULT_VARIABLE ret OUTPUT_QUIET ERROR_QUIET)
if(ret EQUAL "1")
execute_process(COMMAND "conda" "env" "create" "-f" "ismrmrd_client.yml" RESULT_VARIABLE ret)
if(ret EQUAL "1")
message( WARNING "Conda environment for reconstruction client cannot be installed. Python may not be installed.")
else()
message( NOTICE "Succesfully installed conda environment.")
endif()
else()
message( NOTICE "Conda environment already installed. Environment will be updated if necessary.")
execute_process(COMMAND "conda" "run" "-n" "ismrmrd_client" "conda" "env" "update" "--file" "ismrmrd_client.yml" RESULT_VARIABLE ret)
endif()
# Is this here really necessary?
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} hdf5.lib hdf5_cpp.lib")
set(ZLIB_LIBRARY "${HDF5_DIR}/../../lib/zlib.lib")
set(ZLIB_INCLUDE_DIR "${HDF5_DIR}/../../include")
set(ZLIB_FOUND "1")
endif()
SET(prefix "${CMAKE_INSTALL_PREFIX}")
configure_file (
"cmake/config.h.in"
"${PROJECT_SOURCE_DIR}/src/config.h"
@ONLY
)
add_subdirectory (src)
add_subdirectory (share)
# Packaging ---------------------------------------------------------------------
# All
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set (CPACK_GENERATOR "TBZ2")
set (CPACK_PACKAGE_VERSION "${jemris_VERSION_MAJOR}.${jemris_VERSION_MINOR}.${jemris_VERSION_PATCH}")
set (CPACK_PACKAGE_NAME "jemris")
set (CPACK_PACKAGE_CONTACT "Tony Stoecker <tony.stoecker@dzne.de>")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "JEMRIS is a general purpose MRI simulator. Visit http://www.jemris.org for more details.")
# DEB
set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set (CPACK_DEBIAN_PACKAGE_DEPENDS "ginac-tools, openmpi-bin, libsundials-cvode2, libxerces-c3.2, libhdf5-cpp-103")
include (CPack)