Skip to content

Commit

Permalink
full vcpkg test
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed Aug 24, 2024
1 parent f81395a commit 3dab11f
Show file tree
Hide file tree
Showing 21 changed files with 500 additions and 546 deletions.
4 changes: 2 additions & 2 deletions .cmake/configure_and_install_pc_file.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function(configure_and_install_pc_file name version)
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}")
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(VERSION "${version}")

configure_file(${name}.pc.in ${PROJECT_BINARY_DIR}/${name}.pc @ONLY)
Expand Down
51 changes: 25 additions & 26 deletions .cmake/create_targets_both_lib_types.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,31 @@ function(create_targets_both_lib_types basename)
set(lib_shared ${basename}_shared)
set(lib_static ${basename}_static)

if(MSVC)
set(STATIC_LIB_NAME_PRESUFFIX "-static")
else()
set(STATIC_LIB_NAME_PRESUFFIX "")
endif()

# Object target to unify source building for both (shared/static) real targets
add_library(${lib_objlib} OBJECT ${SRC_FILES})

# The two real targets
add_library(${lib_shared} SHARED $<TARGET_OBJECTS:${lib_objlib}>)
add_library(${lib_static} STATIC $<TARGET_OBJECTS:${lib_objlib}>)

include(CheckIPOSupported)
check_ipo_supported(RESULT lto_supported OUTPUT error)
if(lto_supported)
set_target_properties(${lib_objlib} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION_DEBUG FALSE
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE
)
else()
message(STATUS "IPO/LTO not supported: <${error}>")
endif()

# Internal deps
foreach(idep ${ARGN})
add_dependencies(${lib_objlib} ${idep}_objlib)
Expand All @@ -21,48 +39,29 @@ function(create_targets_both_lib_types basename)
set(INTERNAL_DEP_LIB_DIR ${PROJECT_BINARY_DIR}/../../lib${idep}/trunk)
set(INTERNAL_DEP_INC_DIR ${PROJECT_SOURCE_DIR}/../../lib${idep}/trunk/src)
endif()
if(GEN_IS_MULTI_CONFIG)
set(INTERNAL_DEP_LIB_DIR "${INTERNAL_DEP_LIB_DIR}/$<CONFIG>")
endif()
target_include_directories(${lib_objlib} PRIVATE ${INTERNAL_DEP_INC_DIR})
if(TRY_STATIC_LIBS)
target_link_libraries(${lib_shared} "${INTERNAL_DEP_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${idep}${CMAKE_STATIC_LIBRARY_SUFFIX}")
if (VCPKG_TARGET_TRIPLET MATCHES "-static")
target_link_libraries(${lib_shared} PRIVATE "${INTERNAL_DEP_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${idep}${STATIC_LIB_NAME_PRESUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}")
else()
target_link_directories(${lib_shared} PRIVATE "${INTERNAL_DEP_LIB_DIR}")
target_link_libraries(${lib_shared} "${idep}")
target_link_libraries(${lib_shared} PRIVATE ${idep})
endif()
endforeach()

# Main properties
if(MSVC)
set(static_lib_output_name "${basename}-static")
else()
set(static_lib_output_name "${basename}")
endif()
set_target_properties(${lib_shared} PROPERTIES
OUTPUT_NAME ${basename}
PUBLIC_HEADER "${PUBLIC_HEADERS}")
set_target_properties(${lib_static} PROPERTIES
OUTPUT_NAME ${static_lib_output_name}
OUTPUT_NAME "${basename}${STATIC_LIB_NAME_PRESUFFIX}"
PUBLIC_HEADER "${PUBLIC_HEADERS}")

# Defines
target_compile_definitions(${lib_objlib} PRIVATE PACKAGE="${PROJECT_NAME}" VERSION="${PROJECT_VERSION}")

# CFLAGS and include dirs
if(TRY_STATIC_LIBS)
target_compile_options(${lib_objlib} PRIVATE ${DEPS_STATIC_CFLAGS})
else()
target_compile_options(${lib_objlib} PRIVATE ${DEPS_CFLAGS})
endif()
target_include_directories(${lib_objlib} PRIVATE src)

# Link-related properties, flags...
if(TRY_STATIC_LIBS)
target_link_directories(${lib_shared} PRIVATE ${TRY_STATIC_DEPS_LIBSDIRS})
target_link_libraries(${lib_shared} ${TRY_STATIC_DEPS_LDFLAGS_OTHER} ${TRY_STATIC_DEPS_LIBS})
else()
target_link_directories(${lib_shared} PRIVATE ${DEPS_LIBRARY_DIRS})
target_link_libraries(${lib_shared} ${DEPS_LDFLAGS_OTHER} ${DEPS_LIBRARIES})
endif()

