Skip to content

Commit ed0e389

Browse files
committed
cmake: Add defined so-version and public header to lib.
Adding a so-version means defining an ABI level. This level is decoupled from the ordinary version, even a major version change doesn't necessarily mean that the so-version should change (and thus have all dependencies to be rebuilt). Adding the public header to clarify the setup. Gbp-Pq: Name 0002-cmake-Add-defined-so-version-and-public-header-to-li.patch
1 parent cb35d69 commit ed0e389

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

CMakeLists.txt

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
cmake_minimum_required(VERSION 3.5.0)
2-
project(serial)
2+
33

44
# Find catkin
55
find_package(catkin REQUIRED)
66

7-
# General setup
7+
set(PROJ_SOVERSION 1)
88
project(serial
99
VERSION 1.2.1
1010
DESCRIPTION "Cross-platform, Serial Port library written in C++"
@@ -54,7 +54,19 @@ else()
5454
endif()
5555

5656
## Add serial library
57+
set(serial_HEADERS
58+
include/serial/serial.h
59+
include/serial/v8stdint.h
60+
)
61+
# Build, link and install main library
5762
add_library(${PROJECT_NAME} ${serial_SRCS})
63+
set_target_properties(${PROJECT_NAME} PROPERTIES
64+
VERSION ${PROJECT_VERSION}
65+
SOVERSION ${PROJ_SOVERSION}
66+
PUBLIC_HEADER "${serial_HEADERS}"
67+
)
68+
target_include_directories(${PROJECT_NAME} PUBLIC include)
69+
5870
if(APPLE)
5971
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
6072
elseif(UNIX)
@@ -76,12 +88,10 @@ install(TARGETS ${PROJECT_NAME}
7688
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
7789
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
7890
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
91+
PUBLIC_HEADER DESTINATION
92+
${CATKIN_GLOBAL_INCLUDE_DESTINATION}/${PROJECT_NAME}
7993
)
8094

81-
## Install headers
82-
install(FILES include/serial/serial.h include/serial/v8stdint.h
83-
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/serial)
84-
8595
## Tests
8696
if(CATKIN_ENABLE_TESTING)
8797
add_subdirectory(tests)

0 commit comments

Comments
 (0)