diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48144ada..b0296bbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,7 +159,7 @@ jobs: shell: msys2 {0} run: | if [[ "${{ matrix.env }}" = 'clang'* ]]; then - options='-DCMAKE_C_COMPILER=clang' + options='-DCMAKE_C_COMPILER=clang -DCMAKE_UNITY_BUILD=ON' else options='-DCMAKE_C_COMPILER=gcc' fi @@ -197,13 +197,13 @@ jobs: strategy: matrix: include: - - { arch: x64 , plat: windows, crypto: WinCNG , log: 'OFF', shared: 'OFF', zlib: 'OFF' } - - { arch: x64 , plat: windows, crypto: WinCNG , log: 'ON' , shared: 'ON' , zlib: 'OFF' } - - { arch: x64 , plat: windows, crypto: OpenSSL, log: 'OFF', shared: 'ON' , zlib: 'OFF' } - - { arch: x64 , plat: uwp , crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' } - - { arch: arm64, plat: windows, crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' } - - { arch: arm64, plat: uwp , crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' } - - { arch: x86 , plat: windows, crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF' } + - { arch: x64 , plat: windows, crypto: WinCNG , log: 'OFF', shared: 'OFF', zlib: 'OFF', unity: 'OFF' } + - { arch: x64 , plat: windows, crypto: WinCNG , log: 'ON' , shared: 'ON' , zlib: 'OFF', unity: 'OFF' } + - { arch: x64 , plat: windows, crypto: OpenSSL, log: 'OFF', shared: 'ON' , zlib: 'OFF', unity: 'OFF' } + - { arch: x64 , plat: uwp , crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF', unity: 'OFF' } + - { arch: arm64, plat: windows, crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF', unity: 'OFF' } + - { arch: arm64, plat: uwp , crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF', unity: 'ON' } + - { arch: x86 , plat: windows, crypto: WinCNG , log: 'OFF', shared: 'ON' , zlib: 'OFF', unity: 'OFF' } fail-fast: false steps: - uses: actions/checkout@v3 @@ -217,6 +217,7 @@ jobs: else system='Windows' fi + [ "${{ matrix.unity }}" = 'ON' ] && options="${options} -DCMAKE_UNITY_BUILD=ON" cmake . -B bld ${options} \ -DCMAKE_SYSTEM_NAME=${system} \ -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \ @@ -298,6 +299,7 @@ jobs: if: ${{ matrix.build == 'cmake' }} run: | cmake . -B bld ${{ matrix.crypto.cmake }} \ + -DCMAKE_UNITY_BUILD=ON \ -DENABLE_WERROR=ON \ -DENABLE_DEBUG_LOGGING=ON \ -DENABLE_ZLIB_COMPRESSION=ON \ diff --git a/CMakeLists.txt b/CMakeLists.txt index e32ad3a2..246a6170 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) project(libssh2 C) +set(CMAKE_UNITY_BUILD_BATCH_SIZE 32) + option(BUILD_STATIC_LIBS "Build Static Libraries" ON) add_feature_info("Static library" BUILD_STATIC_LIBS "creating libssh2 static library") diff --git a/appveyor.yml b/appveyor.yml index 362a5a9d..cab52b7a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -82,14 +82,6 @@ environment: CRYPTO_BACKEND: "OpenSSL" SKIP_CTEST: "yes" - - job_name: "VS2010, WinCNG, x64, Build-only" - APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2015" - GENERATOR: "Visual Studio 10 2010" - PLATFORM: "x64" - BUILD_SHARED_LIBS: "ON" - CRYPTO_BACKEND: "WinCNG" - SKIP_CTEST: "yes" - - job_name: "VS2008, WinCNG, x86, Build-only" APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2015" GENERATOR: "Visual Studio 9 2008" @@ -98,6 +90,15 @@ environment: CRYPTO_BACKEND: "WinCNG" SKIP_CTEST: "yes" + - job_name: "VS2010, WinCNG, x64, Build-only" + APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2015" + GENERATOR: "Visual Studio 10 2010" + PLATFORM: "x64" + BUILD_SHARED_LIBS: "ON" + CRYPTO_BACKEND: "WinCNG" + UNITY: "ON" + SKIP_CTEST: "yes" + - job_name: "VS2022, WinCNG, x64, Server 2019, Logging" APPVEYOR_BUILD_WORKER_IMAGE: "Visual Studio 2022" GENERATOR: "Visual Studio 17 2022" @@ -167,6 +168,9 @@ build_script: if($env:UWP -eq "ON") { $env:CMAKE_ARG += " -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0" } + if($env:UNITY -eq "ON") { + $env:CMAKE_ARG += " -DCMAKE_UNITY_BUILD=ON" + } $env:CMAKE_ARG += " -DCMAKE_VS_GLOBALS=TrackFileAccess=false" # FIXME: First sshd test sometimes timeouts, subsequent ones almost always fail: # 'libssh2_session_handshake failed (-43): Failed getting banner' diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 7b820027..cf60dd12 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -48,6 +48,7 @@ foreach(example ${EXAMPLES}) # to find generated header target_include_directories(${example} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../src ../src) target_link_libraries(${example} ${LIB_SELECTED} ${LIBRARIES}) + set_target_properties(${example} PROPERTIES UNITY_BUILD false) endforeach() add_target_to_copy_dependencies( diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b76d5558..8c7dec3c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -82,6 +82,7 @@ foreach(test ${DOCKER_TESTS} ${STANDALONE_TESTS} ${SSHD_TESTS}) add_executable(${test} ${test}.c) target_compile_definitions(${test} PRIVATE "${CRYPTO_BACKEND_DEFINE}") target_include_directories(${test} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src" ../src ../include "${CRYPTO_BACKEND_INCLUDE_DIR}") + set_target_properties(${test} PROPERTIES UNITY_BUILD false) # build a single test with gcov if(GCOV_PATH AND test STREQUAL test_auth_keyboard_info_request)