Commit ffe30f8a authored by Samuel Debionne's avatar Samuel Debionne

Update the build sytem to support devel conda package

Add python 2.7 build for Linux
parent ae60b7c7
Pipeline #5697 passed with stages
in 12 minutes and 32 seconds
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
- deploy
build-linux:
.build-conda: &build-conda
stage: build
script:
- git submodule update --init --recursive third-party/bitshuffle
- conda build ./conda --prefix-length=80 --output-folder=dist/ --channel=http://bcu-ci.esrf.fr/stable
artifacts:
paths:
- dist/
tags:
- conda
build-linux:
<<: *build-conda
tags:
- linux
build-win:
stage: build
<<: *build-conda
tags:
- win
deploy-devel:
stage: deploy
environment:
name: devel/$CI_COMMIT_REF_NAME
url: http://bcu-ci.esrf.fr/devel
dependencies:
- build-linux
- build-win
script:
- conda build ./conda --prefix-length=80 --output-folder=dist/ --channel=http://bcu-ci.esrf.fr/stable
artifacts:
paths:
- dist/
- cp -Rf dist/* /conda-devel/
- conda index /conda-devel/
tags:
- conda
- win
- linux
only:
- branches
except:
- stable
when: manual
deploy:
deploy-stable:
stage: deploy
environment:
name: production
......@@ -41,4 +57,6 @@ deploy:
tags:
- conda
- linux
when: manual
only:
- tags
- stable
This diff is collapsed.
if(NOT LIMA_BUILD_SUBMODULES)
# Generate and install package config file and version
set(PROJECT_LIBRARIES limacore h5bshuf)
set(SIP_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/sip/lima)
set(CMAKE_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/lima)
include(cmake/package_config.cmake)
endif()
install(
TARGETS limacore
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(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/project_version.h
${CMAKE_CURRENT_BINARY_DIR}/limacore_export.h
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lima
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/common/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/hardware/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/control/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(
DIRECTORY ${CMAKE_SOURCE_DIR}/control/software_operation/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
if(NOT LIMA_BUILD_SUBMODULES)
install(
FILES ${CMAKE_SOURCE_DIR}/cmake/checksipexc.py
${CMAKE_SOURCE_DIR}/cmake/FindNumPy.cmake
${CMAKE_SOURCE_DIR}/cmake/FindSIP.cmake
${CMAKE_SOURCE_DIR}/cmake/FindSIP.py
${CMAKE_SOURCE_DIR}/cmake/SIPMacros.cmake
${CMAKE_SOURCE_DIR}/cmake/sip_init_numpy.cpp.in
${CMAKE_SOURCE_DIR}/cmake/package_config.cmake
${CMAKE_SOURCE_DIR}/cmake/project_version.cmake
${CMAKE_SOURCE_DIR}/cmake/project_version.cc.in
${CMAKE_SOURCE_DIR}/cmake/project_version.h.in
${CMAKE_SOURCE_DIR}/cmake/LimaTools.cmake
COMPONENT devel
DESTINATION ${CMAKE_INSTALL_DIR}
)
endif()
if(LIMA_ENABLE_PYTHON)
install(DIRECTORY python/Lima/ DESTINATION "${PYTHON_SITE_PACKAGES_DIR}/Lima")
file(GLOB SIP_SOURCES
"${CMAKE_SOURCE_DIR}/common/sip/*.sip"
"${CMAKE_SOURCE_DIR}/common/sip/*.sip"
"${CMAKE_SOURCE_DIR}/hardware/sip/*.sip"
"${CMAKE_SOURCE_DIR}/control/sip/*.sip"
"${CMAKE_SOURCE_DIR}/control/software_operation/sip/*.sip")
if(NOT LIMA_BUILD_SUBMODULES)
install(
FILES ${SIP_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/sip/limacore.sip
${CMAKE_SOURCE_DIR}/sip/limamodules.sip.in
COMPONENT devel
DESTINATION ${SIP_INSTALL_DIR}
)
endif()
endif()
###########################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2017
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# 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/>.
############################################################################
# Use submodules
option(LIMA_BUILD_SUBMODULES "Build with submodules (vs prebuilt packages)?" ON)
if(UNIX)
# Spec-like shared memory
if(DEFINED ENV{COMPILE_SPS_IMAGE})
set(LIMA_ENABLE_SPS_IMAGE "$ENV{COMPILE_SPS_IMAGE}" CACHE BOOL "compile sps_image?" FORCE)
else()
option(LIMA_ENABLE_SPS_IMAGE "compile sps_image?" OFF)
endif()
# openGL real-time display
if(DEFINED ENV{COMPILE_GLDISPLAY})
set(LIMA_ENABLE_GLDISPLAY "$ENV{COMPILE_GLDISPLAY}" CACHE BOOL "compile gldisplay?" FORCE)
else()
option(LIMA_ENABLE_GLDISPLAY "compile sps_image?" OFF)
endif()
endif()
#--------------------------------------------------------------------------------
# Compile tests
#--------------------------------------------------------------------------------
option(LIMA_ENABLE_TESTS "compile test directories ?" OFF)
#--------------------------------------------------------------------------------
# libconfig
#--------------------------------------------------------------------------------
if(DEFINED ENV{LIMA_ENABLE_CONFIG})
set(LIMA_ENABLE_CONFIG "$ENV{LIMA_ENABLE_CONFIG}" CACHE BOOL "compile with libconfig code?" FORCE)
else()
option(LIMA_ENABLE_CONFIG "compile with libconfig?" OFF)
endif()
#--------------------------------------------------------------------------------
# Saving formats can be enabled from environment variables using config.inc file
#--------------------------------------------------------------------------------
if(UNIX)
# The formats have not been tested on windows
if(DEFINED ENV{LIMA_ENABLE_CBF})
set(LIMA_ENABLE_CBF "$ENV{LIMA_ENABLE_CBF}" CACHE BOOL "compile CBF saving code?" FORCE)
else()
option(LIMA_ENABLE_CBF "compile CBF saving code?" OFF)
endif()
if(DEFINED ENV{LIMA_ENABLE_FITS})
set(LIMA_ENABLE_FITS "$ENV{LIMA_ENABLE_FITS}" CACHE BOOL "compile FITS saving code?" FORCE)
else()
option(LIMA_ENABLE_FITS "compile FITS saving code?" OFF)
endif()
if(DEFINED ENV{LIMA_ENABLE_NXS})
set(LIMA_ENABLE_NXS "$ENV{LIMA_ENABLE_NXS}" CACHE BOOL "compile Nexus saving code?" FORCE)
else()
option(LIMA_ENABLE_NXS "compile Nexus saving code?" OFF)
endif()
endif()
if(DEFINED ENV{LIMA_ENABLE_TIFF})
set(LIMA_ENABLE_TIFF "$ENV{LIMA_ENABLE_TIFF}" CACHE BOOL "compile TIFF saving code?" FORCE)
else()
option(LIMA_ENABLE_TIFF "compile TIFF saving code?" OFF)
endif()
if(DEFINED ENV{LIMA_ENABLE_EDFLZ4})
set(LIMA_ENABLE_EDFLZ4 "$ENV{LIMA_ENABLE_EDFLZ4}" CACHE BOOL "compile EDF.LZ4 saving code?" FORCE)
else()
option(LIMA_ENABLE_EDFLZ4 "compile EDF.LZ4 saving code?" OFF)
endif()
if(DEFINED ENV{LIMA_ENABLE_EDFGZ})
set(LIMA_ENABLE_EDFGZ "$ENV{LIMA_ENABLE_EDFGZ}" CACHE BOOL "compile EDF.GZ saving code?" FORCE)
else()
option(LIMA_ENABLE_EDFGZ "compile EDF.GZ saving code?" OFF)
endif()
if(DEFINED ENV{LIMA_ENABLE_HDF5})
set(LIMA_ENABLE_HDF5 "$ENV{LIMA_ENABLE_HDF5}" CACHE BOOL "compile HDF5 saving code?" FORCE)
else()
option(LIMA_ENABLE_HDF5 "compile HDF5 saving code?" OFF)
endif()
if(DEFINED ENV{LIMA_ENABLE_HDF5_BS})
set(LIMA_ENABLE_HDF5_BS "$ENV{LIMA_ENABLE_HDF5_BS}" CACHE BOOL "compile HDF5/BS saving code?" FORCE)
else()
option(LIMA_ENABLE_HDF5_BS "compile HDF5/BS saving code?" OFF)
endif()
# Compile python wrapping code generated using SIP
IF(DEFINED ENV{LIMA_ENABLE_PYTHON})
set(LIMA_ENABLE_PYTHON "$ENV{LIMA_ENABLE_PYTHON}" CACHE BOOL "compile python modules?" FORCE)
else()
option(LIMA_ENABLE_PYTHON "compile python modules?" OFF)
endif()
# Python Tango server
IF(DEFINED ENV{LIMA_ENABLE_PYTANGO_SERVER})
set(LIMA_ENABLE_PYTANGO_SERVER "$ENV{LIMA_ENABLE_PYTANGO_SEVER}" CACHE BOOL "install python tango server?" FORCE)
else()
option(LIMA_ENABLE_PYTANGO_SERVER "install python tango server?" OFF)
endif()
###########################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2017
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# 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(saving_definitions)
set(saving_libs)
set(saving_private_libs)
set(saving_includes)
if(LIMA_ENABLE_EDFGZ)
find_package(ZLIB)
if(${ZLIB_FOUND})
list(APPEND saving_definitions -DWITH_Z_COMPRESSION)
list(APPEND saving_libs ${ZLIB_LIBRARIES})
list(APPEND saving_includes ${ZLIB_INCLUDE_DIRS})
else()
message(FATAL_ERROR "ZLIB library not found, please install or disable LIMA_ENABLE_EDFGZ")
endif()
endif()
if(LIMA_ENABLE_EDFLZ4)
find_package(LZ4)
if (${LZ4_FOUND})
list(APPEND saving_definitions -DWITH_LZ4_COMPRESSION)
list(APPEND saving_libs ${LZ4_LIBRARIES})
list(APPEND saving_includes ${LZ4_INCLUDE_DIRS})
else()
message(FATAL_ERROR "LZ4 library: required version = 1.8.2, please update or switch off LIMA_ENABLE_EDFLZ4")
endif()
endif()
if(LIMA_ENABLE_CBF)
find_package(CBF)
if (${CBF_FOUND})
list(APPEND saving_definitions -DWITH_CBF_SAVING)
list(APPEND saving_definitions -DPROTOTYPES)
list(APPEND control_srcs control/src/CtSaving_Cbf.cpp)
list(APPEND saving_libs ${CBF_LIBRARIES} crypto)
list(APPEND saving_includes ${CBF_INCLUDE_DIRS})
else()
message(FATAL_ERROR "CBF library not found, please install or disable LIMA_ENABLE_CBF")
endif()
endif()
if(LIMA_ENABLE_FITS)
find_package(CCFits)
if(${CCFITS_FOUND})
list(APPEND saving_definitions -DWITH_FITS_SAVING)
list(APPEND control_srcs control/src/CtSaving_Fits.cpp)
list(APPEND saving_libs ${CFITSIO_LIBRARY} ${CCFITS_LIBRARY})
list(APPEND saving_includes ${CFITSIO_INCLUDE_DIR})
else()
message(FATAL_ERROR "CFITSIO and/or CCFITS library not found, please install or disable LIMA_ENABLE_FITS")
endif()
endif()
if(LIMA_ENABLE_HDF5)
#set (HDF5_USE_STATIC_LIBRARIES ON)
find_package(HDF5 COMPONENTS CXX HL)
if(${HDF5_FOUND})
list(APPEND saving_definitions -DWITH_HDF5_SAVING ${HDF5_DEFINITIONS})
list(APPEND control_srcs control/src/CtSaving_Hdf5.cpp)
list(APPEND saving_libs ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${LIB_SZIP} ${LIB_ZLIB})
list(APPEND saving_includes ${HDF5_INCLUDE_DIRS})
else()
message(FATAL_ERROR "HDF5 library not found, please install or disable LIMA_ENABLE_HDF5")
endif()
if(LIMA_ENABLE_HDF5_BS)
#set(BITSHUFFLE_EXTERNALLY_CONFIGURED ON)
add_subdirectory(control/bitshuffle)
list(APPEND saving_definitions -DWITH_BS_COMPRESSION)
list(APPEND saving_includes ${CMAKE_CURRENT_SOURCE_DIR}/third-party/bitshuffle/src)
list(APPEND saving_private_libs h5bshuf_static)
# set(LIB_BS_INCLUDE_DIR "/usr/local/include/" CACHE PATH "Path to BitShuffle include files")
# link_directories(${LIB_HDF5_PLUGIN})
# find_library(LIB_HDF5_BS h5bshuf ${LIB_HDF5_PLUGIN})
# find_path(LIB_BS_INCLUDE_DIR bitshuffle.h)
# list(APPEND saving_libs ${LIB_HDF5_BS})
# list(APPEND saving_includes ${LIB_BS_INCLUDE_DIR})
endif()
endif()
if(LIMA_ENABLE_NXS)
find_package(NXS)
if(${NXS_FOUND})
list(APPEND saving_definitions -DWITH_NXS_SAVING)
list(APPEND control_srcs control/src/CtSaving_NXS.cpp)
list(APPEND saving_includes ${NXS_INCLUDE_DIRS})
list(APPEND saving_libs ${NXS_LIBRARIES})
else()
message(FATAL_ERROR "NEXUS cpp library not installed, please install or disable LIMA_ENABLE_NXS")
endif()
endif()
if(LIMA_ENABLE_TIFF)
find_package(TIFF)
if(${TIFF_FOUND})
list(APPEND saving_definitions -DWITH_TIFF_SAVING)
list(APPEND control_srcs control/src/CtSaving_Tiff.cpp)
list(APPEND saving_libs ${TIFF_LIBRARIES})
list(APPEND saving_includes ${TIFF_INCLUDE_DIRS})
else()
message(FATAL_ERROR "TIFF library not found, please install or disable LIMA_ENABLE_TIFF")
endif()
endif()
Subproject commit 735ba784e07b37fb991b49a00d20e346e7f6ad1a
Subproject commit cf317bbb082eefdbc43d2b6ad0a1989793415314
find_library(LIBCONFIG_LIBRARIES libconfig++)
find_path(LIBCONFIG_INCLUDE_DIRS libconfig.h++)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(config DEFAULT_MSG LIBCONFIG_LIBRARIES LIBCONFIG_INCLUDE_DIRS)
find_path(NXS_INCLUDE_DIRS nexuscpp/nexuscpp.h)
find_library(NXS_LIBRARIES nexuscpp)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NXS DEFAULT_MSG NXS_LIBRARIES NXS_INCLUDE_DIRS)
......@@ -31,7 +31,7 @@ if(SIP_VERSION)
set(SIP_FOUND TRUE)
else(SIP_VERSION)
set(find_sip_py ${CMAKE_SOURCE_DIR}/cmake/FindSIP.py)
set(find_sip_py ${CMAKE_CURRENT_LIST_DIR}/FindSIP.py)
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${find_sip_py} OUTPUT_VARIABLE sip_config)
if(sip_config)
......
......@@ -22,103 +22,79 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
function(limatools_set_library_soversion lib_name version_file)
# this function runs camera's c++ tests
function(limatools_run_camera_tests test_src camera)
file(STRINGS ${version_file} version)
# for lib version as 1.2.3 soverion is fixed to 1.2
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" soversion "${version}")
set_target_properties(${lib_name} PROPERTIES VERSION "${version}" SOVERSION "${soversion}")
endfunction()
function(limatools_run_camera_tests test_src cam_name)
if(${ARGC} GREATER 2)
set(test_arg ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5} ${ARGV6})
endif()
foreach(file ${test_src})
add_executable(${file} "${file}.cpp")
target_link_libraries(${file} limacore lima${cam_name})
add_test(NAME ${file} COMMAND ${file} ${test_arg})
if(WIN32)
# Add the dlls to the %PATH%
string(REPLACE ";" "\;" ESCAPED_PATH "$ENV{PATH}")
set_tests_properties(${file} PROPERTIES ENVIRONMENT "PATH=${ESCAPED_PATH}\;$<SHELL_PATH:$<TARGET_FILE_DIR:limacore>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:processlib>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:lima${cam_name}>>")
endif()
endforeach(file)
if(${ARGC} GREATER 2)
set(test_arg ${ARGV2} ${ARGV3} ${ARGV4} ${ARGV5} ${ARGV6})
endif()
foreach(file ${test_src})
add_executable(${file} "${file}.cpp")
target_link_libraries(${file} limacore lima${camera})
add_test(NAME ${file} COMMAND ${file} ${test_arg})
if(WIN32)
# Add the dlls to the %PATH%
string(REPLACE ";" "\;" ESCAPED_PATH "$ENV{PATH}")
set_tests_properties(${file} PROPERTIES ENVIRONMENT "PATH=${ESCAPED_PATH}\;$<SHELL_PATH:$<TARGET_FILE_DIR:limacore>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:processlib>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:lima${camera}>>")
endif()
endforeach(file)
endfunction()
function(limatools_run_camera_python_tests test_src cam_name)
# this function runs camera's python tests
function(limatools_run_camera_python_tests test_src camera)
foreach(file ${test_src})
foreach(file ${test_src})
add_test(NAME ${file}
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/${file}.py)
if(WIN32)
# Add the dlls to the %PATH%
string(REPLACE ";" "\;" ESCAPED_PATH "$ENV{PATH}")
set_tests_properties(${file} PROPERTIES ENVIRONMENT "PATH=${ESCAPED_PATH}\;$<SHELL_PATH:$<TARGET_FILE_DIR:limacore>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:processlib>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:lima${cam_name}>>;PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/python>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_limacore>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_processlib>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_lima${cam_name}>>")
set_tests_properties(${file} PROPERTIES ENVIRONMENT "PATH=${ESCAPED_PATH}\;$<SHELL_PATH:$<TARGET_FILE_DIR:limacore>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:processlib>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:lima${camera}>>;PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/python>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_limacore>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_processlib>>\;$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_lima${camera}>>")
else()
set_tests_properties(${file} PROPERTIES ENVIRONMENT "PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/python>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_limacore>>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_processlib>>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_lima${cam_name}>>")
set_tests_properties(${file} PROPERTIES ENVIRONMENT "PYTHONPATH=$<SHELL_PATH:${CMAKE_BINARY_DIR}/python>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_limacore>>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_processlib>>:$<SHELL_PATH:$<TARGET_FILE_DIR:python_module_lima${camera}>>")
endif()
endforeach(file)
endforeach(file)
endfunction()
# this function is used to build camera's python binding
function(limatools_run_sip_for_camera camera)
function(limatools_run_sip_for_camera cam_name)
set(MODULE_NAME lima${camera})
# Add %Include directives for every source files
set(INCLUDES)
file(GLOB sipfiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/sip" "${CMAKE_CURRENT_SOURCE_DIR}/sip/*.sip")
foreach(sipfile ${sipfiles})
set(INCLUDES
"${INCLUDES}
%Include ${sipfile}")
set(INCLUDES "${INCLUDES} \n%Include ${sipfile}")
endforeach()
set(IMPORTS
"${IMPORTS}
%Import limacore.sip")
# Add %import directives for every source files
set(sipfiles "limacore.sip" )
list(APPEND sipfiles ${IMPORTS})
set(IMPORTS)
foreach(sipfile ${sipfiles})
set(IMPORTS "${IMPORTS} \n%Import ${sipfile}")
endforeach()
if(SIP_VERSION_STR VERSION_LESS "4.12")
message(FATAL_ERROR "SIP older than 4.12 is no longer supported")
endif()
configure_file(${CMAKE_SOURCE_DIR}/sip/limamodules.sip.in sip/lima${cam_name}.sip)
configure_file(${CMAKE_SOURCE_DIR}/sip/lima_init_numpy.cpp.in sip/lima${cam_name}_init_numpy.cpp)
set(SIP_INCLUDES ${SIP_INCLUDES}
"${CMAKE_SOURCE_DIR}/third-party/Processlib/sip"
"${CMAKE_BINARY_DIR}/sip/core"
"${CMAKE_SOURCE_DIR}/third-party/Processlib/tasks/sip"
"${CMAKE_SOURCE_DIR}/common/sip"
"${CMAKE_SOURCE_DIR}/hardware/sip"
"${CMAKE_SOURCE_DIR}/control/sip"
"${CMAKE_SOURCE_DIR}/control/software_operation/sip"
"${CMAKE_CURRENT_SOURCE_DIR}/sip")
# Uses INCLUDES and IMPORTS
configure_file(${LIMA_SIP_INCLUDE_DIRS}/limamodules.sip.in sip/${MODULE_NAME}.sip)
list(APPEND SIP_INCLUDE_DIRS
${LIMA_SIP_INCLUDE_DIRS}
${PROCESSLIB_SIP_INCLUDE_DIRS}
"${CMAKE_CURRENT_SOURCE_DIR}/sip"
)
add_sip_python_module(lima${cam_name}
${CMAKE_CURRENT_BINARY_DIR}/sip/lima${cam_name}.sip
1)
target_include_directories(python_module_lima${cam_name} PRIVATE
# If Lima is an imported target, set the SIP_DISABLE_FEATURES
set(SIP_DISABLE_FEATURES ${LIMA_SIP_DISABLE_FEATURES})
add_sip_python_module(${MODULE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/sip/${MODULE_NAME}.sip TRUE)
target_include_directories(python_module_${MODULE_NAME} PRIVATE
${PYTHON_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/sip"
"${CMAKE_SOURCE_DIR}/sip/core"
"${CMAKE_SOURCE_DIR}/third-party/Processlib/sip")
target_link_libraries(python_module_lima${cam_name} lima${cam_name})
endfunction()
${NUMPY_INCLUDE_DIRS}
)
# set install dir for libraries "name"
function(limatools_set_install_libdir lib_name)
if(WIN32)
set_target_properties(${lib_name} PROPERTIES PREFIX "lib")
install(TARGETS ${lib_name}
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
else()
include(GNUInstallDirs)
install(TARGETS ${lib_name}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
target_link_libraries(python_module_${MODULE_NAME} PUBLIC ${camera} limacore ${NUMPY_LIBRARIES})
endfunction()
......@@ -19,20 +19,28 @@
# The behaviour of the ADD_SIP_PYTHON_MODULE macro can be controlled by a
# number of variables:
#
# SIP_INCLUDES - List of directories which SIP will scan through when looking
# SIP_INCLUDE_DIRS - List of directories which SIP will scan through when looking
# for included .sip files. (Corresponds to the -I option for SIP.)
#
# SIP_TAGS - List of tags to define when running SIP. (Corresponds to the -t
# option for SIP.)
#
# SIP_CONCAT_PARTS - An integer which defines the number of parts the C++ code
# of each module should be split into. Defaults to 8. (Corresponds to the
# -j option for SIP.)
#
# SIP_DISABLE_FEATURES - List of feature names which should be disabled
# running SIP. (Corresponds to the -x option for SIP.)
#
# SIP_EXTRA_OPTIONS - Extra command line options which should be passed on to
# SIP.
set(SIP_INCLUDES)
# See https://itk.org/Bug/view.php?id=12265
get_filename_component(_SIPMACRO_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
set(SIP_INCLUDE_DIRS)
set(SIP_TAGS)
set(SIP_CONCAT_PARTS 16)
set(SIP_DISABLE_FEATURES)
set(SIP_EXTRA_OPTIONS)
......@@ -56,10 +64,10 @@ macro(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP RUN_CHECK_SIP_EXC)
file(MAKE_DIRECTORY ${_module_path}) # Output goes in this dir.
set(_sip_includes)
foreach (_inc ${SIP_INCLUDES})
set(_sip_include_dirs)
foreach (_inc ${SIP_INCLUDE_DIRS})
get_filename_component(_abs_inc ${_inc} ABSOLUTE)
list(APPEND _sip_includes -I ${_abs_inc})
list(APPEND _sip_include_dirs -I ${_abs_inc})
endforeach (_inc )
set(_sip_tags)
......@@ -72,84 +80,54 @@ macro(ADD_SIP_PYTHON_MODULE MODULE_NAME MODULE_SIP RUN_CHECK_SIP_EXC)
list(APPEND _sip_x -x ${_x})
endforeach (_x ${SIP_DISABLE_FEATURES})
set(_message "-DMESSAGE=Generating CPP code for module ${MODULE_NAME}")
set(_module_sbf ${_module_path}/${MODULE_NAME}.sbf)
execute_process(COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x}
${SIP_EXTRA_OPTIONS} ${_sip_includes}
-b ${_module_sbf} ${_abs_module_sip}
)
if(${MODULE_NAME} STREQUAL "processlib")
message(FATAL_ERROR "processlib module has its own SIPMacros")
endif()
set(_init_numpy "${_child_module_name}_init_numpy.cpp")
set(_init_numpy_cpp ${_module_path}/${_init_numpy})
set(_sip_output_files_list)
execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/readsipsbf.py
${_module_sbf} ${_module_path}
OUTPUT_VARIABLE _sip_output_files_list
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(_sip_output_files)
foreach(filename IN LISTS _sip_output_files_list)
set(_sip_output_files ${_sip_output_files} ${filename})
endforeach(filename)
if(NOT WIN32)
set(TOUCH_COMMAND touch)
else(NOT WIN32)
set(TOUCH_COMMAND echo)
# instead of a touch command, give out the name and append to the files
# this is basically what the touch command does.
foreach(filename ${_sip_output_files})
file(APPEND filename "")
endforeach(filename ${_sip_output_files})
endif(NOT WIN32)
# TODO: add all SIP files with the %Include directive + Exceptions.sip
foreach(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
if( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
set(_sip_output_files ${_sip_output_files} ${_module_path}/sip${_child_module_name}part${CONCAT_NUM}.cpp )
endif( ${CONCAT_NUM} LESS ${SIP_CONCAT_PARTS} )
endforeach(CONCAT_NUM RANGE 0 ${SIP_CONCAT_PARTS} )
add_custom_command(
OUTPUT ${_sip_output_files}
COMMAND ${CMAKE_COMMAND} -E echo ${message}
COMMAND ${TOUCH_COMMAND} ${_sip_output_files}
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS}
${_sip_includes} -c ${_module_path}
${_abs_module_sip}
COMMAND ${CMAKE_COMMAND} -E touch ${_sip_output_files}
COMMAND ${SIP_EXECUTABLE} ${_sip_tags} ${_sip_x} ${SIP_EXTRA_OPTIONS} -j ${SIP_CONCAT_PARTS} -c ${_module_path} ${_sip_include_dirs} ${_abs_module_sip}
DEPENDS ${_abs_module_sip} ${SIP_EXTRA_FILES_DEPEND}
COMMENT "Generating SIP code for module ${MODULE_NAME}"
)
if (${RUN_CHECK_SIP_EXC})
add_custom_command(
OUTPUT ${_sip_output_files}
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/cmake/checksipexc.py ${_sip_output_files}
COMMENT "Running SIP exceptions check"
APPEND
)
endif()
add_custom_command(
OUTPUT ${_sip_output_files}
COMMAND ${PYTHON_EXECUTABLE} "${_SIPMACRO_LIST_DIR}/checksipexc.py" ${_sip_include_dirs} ${_sip_output_files}
COMMENT "Running checksipexc.py"
APPEND
)
endif ()
# Add the import numpy compilation unit
# See https://docs.scipy.org/doc/numpy/reference/c-api.array.html#importing-the-api
configure_file(${_SIPMACRO_LIST_DIR}/sip_init_numpy.cpp.in sip/sip_init_numpy.cpp)
list(APPEND _sip_output_files "${CMAKE_CURRENT_BINARY_DIR}/sip/sip_init_numpy.cpp")
# not sure if type MODULE could be uses anywhere, limit to cygwin for now
set(_sip_all_files ${_init_numpy_cpp} ${_sip_output_files})
if (CYGWIN)
add_library(${_logical_name} MODULE ${_sip_all_files} )
add_library(${_logical_name} MODULE ${_sip_output_files} )
else (CYGWIN)
add_library(${_logical_name} SHARED ${_sip_all_files} )
add_library(${_logical_name} SHARED ${_sip_output_files} )
endif (CYGWIN)
target_link_libraries(${_logical_name} ${PYTHON_LIBRARY})
target_link_libraries(${_logical_name} ${EXTRA_LINK_LIBRARIES})
target_link_libraries(${_logical_name} PRIVATE ${PYTHON_LIBRARY})
target_link_libraries(${_logical_name} PRIVATE ${EXTRA_LINK_LIBRARIES})
set_target_properties(${_logical_name} PROPERTIES
PREFIX "" OUTPUT_NAME ${_child_module_name}
LINKER_LANGUAGE CXX)
if (WIN32)
set_target_properties(${_logical_name} PROPERTIES SUFFIX ".pyd")
set_target_properties(${_logical_name} PROPERTIES IMPORT_SUFFIX ".dll")
endif (WIN32)