-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
113 lines (91 loc) · 4.46 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
cmake_minimum_required(VERSION 2.7)
set(MODELS_NAME cest)
set(MODELS_SRC fwdmodel_cest.cc spline_interpolator.cc)
add_library(fabber_models_${MODELS_NAME} SHARED ${MODELS_SRC} ${MODELS_NAME}_models.cc)
add_executable(fabber_${MODELS_NAME} ${MODELS_SRC} fabber_client.cc)
if(APPLE)
# Uncomment to force use of libstdc++ on Mac as FSL uses this and we cannot link otherwise
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libstdc++")
# Get rid of CMake warning
set(CMAKE_MACOSX_RPATH ON)
endif(APPLE)
find_path(FABBER_INCLUDE_DIR fabber_core/fwdmodel.h
HINTS $ENV{FSLDEVDIR}/include $ENV{FSLDIR}/include .. REQUIRED)
find_path(NEWMAT_INCLUDE_DIR newmat.h
HINTS $ENV{FSLDIR}/extras/include/newmat REQUIRED)
find_path(FSL_INCLUDE_DIR newimage/newimage.h
HINTS $ENV{FSLDIR}/include REQUIRED)
find_path(FSL_EXT_INCLUDE_DIR libprob/libprob.h
HINTS $ENV{FSLDIR}/extras/include REQUIRED)
find_path(BOOST_INCLUDE_DIR boost/shared_ptr.hpp
HINTS $ENV{FSLDIR}/extras/include/boost $ENV{FSLDIR}/extras/include/ REQUIRED)
find_library(PROB_LIBRARY NAMES prob libprob
HINTS $ENV{FSLDIR}/extras/lib REQUIRED )
Message("-- FSL headers in ${FSL_INCLUDE_DIR} ${NEWMAT_INCLUDE_DIR} ${FSL_EXT_INCLUDE_DIR} ${BOOST_INCLUDE_DIR}")
Message("-- Fabber headers in ${FABBER_INCLUDE_DIR}/fabber_core")
find_library(FABBER_LIBRARY NAMES fabbercore libfabbercore
HINTS $ENV{FSLDEVDIR}/lib $ENV{FSLDIR}/lib ../fabber_core/Release ../fabber_core/Debug REQUIRED )
find_library(FABBER_EXEC_LIBRARY NAMES fabberexec libfabberexec
HINTS $ENV{FSLDEVDIR}/lib $ENV{FSLDIR}/lib ../fabber_core/Release ../fabber_core/Debug REQUIRED )
find_library(NEWMAT_LIBRARY NAMES newmat libnewmat
HINTS $ENV{FSLDIR}/extras/lib REQUIRED )
find_library(MISCMATHS_LIBRARY NAMES miscmaths libmiscmaths
HINTS $ENV{FSLDIR}/lib REQUIRED )
find_library(NEWIMAGE_LIBRARY NAMES newimage libnewimage
HINTS $ENV{FSLDIR}/lib REQUIRED )
find_library(FSLIO_LIBRARY NAMES fslio libfslio
HINTS $ENV{FSLDIR}/lib REQUIRED )
find_library(NIFTIIO_LIBRARY NAMES niftiio libniftiio
HINTS $ENV{FSLDIR}/lib REQUIRED )
find_library(ZNZ_LIBRARY NAMES znz libznz
HINTS $ENV{FSLDIR}/lib REQUIRED )
find_library(PROB_LIBRARY NAMES prob libprob
HINTS $ENV{FSLDIR}/extras/lib REQUIRED )
if(WIN32)
# Only use FSL zlib on windows as other versions are unlikely to be
# binary-compatibly
find_library(Z_LIBRARY NAMES z libz zlib zlibd
HINTS $ENV{FSLDIR}/lib REQUIRED NO_DEFAULT_PATH)
else(WIN32)
find_library(Z_LIBRARY NAMES z libz zlib zlibd
HINTS $ENV{FSLDIR}/lib REQUIRED)
endif(WIN32)
set(LIBS ${FABBER_LIBRARY} ${FABBER_EXEC_LIBRARY} ${NEWIMAGE_LIBRARY} ${FSLIO_LIBRARY} ${MISCMATHS_LIBRARY} ${NIFTIIO_LIBRARY} ${ZNZ_LIBRARY} ${NEWMAT_LIBRARY} ${PROB_LIBRARY} ${Z_LIBRARY})
if (UNIX)
set(LIBS ${LIBS} dl)
endif(UNIX)
Message("-- Using Fabber libraries: ${FABBER_LIBRARY} ${FABBER_EXEC_LIBRARY}")
Message("-- Using libznz: ${ZNZ_LIBRARY}")
Message("-- Using miscmaths: ${MISCMATHS_LIBRARY}")
Message("-- Using fslio: ${FSLIO_LIBRARY}")
Message("-- Using newimage: ${NEWIMAGE_LIBRARY}")
Message("-- Using niftiio: ${NIFTIIO_LIBRARY}")
Message("-- Using newmat: ${NEWMAT_LIBRARY} ${NEWMAT_INCLUDE_DIR}")
Message("-- Using newimage: ${NEWIMAGE_LIBRARY}")
Message("-- Using prob: ${PROB_LIBRARY}")
Message("-- Using zlib: ${Z_LIBRARY}")
target_link_libraries(fabber_models_${MODELS_NAME} ${LIBS})
target_link_libraries(fabber_${MODELS_NAME} ${LIBS})
include_directories(SYSTEM ${FABBER_INCLUDE_DIR} ${NEWMAT_INCLUDE_DIR} ${FSL_INCLUDE_DIR} ${FSL_EXT_INCLUDE_DIR} ${FSL_EXT_INCLUDE_DIR}/libprob ${BOOST_INCLUDE_DIR})
# Extract GIT revision for versioning
execute_process(COMMAND
git describe --dirty
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_SHA1
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND
git log -1 --format=%ad --date=local
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE GIT_DATE
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT GIT_SHA1)
set(GIT_SHA1 unknown)
endif(NOT GIT_SHA1)
if (NOT GIT_DATE)
set(GIT_DATE unknown)
endif(NOT GIT_DATE)
add_definitions(-DGIT_SHA1="${GIT_SHA1}" -DGIT_DATE="${GIT_DATE}")
INSTALL(TARGETS fabber_${MODELS_NAME} fabber_models_${MODELS_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)