# Stuff to install and developer-related things
install(TARGETS ${lib_shared} ${lib_static}
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down
95 changes: 0 additions & 95 deletions .cmake/try_static_libs.cmake

This file was deleted.

8 changes: 8 additions & 0 deletions .cmake/vcpkg_overlay_triplets/x64-linux-dynamic-release.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)
set(VCPKG_BUILD_TYPE release)

set(VCPKG_FIXUP_ELF_RPATH ON)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
89 changes: 45 additions & 44 deletions .github/workflows/build.linux.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,69 @@ name: Build Linux

on:
push:
branches: [ master, experimental, experimental2 ]
branches: [ master, experimental, experimental2, fullvcpkg ]
pull_request:
branches: [ master, experimental, experimental2 ]
release:
types: [published]

jobs:
build:
name: "Build: ${{ matrix.os }} - ${{ matrix.deps_type }} deps"
name: "Build: ${{ matrix.arch }} ${{ matrix.os }} - ${{ matrix.upload_suffix }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-20.04]
try_static_deps: ['OFF','ON']
os: [ubuntu-20.04]
arch: [x64]
config: [Release]
statictype: [ON, OFF]
include:
- try_static_deps: 'OFF'
deps_type: shared
- try_static_deps: 'ON'
deps_type: static
- statictype: ON
preset_suffix: ""
upload_suffix: static
- statictype: OFF
preset_suffix: "-Dynamic"
upload_suffix: shared

steps:
- name: Checkout Git Repo
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Checkout Git Repo
uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: workaround for default apt mirror connectivity issues
run: |
sudo sed -i 's/azure\.//' /etc/apt/sources.list
- name: workaround for default apt mirror connectivity issues
run: |
sudo sed -i 's/azure\.//' /etc/apt/sources.list
- name: Install dependencies
run: |
set -e
sudo add-apt-repository universe
sudo apt update
sudo apt install -y cmake ninja-build libarchive-dev libzstd-dev zlib1g-dev libusb-1.0-0-dev libglib2.0-dev gettext nettle-dev libacl1-dev liblzma-dev liblz4-dev libudev-dev libc6-dev
- name: Install dependencies
run: sudo apt install -y libudev-dev

- name: Build tilibs
run: |
set -e
mkdir prefix
prefixpath="$(pwd)/prefix"
mkdir build && cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DTRY_STATIC_LIBS=${{ matrix.try_static_deps }} -DCMAKE_INSTALL_PREFIX=${prefixpath} ..
cmake --build . --target all
- name: Install latest CMake
uses: lukka/get-cmake@a70f1cfa1857a3eecfe0d34962269e1b1e8be56c # latest as of 2024-08-08

- name: Test tilibs
run: |
cd build
cmake --build . --target check
- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@d87e7fac99f22776a4973d7e413921ea254c1fc9 # latest as of 2024-08-08

- name: Install tilibs
run: |
cd build
cmake --build . --target install
- name: create install folder
run: |
mkdir -p "${{ github.workspace }}/tilibs.build/Linux-${{ matrix.arch }}/prefix"
- name: Prepare install folder for upload
run: mv prefix tilibs_${{ matrix.os }}_${{ matrix.deps_type }}Deps
- name: Build and install tilibs ${{ matrix.config }} on Linux ${{ matrix.arch }}
uses: lukka/run-cmake@4b1adc1944be8367be9f4e08303ce49918db8e3c # latest as of 2024-08-08
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
configurePreset: 'Linux-${{ matrix.arch }}${{ matrix.preset_suffix }}'
configurePresetAdditionalArgs: "['-DDEPS_RELEASE_ONLY=ON']"
buildPreset: 'Linux-${{ matrix.arch }}${{ matrix.preset_suffix }}-${{ matrix.config }}'
buildPresetAdditionalArgs: "['--target', 'check', 'install']"
env:
CMAKE_INSTALL_PREFIX_OVERRIDE: ${{ github.workspace }}/tilibs.build/Linux-${{ matrix.arch }}/prefix
VCPKG_DEFAULT_HOST_TRIPLET: ${{ matrix.arch }}-linux-release
VCPKG_FORCE_SYSTEM_BINARIES: 1

- name: Upload install folder
uses: actions/upload-artifact@v3
with:
name: tilibs_${{ matrix.os }}_${{ matrix.deps_type }}Deps
path: tilibs_${{ matrix.os }}_${{ matrix.deps_type }}Deps/
- name: Upload install folder
uses: actions/upload-artifact@v4
with:
name: tilibs_${{ matrix.os }}-${{ matrix.arch }}_${{ matrix.upload_suffix }}Deps
path: ${{ github.workspace }}/tilibs.build/Linux-${{ matrix.arch }}/prefix
Loading

0 comments on commit 3dab11f

Please sign in to comment.