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

Commit

Permalink
Merge pull request #763 from t-b/backport/allow-turning-shared-librar…
Browse files Browse the repository at this point in the history
…y-building-off

Allow turning shared library building off
  • Loading branch information
t-b committed Sep 15, 2020
2 parents 7944e94 + 74bbee3 commit ef0c2be
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ language: cpp

env:
matrix:
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Release SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON
- OS_TYPE=debian9 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON
- OS_TYPE=debian8 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=ON COVERALLS=ON STOCK_CPPZMQ=OFF
- OS_TYPE=debian7 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Release SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=ON RUN_TESTS=ON
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=ON RUN_TESTS=ON
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=OFF RUN_TESTS=OFF
- OS_TYPE=debian9 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=ON RUN_TESTS=ON
- OS_TYPE=debian8 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=ON COVERALLS=ON STOCK_CPPZMQ=OFF BUILD_SHARED_LIBS=ON RUN_TESTS=ON
- OS_TYPE=debian7 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=ON RUN_TESTS=ON

notifications:
email: false
Expand Down
3 changes: 3 additions & 0 deletions .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ echo "CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE"
echo "OS_TYPE=$OS_TYPE"
echo "TANGO_HOST=$TANGO_HOST"
echo "COVERALLS=$COVERALLS"
echo "BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS"
echo "############################"

docker exec cpp_tango mkdir -p /home/tango/src/build
Expand All @@ -15,11 +16,13 @@ docker exec cpp_tango mkdir -p /home/tango/src/build
MAKEFLAGS=${MAKEFLAGS:- -j 2}
COVERALLS=${COVERALLS:-OFF}
USE_PCH=${USE_PCH:-OFF}
BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-ON}
COVERALLS_MODULE_PATH=/home/tango/coveralls-cmake/cmake

docker exec cpp_tango cmake \
-H/home/tango/src \
-B/home/tango/src/build \
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCPPZMQ_BASE=/home/tango \
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \
Expand Down
8 changes: 7 additions & 1 deletion .travis/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

if [ $RUN_TESTS = "OFF" ]
then
echo "Skipping tests as requested"
exit 0
fi

TEST_COMMAND="exec ctest --output-on-failure"
if [ $COVERALLS = "ON" ]
then
Expand All @@ -25,4 +31,4 @@ docker exec cpp_tango /bin/sh -c 'cd /home/tango/src/build/cpp_test_suite/enviro
if [ $? -ne "0" ]
then
exit -1
fi
fi
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)

project(cppTango)

include(CTest)

#need to define the version of the library
Expand Down Expand Up @@ -33,7 +36,12 @@ add_subdirectory("log4tango")
add_subdirectory("cppapi")

if(BUILD_TESTING)
if(BUILD_SHARED_LIBS)
add_subdirectory("cpp_test_suite")
else()
message(WARNING "Not building the tests, because that is currently supported only when BUILD_SHARED_LIBS is ON")
SET(BUILD_TESTING OFF)
endif()
endif()

if(WIN32)
Expand Down
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- `-DCMAKE_VERBOSE_MAKEFILE=true`
- `-DTANGO_USE_USING_NAMESPACE=<ON|OFF>` choose `OFF` for modern builds
- `-DBUILD_TESTING=<ON|OFF>` Build the test suite (`ON` by default)
- `-DBUILD_SHARED_LIBS=<ON|OFF>` Build tango as shared library (`ON` by default)

Typical output:

Expand Down
1 change: 1 addition & 0 deletions configure/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,4 @@ include(GNUInstallDirs)
include(configure/coveralls.cmake)

option(TANGO_JPEG_MMX "Build MMX support" ON)
option(BUILD_SHARED_LIBS "Build a shared library instead of static" ON)
44 changes: 17 additions & 27 deletions configure/cmake_linux.cmake
Original file line number Diff line number Diff line change
@@ -1,35 +1,25 @@
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>)
add_library(tango $<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 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 PUBLIC _REENTRANT)

set_target_properties(tango PROPERTIES
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}")
if(BUILD_SHARED_LIBS)
target_compile_options(tango PRIVATE -fPIC)
target_compile_definitions(tango PUBLIC _REENTRANT)
set_target_properties(tango PROPERTIES
VERSION ${LIBRARY_VERSION}
SOVERSION ${SO_VERSION})
install(TARGETS tango LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
else()
install(TARGETS tango ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()

configure_file(tango.pc.cmake tango.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tango.pc"
Expand All @@ -53,6 +43,6 @@ if(CURL)
COMMAND ${CURL} -v -T ${CPACK_PACKAGE_FILE_NAME}.deb -u$ENV{BINTRAY_USER_NAME}:$ENV{BINTRAY_API_KEY} \"https://api.bintray.com/content/tango-controls/debian/cppTango/${LIBRARY_VERSION}/pool/main/libt/${LINUX_FLAVOUR}/${CPACK_PACKAGE_FILE_NAME}.deb\;deb_distribution=${LINUX_FLAVOUR}\;deb_component=main\;deb_architecture=${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}\;publish=1\;override=1\"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
DEPENDS ${PROJECT_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}.deb)
elseif(CURL)
else(CURL)
message(WARNING "curl was not found deploy won't be possible")
endif(CURL)

0 comments on commit ef0c2be

Please sign in to comment.