ソースを参照

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

Improve CMake build
pull/275/head
Manfred Wallner 2ヶ月前
committed by GitHub
コミット
4d7010daf1
この署名に対応する既知のキーがデータベースに存在しません GPGキー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


読み込み中…
キャンセル
保存