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

Commit ef0c2be

Browse files
authored
Merge pull request #763 from t-b/backport/allow-turning-shared-library-building-off
Allow turning shared library building off
2 parents 7944e94 + 74bbee3 commit ef0c2be

File tree

7 files changed

+43
-33
lines changed

7 files changed

+43
-33
lines changed

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ language: cpp
44

55
env:
66
matrix:
7-
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Release SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON
8-
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON
9-
- OS_TYPE=debian9 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON
10-
- OS_TYPE=debian8 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=ON COVERALLS=ON STOCK_CPPZMQ=OFF
11-
- OS_TYPE=debian7 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON
7+
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Release SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=ON RUN_TESTS=ON
8+
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=ON RUN_TESTS=ON
9+
- OS_TYPE=debian10 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=OFF RUN_TESTS=OFF
10+
- OS_TYPE=debian9 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=ON RUN_TESTS=ON
11+
- OS_TYPE=debian8 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=ON COVERALLS=ON STOCK_CPPZMQ=OFF BUILD_SHARED_LIBS=ON RUN_TESTS=ON
12+
- OS_TYPE=debian7 CMAKE_BUILD_TYPE=Debug SONAR_SCANNER=OFF COVERALLS=OFF STOCK_CPPZMQ=ON BUILD_SHARED_LIBS=ON RUN_TESTS=ON
1213

1314
notifications:
1415
email: false

.travis/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ echo "CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE"
77
echo "OS_TYPE=$OS_TYPE"
88
echo "TANGO_HOST=$TANGO_HOST"
99
echo "COVERALLS=$COVERALLS"
10+
echo "BUILD_SHARED_LIBS=$BUILD_SHARED_LIBS"
1011
echo "############################"
1112

1213
docker exec cpp_tango mkdir -p /home/tango/src/build
@@ -15,11 +16,13 @@ docker exec cpp_tango mkdir -p /home/tango/src/build
1516
MAKEFLAGS=${MAKEFLAGS:- -j 2}
1617
COVERALLS=${COVERALLS:-OFF}
1718
USE_PCH=${USE_PCH:-OFF}
19+
BUILD_SHARED_LIBS=${BUILD_SHARED_LIBS:-ON}
1820
COVERALLS_MODULE_PATH=/home/tango/coveralls-cmake/cmake
1921

2022
docker exec cpp_tango cmake \
2123
-H/home/tango/src \
2224
-B/home/tango/src/build \
25+
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \
2326
-DCMAKE_VERBOSE_MAKEFILE=ON \
2427
-DCPPZMQ_BASE=/home/tango \
2528
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} \

.travis/test.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#!/usr/bin/env bash
22

3+
if [ $RUN_TESTS = "OFF" ]
4+
then
5+
echo "Skipping tests as requested"
6+
exit 0
7+
fi
8+
39
TEST_COMMAND="exec ctest --output-on-failure"
410
if [ $COVERALLS = "ON" ]
511
then
@@ -25,4 +31,4 @@ docker exec cpp_tango /bin/sh -c 'cd /home/tango/src/build/cpp_test_suite/enviro
2531
if [ $? -ne "0" ]
2632
then
2733
exit -1
28-
fi
34+
fi

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
cmake_minimum_required(VERSION 2.8.12)
2+
3+
project(cppTango)
4+
25
include(CTest)
36

47
#need to define the version of the library
@@ -33,7 +36,12 @@ add_subdirectory("log4tango")
3336
add_subdirectory("cppapi")
3437

3538
if(BUILD_TESTING)
39+
if(BUILD_SHARED_LIBS)
3640
add_subdirectory("cpp_test_suite")
41+
else()
42+
message(WARNING "Not building the tests, because that is currently supported only when BUILD_SHARED_LIBS is ON")
43+
SET(BUILD_TESTING OFF)
44+
endif()
3745
endif()
3846

3947
if(WIN32)

INSTALL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- `-DCMAKE_VERBOSE_MAKEFILE=true`
2929
- `-DTANGO_USE_USING_NAMESPACE=<ON|OFF>` choose `OFF` for modern builds
3030
- `-DBUILD_TESTING=<ON|OFF>` Build the test suite (`ON` by default)
31+
- `-DBUILD_SHARED_LIBS=<ON|OFF>` Build tango as shared library (`ON` by default)
3132

3233
Typical output:
3334

configure/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,4 @@ include(GNUInstallDirs)
214214
include(configure/coveralls.cmake)
215215

216216
option(TANGO_JPEG_MMX "Build MMX support" ON)
217+
option(BUILD_SHARED_LIBS "Build a shared library instead of static" ON)

configure/cmake_linux.cmake

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
project(libtango)
22

3-
add_library(tango SHARED $<TARGET_OBJECTS:log4tango_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>)
3+
add_library(tango $<TARGET_OBJECTS:log4tango_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>)
99
target_link_libraries(tango PUBLIC ${ZMQ_PKG_LIBRARIES} ${OMNIORB_PKG_LIBRARIES} ${OMNICOS_PKG_LIBRARIES} ${OMNIDYN_PKG_LIBRARIES} ${CMAKE_DL_LIBS})
10-
target_compile_options(tango PRIVATE -fPIC)
1110
target_include_directories(tango PUBLIC ${ZMQ_PKG_INCLUDE_DIRS} ${OMNIORB_PKG_INCLUDE_DIRS} ${OMNIDYN_PKG_INCLUDE_DIRS})
12-
1311
target_compile_options(tango PUBLIC ${ZMQ_PKG_CFLAGS_OTHER} ${OMNIORB_PKG_CFLAGS_OTHER} ${OMNICOS_PKG_CFLAGS_OTHER} ${OMNIDYN_PKG_CFLAGS_OTHER})
14-
target_compile_definitions(tango PUBLIC _REENTRANT)
15-
16-
set_target_properties(tango PROPERTIES
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)
3012

31-
install(TARGETS tango LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
32-
install(TARGETS tango-static ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
13+
if(BUILD_SHARED_LIBS)
14+
target_compile_options(tango PRIVATE -fPIC)
15+
target_compile_definitions(tango PUBLIC _REENTRANT)
16+
set_target_properties(tango PROPERTIES
17+
VERSION ${LIBRARY_VERSION}
18+
SOVERSION ${SO_VERSION})
19+
install(TARGETS tango LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
20+
else()
21+
install(TARGETS tango ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}")
22+
endif()
3323

3424
configure_file(tango.pc.cmake tango.pc @ONLY)
3525
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tango.pc"
@@ -53,6 +43,6 @@ if(CURL)
5343
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\"
5444
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
5545
DEPENDS ${PROJECT_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}.deb)
56-
elseif(CURL)
46+
else(CURL)
5747
message(WARNING "curl was not found deploy won't be possible")
5848
endif(CURL)

0 commit comments

Comments
 (0)