Skip to content

Commit

Permalink
Using nix for linux clang builds
Browse files Browse the repository at this point in the history
  • Loading branch information
gracicot committed Sep 16, 2024
1 parent 7419505 commit 37d60d7
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 667 deletions.
53 changes: 6 additions & 47 deletions .github/workflows/all-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,61 +46,20 @@ jobs:

linux-clang:
name: Clang ${{ matrix.clang }} Linux
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
fail-fast: true
matrix:
arch: [x64]
os: [ubuntu-20.04]
clang: [11, 12, 13, 14]
include:
- clang: 15
os: ubuntu-22.04
arch: x64
- clang: 16
os: ubuntu-22.04
arch: x64
- clang: 17
os: ubuntu-22.04
arch: x64
- clang: 18
os: ubuntu-22.04
arch: x64
clang: [11, 12, 13, 14, 15, 16, 17, 18, 19]

steps:
- uses: actions/checkout@v4

# Minimum GCC version required for vcpkg
- uses: egor-tensin/setup-gcc@v1
- uses: cachix/install-nix-action@v27
with:
version: 9
platform: ${{ matrix.arch }}
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: get-cmake
uses: lukka/get-cmake@v3.26.0

- name: Run vcpkg
uses: lukka/run-vcpkg@v11
with:
# Location of the vcpkg as submodule of the repository.
vcpkgDirectory: '${{ github.workspace }}/vcpkg'
vcpkgGitCommitId: '3508985146f1b1d248c67ead13f8f54be5b4f5da'
# Since the cache must be invalidated when content of the vcpkg.json file changes, let's
# compute its hash and append this to the computed cache's key.
appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }}

- uses: egor-tensin/setup-clang@v1
with:
version: ${{ matrix.clang }}
platform: ${{ matrix.arch }}

- name: 'Run CMake'
uses: lukka/run-cmake@v10
with:
configurePreset: 'ci'
buildPreset: 'ci'
testPreset: 'ci'
configurePresetCmdString: '[`--preset`, `$[env.CONFIGURE_PRESET_NAME]`]'
- run: nix develop .#ci-clang${{ matrix.clang }} --command bash -c "cmake --preset ci-linux && cmake --build --preset ci-linux && ctest --preset ci-linux"

linux-gcc:
name: GCC ${{ matrix.gcc }} Linux
Expand Down
133 changes: 52 additions & 81 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.29)

set(KANGARU_VERSION_MAJOR "4")
set(KANGARU_VERSION_MINOR "3")
set(KANGARU_VERSION_PATCH "1")

set(KANGARU_VERSION "${KANGARU_VERSION_MAJOR}.${KANGARU_VERSION_MINOR}.${KANGARU_VERSION_PATCH}")

project(kangaru VERSION ${KANGARU_VERSION} LANGUAGES CXX)
project(kangaru VERSION 5.0.0 LANGUAGES CXX)

option(KANGARU_BUILD_EXAMPLES "Build kangaru examples" false)
option(KANGARU_INSTALL "Generate kangaru installation target" true)
option(KANGARU_EXPORT "Export kangaru source tree as package" true)
option(KANGARU_REVERSE_DESTRUCTION "Reverse destruction order in the container mimicking a stack" false)
option(KANGARU_HASH_TYPE_ID "Generate the type IDs using the hashed type names" false)
option(KANGARU_REVERSE_DESTRUCTION "Reverse destruction order in the container mimicking a stack" ON)
option(KANGARU_HASH_TYPE_ID "Generate the type IDs using the hashed type names" ON)
option(KANGARU_NO_EXCEPTION "Disable exceptions by replacing throws by asserts" false)
option(KANGARU_BENCHMARK "Build benchmark binaries" false)
option(KANGARU_TEST "Build test binaries" false)
option(KANGARU_TEST_CXX14 "Build C++14 test binaries" false)
option(KANGARU_TEST_CXX17 "Build C++17 test binaries" false)
option(KANGARU_TEST "Build test binaries" ON)

