Commit 8e3d9473 authored by Arnaud Le Meillour's avatar Arnaud Le Meillour
Browse files

build DS with all class in Shared Lib

parent 7d5cf3ca
Pipeline #58050 passed with stage
in 15 seconds
......@@ -2,19 +2,19 @@ set(HOME_PREFIX ESRF)
###############################################################################
# List of TANGO device servers to build (from defined classes below)
set(PROJECT_DEVICE_SERVERS
set(PROJECT_BIN_SERVERS
Serial
)
# Shared libraries of TANGO classes needed on this project
set(PROJECT_CLASSES_SHARED
# External shared libraries of TANGO classes needed on this project
set(PROJECT_LIB_CLASSES_EXTERNAL
)
# Local libraries of TANGO classes needed on this project
set(PROJECT_CLASSES_LOCAL
# Local shared libraries of TANGO classes needed on this project
set(PROJECT_LIB_CLASSES_INTERNAL
Serial
)
# Global dependencies (C++, Tango...)
set(GLOBAL_LIB_EXT tango;COS4;omniORB4;omniDynamic4;omnithread;zmq)
set(GLOBAL_LIB_LOC dl;pthread)
set(GLOBAL_LIB_EXTERNAL tango;COS4;omniORB4;omniDynamic4;omnithread;zmq)
set(GLOBAL_LIB_SYSTEM dl;pthread)
# Default repository
set(DEV_REPOSITORY "/opt/os_dev")
......@@ -37,10 +37,13 @@ endif()
project(Root)
#######################################
# Set the build type as Release if no Debug mode is requested
# Set the build type as Release (with debug info) if no Debug mode is requested
message("BUILD CONFIG ##############################")
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_BUILD_TYPE Release)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(BUILD_TYPE "debug")
else()
set(CMAKE_BUILD_TYPE RelWithDebInfo)
set(BUILD_TYPE "release")
endif()
#######################################
......@@ -62,18 +65,18 @@ include(./cmake/lib.cmake)
######################################
# Set local CMAKE_INSTALL_PREFIX to our ref repository if specific install DIR done
# Add build type [Release, Debug] subdirectory to the install DIR
set(CMAKE_INSTALL_PREFIX_previous ${CMAKE_INSTALL_PREFIX})
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(_CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
unset(CMAKE_INSTALL_PREFIX CACHE)
set(CMAKE_INSTALL_PREFIX "${DEV_REPOSITORY}/${CMAKE_BUILD_TYPE}")
message(STATUS "${HOME_PREFIX}::Change default CMAKE_INSTALL_PREFIX (${_CMAKE_INSTALL_PREFIX}) to ${CMAKE_INSTALL_PREFIX}")
set(INSTALL_PREFIX "${DEV_REPOSITORY}")
else()
set(_CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
unset(CMAKE_INSTALL_PREFIX CACHE)
set(CMAKE_INSTALL_PREFIX "${_CMAKE_INSTALL_PREFIX}/${CMAKE_BUILD_TYPE}")
message(STATUS "${HOME_PREFIX}::Change requested CMAKE_INSTALL_PREFIX (${_CMAKE_INSTALL_PREFIX}) to ${CMAKE_INSTALL_PREFIX}")
set(INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
endif()
set(CMAKE_PREFIX_PATH ${HOME_DEV_REPO}/${CMAKE_BUILD_TYPE})
unset(CMAKE_INSTALL_PREFIX CACHE)
set(CMAKE_INSTALL_PREFIX "${INSTALL_PREFIX}/${BUILD_TYPE}")
message(STATUS "${HOME_PREFIX}::Change CMAKE_INSTALL_PREFIX (${CMAKE_INSTALL_PREFIX_previous}) to ${CMAKE_INSTALL_PREFIX}")
#######################################
# Debud info
......@@ -83,12 +86,11 @@ set(CMAKE_PREFIX_PATH ${HOME_DEV_REPO}/${CMAKE_BUILD_TYPE})
# Load global resources
message("GLOBAL LIB RESOURCES ##############################")
foreach(LIB IN ITEMS ${GLOBAL_LIB_EXT})
foreach(LIB IN ITEMS ${GLOBAL_LIB_EXTERNAL})
#set(CMAKE_FIND_DEBUG_MODE TRUE)
find_package(${LIB} REQUIRED
PATHS
${DEV_REPOSITORY}/${CMAKE_BUILD_TYPE}/lib/cmake
${CMAKE_PREFIX_PATH}/lib/cmake
${DEV_REPOSITORY}/${BUILD_TYPE}/lib/cmake
)
#set(CMAKE_FIND_DEBUG_MODE FALSE)
message(STATUS "${HOME_PREFIX}::Registering the global ${LIB} library ...")
......@@ -100,24 +102,23 @@ foreach(LIB IN ITEMS ${GLOBAL_LIB_EXT})
list(APPEND GLOBAL_INCLUDE_DIR ${${LIB}_INCLUDE_DIR})
endforeach()
list(APPEND GLOBAL_LIB ${GLOBAL_LIB_LOC})
list(APPEND GLOBAL_LIB ${GLOBAL_LIB_SYSTEM})
message(STATUS "${HOME_PREFIX}::GLOBAL libraries: ${GLOBAL_LIB}")
#######################################
# Project TANGO classes
message("TANGO CLASSES RESOURCES ##############################")
if(PROJECT_CLASSES_SHARED)
message("## Management of shared TANGO classes ...")
set(_PROJECT_CLASSES_SHARED ${PROJECT_CLASSES_SHARED})
while(_PROJECT_CLASSES_SHARED)
list(POP_FRONT _PROJECT_CLASSES_SHARED CLASS_NAME CLASS_VERSION)
if(PROJECT_LIB_CLASSES_EXTERNAL)
message("## Management of TANGO classes (shared libraries external to this project)...")
set(PROJECT_LIB_CLASSES_EXTERNAL_clone ${PROJECT_LIB_CLASSES_EXTERNAL})
while(PROJECT_LIB_CLASSES_EXTERNAL_clone)
list(POP_FRONT PROJECT_LIB_CLASSES_EXTERNAL_clone CLASS_NAME CLASS_VERSION)
#set(CMAKE_FIND_DEBUG_MODE TRUE)
find_package(${CLASS_NAME} ${CLASS_VERSION} REQUIRED
PATHS
${DEV_REPOSITORY}/${CMAKE_BUILD_TYPE}/lib/classes
${DEV_REPOSITORY}/${BUILD_TYPE}/lib/classes
${CMAKE_INSTALL_PREFIX}/lib/classes
${CMAKE_PREFIX_PATH}/lib/classes
)
#set(CMAKE_FIND_DEBUG_MODE FALSE)
message(STATUS "${HOME_PREFIX}::Registering the shared ${CLASS_NAME} library in version ${CLASS_VERSION}")
......@@ -127,10 +128,10 @@ if(PROJECT_CLASSES_SHARED)
endwhile()
endif()
if(PROJECT_CLASSES_LOCAL)
message("## Management of local TANGO classes ...")
if(PROJECT_LIB_CLASSES_INTERNAL)
message("## Management of TANGO classes (shared libraries internal to this project)...")
unset(CLASS CACHE)
foreach(CLASS IN ITEMS ${PROJECT_CLASSES_LOCAL})
foreach(CLASS IN ITEMS ${PROJECT_LIB_CLASSES_INTERNAL})
add_subdirectory(./classes/${CLASS})
endforeach()
endif()
......@@ -139,10 +140,10 @@ endif()
# Project TANGO device servers
message("TANGO DEVICE SERVERS ##############################")
if(PROJECT_DEVICE_SERVERS)
if(PROJECT_BIN_SERVERS)
message("## Management of TANGO device servers ...")
unset(DEVICE_SERVER CACHE)
foreach(DEVICE_SERVER IN ITEMS ${PROJECT_DEVICE_SERVERS})
foreach(DEVICE_SERVER IN ITEMS ${PROJECT_BIN_SERVERS})
add_subdirectory(servers/${DEVICE_SERVER})
endforeach()
endif()
\ No newline at end of file
......@@ -8,7 +8,6 @@ project(Serial
CXX
)
set(PROJECT_DEPENDENCIES )
set(BUILD_SHARED YES)
message(STATUS "${HOME_PREFIX}::Build preparation for 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.
......@@ -31,13 +30,7 @@ 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()
include(${CMAKE_SOURCE_DIR}/cmake/build-shared.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)
if(${_CLASS} IN_LIST PROJECT_LIB_CLASSES_EXTERNAL)
list(APPEND CLASSES_EXT ${${_CLASS}_LIB})
list(APPEND CLASSES_EXT_LIB_DIR ${${_CLASS}_LIB_DIR})
list(APPEND CLASSES_EXT_INCLUDE_DIR ${${_CLASS}_INCLUDE_DIR})
elseif(${_CLASS} IN_LIST PROJECT_LIB_CLASSES_INTERNAL)
list(APPEND CLASSES_INT ${_CLASS})
list(APPEND CLASSES_INT_TARGET ${_CLASS}_shared)
list(APPEND CLASSES_INT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/classes/${_CLASS}/include)
else()
message(FATAL_ERROR "${HOME_PREFIX}:: - fail to load class (not found): ${_CLASS}")
endif()
endforeach()
if(CLASSES_SHARED)
message(STATUS "${HOME_PREFIX}:: - add shared class: ${CLASSES_SHARED}")
if(CLASSES_EXT)
message(STATUS "${HOME_PREFIX}:: - add external class (shared lib): ${CLASSES_EXT}")
endif()
if(CLASSES_LOCAL_TARGET)
message(STATUS "${HOME_PREFIX}:: - add static class: ${CLASSES_LOCAL_TARGET}")
if(CLASSES_INT_TARGET)
message(STATUS "${HOME_PREFIX}:: - add local class (shared lib): ${CLASSES_INT_TARGET}")
endif()
endif()
\ No newline at end of file
......@@ -12,21 +12,21 @@ target_sources(${BINARY_TARGET}
target_link_libraries(${BINARY_TARGET}
PRIVATE
${GLOBAL_LIB}
${CLASSES_SHARED}
${CLASSES_LOCAL_TARGET}
${CLASSES_EXT}
${CLASSES_INT_TARGET}
)
target_link_directories(${BINARY_TARGET}
PRIVATE
${GLOBAL_LIB_DIR}
${CLASSES_SHARED_LIB_DIR}
${CLASSES_EXT_LIB_DIR}
)
target_include_directories(${BINARY_TARGET}
PRIVATE
${GLOBAL_INCLUDE_DIR}
${CLASSES_SHARED_INCLUDE_DIR}
${CLASSES_LOCAL_INCLUDE_DIR}
${CLASSES_EXT_INCLUDE_DIR}
${CLASSES_INT_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
......
......@@ -19,21 +19,21 @@ target_link_libraries(${SHARED_TARGET}
PRIVATE
${GLOBAL_LIB}
PUBLIC
${CLASSES_SHARED}
${CLASSES_LOCAL_TARGET}
${CLASSES_EXT}
${CLASSES_INT_TARGET}
)
target_link_directories(${SHARED_TARGET}
PRIVATE
${GLOBAL_LIB_DIR}
${CLASSES_SHARED_LIB_DIR}
${CLASSES_EXT_LIB_DIR}
)
target_include_directories(${SHARED_TARGET}
PRIVATE
${GLOBAL_INCLUDE_DIR}
${CLASSES_SHARED_INCLUDE_DIR}
${CLASSES_LOCAL_INCLUDE_DIR}
${CLASSES_EXT_INCLUDE_DIR}
${CLASSES_INT_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
......
set(STATIC_TARGET ${PROJECT_NAME}_static)
add_library(${STATIC_TARGET} STATIC)
message(STATUS "${HOME_PREFIX}:: - built static via target ${STATIC_TARGET}")
include(${CMAKE_SOURCE_DIR}/cmake/conf-build.cmake)
target_sources(${STATIC_TARGET}
PRIVATE
${SOURCE_FILES}
)
target_link_libraries(${STATIC_TARGET}
PRIVATE
${GLOBAL_LIB}
${CLASSES_SHARED}
${CLASSES_LOCAL_TARGET}
)
target_link_directories(${STATIC_TARGET}
PRIVATE
${GLOBAL_LIB_DIR}
${CLASSES_SHARED_LIB_DIR}
)
target_include_directories(${STATIC_TARGET}
PRIVATE
${GLOBAL_INCLUDE_DIR}
${CLASSES_SHARED_INCLUDE_DIR}
${CLASSES_LOCAL_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_compile_options(${STATIC_TARGET}
PRIVATE
${COMPILE_OPTIONS}
)
target_compile_features(${STATIC_TARGET}
PRIVATE
cxx_std_11
)
set_target_properties(${STATIC_TARGET}
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}-${PROJECT_VERSION}
)
if(BUILD_SHARED STREQUAL YES)
install(TARGETS ${STATIC_TARGET} EXPORT ${STATIC_TARGET}_export
ARCHIVE DESTINATION "${INSTALL_LIBDIR}"
PERMISSIONS ${DEFAULT_PERMISSIONS_LIB}
)
endif()
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