Commit cadb06ae authored by Arnaud Le Meillour's avatar Arnaud Le Meillour
Browse files

Update CI/CD files

parent 6951e780
<<<<<<< HEAD
.project-build:
......@@ -26,12 +27,21 @@ variables:
REPO_DOCKER_IMG: gitlab-registry.esrf.fr/accelerators/cicd/ci-cd/tango-img
REPO_FS: segsrv.esrf.fr:/segfs/tango/release_gitlab/os/${OS_FS}
REPO_FS_PATH: /opt/os_dev
stages:
- build
- test
- deploy
=======
# This CI/CD Gitlab file include a centralized CI file : build_project.yml, frm local project : accelerators/cicd/ci-cd/ds-project-template, branch : rev1
# This centralized CI file load itself specific other file by OS which contain finale job to execute.
# You can override directives merge by these included file with the "masked job" below which are included by the main jobs.
# - If you add new directvie the previous declared one stay active
# - If you override exitente directive, you can use gitlab reference to include sub part of masked Job
# ex
#.project-build:
# script:
# - !reference [.common-build, script]
# - ls -la ...
>>>>>>> develop
<<<<<<< HEAD
###############################################################################
# To specifiy Gitlab unner which have docker engine available
.common-job:
......@@ -265,3 +275,22 @@ ubuntu20:release:deploy:
artifacts: true
=======
.project-build:
after_script:
- "## End of script."
.project-test:
after_script:
- "## End of script."
.project-deploy:
after_script:
- "## End of script."
include:
- project: 'accelerators/cicd/ci-cd/template'
ref: 'tango_9.3'
file: 'build_project.yml'
>>>>>>> develop
# Generic main project
project(Root)
cmake_minimum_required (VERSION 3.15)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(library)
include(init-project)
###############################################################################
# List of TANGO device servers to build (from defined classes/lib below)
set(PROJECT_BIN
Serial
)
# External shared libraries needed on this project
set(PROJECT_LIB_EXTERNAL
)
# 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_LIB_INTERNAL})
add_subdirectory(./classes/${CLASS})
endforeach()
endif()
# Local Tango Classes build in this project
addTangoClasses(Serial)
# 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
# Local Tango Servers build in this project
addTangoServers(Serial)
\ No newline at end of file
......@@ -3,7 +3,7 @@
C++ source for the SerialClass
Two branch available:
release:
dev:
develop:
## Cloning
......
......@@ -7,29 +7,10 @@ project(Serial
LANGUAGES
CXX
)
set(PROJECT_DEPENDENCIES )
# Tango Class dependencies (inheritance) declaration
set(TC_DEPENDENCIES )
###############################################################################
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)
#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)
elseif(UNIX)
List(APPEND SOURCE_FILES src/SerialLinux.cpp)
endif()
# Mgmt project tango class dependencies
include(${CMAKE_SOURCE_DIR}/cmake/add-dependencies.cmake)
# Build library
include(${CMAKE_SOURCE_DIR}/cmake/build-lib.cmake)
include(build-tango-class)
includeOptional(${CMAKE_CURRENT_SOURCE_DIR}/user-build.cmake)
# Specific Serial sources config
if(WIN32)
List(APPEND EXTRA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/SerialWin32.cpp)
elseif(UNIX)
List(APPEND EXTRA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/SerialLinux.cpp)
endif()
msg(STATUS "- Add extra files :")
print(EXTRA_FILES)
target_sources(${TC_TARGET}
PRIVATE
${EXTRA_FILES}
)
\ No newline at end of file
if(PROJECT_DEPENDENCIES)
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(TARGET_EXT_LIB)
message(STATUS "${USER_PREFIX}:: - add external class (shared lib): ${TARGET_EXT_LIB}")
endif()
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
set(BINARY_TARGET ${PROJECT_NAME}_binary)
add_executable(${BINARY_TARGET})
message(STATUS "${USER_PREFIX}:: - building binary ${PROJECT_NAME} via target ${BINARY_TARGET}")
target_sources(${BINARY_TARGET}
PRIVATE
${SOURCE_FILES}
)
target_link_libraries(${BINARY_TARGET}
PRIVATE
${GLOBAL_LIB}
${TARGET_EXT_LIB}
${TARGET_INT_LIB_TARGET}
)
target_link_directories(${BINARY_TARGET}
PRIVATE
${GLOBAL_LIB_DIR}
${TARGET_EXT_LIB_DIR}
)
target_include_directories(${BINARY_TARGET}
PRIVATE
${GLOBAL_INCLUDE_DIR}
${TARGET_EXT_LIB_INCLUDE_DIR}
${TARGET_INT_LIB_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_compile_options(${BINARY_TARGET}
PRIVATE
${COMPILE_OPTIONS}
)
target_compile_features(${BINARY_TARGET}
PRIVATE
${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}-${PROJECT_VERSION}
)
install(TARGETS ${BINARY_TARGET} EXPORT ${BINARY_TARGET}_export
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
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION
${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/cmake
PERMISSIONS
${DEFAULT_PERMISSIONS_LIB}
)
install(EXPORT ${LIB_TARGET}_export
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}-${PROJECT_VERSION}/cmake
PERMISSIONS ${DEFAULT_PERMISSIONS_LIB}
)
\ No newline at end of file
# Set specific Local variables
set(TC_TARGET ${PROJECT_NAME}_lib-target)
set(TC_EXPORT ${PROJECT_NAME}_lib-export)
# Target declaration
add_library(${TC_TARGET})
msg(STATUS "Define Library target ${TC_TARGET}")
###############################################################################
# DEFAULT TANGO CLASS BUILD CONFIGURATION #####################################
set(TC_COMPILE_FEATURES )
set(TC_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
)
set(CMAKE_INSTALL_CMAKEDIR cmake)
# Set name of output lib
set(TC_OUTPUT_NAME ${PROJECT_NAME})
set(TC_OUTPUT_NAME_RELEASE ${PROJECT_NAME})
set(TC_OUTPUT_NAME_DEBUG ${PROJECT_NAME})
set(TC_PERMISSIONS_LIB_FILES ) # Compilation features & options
set(TC_PERMISSIONS_CMAKE_FILES )
# INSTITUTE TANGO CLASS BUILD CONFIGURATION ###################################
configTangoClass()
###############################################################################
# Add Tango Classes dependencies
addDependencies(${TC_DEPENDENCIES})
# Get header files
getFiles(TC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include "*.hpp")
getFiles(TC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include "*.h")
target_sources(${TC_TARGET}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/${PROJECT_NAME}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/${PROJECT_NAME}Class.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/${PROJECT_NAME}StateMachine.cpp
)
# Add Version file
# configure_file(
# "${TC_TEMPLATE_DIR}/VersionConfig.h.in"
# "${CMAKE_CURRENT_BINARY_DIR}/VersionConfig.h"
# )
# target_sources(${TC_TARGET}
# PRIVATE
# ${CMAKE_CURRENT_BINARY_DIR}/VersionConfig.h
# )
target_link_libraries(${TC_TARGET}
PRIVATE
Tango_lib-target
PUBLIC
${TC_TANGO_CLASSES_TARGET}
)
target_include_directories(${TC_TARGET}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_compile_options(${TC_TARGET}
PRIVATE
${TC_COMPILE_OPTIONS}
)
target_compile_features(${TC_TARGET}
PRIVATE
${TC_COMPILE_FEATURES}
)
set_target_properties(${TC_TARGET}
PROPERTIES
OUTPUT_NAME ${TC_OUTPUT_NAME}
OUTPUT_NAME_RELEASE ${TC_OUTPUT_NAME_RELEASE}
OUTPUT_NAME_DEBUG ${TC_OUTPUT_NAME_DEBUG}
PUBLIC_HEADER "${TC_HEADER}"
SOVERSION ${PROJECT_VERSION_MAJOR}
VERSION ${PROJECT_VERSION}
INTERFACE_${PROJECT_NAME}_MAJOR_VERSION ${PROJECT_VERSION_MAJOR}
COMPATIBLE_INTERFACE_STRING ${PROJECT_NAME}_MAJOR_VERSION
)
install(TARGETS ${TC_TARGET}
EXPORT ${TC_EXPORT}
PERMISSIONS ${TC_PERMISSIONS_LIB_FILES}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
configure_package_config_file(
"${TC_TEMPLATE_DIR}/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY AnyNewerVersion # <AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion>
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION
${CMAKE_INSTALL_CMAKEDIR}
PERMISSIONS
${TC_PERMISSIONS_CMAKE_FILES}
)
export(EXPORT ${TC_EXPORT}
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
NAMESPACE ${PROJECT_NAME}::
)
install(EXPORT ${TC_EXPORT}
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
PERMISSIONS ${TC_PERMISSIONS_CMAKE_FILES}
)
include(debug)
\ No newline at end of file
# Set specific Local variables
set(TC_TARGET ${PROJECT_NAME}_bin-target)
set(TC_EXPORT ${PROJECT_NAME}_bin-export)
# Target declaration
add_executable(${TC_TARGET})
msg(DEBUG "Define Executable target ${TC_TARGET}")
################################################################################
# DEFAULT TANGO SERVER BUILD CONFIGURATION #####################################
set(TC_PERMISSIONS_BIN_FILES )
set(TC_COMPILE_FEATURES ) # Compilation features & options
set(TC_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
)
# Set name of output Device server binary
set(TC_OUTPUT_NAME ${PROJECT_NAME})
set(TC_OUTPUT_NAME_RELEASE ${PROJECT_NAME})
set(TC_OUTPUT_NAME_DEBUG ${PROJECT_NAME})
# INSTITUTE TANGO SERVER BUILD CONFIGURATION ###################################
configTangoServer()
################################################################################
# Add Tango Classes dependencies
addDependencies(${TC_DEPENDENCIES})
target_sources(${TC_TARGET}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/MultiClassesFactory.cpp
)
target_link_libraries(${TC_TARGET}
PRIVATE
Tango_lib-target
${TC_TANGO_CLASSES_TARGET}
)
target_include_directories(${TC_TARGET}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_compile_options(${TC_TARGET}
PRIVATE
${TC_COMPILE_OPTIONS}
)
target_compile_features(${TC_TARGET}
PRIVATE
${TC_COMPILE_FEATURES}
)
set_target_properties(${TC_TARGET}
PROPERTIES
OUTPUT_NAME ${TC_OUTPUT_NAME}
OUTPUT_NAME_RELEASE ${TC_OUTPUT_NAME_RELEASE}
OUTPUT_NAME_DEBUG ${TC_OUTPUT_NAME_DEBUG}
)
install(TARGETS ${TC_TARGET} EXPORT ${TC_EXPORT}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS ${TC_PERMISSIONS_BIN_FILES}
)
include(debug)
\ No newline at end of file
message("# LOAD DEFAULT CONFIGURATION - default-config.cmake")
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there." )
endif()
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_SKIP_RPATH true)
set(USER_PREFIX "LOG")
#include(FindPkgConfig)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Compilation features & options
set(COMPILE_FEATURES cxx_std_11)
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
)