set(KGR_KANGARU_NOEXCEPTION ${KANGARU_NO_EXCEPTION})
set(KGR_KANGARU_REVERSE_DESTRUCTION ${KANGARU_REVERSE_DESTRUCTION})
Expand All @@ -40,21 +29,13 @@ if(KANGARU_TEST_CXX14 OR KANGARU_TEST_CXX17 OR KANGARU_TEST)
set(KANGARU_ENABLE_TESTS true)
endif()

set(KANGARU_INSTALL_INCLUDE_DIR "include")

add_library(kangaru INTERFACE)
add_library(kangaru::kangaru ALIAS kangaru)

add_library(kangaru-internal-warnings INTERFACE)
target_compile_options(kangaru-internal-warnings INTERFACE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:-Werror -Wall -Wextra -Wno-error=unused-parameter -Wno-error=unused-variable -Wno-error=unused-private-field>
$<$<CXX_COMPILER_ID:GNU>:-Werror -Wall -Wextra>
$<$<CXX_COMPILER_ID:MSVC>:/W3>
)

target_compile_features(kangaru INTERFACE cxx_std_20)
target_include_directories(kangaru INTERFACE
$<INSTALL_INTERFACE:${KANGARU_INSTALL_INCLUDE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated/include>
)
Expand All @@ -68,61 +49,51 @@ if(KANGARU_ENABLE_TESTS)
add_subdirectory(tests)
endif()

if(KANGARU_BENCHMARK)
add_subdirectory(benchmark)
endif()
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

if(KANGARU_EXPORT)
export(PACKAGE kangaru)
endif()
set(KANGARU_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/kangaru")
mark_as_advanced(KANGARU_INSTALL_CMAKEDIR)

if(KANGARU_INSTALL)
set(KANGARU_CONFIG_PATH "lib/cmake/kangaru")

include(CMakePackageConfigHelpers)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/kangaruConfigVersion.cmake"
VERSION ${KANGARU_VERSION}
COMPATIBILITY SameMajorVersion
)

# build tree package config
configure_file(
cmake/config/kangaruBuildConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/kangaruConfig.cmake
@ONLY
)

# install tree package config
configure_package_config_file(
cmake/config/kangaruConfig.cmake.in
${KANGARU_CONFIG_PATH}/kangaruConfig.cmake
INSTALL_DESTINATION ${KANGARU_CONFIG_PATH}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

install(
DIRECTORY include/kangaru ${CMAKE_CURRENT_BINARY_DIR}/generated/include/kangaru
DESTINATION ${KANGARU_INSTALL_INCLUDE_DIR} FILES_MATCHING PATTERN "*.hpp"
)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${KANGARU_CONFIG_PATH}/kangaruConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/kangaruConfigVersion.cmake"
DESTINATION ${KANGARU_CONFIG_PATH}
)

install(TARGETS kangaru EXPORT kangaruTargets)

export(
EXPORT kangaruTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/kangaruTargets.cmake"
)

install(
EXPORT kangaruTargets FILE kangaruTargets.cmake
DESTINATION ${KANGARU_CONFIG_PATH}
)
endif()
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/kangaru-config-version.cmake"
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)

# build tree package config
configure_file(
cmake/config/kangaru-config.cmake.in
kangaru-config.cmake
@ONLY
)

install(
DIRECTORY include/kangaru ${CMAKE_CURRENT_BINARY_DIR}/generated/include/kangaru
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.hpp"
)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/kangaru-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/kangaru-config-version.cmake"
DESTINATION ${KANGARU_INSTALL_CMAKEDIR}
)

install(TARGETS kangaru EXPORT kangaru-targets)

install(
EXPORT kangaru-targets
NAMESPACE kangaru::
DESTINATION ${KANGARU_INSTALL_CMAKEDIR}
)

export(
EXPORT kangaru-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/kangaru-targets.cmake"
)

install(
EXPORT kangaru-targets FILE kangaru-targets.cmake
DESTINATION ${KANGARU_INSTALL_CMAKEDIR}
)
Loading

0 comments on commit 37d60d7

Please sign in to comment.