Commit 069db9e8 authored by Arnaud Le Meillour's avatar Arnaud Le Meillour
Browse files

Merge branch 'develop' into 'release'

Version 2.1.0

See merge request !1
parents 5eaaaf57 5ba552cd
Pipeline #64613 passed with stages
in 26 seconds
......@@ -12,6 +12,7 @@ obj/
bin/
build/
.project
.idea
/.metadata/
.settings/
core
......
......@@ -4,153 +4,46 @@ variables:
stages:
- build
- test
- deploy
#- trig
.build:debug: &build-debug
.common-build:
stage: build
only:
- develop
- branches
- merge_requests
- tags
script:
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Debug -DRES_DIR=${RES_DIR} -DCMAKE_INSTALL_PREFIX=/opt/os_dev ..
- cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..
- make -j
- tree -Ca -I ".*" ..
artifacts:
paths:
- build
expire_in: 1 day
.build:release: &build-release
.common-test:
stage: test
only:
- develop
- branches
- merge_requests
script:
- mkdir build && cd build
- cmake -DCMAKE_BUILD_TYPE=Release -DRES_DIR=${RES_DIR} -DCMAKE_INSTALL_PREFIX=/opt/os_dev ..
- make -j
- tree -Ca -I ".*" ..
artifacts:
paths:
- build
expire_in: 1 day
- cd build
- mkdir $CI_PROJECT_DIR/test
- make DESTDIR=$CI_PROJECT_DIR/test install
- tree -Ca $CI_PROJECT_DIR/test
.deploy: &deploy
.common-deploy:
stage: deploy
only:
- develop
- merge_requests
when: manual
- tags
script:
- cd build
- test -d /opt/os_dev
- '[[ -d ${BUILD_DIR}/lib/classes ]]'
- make install
- tree -Ca -I '.*' /opt/os_dev
# JOB DEBIAN 9 ################################################
build:debian9:debug:
stage: build
tags:
- shell, debian9
before_script:
- export RES_DIR=/segfs/tango/release/debian9
<<: *build-debug
build:debian9:release:
stage: build
tags:
- shell, debian9
before_script:
- export RES_DIR=/segfs/tango/release/debian9
<<: *build-release
deploy:debian9:debug:
stage: deploy
tags:
- shell, debian9
<<: *deploy
needs:
- build:debian9:debug
deploy:debian9:release:
stage: deploy
tags:
- shell, debian9
<<: *deploy
needs:
- build:debian9:release
# JOB UBUNTU 20.04 ################################################
build:ubuntu20.04:debug:
stage: build
tags:
- shell, ubuntu20
before_script:
- export RES_DIR=/segfs/tango/release/ubuntu20.04
<<: *build-debug
build:ubuntu20.04:release:
stage: build
tags:
- shell, ubuntu20
before_script:
- export RES_DIR=/segfs/tango/release/ubuntu20.04
<<: *build-release
deploy_ubuntu20.04:debug:
stage: deploy
tags:
- shell, ubuntu20
<<: *deploy
needs:
- build:ubuntu20.04:debug
deploy_ubuntu20.04:release:
stage: deploy
tags:
- shell, ubuntu20
<<: *deploy
needs:
- build:ubuntu20.04:release
##############################################
# trigger:downstream:
# stage: trig
# only:
# - master
# when: manual
# inherit:
# variables: false
# trigger:
# project: accelerators/tosort/modbus
# branch: master
# Install CMake withe docker image
# cd /tmp
# wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2-linux-x86_64.sh
# chmod +x cmake-3.20.2-linux-x86_64.sh
# ./cmake-3.20.2-linux-x86_64.sh
#make package
include:
- project: 'accelerators/cicd/templates_cicd/template-rev1'
ref: main
file: '/build_project.yml'
set(HOME_PREFIX ESRF)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
message("")
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "${HOME_PREFIX}::In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there." )
endif()
# Check if execute from GitLab
if(DEFINED ENV{CI_COMMIT_SHA})
set(BATCH YES)
message(STATUS "${HOME_PREFIX}::build ${CMAKE_BUILD_TYPE} (GitLab)")
else()
set(BATCH NO)
message(STATUS "${HOME_PREFIX}::build ${CMAKE_BUILD_TYPE} (interactive)")
endif()
cmake_minimum_required (VERSION 3.9)
set(CMAKE_SKIP_RPATH true)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(./cmake/lib.cmake)
#######################################
# Generic main project
project(Root)
cmake_minimum_required (VERSION 3.15)
#######################################
# All the classes available for project servers
set(PROJECT_CLASSES_SHARED
)
set(PROJECT_CLASSES_LOCAL
###############################################################################
# List of TANGO device servers to build (from defined classes/lib below)
set(PROJECT_BIN
Serial
)
Set(PROJECT_CLASSES_LOCAL_TO_IGNORE
# External shared libraries needed on this project
set(PROJECT_LIB_EXTERNAL
)
#######################################
# make cache variables for install destinations
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
#######################################
# Tango resources
## Until use find_package() for Tango lib, give static path by arg
message("TANGO LIB RESOURCES ##############################")
if((DEFINED RES_DIR) AND (EXISTS ${RES_DIR}))
message(STATUS "${HOME_PREFIX}::RES_DIR defined: ${RES_DIR}")
else()
message(FATAL_ERROR "${HOME_PREFIX}::No RES_DIR defined to get TANGO LIB")
endif()
set(TANGO_LIB tango;COS4;omniORB4;omniDynamic4;omnithread;zmq;dl;pthread)
message(STATUS "${HOME_PREFIX}::Libraries include: ${TANGO_LIB}")
set(TANGO_LIB_DIR ${RES_DIR}/lib)
message(STATUS "${HOME_PREFIX}::Libraries path: ${TANGO_LIB_DIR}")
set(TANGO_INCLUDE_DIR ${RES_DIR}/include/tango)
set(TANGO_DEPENDENCY_INCLUDE_DIR ${RES_DIR}/include)
message(STATUS "${HOME_PREFIX}::TANGO include path: ${TANGO_INCLUDE_DIR} ${TANGO_DEPENDENCY_INCLUDE_DIR}")
#######################################
# Project classes
message("TANGO CLASSES RESOURCES ##############################")
message("## search local class directory...")
GET_SUBDIRS(SUBDIRS ${PROJECT_SOURCE_DIR}/classes)
unset(CLASS CACHE)
foreach(CLASS IN ITEMS ${SUBDIRS})
list(APPEND CLASSES_LOCAL_FOUND ${CLASS})
endforeach()
unset(CLASS CACHE)
foreach(CLASS IN ITEMS ${PROJECT_CLASSES_LOCAL_TO_IGNORE})
list(REMOVE_ITEM CLASSES_LOCAL_FOUND ${CLASS})
endforeach()
if(CLASSES_LOCAL_FOUND)
message(STATUS "${HOME_PREFIX}::Local classes found: ${CLASSES_LOCAL_FOUND}")
else()
message(STATUS "${HOME_PREFIX}::No local classes found !")
endif()
if(PROJECT_CLASSES_SHARED)
message("## Get shared class env info...")
set(_PROJECT_CLASSES_SHARED ${PROJECT_CLASSES_SHARED})
while(_PROJECT_CLASSES_SHARED)
list(POP_FRONT _PROJECT_CLASSES_SHARED CLASS_NAME CLASS_VERSION)
#set(CMAKE_FIND_DEBUG_MODE TRUE)
find_package(${CLASS_NAME} ${CLASS_VERSION} REQUIRED)
#set(CMAKE_FIND_DEBUG_MODE FALSE)
message(STATUS "${HOME_PREFIX}::Load shared class ${CLASS_NAME} in version ${CLASS_VERSION}")
message(STATUS "${HOME_PREFIX}:: - ${CLASS_NAME}_LIB = ${${CLASS_NAME}_LIB}")
message(STATUS "${HOME_PREFIX}:: - ${CLASS_NAME}_LIB_DIR = ${${CLASS_NAME}_LIB_DIR}")
message(STATUS "${HOME_PREFIX}:: - ${CLASS_NAME}_INCLUDE_DIR = ${${CLASS_NAME}_INCLUDE_DIR}")
endwhile()
endif()
if(PROJECT_CLASSES_LOCAL)
message("## Build static from local class...")
# Local shared libraries needed on this project
set(PROJECT_LIB_INTERNAL
Serial
)
# Default global dependencies
set(DEFAULT_LIB_TANGO tango;COS4;omniORB4;omniDynamic4;omnithread;zmq)
set(DEFAULT_LIB_SYSTEM dl;pthread)
###############################################################################
# Load base cmake macro
include(./cmake/macro/default-macro.cmake)
# Load user cmake macro
include(./cmake/macro/user-macro.cmake)
# Load base cmake configuration
include(./cmake/config/default-config.cmake)
# Load user cmake configuration
include(./cmake/config/user-config.cmake)
# Load external libraries
include(./cmake/find-lib.cmake)
# Build internal libraries
if(PROJECT_LIB_INTERNAL)
message("# BUILD INTERNAL LIB")
unset(CLASS CACHE)
foreach(CLASS IN ITEMS ${PROJECT_CLASSES_LOCAL})
if(${CLASS} IN_LIST CLASSES_LOCAL_FOUND)
add_subdirectory(./classes/${CLASS})
else()
message(FATAL_ERROR "${HOME_PREFIX}::Requested class ${CLASS} not available !" )
endif()
foreach(CLASS IN ITEMS ${PROJECT_LIB_INTERNAL})
add_subdirectory(./classes/${CLASS})
endforeach()
endif()
#######################################
# Build device servers binary
message("TANGO DEVICE SERVERS ##############################")
add_subdirectory(servers/Serial)
#######################################
# Debud info
#include(${CMAKE_SOURCE_DIR}/cmake/env.cmake)
# Build TANGO device servers
if(PROJECT_BIN)
message("# BUILD TANGO DEVICE SERVERS")
unset(DEVICE_SERVER CACHE)
foreach(DEVICE_SERVER IN ITEMS ${PROJECT_BIN})
add_subdirectory(servers/${DEVICE_SERVER})
endforeach()
endif()
\ No newline at end of file
......@@ -8,36 +8,28 @@ project(Serial
CXX
)
set(PROJECT_DEPENDENCIES )
set(BUILD_SHARED YES)
###############################################################################
message(STATUS "${HOME_PREFIX}::Prepare build(s) for TANGO class ${PROJECT_NAME} in version ${PROJECT_VERSION}")
message(STATUS "${USER_PREFIX}::Build TANGO class ${PROJECT_NAME} in version ${PROJECT_VERSION}")
# If your build need more specific directives, replace include file by it's containt and custom your build.
#######################################
# Add project source files
unset(_SOURCE_FILES)
set(_SOURCE_FILES
unset(SOURCE_FILES)
#AUX_SOURCE_DIRECTORY(./src SOURCE_FILES)
set(SOURCE_FILES
src/${PROJECT_NAME}.cpp
src/${PROJECT_NAME}Class.cpp
src/${PROJECT_NAME}StateMachine.cpp
)
if(WIN32)
List(APPEND _SOURCE_FILES src/SerialWin32.cpp)
List(APPEND SOURCE_FILES src/SerialWin32.cpp)
elseif(UNIX)
List(APPEND _SOURCE_FILES src/SerialLinux.cpp)
List(APPEND SOURCE_FILES src/SerialLinux.cpp)
endif()
#######################################
# Mgmt project tango class dependencies
include(${CMAKE_SOURCE_DIR}/cmake/add-dependencies.cmake)
#######################################
# Build Static lib
include(${CMAKE_SOURCE_DIR}/cmake/build-static.cmake)
#######################################
# Build Shared Lib
if(BUILD_SHARED STREQUAL YES)
include(${CMAKE_SOURCE_DIR}/cmake/build-shared.cmake)
endif(BUILD_SHARED STREQUAL YES)
# Build library
include(${CMAKE_SOURCE_DIR}/cmake/build-lib.cmake)
if(PROJECT_DEPENDENCIES)
unset(_CLASS CACHE)
foreach(_CLASS IN ITEMS ${PROJECT_DEPENDENCIES})
if(${_CLASS} IN_LIST PROJECT_CLASSES_SHARED)
list(APPEND CLASSES_SHARED ${${_CLASS}_LIB})
list(APPEND CLASSES_SHARED_LIB_DIR ${${_CLASS}_LIB_DIR})
list(APPEND CLASSES_SHARED_INCLUDE_DIR ${${_CLASS}_INCLUDE_DIR})
elseif(${_CLASS} IN_LIST PROJECT_CLASSES_LOCAL)
#list(APPEND CLASSES_LOCAL ${_CLASS})
list(APPEND CLASSES_LOCAL_TARGET ${_CLASS}_static)
list(APPEND CLASSES_LOCAL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/classes/${_CLASS}/include)
unset(_LIB CACHE)
foreach(_LIB IN ITEMS ${PROJECT_DEPENDENCIES})
if(${_LIB} IN_LIST PROJECT_LIB_EXTERNAL)
list(APPEND TARGET_EXT_LIB ${${_LIB}_LIB})
list(APPEND TARGET_EXT_LIB_DIR ${${_LIB}_LIB_DIR})
list(APPEND TARGET_EXT_LIB_INCLUDE_DIR ${${_LIB}_INCLUDE_DIR})
elseif(${_LIB} IN_LIST PROJECT_LIB_INTERNAL)
list(APPEND TARGET_INT_LIB ${_LIB})
list(APPEND TARGET_INT_LIB_TARGET ${_LIB}_target)
list(APPEND TARGET_INT_LIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/classes/${_LIB}/include)
else()
message(FATAL_ERROR "${USER_PREFIX}:: - fail to load class (not found): ${_LIB}")
endif()
endforeach()
if(CLASSES_SHARED)
message(STATUS "${HOME_PREFIX}:: - add shared class: ${CLASSES_SHARED}")
if(TARGET_EXT_LIB)
message(STATUS "${USER_PREFIX}:: - add external class (shared lib): ${TARGET_EXT_LIB}")
endif()
if(CLASSES_LOCAL_TARGET)
message(STATUS "${HOME_PREFIX}:: - add static class: ${CLASSES_LOCAL_TARGET}")
if(TARGET_INT_LIB_TARGET)
message(STATUS "${USER_PREFIX}:: - add local class (shared lib): ${TARGET_INT_LIB_TARGET}")
endif()
endif()
\ No newline at end of file
unset(_SOURCE_FILES)
AUX_SOURCE_DIRECTORY(./src _SOURCE_FILES)
\ No newline at end of file
set(BINARY_TARGET ${PROJECT_NAME}_binary)
add_executable(${BINARY_TARGET})
message(STATUS "${HOME_PREFIX}:: - building binary ${BINARY_TARGET}")
message(STATUS "${USER_PREFIX}:: - building binary ${PROJECT_NAME} via target ${BINARY_TARGET}")
target_sources(${BINARY_TARGET}
PRIVATE
${_SOURCE_FILES}
${SOURCE_FILES}
)
target_link_libraries(${BINARY_TARGET}
PRIVATE
${TANGO_LIB}
${CLASSES_SHARED}
${CLASSES_LOCAL_TARGET}
${GLOBAL_LIB}
${TARGET_EXT_LIB}
${TARGET_INT_LIB_TARGET}
)
target_link_directories(${BINARY_TARGET}
PRIVATE
${TANGO_LIB_DIR}
${CLASSES_SHARED_LIB_DIR}
${GLOBAL_LIB_DIR}
${TARGET_EXT_LIB_DIR}
)
target_include_directories(${BINARY_TARGET}
PRIVATE
${TANGO_INCLUDE_DIR}
${TANGO_DEPENDENCY_INCLUDE_DIR}
${CLASSES_SHARED_INCLUDE_DIR}
${CLASSES_LOCAL_INCLUDE_DIR}
${GLOBAL_INCLUDE_DIR}
${TARGET_EXT_LIB_INCLUDE_DIR}
${TARGET_INT_LIB_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
unset(_COMPILE_OPTIONS)
if(BATCH STREQUAL YES)
set(_COMPILE_OPTIONS
-W # Inhibit all warning messages.
)
else()
set(_COMPILE_OPTIONS
#-Werror # Make all warnings into errors.
-Wall # This enables all the warnings.
-Wextra # This enables some extra warning flags.
-Wpedantic # Issue all the warnings demanded by strict ISO C and ISO C++
-Wnon-virtual-dtor # warns whenever a class with virtual function does not declare a virtual destructor.
-Wshadow # Warn whenever a local variable or type declaration shadows another variable
)
endif()
target_compile_options(${BINARY_TARGET}
PRIVATE
${_COMPILE_OPTIONS}
${COMPILE_OPTIONS}
)
target_compile_features(${BINARY_TARGET}
PRIVATE
cxx_std_11
${COMPILE_FEATURES}
)
set_target_properties(${BINARY_TARGET}
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}-${PROJECT_VERSION}
OUTPUT_NAME_RELEASE ${PROJECT_NAME}-${PROJECT_VERSION}
OUTPUT_NAME_DEBUG ${PROJECT_NAME}_d-${PROJECT_VERSION}
OUTPUT_NAME_DEBUG ${PROJECT_NAME}-${PROJECT_VERSION}
)
install(TARGETS ${BINARY_TARGET} EXPORT ${BINARY_TARGET}_export
DESTINATION "${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}"
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}
PERMISSIONS ${DEFAULT_PERMISSIONS_BIN}
)
\ No newline at end of file
set(LIB_TARGET ${PROJECT_NAME}_target)
add_library(${LIB_TARGET})
message(STATUS "${USER_PREFIX}:: - building library ${PROJECT_NAME} via target ${LIB_TARGET}")
unset(PUBLIC_HEADER)
GET_HEADER_FILES(_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include)
foreach(_HEADER IN ITEMS ${_HEADERS})
list(APPEND PUBLIC_HEADER include/${_HEADER})
endforeach()
target_sources(${LIB_TARGET}
PRIVATE
${SOURCE_FILES}
)
target_link_libraries(${LIB_TARGET}
PRIVATE
${GLOBAL_LIB}
PUBLIC
${TARGET_EXT_LIB}
${TARGET_INT_LIB_TARGET}
)
target_link_directories(${LIB_TARGET}
PRIVATE
${GLOBAL_LIB_DIR}
PUBLIC
${TARGET_EXT_LIB_DIR}
)
target_include_directories(${LIB_TARGET}
PRIVATE
${GLOBAL_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
${TARGET_INT_LIB_INCLUDE_DIR}
PUBLIC
${TARGET_EXT_LIB_INCLUDE_DIR}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/include>
)
target_compile_options(${LIB_TARGET}
PRIVATE
${COMPILE_OPTIONS}
)
target_compile_features(${LIB_TARGET}
PRIVATE
${COMPILE_FEATURES}
)
set_target_properties(${LIB_TARGET}
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
OUTPUT_NAME_RELEASE ${PROJECT_NAME}
OUTPUT_NAME_DEBUG ${PROJECT_NAME}
PUBLIC_HEADER "${PUBLIC_HEADER}"
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
)
install(TARGETS ${LIB_TARGET} EXPORT ${LIB_TARGET}_export
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/lib
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/include
INCLUDES DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/include
PERMISSIONS ${DEFAULT_PERMISSIONS_LIB}
)
configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/template/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/cmake
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
COMPATIBILITY AnyNewerVersion
)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
unset(SOURCES)
GET_HEADER_FILES(_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src)
foreach(_HEADER IN ITEMS ${_HEADERS})
list(APPEND SOURCES src/${_HEADER})
endforeach()
GET_SOURCE_FILES(_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src)
foreach(_SRC IN ITEMS ${_SRC_FILES})
list(APPEND SOURCES src/${_SRC})
endforeach()
install(
FILES
${SOURCES}
DESTINATION
${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/src
PERMISSIONS
${DEFAULT_PERMISSIONS_LIB}
)
endif()
install(
FILES