Skip to content

Commit

Permalink
<TBBAS-1840> Create binary artifacts with cpack in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sedovmo committed Oct 22, 2024
1 parent 9ba39ab commit 13092e1
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 87 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
package_path: ${{ github.workspace }}/build/package/

jobs:
build_linux:
Expand All @@ -25,9 +28,11 @@ jobs:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
cpack: tgz
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
cpack: tgz

steps:
- name: Install basic dependencies
Expand Down Expand Up @@ -60,6 +65,7 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCPACK_GENERATOR=${{ matrix.cpack }}
-S ${{ github.workspace }}
- name: Build
Expand All @@ -79,6 +85,19 @@ jobs:
name: Test Results ${{ matrix.os }}-${{ matrix.c_compiler }}
path: ${{ steps.strings.outputs.build-output-dir }}/Testing/Temporary/LastTest.log
retention-days: 7

- name: Package
if: always()
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: cpack -C ${{ matrix.build_type }}

- name: Upload binaries
if: always()
uses: actions/upload-artifact@v4
with:
name: asam-cmp-${{ matrix.os }}-${{ matrix.c_compiler }}
path: ${{ env.package_path }}
retention-days: 7

build_windows:
runs-on: ${{ matrix.os }}
Expand All @@ -96,6 +115,7 @@ jobs:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
cpack: zip

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -123,6 +143,7 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCPACK_GENERATOR=${{ matrix.cpack }}
-S ${{ github.workspace }}
- name: Build
Expand All @@ -141,4 +162,17 @@ jobs:
with:
name: Test Results ${{ matrix.os }}-${{ matrix.c_compiler }}
path: ${{ steps.strings.outputs.build-output-dir }}/Testing/Temporary/LastTest.log
retention-days: 7

- name: Package
if: always()
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: cpack -C ${{ matrix.build_type }}

- name: Upload binaries
if: always()
uses: actions/upload-artifact@v4
with:
name: asam-cmp-${{ matrix.os }}-${{ matrix.c_compiler }}
path: ${{ env.package_path }}
retention-days: 7
22 changes: 21 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,24 @@ endif()

if (${REPO_OPTION_PREFIX}_BUILD_DATA_SINK)
add_subdirectory(asam_cmp_data_sink)
endif()
endif()

# Set CPack variables
set(CPACK_COMPONENTS_ALL RUNTIME)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_BINARY_DIR}/package")

# Set the CPack generator based on the platform
if (WIN32)
set(CPACK_GENERATOR "ZIP")
elseif (UNIX AND NOT APPLE)
cmake_host_system_information(RESULT DISTRO_ID QUERY DISTRIB_ID)
cmake_host_system_information(RESULT DISTRO_VERSION_ID QUERY DISTRIB_VERSION_ID)
set(CPACK_SYSTEM_NAME "${DISTRO_ID}${DISTRO_VERSION_ID}")
set(CPACK_GENERATOR "TGZ")
endif()

# Include CPack for packaging
include(CPack)
28 changes: 7 additions & 21 deletions asam_cmp_capture_module/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,11 @@ target_include_directories(${LIB_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_
$<INSTALL_INTERFACE:include>
)

set_target_properties(${LIB_NAME} PROPERTIES PUBLIC_HEADER "${SRC_PublicHeaders}")

opendaq_set_module_properties(${LIB_NAME} ${PROJECT_VERSION_MAJOR})
create_version_header(${LIB_NAME})

install(TARGETS ${LIB_NAME}
RUNTIME DESTINATION ${INSTALL_BIN_DIR}
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${INSTALL_LIB_DIR}
PUBLIC_HEADER DESTINATION include/${TARGET_FOLDER_NAME}
COMPONENT RUNTIME
)

if (${REPO_OPTION_PREFIX}_ENABLE_TESTS)
Expand Down Expand Up @@ -98,23 +93,14 @@ if (${REPO_OPTION_PREFIX}_ENABLE_TESTS)
)

target_link_libraries(${PROJECT_NAME}_lib PUBLIC daq::opendaq
Pcap++
asam_cmp
asam_cmp_common_lib
Pcap++
asam_cmp
asam_cmp_common_lib
)

target_include_directories(${PROJECT_NAME}_lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
$<INSTALL_INTERFACE:include>
)

set_target_properties(${PROJECT_NAME}_lib PROPERTIES PUBLIC_HEADER "${SRC_PublicHeaders}")

