From ed4164eaeaec10833108b9ddea4597005addc2a1 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 7 Sep 2026 10:36:19 -0400 Subject: [PATCH 1/3] CMakeLists.txt: remove explicit static libraries Currently both shared and static libraries are built via duplicate calls to add_library, set_target_properties, target_link_libraries, etc. Typically only one of these is desired, and CMake provides a variable to control it: https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html This commit removes the explicit static libraries, and then removes the explicit "SHARED" from the remaining add_library(). The end result is that one type of library is installed, and it is controlled by the BUILD_SHARED_LIBS flag. Gentoo-bug: https://bugs.gentoo.org/982096 --- CMakeLists.txt | 17 +++-------------- tools/blisp/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7d84f3..8f4e39e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set(CMAKE_C_STANDARD 11) option(BLISP_BUILD_CLI "Build CLI Tool" OFF) option(BLISP_USE_SYSTEM_LIBRARIES "Use system-installed libraries" "${CMAKE_USE_SYSTEM_LIBRARIES}") option(COMPILE_TESTS "Compile the tests" OFF) +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) add_library(libblisp_obj OBJECT lib/blisp.c @@ -30,8 +31,7 @@ endif() set_property(TARGET libblisp_obj PROPERTY POSITION_INDEPENDENT_CODE 1) -add_library(libblisp SHARED $) -add_library(libblisp_static STATIC $) +add_library(libblisp $) set(BLISP_PUBLIC_HEADERS include/blisp.h @@ -44,20 +44,11 @@ set_target_properties(libblisp PROPERTIES PUBLIC_HEADER "${BLISP_PUBLIC_HEADERS}" VERSION 0.0.5 SOVERSION 1 - LIBRARY_OUTPUT_DIRECTORY "shared" - OUTPUT_NAME "blisp") - -set_target_properties(libblisp_static PROPERTIES - PUBLIC_HEADER "${BLISP_PUBLIC_HEADERS}" - VERSION 0.0.5 - SOVERSION 1 - ARCHIVE_OUTPUT_DIRECTORY "static" OUTPUT_NAME "blisp") if(BLISP_USE_SYSTEM_LIBRARIES) find_package(Libserialport REQUIRED) target_link_libraries(libblisp PUBLIC Libserialport::Libserialport) - target_link_libraries(libblisp_static PUBLIC Libserialport::Libserialport) target_include_directories(libblisp_obj PUBLIC ${Libserialport_INCLUDE_DIRS}) else() if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") @@ -70,7 +61,6 @@ else() if(WIN32) target_link_libraries(libblisp PRIVATE Setupapi.lib) - target_link_libraries(libblisp_static PRIVATE Setupapi.lib) target_compile_definitions(libblisp_obj PRIVATE LIBSERIALPORT_MSBUILD) target_sources(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport/windows.c) @@ -89,7 +79,6 @@ else() elseif(UNIX AND ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") target_include_directories(libblisp_obj PRIVATE /usr/local/include/) target_link_libraries(libblisp PRIVATE -L/usr/local/lib usb serialport) - target_link_libraries(libblisp_static PRIVATE -L/usr/local/lib usb serialport) elseif(APPLE) target_sources(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/vendor/libserialport/macosx.c) @@ -104,7 +93,7 @@ else() endif() include(GNUInstallDirs) -install(TARGETS libblisp libblisp_static +install(TARGETS libblisp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/tools/blisp/CMakeLists.txt b/tools/blisp/CMakeLists.txt index 3af2488..f6a9a17 100644 --- a/tools/blisp/CMakeLists.txt +++ b/tools/blisp/CMakeLists.txt @@ -21,7 +21,7 @@ target_include_directories(blisp PRIVATE target_link_libraries(blisp PRIVATE argtable3::argtable3 - libblisp_static file_parsers) + libblisp file_parsers) if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") target_compile_options(libblisp_obj PRIVATE -Wall -Wextra -Wpedantic) From 16e42af1e01bd5d6a91523964e723450ce491e9f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 11 Sep 2026 11:26:20 -0400 Subject: [PATCH 2/3] tools/blisp/CMakeLists.txt: link libm manually When the bundled argtable3 is used, the -lm flag from its pkg-config file is not picked up by the build system, and this can lead to link failures. Here we add it manually when BLISP_USE_SYSTEM_LIBRARIES is disabled. --- tools/blisp/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/blisp/CMakeLists.txt b/tools/blisp/CMakeLists.txt index f6a9a17..5c6c03c 100644 --- a/tools/blisp/CMakeLists.txt +++ b/tools/blisp/CMakeLists.txt @@ -14,6 +14,11 @@ else() target_include_directories(blisp PRIVATE "${CMAKE_SOURCE_DIR}/vendor/argtable3/src") + + # find_package(Argtable3) will pick up -lm from argtable3's .pc + # file, but we need to supply it manually when linking directly + # against the bundled library. + target_link_libraries(blisp PRIVATE m) endif() target_include_directories(blisp PRIVATE From ea58525c6858cfef954a7acf4e4ee59764636dc8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 11 Sep 2026 14:23:26 -0400 Subject: [PATCH 3/3] .github/workflows/build.yml: build verbosely Add --verbose to each "cmake --build" command. --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6b942d1..f20f551 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ jobs: mkdir build cd build cmake .. -DBLISP_BUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release - cmake --build . --config Release + cmake --build . --config Release --verbose - name: Upload results uses: actions/upload-artifact@v4 with: @@ -54,7 +54,7 @@ jobs: mkdir build cd build cmake .. -DBLISP_BUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release - cmake --build . + cmake --build . --verbose - name: Upload results uses: actions/upload-artifact@v4 with: @@ -75,7 +75,7 @@ jobs: mkdir build cd build cmake .. -DBLISP_BUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release - cmake --build . + cmake --build . --verbose - name: Upload results uses: actions/upload-artifact@v4 with: @@ -144,7 +144,7 @@ jobs: mkdir build cd build cmake .. -DBLISP_BUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release - cmake --build . -j2 + cmake --build . -j2 --verbose cp ./tools/blisp/blisp "/artifacts/${artifact_name}" echo "Produced artifact at /artifacts/${artifact_name}" @@ -168,7 +168,7 @@ jobs: mkdir build cd build cmake .. -DBLISP_BUILD_CLI=ON -DCOMPILE_TESTS=ON - cmake --build . + cmake --build . --verbose - name: Run unit tests run: | cd build