CMakeLists.txt 5.29 KB
Newer Older
1
###########################################################################
Aitor Henry's avatar
Aitor Henry committed
2
3
# This file is part of LImA, a Library for Image Acquisition
#
Laurent Claustre's avatar
Laurent Claustre committed
4
#  Copyright (C) : 2009-2019
5
#  European Synchrotron Radiation Facility
6
#  CS40220 38043 Grenoble Cedex 9
7
#  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
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, see <http://www.gnu.org/licenses/>.
Aitor Henry's avatar
Aitor Henry committed
23
############################################################################
24
25
26
27
28
29
30
31

cmake_minimum_required(VERSION 3.1)

project(eiger)

# Include additional modules that are used inconditionnaly
include(GNUInstallDirs)
include(GenerateExportHeader)
Aitor Henry's avatar
Aitor Henry committed
32

33
34
35
36
37
38
39
40
# 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)
Aitor Henry's avatar
Aitor Henry committed
41

42
43
44
45
46
47
48
49
# 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)
50
endif()
51
52

if (CAMERA_MASTER_PROJECT)
Laurent Claustre's avatar
Laurent Claustre committed
53
  find_package(Lima REQUIRED COMPONENTS devel tools)
54
endif()
55
56

# CMake additional macros
Samuel Debionne's avatar
Samuel Debionne committed
57
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${LIMA_CMAKE_INCLUDE_DIRS} ${CMAKE_MODULE_PATH})
58

Laurent Claustre's avatar
Laurent Claustre committed
59
60
include(LimaTools)

61
62
63
64
# Set version
include(project_version)

# Enable python binding code compilation using sip generator
Samuel Debionne's avatar
Samuel Debionne committed
65
66
if (CAMERA_MASTER_PROJECT)
  option(LIMA_ENABLE_PYTHON "compile python binding code?" OFF)
Laurent Claustre's avatar
Laurent Claustre committed
67
  option(LIMA_ENABLE_PYTANGO_SERVER "install python tango server?" OFF)
Samuel Debionne's avatar
Samuel Debionne committed
68

Laurent Claustre's avatar
Laurent Claustre committed
69
70
  if (LIMA_ENABLE_PYTHON)
    limatools_find_python_and_sip()
71
  endif()
72
endif()
73

Laurent Claustre's avatar
Laurent Claustre committed
74

75
76
77
78
79
80
81
82
83
84
85
86
87
88
find_package(CURL REQUIRED)
find_package(LZ4 REQUIRED)
find_package(ZMQ REQUIRED)
find_package(JsonCpp REQUIRED)

file(GLOB_RECURSE EIGER_INCS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")

set(EIGER_SDK_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/sdk" CACHE PATH "location of eiger sdk")

add_library(eiger SHARED
  src/EigerCamera.cpp
  src/EigerInterface.cpp
  src/EigerDetInfoCtrlObj.cpp
  src/EigerSyncCtrlObj.cpp
89
  src/EigerEventCtrlObj.cpp
90
91
92
  src/EigerDecompress.cpp
  src/EigerSavingCtrlObj.cpp
  src/EigerStream.cpp
93
  src/EigerStreamInfo.cpp
94
95
96
97
98
99
100
101
102
103
104
  sdk/linux/EigerAPI/src/CurlLoop.cpp
  sdk/linux/EigerAPI/src/Requests.cpp
  ${EIGER_INCS}
)

# Generate export macros
generate_export_header(eiger)

# Set version and output name
set_target_properties(eiger PROPERTIES
  OUTPUT_NAME "lima${PROJECT_NAME_LOWER}"
Samuel Debionne's avatar
Samuel Debionne committed
105
  VERSION "${PROJECT_VERSION}"
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  SOVERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")

# Add dependencies
target_include_directories(eiger
  PUBLIC "$<BUILD_INTERFACE:${EIGER_SDK_ROOT}/linux/EigerAPI/include>"
  PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
  PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/tools/src>"
  PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"           # For export header
  PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

target_link_libraries(eiger PUBLIC
  ${CURL_LIBRARIES}
  ${LZ4_LIBRARIES}
  ${ZMQ_LIBRARIES}
  JsonCpp::JsonCpp
  limacore
123
  h5bshuf_objects
124
125
126
127
128
129
130
131
132
133
)

if(WIN32)
  target_compile_definitions(eiger
    PRIVATE eiger_EXPORTS
    PUBLIC NOMINMAX)
  set_target_properties(eiger PROPERTIES PREFIX "lib" IMPORT_PREFIX "lib")
endif()

# Binding code for python
Samuel Debionne's avatar
Samuel Debionne committed
134
if(LIMA_ENABLE_PYTHON)
135
136
137
138
139
140
141
142
143
  limatools_run_sip_for_camera(eiger)
endif()

# Generate and install package config file and version
if(CAMERA_MASTER_PROJECT)
  set(PROJECT_LIBRARIES eiger)
  set(SIP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/sip/lima)
  set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/lima)
  include(package_config)
144
endif()
Aitor Henry's avatar
Aitor Henry committed
145

146
## Installation
Aitor Henry's avatar
Aitor Henry committed
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
install(
  TARGETS eiger
  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}/eiger_export.h
  COMPONENT devel
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

Samuel Debionne's avatar
Samuel Debionne committed
172
if(LIMA_ENABLE_PYTHON)
173
174
175
  install(
    DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/
    DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/Eiger"
Laurent Claustre's avatar
Laurent Claustre committed
176
177
178
179
    )
  if (LIMA_ENABLE_PYTANGO_SERVER)
    add_subdirectory(tango)
  endif()
180
endif()
Aitor Henry's avatar
Aitor Henry committed
181

182
183
184
185
## Tests
if(CAMERA_ENABLE_TESTS)
  enable_testing()
  #add_subdirectory(test)
186
endif()