forked from soleil-ica/Processlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
247 lines (226 loc) · 9.81 KB
/
CMakeLists.txt
File metadata and controls
247 lines (226 loc) · 9.81 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
###########################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2017
# European Synchrotron Radiation Facility
# CS40220 38043 Grenoble Cedex 9
# FRANCE
#
# Contact: lima@esrf.fr
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
# README -- README --README -- README --README -- README --README -- README
# To include Processlib as a sub-project within another project (e.g LIMA)
# set PROCESSLIB_EXTERNALLY_CONFIGURED to ON and supply value for following variables...
#
# - PROCESSLIB_EXTERNALLY_ENABLE_PYTHON:
# Set this "ON" to create binding codes for python
#
# For installation purpose one can set the following variables...
#
# - CMAKE_INSTALL_PREFIX:
# Set this to a installation directory, default for UNIX is /usr/local
#
# - PYTHON_SITE_PACKAGES_DIR:
# Set this to an alternative python site-packages directory,
# default is the python installation directory, for UNIX it
# can be /usr/lib/python2.7/dist-packages/ .
#--------------------------------------------------------------------------------
# Enable/Disable python binding but depending if project is included as a
# sub-project, see above for further instructions
#--------------------------------------------------------------------------------
if (NOT PROCESSLIB_EXTERNALLY_CONFIGURED)
option(PROCESSLIB_ENABLE_PYTHON "compile python binding code?" OFF)
endif()
if (PROCESSLIB_EXTERNALLY_CONFIGURED)
if (PROCESSLIB_EXTERNALLY_ENABLE_PYTHON)
set(PROCESSLIB_ENABLE_PYTHON ON)
else()
set(PROCESSLIB_ENABLE_PYTHON OFF)
endif()
endif()
#--------------------------------------------------------------------------------
# cmake/ directory contains tools
#--------------------------------------------------------------------------------
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(ProcesslibTools)
#--------------------------------------------------------------------------------
# If Processlib is used as a standalone library set here everything required
#--------------------------------------------------------------------------------
if (NOT PROCESSLIB_EXTERNALLY_CONFIGURED)
cmake_minimum_required(VERSION 2.8)
project (processlib)
#--------------------------------------------------------------------------------
# Threads lib required
#--------------------------------------------------------------------------------
find_package(Threads REQUIRED)
#--------------------------------------------------------------------------------
# Enable python binding code compilation using sip generator
#--------------------------------------------------------------------------------
if(PROCESSLIB_ENABLE_PYTHON)
find_package(PythonInterp 2.6)
find_package(PythonLibs 2.6)
if(${PYTHONINTERP_FOUND})
# python site-packages folder
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print (get_python_lib())"
OUTPUT_VARIABLE _PYTHON_SITE_PACKAGES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
find_package(SIP)
include(SIPMacros)
set(PYTHON_SITE_PACKAGES_DIR ${_PYTHON_SITE_PACKAGES_DIR} CACHE PATH "where should python modules be installed?")
if(WIN32)
set(NUMPY_INCLUDE_DIR "${_PYTHON_SITE_PACKAGES_DIR}/numpy/core/include" CACHE PATH "Path to NumPy include folder")
set(NUMPY_LIB_DIR "${_PYTHON_SITE_PACKAGES_DIR}/numpy/core/lib" CACHE PATH "Path to NumPy lib folder")
include_directories(${NUMPY_INCLUDE_DIR})
link_directories(${NUMPY_LIB_DIR})
endif()
if(!${SIP_FOUND})
message(FATAL_ERROR "sip executable not found, cannot build python extensions")
endif()
if(WIN32)
set(SIP_TAGS WIN32_PLATFORM)
elseif(UNIX)
set(SIP_TAGS POSIX_PLATFORM)
endif(WIN32)
set(SIP_EXTRA_OPTIONS -e -g)
endif()
endif(NOT PROCESSLIB_EXTERNALLY_CONFIGURED)
if (WIN32)
# GSL is available from binary packages at https://code.google.com/archive/p/oscats/downloads for win64
# and at gnuwin32 site for win32 compiled with msvc2008
# for msvc2015 binary packages are from https://www.bruot.org/hp/libraries/
# but now safe from http://ftp.esrf.fr/dist/bliss/lima/GSL-windows.zip
if (${CMAKE_GENERATOR} MATCHES "(2008|2010|2013)")
if (${CMAKE_GENERATOR} MATCHES "Win64$")
set(GSL_VERSION "gsl-win64-msvc2008")
else()
set(GSL_VERSION "gsl-win32-msvc2008")
# GSL static libs are not SAFESH so force the option in case cmake enable it by default (Visual Studio 12 2013)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
endif()
elseif (${CMAKE_GENERATOR} MATCHES "2015|2017")
if (${CMAKE_GENERATOR} MATCHES "Win64$")
set(GSL_VERSION "gsl-win64-msvc2015")
else()
set(GSL_VERSION "gsl-win32-msvc2015")
endif()
else()
message(FATAL_ERROR "This compiler is not supported: " ${CMAKE_GENERATOR})
endif()
set(LIB_GSL_INCLUDE_DIR "C:/Program Files/GSL-windows/${GSL_VERSION}/include" CACHE PATH "Path to GSL includes")
set(LIB_GSL_DIR "C:/Program Files/GSL-windows/${GSL_VERSION}/lib" CACHE PATH "Path to GSL lib folder")
include_directories(${LIB_GSL_INCLUDE_DIR})
link_directories(${LIB_GSL_DIR})
message("LIB_GSL_DIR = " ${LIB_GSL_DIR})
else()
find_path(LIB_GSL_INCLUDE_DIR gsl/gsl_errno.h)
endif()
set(processlib_srcs
core/src/GslErrorMgr.cpp
core/src/PoolThreadMgr.cpp
core/src/TaskEventCallback.cpp
core/src/LinkTask.cpp
core/src/SinkTask.cpp
core/src/TaskMgr.cpp
core/src/HeaderContainer.cpp
tasks/src/BackgroundSubstraction.cpp
tasks/src/FlatfieldCorrection.cpp
tasks/src/RoiCounter.cpp
tasks/src/Binning.cpp
tasks/src/Flip.cpp
tasks/src/SoftRoi.cpp
tasks/src/Bpm.cpp
tasks/src/Mask.cpp
tasks/src/Roi2Spectrum.cpp
tasks/src/Rotation.cpp
tasks/src/PeakFinder.cpp
)
if(WIN32)
list(APPEND processlib_srcs core/src/WindowSpecific/pthread_cancelling.cpp
core/src/WindowSpecific/pthread_cond.cpp
core/src/WindowSpecific/pthread_key.cpp
core/src/WindowSpecific/pthread_mutex.cpp
core/src/WindowSpecific/pthread_rwlock.cpp
core/src/WindowSpecific/pthread_thread.cpp
core/src/WindowSpecific/stdio_compat.cpp
core/src/WindowSpecific/time_compat.cpp
)
endif()
#--------------------------------------------------------------------------------
# Add the library processlib definition
#--------------------------------------------------------------------------------
file(STRINGS "VERSION" processlib_ver)
add_library(processlib SHARED
${processlib_srcs})
processlib_set_library_soversion(processlib "VERSION")
if(WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/core/include/WindowSpecific")
endif()
target_include_directories(processlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/core/include")
target_include_directories(processlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/tasks/include")
if(THREADS_HAVE_PTHREAD_ARG)
target_compile_options(PUBLIC processlib "-pthread")
endif()
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(processlib "${CMAKE_THREAD_LIBS_INIT}")
endif()
if(WIN32)
find_library(LIB_GSL libgsl ${LIB_GSL_DIR})
find_library(LIB_GSLCBLAS libgslcblas ${LIB_GSL_DIR})
else()
find_library(LIB_GSL gsl)
find_library(LIB_GSLCBLAS gslcblas)
endif()
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(GSL DEFAULT_MSG LIB_GSL LIB_GSL_INCLUDE_DIR)
if(${GSL_FOUND})
target_link_libraries(processlib ${LIB_GSL} ${LIB_GSLCBLAS})
target_include_directories(processlib PUBLIC ${LIB_GSL_INCLUDE_DIR})
endif()
if(WIN32)
target_compile_definitions(processlib PRIVATE LIBPROCESSLIB_EXPORTS)
set_target_properties(processlib PROPERTIES PREFIX "lib")
endif()
if(WIN32)
install(TARGETS processlib
DESTINATION lib)
else()
install(TARGETS processlib
LIBRARY DESTINATION lib)
endif()
# did not know why logilab disabled bpm for win64
#if(CMAKE_SYSTEM_NAME EQUAL "Windows")
# if(CMAKE_SIZEOF_VOID_P EQUAL 8)
# set(SIP_DISABLE_FEATURES "BPM_SUPPORT")
# endif()
#endif()
#--------------------------------------------------------------------------------
# SIP generates binding code for python
#--------------------------------------------------------------------------------
if(PROCESSLIB_ENABLE_PYTHON)
if(SIP_VERSION_STR VERSION_LESS "4.12")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sip/processlib_before_4_12.sip sip/processlib.sip)
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sip/processlib.sip sip/processlib.sip)
endif()
set(SIP_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/tasks/sip")
add_sip_python_module(processlib "${CMAKE_CURRENT_BINARY_DIR}/sip/processlib.sip")
target_include_directories(python_module_processlib PRIVATE ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/sip)
target_link_libraries(python_module_processlib processlib)
endif()