CMakeLists.txt 6.51 KB
Newer Older
1
2
3
4
5
6
7
###########################################################################
# This file is part of LImA, a Library for Image Acquisition
#
#  Copyright (C) : 2009-2017
#  European Synchrotron Radiation Facility
#  BP 220, Grenoble 38043
#  FRANCE
8
#
9
#  Contact: lima@esrf.fr
10
#
11
12
13
14
#  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.
15
#
16
17
18
19
#  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.
20
#
21
22
23
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
24
25
26
27
28

cmake_minimum_required(VERSION 3.1)

project(slsdetector)

29
set(NAME slsdetector)
30

31
32
33
34
# Include additional modules that are used inconditionnaly
include(GNUInstallDirs)
include(GenerateExportHeader)

35
36
37
38
39
40
# If conda build, always set lib dir to 'lib'
if(NOT LIMA_ENABLE_NUMA)
  message(FATAL_ERROR
          "slsdetector requires NUMA control in Lima: set LIMA_ENABLE_NUMA ON")
endif()

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
# If conda build, always set lib dir to 'lib'
if($ENV{CONDA_BUILD})
  set(CMAKE_INSTALL_LIBDIR "lib")
endif()

# Set lower / upper case project names
string(TOUPPER "${PROJECT_NAME}" PROJECT_NAME_UPPER)
string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)

# Set targets export name (used by lima and dependencies)
set(TARGETS_EXPORT_NAME "${PROJECT_NAME_LOWER}-targets")
#set(namespace "${PROJECT_NAME}::")

# Check if project is being used directly or via add_subdirectory
set(CAMERA_MASTER_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
  set(CAMERA_MASTER_PROJECT ON)
endif()

if (CAMERA_MASTER_PROJECT)
  find_package(Lima REQUIRED)
endif()

# CMake additional macros
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${LIMA_CMAKE_INCLUDE_DIRS} ${CMAKE_MODULE_PATH})

# Set version
include(project_version)

# Enable python binding code compilation using sip generator
71
72
73
if (CAMERA_MASTER_PROJECT)
  option(LIMA_ENABLE_PYTHON "compile python binding code?" OFF)
endif()
74

75
if (LIMA_ENABLE_PYTHON)
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
  # Find python interpreter and libs
  find_package(PythonInterp)
  find_package(PythonLibs)
  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()

  set(PYTHON_SITE_PACKAGES_DIR ${_PYTHON_SITE_PACKAGES_DIR} CACHE PATH "where should python modules be installed?")

  find_package(SIP REQUIRED)
  include(SIPMacros)
  if(WIN32)
    set(SIP_TAGS WIN32_PLATFORM)
  elseif(UNIX)
    set(SIP_TAGS POSIX_PLATFORM)
  endif(WIN32)
  set(SIP_EXTRA_OPTIONS -e -g)

  find_package(NumPy REQUIRED)
endif()

# Additional packages
101
102
find_package(Numa REQUIRED)

103
104
# slsDetectorPackage
set(SLS_DETECTOR_DIR ${CMAKE_CURRENT_SOURCE_DIR}/slsDetectorPackage)
105
106
set(SLS_DETECTOR_SW ${SLS_DETECTOR_DIR}/slsDetectorSoftware)
set(SLS_DETECTOR_RECV ${SLS_DETECTOR_DIR}/slsReceiverSoftware)
107

108
109
option (USE_TEXTCLIENT "Text Client" ON)
option (USE_RECEIVER "Receiver" ON)
110
option (USE_GUI "GUI" OFF)
111

112
113
add_subdirectory(${SLS_DETECTOR_DIR})

114
115
116
117
file(GLOB_RECURSE SLSDETECTOR_INCS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")

add_library(slsdetector SHARED
  src/SlsDetectorDefs.cpp
118
  src/SlsDetectorFrameMap.cpp
119
120
  src/SlsDetectorArgs.cpp
  src/SlsDetectorCPUAffinity.cpp
121
  src/SlsDetectorBebTools.cpp
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  src/SlsDetectorModel.cpp
  src/SlsDetectorReceiver.cpp
  src/SlsDetectorCamera.cpp
  src/SlsDetectorEiger.cpp
  src/SlsDetectorInterface.cpp
  ${SLSDETECTOR_INCS}
)

# Generate export macros
generate_export_header(slsdetector)

# Set version and output name
set_target_properties(slsdetector PROPERTIES
  OUTPUT_NAME "lima${PROJECT_NAME_LOWER}"
Samuel Debionne's avatar
Samuel Debionne committed
136
  VERSION "${PROJECT_VERSION}"
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
  SOVERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")

# Add dependencies
target_include_directories(slsdetector
    PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
    PUBLIC "$<BUILD_INTERFACE:${SLS_DETECTOR_SW}/include>"
    PUBLIC "$<BUILD_INTERFACE:${SLS_DETECTOR_SW}/commonFiles>"
    PUBLIC "$<BUILD_INTERFACE:${SLS_DETECTOR_SW}/slsDetector>"
    PUBLIC "$<BUILD_INTERFACE:${SLS_DETECTOR_SW}/multiSlsDetector>"
    PUBLIC "$<BUILD_INTERFACE:${SLS_DETECTOR_SW}/slsDetectorServer>"
    PUBLIC "$<BUILD_INTERFACE:${SLS_DETECTOR_SW}/slsDetectorAnalysis>"
    PUBLIC "$<BUILD_INTERFACE:${SLS_DETECTOR_SW}/slsReceiverInterface>"
    PUBLIC "$<BUILD_INTERFACE:${SLS_DETECTOR_RECV}/include>"
    PUBLIC "$<BUILD_INTERFACE:${NUMA_INCLUDE_DIR}>"
    PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"           # For export header
    PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
154
155

message("NUMA_LIBRARY=" ${NUMA_LIBRARY})
156

157
158
159
160
161
target_link_libraries(slsdetector
  PUBLIC limacore
  PUBLIC slsDetectorShared slsReceiverShared zmq
  PUBLIC ${NUMA_LIBRARY}
)
162

163
# Binding code for python
164
if(LIMA_ENABLE_PYTHON)
165
166
167
  include(LimaTools)
  limatools_run_sip_for_camera(slsdetector)
endif()
168

169
170
171
172
173
174
# Generate and install package config file and version
if(CAMERA_MASTER_PROJECT)
  set (PROJECT_LIBRARIES slsdetector)
  set(SIP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/sip/lima)
  set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/lima)
  include(package_config)
175
176
endif()

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
## Installation

install(
  TARGETS slsdetector
  EXPORT "${TARGETS_EXPORT_NAME}"
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}   # import library
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}   # .so files are libraries
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}   # .dll files are binaries
  INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}  # this does not actually install anything (but used by downstream projects)
)

install(
  DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
  COMPONENT devel
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  FILES_MATCHING PATTERN "*.h"
)

install(
  FILES
    ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/project_version.h
    ${PROJECT_BINARY_DIR}/slsdetector_export.h
  COMPONENT devel
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

203
if(LIMA_ENABLE_PYTHON)
204
205
206
207
208
  install(
    DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/
    DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/SlsDetector"
  )
endif()
209

210
211
212
## Tests
if(CAMERA_ENABLE_TESTS)
    enable_testing()
213
    add_subdirectory(test)
214
endif()