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

Update CMake files

parent c0ef6f14
Pipeline #81228 passed with stages
.project-build:
after_script:
- "## End of script."
# Additional directive to this project
.project-test:
.project-build:
after_script:
- "## End of script."
......@@ -12,5 +10,5 @@
include:
- project: 'accelerators/cicd/ci-cd/template'
ref: 'tango_9.3'
file: 'build_project.yml'
ref: 'Tango_9.3_A'
file: 'build_project.yml'
\ No newline at end of file
# Generic main project
project(Root)
cmake_minimum_required (VERSION 3.15)
cmake_minimum_required (VERSION 3.16)
include(./cmake/library.cmake)
include(./cmake/init-project.cmake)
###############################################################################
# DEFAULT PROJECT CONFIGURATION
# Configure local tango Targets (Classes & Servers)
addTangoTarget(
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_VERBOSE_MAKEFILE OFF) # Show all variables list in debug.cmake by target
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_SKIP_RPATH true)
OPTION(BUILD_SHARED_LIBS "Build Tango classes as Shared libraries" ON)
###############################################################################
# Load (if exists) cmake INSTITUTE configuration file with include macro with name:
# - configProject() -> Load after main configuration in this file
# - configTangoClass() -> Load after default Tango Class target configuration
# - configTangoServer() -> Load after default Tango Server target configuration
#
includeOptional("/opt/os_dev/ESRF-config.cmake")
include(./cmake/build-common.cmake)
###############################################################################
# External Tango Classes needed by this project
getTangoClass(BY_FS
NAME Serial
VERSION 2
SEARCH_DIR "/opt/os_dev/release/classes/Serial/current"
)
###############################################################################
# Local Tango Classes build in this project
addTangoTargets(
DEVICE_CLASSES
AttributeCombiner
AttributeCombiner 1.0.2
DEVICE_SERVERS
AttributeCombiner
AttributeCombiner 1.0.2
)
###############################################################################
project(AttributeCombiner
VERSION
1.0.2
${_VERSION}
DESCRIPTION
"A Class to allows to group or merge scalar or spectrum attributes."
LANGUAGES
CXX
)
# Tango Class dependencies (inheritance) declaration
# Tango Class dependencies (inheritance from parent Tango Class) declaration
set(TC_DEPENDENCIES )
###############################################################################
# Build library
......
# Specific Modbus sources config
List(APPEND EXTRA_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/AttributeMap.cpp
# To add extra sources files for this Tango class,
# use addExtraFiles() macro
addExtraFiles(
AttributeMap.cpp
)
msg(STATUS "- Add extra files :")
print(EXTRA_FILES)
target_sources(${TC_TARGET}
PRIVATE
${EXTRA_FILES}
)
\ No newline at end of file
###############################################################################
# Load (if exists) cmake INSTITUTE configuration file with include macro with name:
# - configProject() -> Load after main configuration in this file
# - configTangoClass() -> Load after default Tango Class target configuration
# - configTangoServer() -> Load after default Tango Server target configuration
#
includeOptional("/opt/os_dev/ESRF-config.cmake")
###############################################################################
###############################################################################
# DEFAULT PROJECT CONFIGURATION
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) # Show all variables list in debug.cmake by target
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_SKIP_RPATH true)
OPTION(BUILD_SHARED_LIBS "Build Tango classes as Shared libraries" ON)
# Detect some system environment variables and if existing, recreate them as CMake variables
# to use them for config
......@@ -67,22 +45,23 @@ getGitInfo()
msg(SECTION "CONFIGURE TANGO LIBRARIES TARGET : Tango_lib-target")
# GET TANGO LIBRARIES
set(TC_TANGO_LIB dl;pthread;zmq;omniORB4;COS4;omniDynamic4;omnithread;tango)
#set(TC_TANGO_LIB dl;pthread;zmq;omniORB4;COS4;omniDynamic4;omnithread;tango)
set(TC_TANGO_LIB)
set(TC_TANGO_LIB_DIR)
set(TC_TANGO_LIB_INCLUDE_DIR)
if(NOT TARGET Tango_lib-target)
#-ZeroMQ-####################
findLib(
NAME zmq
NAME_CMAKE ZeroMQ
NAME_PKG_CONFIG libzmq
VERSION ${TC_ZMQ_VERSION}
SEARCH_DIR ${TC_ZMQ_DIR}
OUTPUT_LIB_DIR TC_TANGO_LIB_DIR
OUTPUT_INCLUDE_DIR TC_TANGO_LIB_INCLUDE_DIR
)
# #-ZeroMQ-####################
# findLib(
# NAME zmq
# NAME_CMAKE ZeroMQ
# NAME_PKG_CONFIG libzmq
# VERSION ${TC_ZMQ_VERSION}
# SEARCH_DIR ${TC_ZMQ_DIR}
# OUTPUT_LIB_DIR TC_TANGO_LIB_DIR
# OUTPUT_INCLUDE_DIR TC_TANGO_LIB_INCLUDE_DIR
# )
#-CppZMQ-####################
findLib(
......@@ -90,19 +69,20 @@ if(NOT TARGET Tango_lib-target)
NAME_CMAKE cppzmq
VERSION ${TC_CPPZMQ_VERSION}
SEARCH_DIR ${TC_ZMQ_DIR};${TC_CPPZMQ_DIR}
OUTPUT_LIB TC_TANGO_LIB
OUTPUT_LIB_DIR TC_TANGO_LIB_DIR
OUTPUT_INCLUDE_DIR TC_TANGO_LIB_INCLUDE_DIR
)
#-omniORB-####################
findLib(
NAME omniORB
NAME_PKG_CONFIG omniORB4
VERSION ${TC_OMNIORB_VERSION}
SEARCH_DIR ${TC_OMNIORB_DIR}
OUTPUT_LIB_DIR TC_TANGO_LIB_DIR
OUTPUT_INCLUDE_DIR TC_TANGO_LIB_INCLUDE_DIR
)
# #-omniORB-####################
# findLib(
# NAME omniORB
# NAME_PKG_CONFIG omniORB4
# VERSION ${TC_OMNIORB_VERSION}
# SEARCH_DIR ${TC_OMNIORB_DIR}
# OUTPUT_LIB_DIR TC_TANGO_LIB_DIR
# OUTPUT_INCLUDE_DIR TC_TANGO_LIB_INCLUDE_DIR
# )
#-cppTango-####################
findLib(
......@@ -110,6 +90,7 @@ if(NOT TARGET Tango_lib-target)
NAME_PKG_CONFIG tango
VERSION ${TC_CPPTANGO_VERSION}
SEARCH_DIR ${TC_ZMQ_DIR};${TC_CPPZMQ_DIR};${TC_OMNIORB_DIR};${TC_CPPTANGO_DIR}
OUTPUT_LIB TC_TANGO_LIB
OUTPUT_LIB_DIR TC_TANGO_LIB_DIR
OUTPUT_INCLUDE_DIR TC_TANGO_LIB_INCLUDE_DIR
)
......
......@@ -52,14 +52,14 @@ target_sources(${TC_TARGET}
)
# 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
# )
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
......@@ -107,6 +107,7 @@ install(TARGETS ${TC_TARGET} Tango_lib-target
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# Add Cmake config file
configure_package_config_file(
"${TC_TEMPLATE_DIR}/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
......
......@@ -28,6 +28,7 @@ if(CMAKE_VERBOSE_MAKEFILE)
printDebug(CMAKE_MODULE_PATH)
printDebug(CMAKE_VERBOSE_MAKEFILE)
printDebug(CMAKE_BUILD_TYPE)
printDebug(CMAKE_BUILD_DIRECTORY)
printDebug(CMAKE_BUILD_FILES_DIRECTORY)
......
......@@ -91,7 +91,7 @@ endmacro()
# if it does not already have a value
#
macro(setVarEmpty VAR_CMAKE VALUE)
if(${VAR_CMAKE}})
if(${VAR_CMAKE})
if("S{${VAR_CMAKE}}" STREQUAL "")
msg(DEBUG_1 "Empty variable ${VAR_CMAKE} set with value : ${VALUE}")
set(${VAR_CMAKE} ${VALUE})
......@@ -144,7 +144,40 @@ macro(addDependencies)
endmacro()
############################################
# Macro to Add Extra files in current Target
#
#
macro(addExtraFiles)
if(${ARGC} GREATER 0)
foreach(_FILES IN ITEMS ${ARGN})
List(APPEND EXTRA_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/${_FILES}
)
endforeach()
msg(STATUS_1 "Add extra files :")
print(EXTRA_FILES)
target_sources(${TC_TARGET}
PRIVATE
${EXTRA_FILES}
)
endif()
endmacro()
############################################
# Empty Macro available for override and add specific institute configuration
#
#
macro(configProject)
endmacro()
macro(configTangoClass)
endmacro()
macro(configTangoServer)
endmacro()
#########################################################################################################
......@@ -478,7 +511,7 @@ function(findLib)
# Parse the parameters
set(ARGS_OPTIONS )
set(ARGS_ONE_VALUE NAME NAME_CMAKE NAME_PKG_CONFIG VERSION OUTPUT_LIB_DIR OUTPUT_INCLUDE_DIR)
set(ARGS_ONE_VALUE NAME NAME_CMAKE NAME_PKG_CONFIG VERSION OUTPUT_LIB OUTPUT_LIB_DIR OUTPUT_INCLUDE_DIR)
set(ARGS_MULTI_VALUE SEARCH_DIR)
cmake_parse_arguments(_LIB "${ARGS_OPTIONS}" "${ARGS_ONE_VALUE}" "${ARGS_MULTI_VALUE}" ${ARGN})
......@@ -506,6 +539,9 @@ function(findLib)
printDebug(${_LIB_NAME_CMAKE}_LIB_DIR)
endif()
# Update Parent scope variables
if(DEFINED ${_LIB_NAME_PKG_CONFIG}_LIBRARY)
appendParentScope(${_LIB_OUTPUT_LIB} "${${_LIB_NAME_PKG_CONFIG}_LIBRARY}")
endif()
if(DEFINED ${_LIB_NAME_CMAKE}_LIB_DIR )
appendParentScope(${_LIB_OUTPUT_LIB_DIR} ${${_LIB_NAME_CMAKE}_LIB_DIR})
endif()
......@@ -524,6 +560,8 @@ function(findLib)
# Change format of control version for PkgConfig search
if(_LIB_VERSION)
set(ARG_VERSION ${_LIB_NAME_PKG_CONFIG}>=${_LIB_VERSION})
else()
set(ARG_VERSION ${_LIB_NAME_PKG_CONFIG})
endif()
msg(DEBUG " - Search ${_LIB_NAME_PKG_CONFIG} (${ARG_VERSION}) via Pkg-Config")
printDebug(CMAKE_PREFIX_PATH)
......@@ -543,6 +581,9 @@ function(findLib)
printDebug(${_LIB_NAME_PKG_CONFIG}_PREFIX)
printDebug(${_LIB_NAME_PKG_CONFIG}_LIBDIR)
# Update Parent scope variables
if(DEFINED ${_LIB_NAME_PKG_CONFIG}_LIBRARIES)
appendParentScope(${_LIB_OUTPUT_LIB} "${${_LIB_NAME_PKG_CONFIG}_LIBRARIES}")
endif()
if(DEFINED ${_LIB_NAME_PKG_CONFIG}_LIBRARY_DIRS)
appendParentScope(${_LIB_OUTPUT_LIB_DIR} "${${_LIB_NAME_PKG_CONFIG}_LIBRARY_DIRS}")
endif()
......@@ -651,7 +692,7 @@ endfunction()
# Function to execute add_subdirectory() directive for each target
# Tango classes ad tango servers
#
function(addTangoTarget)
function(addTangoTargets)
# Parse the parameters
set(ARGS_OPTIONS )
......@@ -659,22 +700,29 @@ function(addTangoTarget)
set(ARGS_MULTI_VALUE DEVICE_CLASSES DEVICE_SERVERS)
cmake_parse_arguments(_TARGET "${ARGS_OPTIONS}" "${ARGS_ONE_VALUE}" "${ARGS_MULTI_VALUE}" ${ARGN})
foreach(_TARGET IN ITEMS ${_TARGET_DEVICE_CLASSES})
set(CLASSES_TARGET ${_TARGET_DEVICE_CLASSES})
while(CLASSES_TARGET)
list(POP_FRONT CLASSES_TARGET _TARGET _VERSION)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/classes/${_TARGET}/CMakeLists.txt)
msg(SECTION "CONFIGURE TANGO CLASS TARGET : ${_TARGET}")
msg(SECTION "CONFIGURE TANGO CLASS TARGET : ${_TARGET} with version ${_VERSION}")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/classes/${_TARGET})
else()
msg(FATAL_ERROR "Fail to add target ${_TARGET}")
msg(FATAL_ERROR "Fail to add target ${_TARGET} in version ${_VERSION}")
endif()
endforeach()
endwhile()
foreach(_TARGET IN ITEMS ${_TARGET_DEVICE_SERVERS})
set(SERVERS_TARGET ${_TARGET_DEVICE_SERVERS})
while(SERVERS_TARGET)
list(POP_FRONT SERVERS_TARGET _TARGET _VERSION)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/servers/${_TARGET}/CMakeLists.txt)
msg(SECTION "CONFIGURE TANGO SERVER TARGET : ${_TARGET}")
msg(SECTION "CONFIGURE TANGO SERVER TARGET : ${_TARGET} with version ${_VERSION}")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/servers/${_TARGET})
else()
msg(FATAL_ERROR "Fail to add target ${_TARGET}")
msg(FATAL_ERROR "Fail to add target ${_TARGET} in version ${_VERSION}")
endif()
endforeach()
endwhile()
message("")
endfunction()
......@@ -4,11 +4,11 @@
#ifndef RELEASE_VERSION_H
#define RELEASE_VERSION_H
const std::string VersionMajor = "${VERSION_MAJOR}";
const std::string VersionMinor = "${VERSION_MINOR}";
const std::string VersionPatch = "${VERSION_PATCH}";
const std::string VersionMajor = "${PROJECT_VERSION_MAJOR}";
const std::string VersionMinor = "${PROJECT_VERSION_MINOR}";
const std::string VersionPatch = "${PROJECT_VERSION_PATCH}";
const std::string VersionBuildTimestamp = "${VERSION_BUILD_TIMESTAMP}";
const std::string VersionString = "${VERSION_STRING}";
const std::string VersionString = "${PROJECT_VERSION}";
const std::string GitVersionTag = "${GIT_TAG}";
const std::string GitVersionSHA1 = "${GIT_SHA1}";
......@@ -22,11 +22,11 @@ const std::string GitVersionExtended = "${GIT_EXTENDED_INFO}";
const std::string GitVersionMessage = "${GIT_REPOSITORY_STATUS}";
const std::vector<std::string> ConfigParameters = {
"VersionMajor=${VERSION_MAJOR}",
"VersionMinor=${VERSION_MINOR}",
"VersionPatch=${VERSION_PATCH}",
"VersionMajor=${PROJECT_VERSION_MAJOR}",
"VersionMinor=${PROJECT_VERSION_MINOR}",
"VersionPatch=${PROJECT_VERSION_PATCH}",
"VersionBuildTimestamp=${VERSION_BUILD_TIMESTAMP}",
"VersionString=${VERSION_STRING}",
"VersionString=${PROJECT_VERSION}",
"GitVersionTag=${GIT_TAG}",
"GitVersionSHA1=${GIT_SHA1}",
"GitVersionShortSHA1=${GIT_SHA1_SHORT}",
......
###############################################################################
project(AttributeCombiner
VERSION
1.0.2
${_VERSION}
DESCRIPTION
"A Device Server to group or merge scalar or spectrum attributes."
LANGUAGES
......
Supports Markdown
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