Преглед изворни кода

Merge pull request #269 from joggee-fr/jg/cmake

Improve CMake build
pull/275/head
Manfred Wallner пре 2 месеци
committed by GitHub
родитељ
комит
4d7010daf1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
4 измењених фајлова са 18 додато и 15 уклоњено
  1. +5
    -0
      CMakeLists.txt
  2. +5
    -2
      devLib/CMakeLists.txt
  3. +6
    -5
      gpio/CMakeLists.txt
  4. +2
    -8
      wiringPi/CMakeLists.txt

+ 5
- 0
CMakeLists.txt Прегледај датотеку

@@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 3.10)
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
add_subdirectory(devLib)
add_subdirectory(gpio)


+ 5
- 2
devLib/CMakeLists.txt Прегледај датотеку

@@ -22,13 +22,16 @@ set(HEADERS
)

# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2 -Winline -pipe -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat=2 -Winline -pipe")

# Add the library target
add_library(wiringPiDev SHARED ${SRC})

target_include_directories(wiringPiDev PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(wiringPiDev PRIVATE wiringPi)

# 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(FILES ${HEADERS} DESTINATION include)


+ 6
- 5
gpio/CMakeLists.txt Прегледај датотеку

@@ -3,6 +3,11 @@
cmake_minimum_required(VERSION 3.10)
project(gpio)

find_package(PkgConfig REQUIRED)
pkg_check_modules(libcrypt REQUIRED IMPORTED_TARGET)

find_package(Threads REQUIRED)

# Source files
set(SRC
gpio.c
@@ -15,12 +20,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
# Add the executable target
add_executable(gpio ${SRC})

# Find the required libraries
find_library(WIRINGPI_LIB wiringPi)
find_library(WIRINGPI_DEV_LIB wiringPiDev)

# Link the required libraries
target_link_libraries(gpio ${WIRINGPI_LIB} ${WIRINGPI_DEV_LIB} pthread rt m crypt)
target_link_libraries(gpio wiringPi wiringPiDev Threads::Threads m PkgConfig::libcrypt)

# Install the executable
install(TARGETS gpio DESTINATION bin)


+ 2
- 8
wiringPi/CMakeLists.txt Прегледај датотеку

@@ -43,19 +43,13 @@ set(HEADERS
wpiExtensions.h
)
# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Winline -pipe -fPIC -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}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Winline -pipe -Wformat-security")

# Add the library target
add_library(wiringPi SHARED ${SRC})

# 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})

# Add -lm to link with the math library


Loading…
Откажи
Сачувај