Skip to content

Commit

Permalink
Started enabling object library
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianReimold committed Nov 20, 2024
1 parent d42362a commit 2218c80
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 53 deletions.
77 changes: 38 additions & 39 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Ubuntu
on:
push:
pull_request:
branches: [ master ]
branches: [ main ]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
library_type: [static, shared]
library_type: [static, shared, object]
os: [ubuntu-22.04, ubuntu-20.04]

# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
Expand All @@ -28,41 +28,19 @@ jobs:
- name: Set Variables
run: |
if [[ '${{ matrix.library_type }}' == 'static' ]]; then
echo "build_shared_libs=OFF" >> "$GITHUB_ENV"
echo "package_postfix=static" >> "$GITHUB_ENV"
else
echo "build_shared_libs=ON" >> "$GITHUB_ENV"
echo "package_postfix=shared" >> "$GITHUB_ENV"
echo "build_shared_libs=OFF" >> "$GITHUB_ENV"
echo "tcp_pubsub_library_type=STATIC" >> "$GITHUB_ENV"
echo "package_postfix=static" >> "$GITHUB_ENV"
elif [[ '${{ matrix.library_type }}' == 'shared' ]]; then
echo "build_shared_libs=ON" >> "$GITHUB_ENV"
echo "tcp_pubsub_library_type=SHARED" >> "$GITHUB_ENV"
echo "package_postfix=shared" >> "$GITHUB_ENV"
elif [[ '${{ matrix.library_type }}' == 'object' ]]; then
echo "build_shared_libs=OFF" >> "$GITHUB_ENV"
echo "tcp_pubsub_library_type=OBJECT" >> "$GITHUB_ENV"
echo "package_postfix=object" >> "$GITHUB_ENV"
fi
- name: Getting closer to vanilla Ubuntu 18.04
run: |
if [[ '${{ matrix.os }}' == 'ubuntu-18.04' ]]; then
sudo apt-get -y update
echo "Creating directory for libgcc1"
mkdir libgcc1_deb
cd libgcc1_deb
pwd
echo "Downloading bionic-security libgcc1"
apt-get download -t bionic-security libgcc1
echo "Purging GH Actions toolchain PPA"
sudo apt-get -y install ppa-purge
sudo ppa-purge -y ubuntu-toolchain-r/test
echo "installing libgcc1_deb"
sudo dpkg -i *
echo "Installing g++"
sudo apt-get -y install g++
cd ..
fi
shell: bash

- name: Checkout
uses: actions/checkout@v4
with:
Expand All @@ -78,13 +56,23 @@ jobs:
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
cmake -B ${{github.workspace}}/_build \
-DTCP_PUBSUB_BUILD_SAMPLES=ON \
-DTCP_PUBSUB_BUILD_TESTS=ON \
-DTCP_PUBSUB_USE_BUILTIN_ASIO=ON \
-DTCP_PUBSUB_USE_BUILTIN_RECYCLE=ON \
-TCP_PUBSUB_USE_BUILTIN_GTEST=ON \
-DTCP_PUBSUB_LIBRARY_TYPE=${{env.tcp_pubsub_library_type}} \
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DBUILD_SHARED_LIBS=${{ env.build_shared_libs }}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/_build --config ${{env.BUILD_TYPE}}

- name: Run Tests
run: ctest -C Release -V
working-directory: ${{ github.workspace }}/_build

- name: Read Project Version from CMakeCache
run: |
cmake_project_version_string=$(cat "${{github.workspace}}/_build/CMakeCache.txt" | grep "^CMAKE_PROJECT_VERSION:")
Expand All @@ -96,18 +84,21 @@ jobs:
- name: CPack
run: cpack -G DEB
working-directory: ${{ github.workspace }}/_build
if: ${{ matrix.library_type != 'object' }}

- name: Rename .deb installer
run: |
mv *.deb '${{ env.PROJECT_NAME }}-${{ env.CMAKE_PROJECT_VERSION }}-${{ matrix.os }}-${{ env.package_postfix }}.deb'
shell: bash
working-directory: ${{github.workspace}}/_build/_package/
if: ${{ matrix.library_type != 'object' }}

- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME }}-${{ env.CMAKE_PROJECT_VERSION }}-${{ matrix.os }}-${{ env.package_postfix }}
path: ${{github.workspace}}/_build/_package/*.deb
if: ${{ matrix.library_type != 'object' }}

############################################
# Test if our binary can be linked against
Expand All @@ -116,24 +107,32 @@ jobs:
- name: Install binaries
shell: bash
run: sudo dpkg -i ${{ github.workspace }}/_build/_package/*.deb
if: ${{ matrix.library_type != 'object' }}

- name: Compile integration test (Release)
run: |
cmake -B ${{github.workspace}}/samples/integration_test/_build/release -DCMAKE_BUILD_TYPE=Release
cmake -B ${{github.workspace}}/samples/integration_test/_build/release \
-DCMAKE_BUILD_TYPE=Release
cmake --build ${{github.workspace}}/samples/integration_test/_build/release
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}

- name: Run integration test (Release)
run: ./integration_test
working-directory: ${{ github.workspace }}/samples/integration_test/_build/release
if: ${{ matrix.library_type != 'object' }}

- name: Compile integration test (Debug)
run: |
cmake -B ${{github.workspace}}/samples/integration_test/_build/debug -DCMAKE_BUILD_TYPE=Debug
cmake --build ${{github.workspace}}/samples/integration_test/_build/debug
cmake -B ${{github.workspace}}/samples/integration_test/_build/debug \
-DCMAKE_BUILD_TYPE=Debug
cmake --build ${{github.workspace}}/samples/integration_test/_build/debug
working-directory: ${{ github.workspace }}/samples/integration_test
if: ${{ matrix.library_type != 'object' }}

- name: Run integration test (Debug)
run: ./integration_test
working-directory: ${{ github.workspace }}/samples/integration_test/_build/debug

if: ${{ matrix.library_type != 'object' }}
16 changes: 14 additions & 2 deletions tcp_pubsub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ target_compile_definitions(${PROJECT_NAME}
_WIN32_WINNT=0x0601
)

# Check if tcp_pubsub is an object library. If so, define TCP_PUBSUB_STATIC_DEFINE,
# so the CMake generated export header will be correct.
get_target_property(tcp_pubsub_target_type tcp_pubsub TYPE)
if (tcp_pubsub_target_type STREQUAL OBJECT_LIBRARY)
target_compile_definitions(${PROJECT_NAME}
PUBLIC
TCP_PUBSUB_STATIC_DEFINE
)
endif()

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)

target_compile_options(${PROJECT_NAME} PRIVATE
Expand Down Expand Up @@ -110,8 +120,10 @@ set_target_properties(${PROJECT_NAME} PROPERTIES

##################################

include(sourcetree.cmake)
create_source_tree(${includes} ${sources})
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES
${includes}
${sources}
)

################################################################################
### Installation rules
Expand Down
12 changes: 0 additions & 12 deletions tcp_pubsub/sourcetree.cmake

This file was deleted.

0 comments on commit 2218c80

Please sign in to comment.