From 1cbc7a0d10d29733bfa363a2e14b00d99f7c0abb Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Tue, 13 Aug 2024 07:38:58 +0200 Subject: [PATCH 1/2] Enable build of shared and static libs via GitHub Actions --- .github/workflows/main.yml | 43 +++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7790fc8..0e0ed05 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,20 @@ jobs: name: linux-autoconf runs-on: ubuntu-latest + strategy: + matrix: + shared_libs: + - yes + - no + + static_libs: + - yes + - no + + exclude: + - shared_libs: no + static_libs: no + steps: - name: Checkout Code uses: actions/checkout@v4 @@ -25,7 +39,7 @@ jobs: run: ./autogen.sh - name: Configure - run: ./configure + run: ./configure --enable-shared=${{ matrix.shared_libs }} --enable-static=${{ matrix.static_libs }} - name: Make run: make @@ -44,7 +58,7 @@ jobs: ctest --no-tests=error --test-dir . --verbose build-cmake: - name: ${{ matrix.toolchain }} + name: ${{ matrix.toolchain }} (${{ matrix.configuration }}, ${{ matrix.shared_libs }}) runs-on: ${{ matrix.os }} strategy: @@ -56,6 +70,10 @@ jobs: configuration: - Release + + shared_libs: + - ON + - OFF include: - toolchain: linux-gcc @@ -76,10 +94,10 @@ jobs: - name: Configure (${{ matrix.configuration }}) run: | - if [ "${{ matrix.toolchain }}" == "windows-msvc" ]; then - cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=~/install + if [ "${{ matrix.compiler }}" == "msvc" ]; then + cmake -S . -Bbuild -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DCMAKE_INSTALL_PREFIX=~/install else - cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DCMAKE_INSTALL_PREFIX=~/install + cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -DCMAKE_INSTALL_PREFIX=~/install fi - name: Build with ${{ matrix.compiler }} @@ -105,6 +123,15 @@ jobs: name: windows-cygwin runs-on: windows-latest + strategy: + matrix: + configuration: + - Release + + shared_libs: + - ON + - OFF + steps: - name: Set git to use LF run: git config --global core.autocrlf input @@ -121,10 +148,10 @@ jobs: make ninja - - name: Configure (Release) + - name: Configure (${{ matrix.configuration }}) run: | export PATH=/usr/bin:$PATH - cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -G Ninja + cmake -S . -Bbuild -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DCMAKE_UNITY_BUILD=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_TESTING=ON -DBUILD_SHARED_LIBS=${{ matrix.shared_libs }} -G Ninja shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}' - name: Build with gcc @@ -136,7 +163,7 @@ jobs: - name: Test run: | export PATH=/usr/bin:/usr/local/bin:$PATH - ctest --no-tests=error --test-dir build --build-config Release --verbose + ctest --no-tests=error --test-dir build --build-config ${{ matrix.configuration }} --verbose shell: C:\cygwin\bin\bash.exe -eo pipefail -o igncr '{0}' build-nmake: From 89795b24878d816ddbde5cddaaf5fe843e07dd54 Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Tue, 13 Aug 2024 10:37:25 +0200 Subject: [PATCH 2/2] Fix post build command --- CMakeLists.txt | 2 +- tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc5df86..5887924 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,7 +250,7 @@ if(BUILD_TESTING) foreach(executable shptest shputils) add_executable(${executable} ${executable}.c) target_link_libraries(${executable} PRIVATE ${PACKAGE}) - if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21" AND (WIN32 OR CYGWIN)) + if (BUILD_SHARED_LIBS AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21" AND (WIN32 OR CYGWIN)) add_custom_command( TARGET ${executable} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5fc5190..a8f92ad 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -32,7 +32,7 @@ foreach(executable dbf_test sbn_test shp_test) ) target_compile_features(${executable} PUBLIC cxx_std_17) set_target_properties(${executable} PROPERTIES FOLDER "tests" CXX_EXTENSIONS OFF) - if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21" AND (WIN32 OR CYGWIN)) + if (BUILD_SHARED_LIBS AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21" AND (WIN32 OR CYGWIN)) add_custom_command( TARGET ${executable} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $