Skip to content

Commit

Permalink
cmake: Add defined so-version and public header to lib.
Browse files Browse the repository at this point in the history
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.

Note: cherry-pick from PR wjwwood#231

 Conflicts:
	CMakeLists.txt
 Author:    Alec Leamas <[email protected]>
 Date:      Tue Sep 22 13:28:04 2020 +0200

Gbp-Pq: Name 0002-cmake-Add-defined-so-version-and-public-header-to-li.patch
Signed-off-by: Alex Moriarty <[email protected]>
  • Loading branch information
leamas authored and moriarty committed Jun 15, 2023
1 parent c9da89d commit 61da1e2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.5.0)

# General setup
set(PROJ_SOVERSION 1)
project(serial
VERSION 1.2.1
DESCRIPTION "Cross-platform, Serial Port library written in C++"
Expand Down Expand Up @@ -33,9 +34,18 @@ else()
endif()

## Add serial library
set(serial_HEADERS
include/serial/serial.h
include/serial/v8stdint.h
)
# Build, link and install main library
add_library(${PROJECT_NAME} ${serial_SRCS})
set_target_properties(${PROJECT_NAME} PROPERTIES
POSITION_INDEPENDENT_CODE ON)
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJ_SOVERSION}
PUBLIC_HEADER "${serial_HEADERS}"
)
target_include_directories(${PROJECT_NAME} PUBLIC include)

if(APPLE)
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY})
Expand All @@ -58,6 +68,7 @@ install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include/${PROJECT_NAME}
)

## Install headers
Expand Down

0 comments on commit 61da1e2

Please sign in to comment.