diff --git a/configure/CMakeLists.txt b/configure/CMakeLists.txt index 3f032f5a5..715fb835c 100644 --- a/configure/CMakeLists.txt +++ b/configure/CMakeLists.txt @@ -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) diff --git a/configure/cmake_linux.cmake b/configure/cmake_linux.cmake index 3e8e593ef..945e2d199 100644 --- a/configure/cmake_linux.cmake +++ b/configure/cmake_linux.cmake @@ -1,25 +1,36 @@ project(libtango) - - add_library(tango SHARED $ - $ - $ - $ - $ - $) + $ + $ + $ + $ + $) 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_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") diff --git a/cpp_test_suite/CMakeLists.txt b/cpp_test_suite/CMakeLists.txt index 2a361527f..1a37565ae 100644 --- a/cpp_test_suite/CMakeLists.txt +++ b/cpp_test_suite/CMakeLists.txt @@ -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 $ ${DEV1} ${DEV2} ${DEV3} ${DEV1_ALIAS}) diff --git a/cppapi/client/CMakeLists.txt b/cppapi/client/CMakeLists.txt index d3a85ddf5..5be303501 100644 --- a/cppapi/client/CMakeLists.txt +++ b/cppapi/client/CMakeLists.txt @@ -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") diff --git a/cppapi/server/CMakeLists.txt b/cppapi/server/CMakeLists.txt index 02b53af87..1475915ea 100644 --- a/cppapi/server/CMakeLists.txt +++ b/cppapi/server/CMakeLists.txt @@ -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) diff --git a/cppapi/server/idl/CMakeLists.txt b/cppapi/server/idl/CMakeLists.txt index 223bea519..cece00f14 100644 --- a/cppapi/server/idl/CMakeLists.txt +++ b/cppapi/server/idl/CMakeLists.txt @@ -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)