Skip to content

Enable build of both shared and static libs via GitHub Actions #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -56,6 +70,10 @@ jobs:

configuration:
- Release

shared_libs:
- ON
- OFF

include:
- toolchain: linux-gcc
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<TARGET_RUNTIME_DLLS:${executable}> $<TARGET_FILE_DIR:${executable}>
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<TARGET_RUNTIME_DLLS:${executable}> $<TARGET_FILE_DIR:${executable}>
Expand Down