From eed149aeea16f3c3a03bce986dbcbc2504984688 Mon Sep 17 00:00:00 2001 From: Jonathan GUILLOT Date: Tue, 27 Aug 2024 17:56:27 +0200 Subject: [PATCH] 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. --- devLib/CMakeLists.txt | 3 +++ gpio/CMakeLists.txt | 6 +----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/devLib/CMakeLists.txt b/devLib/CMakeLists.txt index 272d369..70c4ce2 100644 --- a/devLib/CMakeLists.txt +++ b/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}) diff --git a/gpio/CMakeLists.txt b/gpio/CMakeLists.txt index c69a747..faf30e2 100644 --- a/gpio/CMakeLists.txt +++ b/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)