install(TARGETS ${PROJECT_NAME}_lib
RUNTIME DESTINATION ${INSTALL_BIN_DIR}
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${INSTALL_LIB_DIR}
PUBLIC_HEADER DESTINATION include/${TARGET_FOLDER_NAME}
)

endif()
endif()
112 changes: 47 additions & 65 deletions asam_cmp_data_sink/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ set(SRC_PublicHeaders module_dll.h
set(SRC_PrivateHeaders
)

if (MSVC)
add_compile_options(/bigobj)
endif()

prepend_include(${TARGET_FOLDER_NAME} SRC_PrivateHeaders)
prepend_include(${TARGET_FOLDER_NAME} SRC_PublicHeaders)

Expand All @@ -49,78 +53,56 @@ target_include_directories(${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURR
$<INSTALL_INTERFACE:include>
)

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${SRC_PublicHeaders}")

opendaq_set_module_properties(${PROJECT_NAME} ${PROJECT_VERSION_MAJOR})
create_version_header(${PROJECT_NAME})

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${INSTALL_BIN_DIR}
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${INSTALL_LIB_DIR}
PUBLIC_HEADER DESTINATION include/${TARGET_FOLDER_NAME}
COMPONENT RUNTIME
)

if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /bigobj)
endif()

if (${REPO_OPTION_PREFIX}_ENABLE_TESTS)

set(SRC_Lib_Cpp data_sink_module.cpp
data_sink_module_fb.cpp
status_fb_impl.cpp
data_sink_fb.cpp
capture_fb.cpp
interface_fb.cpp
stream_fb.cpp
)

set(SRC_Lib_PublicHeaders common.h
data_sink_module.h
data_sink_module_fb.h
status_fb_impl.h
status_handler.h
data_sink_fb.h
capture_fb.h
interface_fb.h
stream_fb.h
)

set(SRC_Lib_PrivateHeaders
)

prepend_include(${TARGET_FOLDER_NAME} SRC_Lib_PrivateHeaders)
prepend_include(${TARGET_FOLDER_NAME} SRC_Lib_PublicHeaders)

add_library(${PROJECT_NAME}_lib STATIC
${SRC_Lib_Cpp}
${SRC_Lib_PublicHeaders}
${SRC_Lib_PrivateHeaders}
)

target_link_libraries(${PROJECT_NAME}_lib PUBLIC daq::opendaq
Pcap++
asam_cmp
asam_cmp_common_lib
)

target_include_directories(${PROJECT_NAME}_lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
$<INSTALL_INTERFACE:include>
)

set_target_properties(${PROJECT_NAME}_lib PROPERTIES PUBLIC_HEADER "${SRC_PublicHeaders}")

install(TARGETS ${PROJECT_NAME}_lib
RUNTIME DESTINATION ${INSTALL_BIN_DIR}
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${INSTALL_LIB_DIR}
PUBLIC_HEADER DESTINATION include/${TARGET_FOLDER_NAME}
)

if (MSVC)
target_compile_options(${PROJECT_NAME}_lib PRIVATE /bigobj)
endif()
set(SRC_Lib_Cpp data_sink_module.cpp
data_sink_module_fb.cpp
status_fb_impl.cpp
data_sink_fb.cpp
capture_fb.cpp
interface_fb.cpp
stream_fb.cpp
)

set(SRC_Lib_PublicHeaders common.h
data_sink_module.h
data_sink_module_fb.h
status_fb_impl.h
status_handler.h
data_sink_fb.h
capture_fb.h
interface_fb.h
stream_fb.h
)

set(SRC_Lib_PrivateHeaders
)

prepend_include(${TARGET_FOLDER_NAME} SRC_Lib_PrivateHeaders)
prepend_include(${TARGET_FOLDER_NAME} SRC_Lib_PublicHeaders)

add_library(${PROJECT_NAME}_lib STATIC
${SRC_Lib_Cpp}
${SRC_Lib_PublicHeaders}
${SRC_Lib_PrivateHeaders}
)

target_link_libraries(${PROJECT_NAME}_lib PUBLIC daq::opendaq
Pcap++
asam_cmp
asam_cmp_common_lib
)

target_include_directories(${PROJECT_NAME}_lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
$<INSTALL_INTERFACE:include>
)

endif()

0 comments on commit 13092e1

Please sign in to comment.