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

Commit af72afb

Browse files
authored
Generate static library and fix compilation definitions (#17) (#437)
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
1 parent 7a4b620 commit af72afb

File tree

6 files changed

+42
-12
lines changed

6 files changed

+42
-12
lines changed

configure/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ if(NOT WIN32)
175175
message("found GNU compiler ...")
176176
if(CMAKE_BUILD_TYPE MATCHES Release)
177177
message("setup for release build ...")
178-
add_definitions(-D_FORTIFY_SOURCE=3)
178+
add_definitions(-D_FORTIFY_SOURCE=2)
179179
else()
180180
message("setup for debug build ...")
181181
add_compile_options(-O0 -Wall -Wextra -pedantic)

configure/cmake_linux.cmake

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
11
project(libtango)
22

3-
4-
53
add_library(tango SHARED $<TARGET_OBJECTS:log4tango_objects>
6-
$<TARGET_OBJECTS:client_objects>
7-
$<TARGET_OBJECTS:idl_objects>
8-
$<TARGET_OBJECTS:jpeg_objects>
9-
$<TARGET_OBJECTS:jpeg_mmx_objects>
10-
$<TARGET_OBJECTS:server_objects>)
4+
$<TARGET_OBJECTS:client_objects>
5+
$<TARGET_OBJECTS:idl_objects>
6+
$<TARGET_OBJECTS:jpeg_objects>
7+
$<TARGET_OBJECTS:jpeg_mmx_objects>
8+
$<TARGET_OBJECTS:server_objects>)
119
target_link_libraries(tango PUBLIC ${ZMQ_PKG_LIBRARIES} ${OMNIORB_PKG_LIBRARIES} ${OMNICOS_PKG_LIBRARIES} ${OMNIDYN_PKG_LIBRARIES} ${CMAKE_DL_LIBS})
1210
target_compile_options(tango PRIVATE -fPIC)
1311
target_include_directories(tango PUBLIC ${ZMQ_PKG_INCLUDE_DIRS} ${OMNIORB_PKG_INCLUDE_DIRS} ${OMNIDYN_PKG_INCLUDE_DIRS})
1412

1513
target_compile_options(tango PUBLIC ${ZMQ_PKG_CFLAGS_OTHER} ${OMNIORB_PKG_CFLAGS_OTHER} ${OMNICOS_PKG_CFLAGS_OTHER} ${OMNIDYN_PKG_CFLAGS_OTHER})
16-
target_compile_definitions(tango PRIVATE OMNI_UNLOADABLE_STUBS _TANGO_LIB)
14+
target_compile_definitions(tango PUBLIC _REENTRANT)
1715

1816
set_target_properties(tango PROPERTIES
19-
VERSION ${LIBRARY_VERSION}
20-
SOVERSION ${SO_VERSION})
17+
VERSION ${LIBRARY_VERSION}
18+
SOVERSION ${SO_VERSION})
19+
20+
add_library(tango-static STATIC $<TARGET_OBJECTS:log4tango_objects>
21+
$<TARGET_OBJECTS:client_objects>
22+
$<TARGET_OBJECTS:idl_objects>
23+
$<TARGET_OBJECTS:jpeg_objects>
24+
$<TARGET_OBJECTS:jpeg_mmx_objects>
25+
$<TARGET_OBJECTS:server_objects>)
26+
target_link_libraries(tango-static PUBLIC ${ZMQ_PKG_LIBRARIES} ${OMNIORB_PKG_LIBRARIES} ${OMNICOS_PKG_LIBRARIES} ${OMNIDYN_PKG_LIBRARIES} ${CMAKE_DL_LIBS})
27+
target_include_directories(tango-static PUBLIC ${ZMQ_PKG_INCLUDE_DIRS} ${OMNIORB_PKG_INCLUDE_DIRS} ${OMNIDYN_PKG_INCLUDE_DIRS})
28+
target_compile_options(tango-static PUBLIC ${ZMQ_PKG_CFLAGS_OTHER} ${OMNIORB_PKG_CFLAGS_OTHER} ${OMNICOS_PKG_CFLAGS_OTHER} ${OMNIDYN_PKG_CFLAGS_OTHER})
29+
set_target_properties(tango-static PROPERTIES OUTPUT_NAME tango)
2130

2231
install(TARGETS tango LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
32+
install(TARGETS tango-static ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
33+
2334
configure_file(tango.pc.cmake tango.pc @ONLY)
2435
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tango.pc"
2536
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")

cpp_test_suite/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ add_subdirectory(environment)
2323
macro(TEST_SUITE_ADD_TEST test)
2424
message("Add executable ${test}")
2525
add_executable(${test} ${test}.cpp)
26-
target_compile_definitions(${test} PUBLIC "-DVALGRIND -D_PTHREADS -D_REENTRANT")
26+
target_compile_definitions(${test} PUBLIC "-DVALGRIND -D_PTHREADS")
2727
target_link_libraries(${test} tango ${CMAKE_DL_LIBS})
2828
#TODO generalize tests
2929
# add_test(NAME "CPP::${test}" COMMAND $<TARGET_FILE:${test}> ${DEV1} ${DEV2} ${DEV3} ${DEV1_ALIAS})

cppapi/client/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,14 @@ if(WIN32)
7171
else(WIN32)
7272
add_library(client_objects OBJECT ${SOURCES})
7373
target_compile_options(client_objects PRIVATE -fPIC)
74+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
75+
target_compile_definitions(client_objects PRIVATE _REENTRANT _TANGO_LIB)
76+
else()
77+
# Do not define _TANGO_LIB when compiling Tango debug library on Linux
78+
# in order to keep the same behaviour as in the past:
79+
# cout messages are not redirected to the logging system but are
80+
# instead displayed directly on the console
81+
target_compile_definitions(client_objects PRIVATE _REENTRANT)
82+
endif()
7483
endif(WIN32)
7584
install(FILES ${HEADERS} DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/tango")

cppapi/server/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ if(WIN32)
153153
else(WIN32)
154154
add_library(server_objects OBJECT ${SOURCES})
155155
target_compile_options(server_objects PRIVATE -fPIC)
156+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
157+
target_compile_definitions(server_objects PRIVATE _REENTRANT _TANGO_LIB)
158+
else()
159+
# Do not define _TANGO_LIB when compiling Tango debug library on Linux
160+
# in order to keep the same behaviour as in the past:
161+
# A Linux Tango Device Server using the debug tango lib will display
162+
# twice "Ready to accept requests" at startup
163+
target_compile_definitions(server_objects PRIVATE _REENTRANT)
164+
endif()
156165
endif(WIN32)
157166

158167
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tango_const.h.in ${CMAKE_CURRENT_BINARY_DIR}/tango_const.h)

cppapi/server/idl/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,6 @@ if(WIN32)
6565
else(WIN32)
6666
add_library(idl_objects OBJECT ${SOURCES} tango.h)
6767
target_compile_options(idl_objects PRIVATE -fPIC)
68+
target_compile_definitions(idl_objects PRIVATE OMNI_UNLOADABLE_STUBS)
6869
install(FILES tango.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}/tango/idl")
6970
endif(WIN32)

0 commit comments

Comments
 (0)