浏览代码

Directly link with targets from CMake

Consider the ful package delivers the two libraries wiringPi and
wiringPiDev with the associated binary gpio. We don't have to build and
install each component separately first.
pull/269/head
Jonathan GUILLOT 2 个月前
父节点
当前提交
eed149aeea
共有 2 个文件被更改,包括 4 次插入5 次删除
  1. +3
    -0
      devLib/CMakeLists.txt
  2. +1
    -5
      gpio/CMakeLists.txt

+ 3
- 0
devLib/CMakeLists.txt 查看文件

@@ -27,6 +27,9 @@ 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 ${WIRINGPI_VERSION} SOVERSION ${WIRINGPI_SOVERSION})



+ 1
- 5
gpio/CMakeLists.txt 查看文件

@@ -20,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} Threads::Threads m PkgConfig::libcrypt)
target_link_libraries(gpio wiringPi wiringPiDev Threads::Threads m PkgConfig::libcrypt)

# Install the executable
install(TARGETS gpio DESTINATION bin)


正在加载...
取消
保存