By the way, set SOVERSION to version major. It also fixes wiringPiDev shared library version not correctly set.pull/269/head
@@ -1,6 +1,11 @@ | |||||
cmake_minimum_required(VERSION 3.10) | cmake_minimum_required(VERSION 3.10) | ||||
project(WiringPiLib) | project(WiringPiLib) | ||||
# Read version from version.h | |||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.h" WIRINGPI_VERSION) | |||||
string(REGEX REPLACE ".*VERSION \"([0-9]+.[0-9]+)\".*" "\\1" WIRINGPI_VERSION "${WIRINGPI_VERSION}") | |||||
string(REGEX REPLACE "([0-9]+)\..*" "\\1" WIRINGPI_SOVERSION "${WIRINGPI_VERSION}") | |||||
# Include subdirectories | # Include subdirectories | ||||
add_subdirectory(devLib) | add_subdirectory(devLib) | ||||
add_subdirectory(gpio) | add_subdirectory(gpio) | ||||
@@ -28,7 +28,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2 -Winline -pipe") | |||||
add_library(wiringPiDev SHARED ${SRC}) | add_library(wiringPiDev SHARED ${SRC}) | ||||
# Set the library version | # Set the library version | ||||
set_target_properties(wiringPiDev PROPERTIES VERSION ${VERSION} SOVERSION ${WIRINGPI_SONAME_SUFFIX}) | |||||
set_target_properties(wiringPiDev PROPERTIES VERSION ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_SOVERSION}) | |||||
# Install headers | # Install headers | ||||
install(FILES ${HEADERS} DESTINATION include) | install(FILES ${HEADERS} DESTINATION include) | ||||
@@ -44,18 +44,12 @@ set(HEADERS | |||||
) | ) | ||||
# Compiler flags | # Compiler flags | ||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Winline -pipe -Wformat-security") | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Winline -pipe -Wformat-security") | ||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-soname,libwiringPi.so${WIRINGPI_SONAME_SUFFIX}") | |||||
# Read version from version.h | |||||
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/../version.h" VERSION) | |||||
string(REGEX REPLACE ".*VERSION \"([0-9]+.[0-9]+)\".*" "\\1" VERSION "${VERSION}") | |||||
# Add the library target | # Add the library target | ||||
add_library(wiringPi SHARED ${SRC}) | add_library(wiringPi SHARED ${SRC}) | ||||
# Set the library version | # Set the library version | ||||
set(WIRINGPI_SONAME_SUFFIX "1") | |||||
set_target_properties(wiringPi PROPERTIES VERSION ${VERSION} SOVERSION ${WIRINGPI_SONAME_SUFFIX}) | |||||
set_target_properties(wiringPi PROPERTIES VERSION ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_SOVERSION}) | |||||
target_include_directories(wiringPi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | target_include_directories(wiringPi PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) | ||||
# Add -lm to link with the math library | # Add -lm to link with the math library | ||||