Browse Source

Globally set shared library versions from root CMakeLists.txt

By the way, set SOVERSION to version major. It also fixes wiringPiDev
shared library version not correctly set.
pull/269/head
Jonathan GUILLOT 2 months ago
parent
commit
26c45372ca
3 changed files with 7 additions and 8 deletions
  1. +5
    -0
      CMakeLists.txt
  2. +1
    -1
      devLib/CMakeLists.txt
  3. +1
    -7
      wiringPi/CMakeLists.txt

+ 5
- 0
CMakeLists.txt View File

@@ -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)


+ 1
- 1
devLib/CMakeLists.txt View File

@@ -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)


+ 1
- 7
wiringPi/CMakeLists.txt View File

@@ -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


Loading…
Cancel
Save