Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Commit

Permalink
Generate static library and fix compilation definitions (#17) (#437)
Browse files Browse the repository at this point in the history
Compile with -D_REENTRANT to ensure compatibility with old compilers
_FORTIFY_SOURCE=3 => _FORTIFY_SOURCE=2
Compile Tango library Linux release version with -D_TANGO_LIB
Compile CORBA stubs with -DOMNI_UNLOADABLE_STUBS
  • Loading branch information
bourtemb authored May 15, 2018
1 parent 7a4b620 commit af72afb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 12 deletions.
2 changes: 1 addition & 1 deletion configure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ if(NOT WIN32)
message("found GNU compiler ...")
if(CMAKE_BUILD_TYPE MATCHES Release)
message("setup for release build ...")
add_definitions(-D_FORTIFY_SOURCE=3)
add_definitions(-D_FORTIFY_SOURCE=2)
else()
message("setup for debug build ...")
add_compile_options(-O0 -Wall -Wextra -pedantic)
Expand Down
31 changes: 21 additions & 10 deletions configure/cmake_linux.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
project(libtango)



add_library(tango SHARED $<TARGET_OBJECTS:log4tango_objects>
$<TARGET_OBJECTS:client_objects>
$<TARGET_OBJECTS:idl_objects>
$<TARGET_OBJECTS:jpeg_objects>
$<TARGET_OBJECTS:jpeg_mmx_objects>
$<TARGET_OBJECTS:server_objects>)
$<TARGET_OBJECTS:client_objects>
$<TARGET_OBJECTS:idl_objects>
$<TARGET_OBJECTS:jpeg_objects>
$<TARGET_OBJECTS:jpeg_mmx_objects>
$<TARGET_OBJECTS:server_objects>)
target_link_libraries(tango PUBLIC ${ZMQ_PKG_LIBRARIES} ${OMNIORB_PKG_LIBRARIES} ${OMNICOS_PKG_LIBRARIES} ${OMNIDYN_PKG_LIBRARIES} ${CMAKE_DL_LIBS})
target_compile_options(tango PRIVATE -fPIC)
target_include_directories(tango PUBLIC ${ZMQ_PKG_INCLUDE_DIRS} ${OMNIORB_PKG_INCLUDE_DIRS} ${OMNIDYN_PKG_INCLUDE_DIRS})

target_compile_options(tango PUBLIC ${ZMQ_PKG_CFLAGS_OTHER} ${OMNIORB_PKG_CFLAGS_OTHER} ${OMNICOS_PKG_CFLAGS_OTHER} ${OMNIDYN_PKG_CFLAGS_OTHER})
target_compile_definitions(tango PRIVATE OMNI_UNLOADABLE_STUBS _TANGO_LIB)
target_compile_definitions(tango PUBLIC _REENTRANT)

set_target_properties(tango PROPERTIES
VERSION ${LIBRARY_VERSION}
SOVERSION ${SO_VERSION})
VERSION ${LIBRARY_VERSION}
SOVERSION ${SO_VERSION})

add_library(tango-static STATIC $<TARGET_OBJECTS:log4tango_objects>
$<TARGET_OBJECTS:client_objects>
$<TARGET_OBJECTS:idl_objects>
$<TARGET_OBJECTS:jpeg_objects>
$<TARGET_OBJECTS:jpeg_mmx_objects>
$<TARGET_OBJECTS:server_objects>)
target_link_libraries(tango-static PUBLIC ${ZMQ_PKG_LIBRARIES} ${OMNIORB_PKG_LIBRARIES} ${OMNICOS_PKG_LIBRARIES} ${OMNIDYN_PKG_LIBRARIES} ${CMAKE_DL_LIBS})
target_include_directories(tango-static PUBLIC ${ZMQ_PKG_INCLUDE_DIRS} ${OMNIORB_PKG_INCLUDE_DIRS} ${OMNIDYN_PKG_INCLUDE_DIRS})
target_compile_options(tango-static PUBLIC ${ZMQ_PKG_CFLAGS_OTHER} ${OMNIORB_PKG_CFLAGS_OTHER} ${OMNICOS_PKG_CFLAGS_OTHER} ${OMNIDYN_PKG_CFLAGS_OTHER})
set_target_properties(tango-static PROPERTIES OUTPUT_NAME tango)

install(TARGETS tango LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
install(TARGETS tango-static ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")

configure_file(tango.pc.cmake tango.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tango.pc"
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")
Expand Down
2 changes: 1 addition & 1 deletion cpp_test_suite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ add_subdirectory(environment)
macro(TEST_SUITE_ADD_TEST test)
message("Add executable ${test}")
add_executable(${test} ${test}.cpp)
target_compile_definitions(${test} PUBLIC "-DVALGRIND -D_PTHREADS -D_REENTRANT")
target_compile_definitions(${test} PUBLIC "-DVALGRIND -D_PTHREADS")
target_link_libraries(${test} tango ${CMAKE_DL_LIBS})
#TODO generalize tests
# add_test(NAME "CPP::${test}" COMMAND $<TARGET_FILE:${test}> ${DEV1} ${DEV2} ${DEV3} ${DEV1_ALIAS})
Expand Down
9 changes: 9 additions & 0 deletions cppapi/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,14 @@ if(WIN32)
else(WIN32)
add_library(client_objects OBJECT ${SOURCES})
target_compile_options(client_objects PRIVATE -fPIC)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(client_objects PRIVATE _REENTRANT _TANGO_LIB)
else()
# Do not define _TANGO_LIB when compiling Tango debug library on Linux
# in order to keep the same behaviour as in the past:
# cout messages are not redirected to the logging system but are
# instead displayed directly on the console
target_compile_definitions(client_objects PRIVATE _REENTRANT)
endif()
endif(WIN32)
install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/tango")
9 changes: 9 additions & 0 deletions cppapi/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ if(WIN32)
else(WIN32)
add_library(server_objects OBJECT ${SOURCES})
target_compile_options(server_objects PRIVATE -fPIC)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
target_compile_definitions(server_objects PRIVATE _REENTRANT _TANGO_LIB)
else()
# Do not define _TANGO_LIB when compiling Tango debug library on Linux
# in order to keep the same behaviour as in the past:
# A Linux Tango Device Server using the debug tango lib will display
# twice "Ready to accept requests" at startup
target_compile_definitions(server_objects PRIVATE _REENTRANT)
endif()
endif(WIN32)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tango_const.h.in ${CMAKE_CURRENT_BINARY_DIR}/tango_const.h)
Expand Down
1 change: 1 addition & 0 deletions cppapi/server/idl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ if(WIN32)
else(WIN32)
add_library(idl_objects OBJECT ${SOURCES} tango.h)
target_compile_options(idl_objects PRIVATE -fPIC)
target_compile_definitions(idl_objects PRIVATE OMNI_UNLOADABLE_STUBS)
install(FILES tango.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/tango/idl")
endif(WIN32)

0 comments on commit af72afb

Please sign in to comment.