This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
ilastik.cmake
157 lines (132 loc) · 6.71 KB
/
ilastik.cmake
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
#
# Install ilastik headless (non-GUI) from source
#
# Ilastik is composed of 3 git repos, 2 of which are necessary for headless mode.
#
# lazyflow
# ilastik
# volumina (for gui builds)
#
# Also, you must build lazyflow/lazyflow/drtile with CMake to produce drtile.so shared library.
# This is done in the CONFIGURE_COMMAND below and the shared library is saved in the
# drtile source directory.
if (NOT ilastik_NAME)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
include (ExternalProject)
include (ExternalSource)
include (BuildSupport)
include (TemplateSupport)
include (vigra)
include (h5py)
include (psutil)
include (blist)
include (greenlet)
include (cylemon)
include (yapsy)
include (pgmlink)
include (scikit-learn)
include (nose)
include (faulthandler)
include (jsonschema) # Required for the dvid extension.
include (opengm)
include (futures)
include (iiboost)
# select the desired ilastik commit
set(DEFAULT_ILASTIK_VERSION 779685cc1e6b78b633fcd1737c5eae78e8b72ddb) # 2014-09-18
IF(NOT DEFINED ILASTIK_VERSION)
SET(ILASTIK_VERSION "${DEFAULT_ILASTIK_VERSION}")
ENDIF()
SET(ILASTIK_VERSION ${ILASTIK_VERSION}
CACHE STRING "Specify ilastik branch/tag/commit to be used (default: ${DEFAULT_ILASTIK_VERSION})")
external_git_repo (ilastik
${ILASTIK_VERSION}
https://github.com/ilastik/ilastik-meta
ilastik)
set(lazyflow_SRC_DIR "${ilastik_SRC_DIR}/lazyflow")
if("${ILASTIK_VERSION}" STREQUAL "master")
# If the user's build is old, he might be linked to the janelia-flyem remote
# Force the remote to update from ilastik/ilastik-meta by removing origin and adding it again
set(ILASTIK_UPDATE_COMMAND git remote rm origin && git remote add origin https://github.com/ilastik/ilastik-meta &&
git fetch origin &&
git checkout master && git pull origin master && git submodule update --init --recursive &&
cd lazyflow && git checkout master && git pull origin master && git submodule update && cd .. &&
cd volumina && git checkout master && git pull origin master && cd .. &&
cd ilastik && git checkout master && git pull origin master && cd ..)
else()
# If the user's build is old, he might be linked to the janelia-flyem remote
# Force the remote to update from ilastik/ilastik-meta by removing origin and adding it again
set(ILASTIK_UPDATE_COMMAND git remote rm origin && git remote add origin https://github.com/ilastik/ilastik-meta &&
git fetch origin && git checkout ${ILASTIK_VERSION} && git submodule update --init --recursive)
endif()
message ("Installing ${ilastik_NAME}/${ILASTIK_VERSION} into FlyEM build area: ${BUILDEM_DIR} ...")
set (ilastik_dependencies ${vigra_NAME} ${h5py_NAME} ${psutil_NAME} ${nose_NAME} ${futures_NAME}
${blist_NAME} ${greenlet_NAME} ${yapsy_NAME} ${faulthandler_NAME}
${cylemon_NAME} ${scikit-learn_NAME} ${jsonschema_NAME} ${opengm_NAME} )
set(ILASTIK_BUILD_IIBOOST TRUE CACHE BOOL "Build support for the IIBoost synapse detection ilastik workflow.")
if (ILASTIK_BUILD_IIBOOST)
set(ilastik_dependencies ${ilastik_dependencies} ${iiboost_NAME})
endif()
if (${build_pgmlink})
# Tracking depends on pgmlink, which depends on CPLEX.
# Most people don't have CPLEX installed on their system.
message ("Building ilastik with CPLEX located in ${CPLEX_ROOT_DIR}")
set (ilastik_dependencies ${ilastik_dependencies} ${pgmlink_NAME})
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# On Mac OS X, building drtile requires explicitly setting several cmake cache variables
ExternalProject_Add(${ilastik_NAME}
DEPENDS ${ilastik_dependencies}
SOURCE_DIR ${ilastik_SRC_DIR}
GIT_REPOSITORY ${ilastik_URL}
GIT_TAG ${ilastik_TAG}
UPDATE_COMMAND ${ILASTIK_UPDATE_COMMAND}
PATCH_COMMAND ""
CONFIGURE_COMMAND ${BUILDEM_ENV_STRING} ${CMAKE_COMMAND}
-DLIBRARY_OUTPUT_PATH=${lazyflow_SRC_DIR}/lazyflow/drtile
-DCMAKE_PREFIX_PATH=${BUILDEM_DIR}
-DPYTHON_EXECUTABLE=${PYTHON_EXE}
-DPYTHON_INCLUDE_DIR=${PYTHON_PREFIX}/include/python2.7
"-DPYTHON_LIBRARY=${PYTHON_PREFIX}/lib/libpython2.7.${BUILDEM_PLATFORM_DYLIB_EXTENSION}"
-DPYTHON_NUMPY_INCLUDE_DIR=${PYTHON_PREFIX}/lib/python2.7/site-packages/numpy/core/include
-DVIGRA_NUMPY_CORE_LIBRARY=${PYTHON_PREFIX}/lib/python2.7/site-packages/vigra/vigranumpycore.so
${lazyflow_SRC_DIR}/lazyflow/drtile
BUILD_COMMAND ${BUILDEM_ENV_STRING} $(MAKE)
TEST_COMMAND ${BUILDEM_DIR}/bin/ilastik_headless_test
INSTALL_COMMAND ""
)
else()
# On Linux, building drtile requires less explicit configuration
# The explicit configuration above would probably work, but let's keep this simple...
ExternalProject_Add(${ilastik_NAME}
DEPENDS ${ilastik_dependencies}
SOURCE_DIR ${ilastik_SRC_DIR}
GIT_REPOSITORY ${ilastik_URL}
GIT_TAG ${ilastik_TAG}
UPDATE_COMMAND ${ILASTIK_UPDATE_COMMAND}
PATCH_COMMAND ""
CONFIGURE_COMMAND ${BUILDEM_ENV_STRING} ${CMAKE_COMMAND}
-DLIBRARY_OUTPUT_PATH=${lazyflow_SRC_DIR}/lazyflow/drtile
# -DCMAKE_PREFIX_PATH=${BUILDEM_DIR}
# -DVIGRA_ROOT=${BUILDEM_DIR}
${lazyflow_SRC_DIR}/lazyflow/drtile
BUILD_COMMAND ${BUILDEM_ENV_STRING} $(MAKE)
TEST_COMMAND ${BUILDEM_DIR}/bin/ilastik_headless_test
INSTALL_COMMAND ""
)
endif()
file(RELATIVE_PATH ILASTIK_DIR_RELATIVE ${BUILDEM_DIR} ${ilastik_SRC_DIR})
file(RELATIVE_PATH PYTHON_PREFIX_RELATIVE ${BUILDEM_DIR} ${PYTHON_PREFIX})
# Add environment setting script
set(SETENV_ILASTIK setenv_ilastik_gui)
configure_file(${TEMPLATE_DIR}/${SETENV_ILASTIK}.in ${BUILDEM_DIR}/bin/${SETENV_ILASTIK}.sh @ONLY)
# Add headless launch script
set(LAUNCH_ILASTIK "ilastik/ilastik.py --headless")
configure_file(${TEMPLATE_DIR}/ilastik_script.template ${BUILDEM_DIR}/bin/ilastik_headless @ONLY)
# Add headless test script
set(LAUNCH_ILASTIK ilastik/tests/test_applets/pixelClassification/testPixelClassificationHeadless.py)
configure_file(${TEMPLATE_DIR}/ilastik_script.template ${BUILDEM_DIR}/bin/ilastik_headless_test @ONLY)
# Add headless launch script for cluster processing
set(LAUNCH_ILASTIK ilastik/ilastik/workflows/pixelClassification/pixelClassificationClusterized.py)
configure_file(${TEMPLATE_DIR}/ilastik_script.template ${BUILDEM_DIR}/bin/ilastik_clusterized @ONLY)
set_target_properties(${ilastik_NAME} PROPERTIES EXCLUDE_FROM_ALL ON)
endif (NOT ilastik_NAME)