Commit 11904278 authored by Samuel Debionne's avatar Samuel Debionne

Merge branch '1-cmake-last-flavor-missing' into 'master'

Resolve "cmake last flavor missing"

Closes #1

See merge request !3
parents a9020398 bd0a313a
###########################################################################
# 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/>.
# 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/>.
############################################################################
set(NAME "marccd")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--add-needed")
cmake_minimum_required(VERSION 3.1)
project(marccd)
set(NAME "marccd") # This is used by LimaTools
# Include additional modules that are used inconditionnaly
include(GNUInstallDirs)
include(GenerateExportHeader)
# 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}::")
# Enable C++11 and later
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 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_CURRENT_SOURCE_DIR}/cmake ${LIMA_CMAKE_INCLUDE_DIRS} ${CMAKE_MODULE_PATH})
# Set version
include(project_version)
# Enable python binding code compilation using sip generator
if (CAMERA_MASTER_PROJECT)
option(LIMA_ENABLE_PYTHON "compile python binding code?" OFF)
endif()
if (LIMA_ENABLE_PYTHON)
# 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()
# Find YAT library
find_package(YAT REQUIRED)
file(GLOB_RECURSE MARCCD_INCS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
# Library definition
add_library(marccd SHARED
src/MarccdCamera.cpp src/MarccdInterface.cpp
src/MarccdDetInfoCtrlObj.cpp src/MarccdSyncCtrlObj.cpp
src/MarccdBinCtrlObj.cpp src/MarccdBufferCtrlObj.cpp
src/MarccdRoiCtrlObj.cpp src/MarccdReader.cpp
${MARCCD_INCS}
)
# Generate export macros
generate_export_header(marccd)
# Add dependencies
target_include_directories(marccd
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>" # For export header
PUBLIC "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
set(${NAME}_srcs src/MarccdCamera.cpp src/MarccdInterface.cpp
src/MarccdDetInfoCtrlObj.cpp src/MarccdSyncCtrlObj.cpp
src/MarccdBinCtrlObj.cpp src/MarccdBufferCtrlObj.cpp
src/MarccdRoiCtrlObj.cpp src/MarccdReader.cpp)
# Set version and output name
set_target_properties(marccd PROPERTIES
OUTPUT_NAME "lima${PROJECT_NAME_LOWER}"
VERSION "${PROJECT_VERSION}"
SOVERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
add_library(lima${NAME} SHARED ${${NAME}_srcs})
target_link_libraries(marccd PUBLIC limacore)
target_include_directories(lima${NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_include_directories(lima${NAME} PUBLIC "/usr/local/yat/include")
target_compile_definitions(marccd PUBLIC ${MARCCD_DEFINITIONS})
find_library(MARCCD_YAT_LIB yat /usr/local/yat/lib64)
find_library(MARCCD_RT_LIB rt)
if("${MARCCD_RT_LIB}" STREQUAL "MARCCD_RT_LIB-NOTFOUND")
message(FATAL_ERROR "${NAME} : librt not found, you can search it in cmake-gui or try to install it if it isn't here.")
target_include_directories(marccd PUBLIC $<BUILD_INTERFACE:${YAT_INCLUDE_DIRS}>)
target_link_libraries(marccd PUBLIC ${YAT_LIBRARIES})
if(WIN32)
target_compile_definitions(marccd
PRIVATE marccd_EXPORTS
PUBLIC NOMINMAX)
set_target_properties(marccd PROPERTIES PREFIX "lib" IMPORT_PREFIX "lib")
endif()
# Binding code for python
if(LIMA_ENABLE_PYTHON)
include(LimaTools)
limatools_run_sip_for_camera(marccd)
endif()
if("${MARCCD_YAT_LIB}" STREQUAL "MARCCD_YAT_LIB-NOTFOUND")
message(FATAL_ERROR "${NAME} : libyat not found, you can search it in cmake-gui or try to install it if it isn't here.")
# Generate and install package config file and version
if(CAMERA_MASTER_PROJECT)
set (PROJECT_LIBRARIES marccd)
set(SIP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/sip/lima)
set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/lima)
include(package_config)
endif()
target_link_libraries(lima${NAME} limacore)
target_link_libraries(lima${NAME} ${MARCCD_YAT_LIB})
target_link_libraries(lima${NAME} ${MARCCD_RT_LIB})
## Installation
install(
TARGETS marccd
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"
)
limatools_set_library_soversion(lima${NAME} "VERSION")
install(TARGETS lima${NAME} LIBRARY DESTINATION lib)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/project_version.h
${PROJECT_BINARY_DIR}/marccd_export.h
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if(LIMA_ENABLE_PYTHON)
limatools_run_sip_for_camera(${NAME})
install(FILES python/__init__.py DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/Marccd")
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/python/
DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima/Marccd"
)
endif()
## Tests
if(CAMERA_ENABLE_TESTS)
enable_testing()
#add_subdirectory(test)
endif()
set(YAT_INCLUDE_DIRS)
set(YAT_LIBRARIES)
set(YAT_DEFINITIONS)
find_path(YAT_INCLUDE_DIRS "yat/yat.h" /usr/local/include)
find_library(YAT_LIB yat /usr/local/lib64)
list(APPEND YAT_LIBRARIES ${YAT_LIB})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(YAT DEFAULT_MSG
YAT_LIBRARIES
YAT_INCLUDE_DIRS
)
# Config file for @PROJECT_NAME_LOWER@
#
# It defines the following variables:
#
# @PROJECT_NAME_UPPER@_INCLUDE_DIRS - include directory
# @PROJECT_NAME_UPPER@_LIBRARIES - all dynamic libraries
# @PROJECT_NAME_UPPER@_STATIC_LIBRARIES - all static libraries
@PACKAGE_INIT@
# Add dependencies here
include(CMakeFindDependencyMacro)
find_dependency(Lima)
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@PROJECT_NAME@")
check_required_components(@PROJECT_NAME_LOWER@)
......@@ -177,7 +177,6 @@ namespace lima
void getNbFrames(int& nb_frames);
void getStatus(Camera::Status& status);
unsigned int getState();
void checkRoi(const Roi& set_roi, Roi& hw_roi);
void setRoi(const Roi& set_roi);
......
......@@ -19,42 +19,6 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
import os, sys, imp, glob
root_name = __path__[0]
mod_name = os.path.basename(root_name)
def version_code(s):
return map(int, s.strip('v').split('.'))
def version_cmp(x, y):
return cmp(version_code(x), version_code(y))
env_var_name = 'LIMA_%s_VERSION' % mod_name.upper()
try:
version = os.environ[env_var_name]
except KeyError:
version = 'LAST'
req_version = version
if version.upper() == 'LAST':
version_dirs = [x for x in os.listdir(root_name) if x.startswith('v')]
version_dirs.sort(version_cmp)
version = version_dirs[-1]
else:
if version[0] != 'v':
version = 'v' + version
mod_path = os.path.join(root_name, version)
if not (os.path.isdir(mod_path) or os.path.islink(mod_path)):
raise ImportError('Invalid %s: %s' % (env_var_name, req_version))
__path__.append(mod_path)
from Lima.Marccd.limamarccd import Marccd as _P
globals().update(_P.__dict__)
del root_name, mod_name, mod_path, x, env_var_name
del version, req_version, version_dirs, version_code, version_cmp
del os, sys, imp, glob
from Lima import Core
from limamarccd import Marccd as _M
globals().update(_M.__dict__)
......@@ -5,7 +5,7 @@ namespace Marccd
// \brief object controlling the marccd detector through a socket
//--------------------------------------------------------------------
class Camera
class Camera /NoDefaultCtors/
{
%TypeHeaderCode
#include <MarccdCamera.h>
......@@ -26,11 +26,7 @@ namespace Marccd
Camera(const std::string& camera_ip,
unsigned int port_number,
const std::string& img_path);
//Camera();
//Camera(const Marccd::Camera&);
~Camera();
//Camera& operator=(const Marccd::Camera&);
void start();
void stop();
......@@ -61,7 +57,6 @@ namespace Marccd
void getNbFrames(int& nb_frames /Out/);
void getStatus(Marccd::Camera::Status& status /Out/);
unsigned int getState();
void setBinning(const Bin&);
void getBinning(Bin& /Out/);
......
......@@ -5,7 +5,7 @@ namespace Marccd
// * \class Interface
// * \brief Marccd hardware interface
//*******************************************************************/
class Interface : HwInterface
class Interface : HwInterface /NoDefaultCtors/
{
%TypeHeaderCode
#include <MarccdInterface.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment