Commit 93ab541b authored by Shervin Nourbakhsh's avatar Shervin Nourbakhsh
Browse files

Merge commit '46e44691' into mer

     - API version number set by CMake in cameo.h header file taking it from the project version set in CMakeLists.txt
     - add Threads as public dependency
     - CPack generating DEB packages
     - split installation into components to create separate .deb packages with cpack
     - the dynamic library is set to be installed
     - the static library is also produced but not installed, it can only be used setting the build tree in the CMAKE_PREFIX_PATH of another project
       This is done in order to embed the C++ API library into the python .so
     - Improved README documentation about how to compile and install
parents 5ff36030 46e44691
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
/Makefile.in /Makefile.in
/.settings/ /.settings/
/Debug/ /Debug/
build/
\ No newline at end of file
if(NOT DEFINED PROJECT_NAME) cmake_minimum_required(VERSION 3.12.0)
cmake_minimum_required(VERSION 3.7.2)
# Project name and version
project(cameo VERSION 1.1.0 LANGUAGES CXX)
#cmake_policy(SET CMP0048 NEW)
endif()
message("========================================")
message("Project ${PROJECT_NAME}, major version: ${PROJECT_VERSION_MAJOR}, version ${PROJECT_VERSION}")
project(cameo-api-cpp
VERSION 1.1.0
LANGUAGES CXX
HOMEPAGE_URL "https://code.ill.fr/cameo/cameo"
)
#--------------- Helpers
include(GNUInstallDirs) include(GNUInstallDirs)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(FetchContent) include(FetchContent)
if(NOT DEFINED BUILD_SHARED_LIBS) # name of the target library
option(BUILD_SHARED_LIBS "Building dynamic (ON) or static (OFF)" ON) set(LIBNAME ${PROJECT_NAME})
#set(BUILD_SHARED_LIBS True) set(NAMESPACE Cameo)
endif() set(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/cameo/api)
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake)
set(component_runtime CAMEO_API_CPP_RUNTIME)
set(component_development CAMEO_API_CPP_DEVELOPMENT)
#--------------- Options
option(CAMEO_API_CPP_TESTS "Compiling the test programs" OFF)
if(NOT DEFINED ${CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_TYPE "Release") # set Release by default
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# fix the RPATH for the linker # fix the RPATH for the linker
#if(not APPLE) if(NOT APPLE)
# set(CMAKE_INSTALL_RPATH $ORIGIN) set(CMAKE_INSTALL_RPATH $ORIGIN)
#endif() endif()
#------------------------------------------------------------ #------------------------------------------------------------
# Dependencies # Dependencies
#------------------------------------------------------------ #------------------------------------------------------------
# this is needed when including this file as subdir
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
find_package(ZeroMQ REQUIRED) find_package(ZeroMQ REQUIRED)
find_package(Rapidjson QUIET) find_package (Threads REQUIRED)
find_package(Rapidjson 1.1.0 QUIET)
if(NOT Rapidjson_FOUND) if(NOT Rapidjson_FOUND)
message(WARNING "Using Rapidjson from GIT repository") message(WARNING "Using Rapidjson from GIT repository")
FetchContent_Declare(rapidjson FetchContent_Declare(rapidjson
GIT_REPOSITORY https://github.com/Tencent/rapidjson.git GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
GIT_TAG v1.1.0 GIT_TAG v1.1.0
GIT_SHALLOW True GIT_SHALLOW True
#INSTALL_COMMAND "make install"
) )
FetchContent_GetProperties(rapidjson) FetchContent_GetProperties(rapidjson)
FetchContent_Populate(rapidjson) FetchContent_Populate(rapidjson)
...@@ -44,118 +52,177 @@ if(NOT Rapidjson_FOUND) ...@@ -44,118 +52,177 @@ if(NOT Rapidjson_FOUND)
set(Rapidjson_ROOT ${rapidjson_SOURCE_DIR}) set(Rapidjson_ROOT ${rapidjson_SOURCE_DIR})
find_package(Rapidjson REQUIRED) find_package(Rapidjson REQUIRED)
endif() endif()
message(${Rapidjson_INCLUDE_DIRS}) message(STATUS "Rapidjson found here: ${Rapidjson_INCLUDE_DIRS}")
#------------------------------------------------------------
#------------------------------------------------------------ #------------------------------------------------------------
# Libraries # Libraries
#------------------------------------------------------------ #------------------------------------------------------------
#--------------- #---------------
# Files # Files
file(GLOB_RECURSE CAMEO_SOURCE_FILES "src/*.cpp") file(GLOB_RECURSE CAMEO_SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
configure_file(include/cameo.h.in ${INSTALL_INCLUDEDIR}/cameo.h )
add_library(cameo ${CAMEO_SOURCE_FILES}) add_library(${LIBNAME}-obj OBJECT ${CAMEO_SOURCE_FILES})
target_link_libraries(cameo PRIVATE zmq) target_link_libraries(${LIBNAME}-obj PUBLIC zmq Threads::Threads)
target_include_directories(cameo target_include_directories(${LIBNAME}-obj
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/ # all the private headers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/ # all the private headers
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> # here's the version
PUBLIC $<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>
) )
target_include_directories(cameo target_include_directories(${LIBNAME}-obj
SYSTEM PRIVATE ${Rapidjson_INCLUDE_DIRS}/ SYSTEM PRIVATE ${Rapidjson_INCLUDE_DIRS}/
) )
#target_include_directories(cameo PRIVATE ${DOCTEST_INCLUDE_DIR}) target_compile_features(${LIBNAME}-obj PUBLIC cxx_std_17)
target_compile_features(cameo PUBLIC cxx_std_17)
set_target_properties(cameo PROPERTIES set_target_properties(${LIBNAME}-obj PROPERTIES
SOVERSION ${PROJECT_VERSION_MAJOR} SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
POSITION_INDEPENDENT_CODE 1 # this is needed for static compilation for cameo-api-python
) )
#--------------- add_library(${LIBNAME}-static STATIC $<TARGET_OBJECTS:${LIBNAME}-obj>)
# Library version add_library(${LIBNAME} $<TARGET_OBJECTS:${LIBNAME}-obj>)
write_basic_package_version_file(cameoConfigVersion.cmake set_target_properties(${LIBNAME} PROPERTIES
COMPATIBILITY SameMajorVersion SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
POSITION_INDEPENDENT_CODE 1 # this is needed for static compilation for cameo-api-python
) )
#------------------------------------------------------------ add_library(${NAMESPACE}::${LIBNAME} ALIAS ${LIBNAME})
# Tests add_library(${NAMESPACE}::${LIBNAME}-obj ALIAS ${LIBNAME}-obj)
add_library(${NAMESPACE}::${LIBNAME}-static ALIAS ${LIBNAME}-static)
target_include_directories(${LIBNAME}-static
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> # here's the version
)
target_compile_features(${LIBNAME}-static PUBLIC cxx_std_17)
target_link_libraries(${LIBNAME}-static PUBLIC zmq Threads::Threads)
#------------------------------------------------------------ #------------------------------------------------------------
# Note: execute ctest --verbose to have more details include(GenerateExportHeader)
enable_testing() generate_export_header(${LIBNAME}
add_subdirectory(tests) EXPORT_MACRO_NAME ${LIBNAME}_EXPORT
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_INCLUDEDIR}/export.h
)
#------------------------------------------------------------ #------------------------------------------------------------
# Install # Install
#------------------------------------------------------------ #------------------------------------------------------------
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cameoConfigVersion.cmake install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake) DESTINATION ${CMAKE_INSTALL_DOCDIR}/
RENAME copyright
COMPONENT ${component_runtime}
)
#---------------
# Library version
write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake
COMPATIBILITY SameMajorVersion
VERSION ${PROJECT_VERSION}
)
write_basic_package_version_file(${PROJECT_NAME}-static-config-version.cmake
COMPATIBILITY SameMajorVersion
VERSION ${PROJECT_VERSION}
)
install(TARGETS ${LIBNAME}
EXPORT cameoTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # windows
COMPONENT ${component_runtime}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/cameo/ # dynamic
COMPONENT ${component_runtime}
NAMELINK_COMPONENT ${component_development} #from CMake 3.12
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/cameo/ # static
COMPONENT ${component_development}
PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR}
COMPONENT ${component_development}
INCLUDES DESTINATION ${INSTALL_INCLUDEDIR}
COMPONENT ${component_development}
)
# this is to install the headers # this is to install the headers
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ # don't forget the trailing / install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ # don't forget the trailing /
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} DESTINATION ${INSTALL_INCLUDEDIR}
COMPONENT ${component_development}
FILES_MATCHING PATTERN *.h
)
# this is to install the version header that is generated by cmake
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ # don't forget the trailing /
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT ${component_development}
FILES_MATCHING PATTERN *.h
) )
# in CMake 3.14 you just need #install(TARGETS cameo) # this is for cameo-api-python to compile from the local build tree
install(TARGETS cameo export(TARGETS ${LIBNAME}-static
EXPORT cameoexport NAMESPACE ${NAMESPACE}::
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # windows FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-static-targets.cmake
COMPONENT cameo_Runtime )
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # dynamic export(EXPORT cameoTargets
COMPONENT cameo_Runtime # FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-${type}-targets.cmake
# NAMELINK_COMPONENT cameo_Development #from CMake 3.12 FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-targets.cmake
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # static NAMESPACE ${NAMESPACE}::
COMPONENT cameo_Development )
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} configure_package_config_file(cmake/${PROJECT_NAME}-config.cmake.in
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${ConfigPackageLocation}
)
configure_file(cmake/${PROJECT_NAME}-static-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-static-config.cmake
COPYONLY
) )
install(EXPORT cameoTargets
FILE ${PROJECT_NAME}-targets.cmake
# FILE ${PROJECT_NAME}Config.cmake #${PROJECT_NAME}Targets.cmake
NAMESPACE ${NAMESPACE}::
DESTINATION ${ConfigPackageLocation}
COMPONENT ${component_development}
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${ConfigPackageLocation}
COMPONENT ${component_development}
)
# This makes the project importable from the install directory # This makes the project importable from the install directory
# Put config file in per-project dir (name MUST match), can also # Put config file in per-project dir (name MUST match), can also
# just go into 'cmake'. # just go into 'cmake'.
install(EXPORT cameoexport
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake if(UNIX)
FILE ${PROJECT_NAME}Config.cmake add_custom_command(
) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/changelog.gz
# makes the project importable from the build directory COMMAND gzip -cn9 ${CMAKE_CURRENT_SOURCE_DIR}/ChangeLog ${CMAKE_CURRENT_BINARY_DIR}/changelog.gz
export(TARGETS cameo FILE ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake) WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/changelog"
# the install_manifest file is created only after the installation.... COMMENT "Compressing changelog"
#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt )
# DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake
# RENAME cameo_install_manifest.txt add_custom_target(changelog
# ) ALL
# DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/changelog.gz
COMMAND gzip -cn9 ${CMAKE_CURRENT_SOURCE_DIR}/ChangeLog > ${CMAKE_CURRENT_BINARY_DIR}/changelog.gz
#enable_testing() )
#add_subdirectory(test)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz"
# include(ExternalProject) DESTINATION "${CMAKE_INSTALL_DOCDIR}"
# find_package(Git REQUIRED) COMPONENT ${component_runtime}
)
# ExternalProject_Add( endif(UNIX)
# doctest
# PREFIX ${CMAKE_BINARY_DIR}/doctest #------------------------------------------------------------
# GIT_REPOSITORY https://github.com/onqtam/doctest.git # Doc
# TIMEOUT 10 #------------------------------------------------------------
# UPDATE_COMMAND ${GIT_EXECUTABLE} pull find_package(Doxygen QUIET)
# CONFIGURE_COMMAND ""
# BUILD_COMMAND ""
# INSTALL_COMMAND ""
# LOG_DOWNLOAD ON
# )
# # Expose required variable (DOCTEST_INCLUDE_DIR) to parent scope
# ExternalProject_Get_Property(doctest source_dir)
# set(DOCTEST_INCLUDE_DIR ${source_dir}/doctest CACHE INTERNAL "Path to include folder for doctest")
#include(CMakeFindDependencyMacro)
#find_dependency(
#include("${CMAKE_CURRENT_LIST_DIR}/cameo.cmake")
################ Doc
find_package(Doxygen)
if (DOXYGEN_FOUND) if (DOXYGEN_FOUND)
# set input and output files # set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
...@@ -175,4 +242,17 @@ else (DOXYGEN_FOUND) ...@@ -175,4 +242,17 @@ else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation") message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND) endif (DOXYGEN_FOUND)
#------------------------------------------------------------
# CPack
#------------------------------------------------------------
include(${CMAKE_CURRENT_SOURCE_DIR}/packaging/CPackConfig.cmake)
include(CPack)
#------------------------------------------------------------
# Tests
#------------------------------------------------------------
if(CAMEO_API_CPP_TESTS)
# Note: execute ctest --verbose to have more details
enable_testing()
add_subdirectory(tests)
endif(CAMEO_API_CPP_TESTS)
## Development
How to find the list of public headers and check that they are all in the include/ directory
1. move all the headers in src/
2. move cameo.h to include/
3. run the following command multiple times until there is no output
```
#!/bin/fish
set -l ORIG_DIR src
for f in (for file in include/*; grep include $file | grep '"'; end | sort | uniq | sed 's|.* "||;s|"||'); if [ -e $ORIG_DIR/$f ] ; echo $f; git mv $ORIG_DIR/$f include/; end; end
```
set(CPACK_PACKAGE_NAME cameo)
set (CPACK_PACKAGE_CHECKSUM MD5)
set (CPACK_COMPONENT_DEV_REQUIRED ON)
set (CPACK_COMPONENT_LIB_REQUIRED ON)
set (CPACK_COMPONENT_DEV_DEPENDS LIB )
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
set (CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON )
set (CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=" )
#set (CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
#set (DEBIAN_PACKAGE_BUILDS_DEPENDS "gcc (>=8), gcc-c++ (>=8), cmake (>=${CMAKE_MINIMUM_REQUIRED_VERSION})" )
set (CPACK_DEBIAN_LIB_PACKAGE_DEPENDS "cameo-server(>=1.0.2)" )
set(CPACK_DEBIAN_DEV_PACKAGE_NAME ${LIBNAME}-dev)
set(CPACK_DEBIAN_DEV_PACKAGE_NAME ${LIBNAME}-dev )
set(CPACK_DEBIAN_LIB_PACKAGE_NAME ${LIBNAME}-lib)
set(CPACK_DEBIAN_LIB_PACKAGE_NAME ${LIBNAME}-lib )
set(CPACK_DEBIAN_DEV_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_DEV_FILE_NAME ${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${PROJECT_VERSION}_${CPACK_DEBIAN_DEV_PACKAGE_ARCHITECTURE}.deb )
set(CPACK_DEBIAN_LIB_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_LIB_FILE_NAME ${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${PROJECT_VERSION}_${CPACK_DEBIAN_LIB_PACKAGE_ARCHITECTURE}.deb )
#if((${CMAKE_BUILD_TYPE} EQUAL "Debug") OR (${CMAKE_BUILD_TYPE} EQUAL "RelWithDebInfo"))
# set (CPACK_DEBIAN_DEBUGINFO_PACKAGE ON)
# set (CPACK_RPM_DEBUGINFO_PACKAGE ON)
#endif()
####### CPACK RPM
#message("CPACK SYSTEM NAME: ${CMAKE_SYSTEM_NAME}")
# cpack_add_component(lib
# DISPLAY_NAME "LIBB"
# DESCRIPTION "runtime library"
# REQUIRED #[HIDDEN | REQUIRED | DISABLED ]
# GROUP LIBBB
# #DEPENDS
# #[INSTALL_TYPES type1 type2 ... ]
# #[DOWNLOADED]
# #[ARCHIVE_FILE filename]
# #[PLIST filename]
# )
# cpack_add_component(dev
# DISPLAY_NAME "DEVV"
# DESCRIPTION "library development"
# #REQUIRED #[HIDDEN | REQUIRED | DISABLED ]
# GROUP DEVVV
# DEPENDS lib
# #[INSTALL_TYPES type1 type2 ... ]
# #[DOWNLOADED]
# #[ARCHIVE_FILE filename]
# #[PLIST filename]
# )
include(CPackConfig.cmake)
set( CPACK_INSTALL_CMAKE_PROJECTS "build/;cameo-api-cpp;ALL;/")
set (CPACK_PACKAGE_CHECKSUM MD5)
set (CPACK_COMPONENT_DEV_REQUIRED ON)
set (CPACK_COMPONENT_LIB_REQUIRED ON)
set (CPACK_COMPONENT_DEV_DEPENDS LIB PARENT_SCOPE)
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON PARENT_SCOPE)
set (CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON PARENT_SCOPE)
set (CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=" PARENT_SCOPE)
#set (CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON)
#set (DEBIAN_PACKAGE_BUILDS_DEPENDS "gcc (>=8), gcc-c++ (>=8), cmake (>=${CMAKE_MINIMUM_REQUIRED_VERSION})" PARENT_SCOPE)
set (CPACK_DEBIAN_LIB_PACKAGE_DEPENDS "cameo-server(>=1.0.2)" PARENT_SCOPE)
set(CPACK_DEBIAN_DEV_PACKAGE_NAME ${LIBNAME}-dev)
set(CPACK_DEBIAN_DEV_PACKAGE_NAME ${LIBNAME}-dev PARENT_SCOPE)
set(CPACK_DEBIAN_LIB_PACKAGE_NAME ${LIBNAME}-lib)
set(CPACK_DEBIAN_LIB_PACKAGE_NAME ${LIBNAME}-lib PARENT_SCOPE)
set(CPACK_DEBIAN_DEV_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_DEV_FILE_NAME ${CPACK_DEBIAN_DEV_PACKAGE_NAME}_${PROJECT_VERSION}_${CPACK_DEBIAN_DEV_PACKAGE_ARCHITECTURE}.deb PARENT_SCOPE)
set(CPACK_DEBIAN_LIB_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_LIB_FILE_NAME ${CPACK_DEBIAN_LIB_PACKAGE_NAME}_${PROJECT_VERSION}_${CPACK_DEBIAN_LIB_PACKAGE_ARCHITECTURE}.deb PARENT_SCOPE)
#if((${CMAKE_BUILD_TYPE} EQUAL "Debug") OR (${CMAKE_BUILD_TYPE} EQUAL "RelWithDebInfo"))
# set (CPACK_DEBIAN_DEBUGINFO_PACKAGE ON)
# set (CPACK_RPM_DEBUGINFO_PACKAGE ON)
#endif()
####### CPACK RPM
#message("CPACK SYSTEM NAME: ${CMAKE_SYSTEM_NAME}")
# cameo-api-cpp
## Dependencies This library provides the C++ API for Cameo.
- cmake 3.7.2
## Compilation dependencies
- cmake 3.12.0
- cppzmq - cppzmq
- rapidjson - [rapidjson](https://github.com/Tencent/rapidjson)
If not found on the system it is automatically downloaded and installed
- doxygen (optional) - doxygen (optional)
### CENTOS 8 For convenience, the packages for some major distributions are listed in the following:
List of packages: - CENTOS 8: `yum install -y cmake cppzmq-devel rapidjson-devel`
- cmake - Debian 10:
- cppzmq-devel - Ubuntu : `sudo apt install cmake libzmq3-dev rapidjson-dev`
- rapidjson-devel
## How to compile and install
``` ```
pkgs="cmake zeromq-devel rapidjson-devel" cmake -S . -B <build directory> -D<OPTION>
yum install -y $pkgs cmake --build <build directory>
``` ```
Possible options are:
- CMAKE_INSTALL_PREFIX=<your_chosen_install_basepath>: to install in a non-standard directory
### Debian XXX In order to install from source:
```
cmake --build <build directory> --target install
```
Debian packages can also be created by:
```
cpack -G DEB --config <build directory>/CPackConfig.cmake -B <build directory>/packaging
```
and be found in `<build directory>/packaging`
### Ubuntu XXX Two packages are created:
```sudo apt install cmake libzmq3-dev rapidjson-dev``` - -lib: the runtime library for the user
- -dev: the development package with the public headers and cmake config files
## Compilation instructions
## Running tests
To compile also the with the test programs:
``` ```
mkdir build/ cmake -S . -B build/ -DCAMEO_API_CPP_TESTS=ON ..
cd build/ cmake --build build/
cmake ..
cmake --build .
``` ```
Developers can follow the instructions [here](doc/DEVEL.md)
## Development
How to find the list of public headers and check that they are all in the include/ directory
1. move all the headers in src/
2. move cameo.h to include/
3. run the following command multiple times until there is no output
```
#!/bin/fish
set -l ORIG_DIR src
for f in (for file in include/*; grep include $file | grep '"'; end | sort | uniq | sed 's|.* "||;s|"||'); if [ -e $ORIG_DIR/$f ] ; echo $f; git mv $ORIG_DIR/$f include/; end; end
```
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(ZeroMQ)
find_dependency (Threads)
if(NOT TARGET ${NAMESPACE}::${LIBNAME})
include(${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-targets.cmake)
endif()
include(CMakeFindDependencyMacro)
find_dependency(ZeroMQ)
find_dependency (Threads)
include(${CMAKE_CURRENT_LIST_DIR}/cameo-api-cpp-static-targets.cmake)
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#ifndef CAMEO_H_ #ifndef CAMEO_H_
#define CAMEO_H_ #define CAMEO_H_
#define CAMEO_API_VERSION_MAJOR 1 #define CAMEO_API_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define CAMEO_API_VERSION_MINOR 0 #define CAMEO_API_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define CAMEO_API_VERSION_REVISION 2 #define CAMEO_API_VERSION_REVISION @PROJECT_VERSION_PATCH@
#include "Application.h" #include "Application.h"
#include "Server.h" #include "Server.h"
......
set(CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ON)
set(CPACK_PACKAGE_CHECKSUM MD5)
set(CPACK_PACKAGE_CONTACT "Yannick Le Goc <legoc@ill.fr>")
set(CPACK_PACKAGE_VENDOR "ILL")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY