From 97f9777500863894d05d33c24baf7a058ff2f04e Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sat, 1 Jun 2024 12:16:06 +0200 Subject: [PATCH] Fix tests & examples on shared build on Windows On Windows DLLs are created which must be in the same folder as the executables. Do that in the main CML and add a matching CI job --- .github/workflows/build.yml | 12 +++++------- CMakeLists.txt | 6 ++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69c53bf2..ae654fc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,13 +7,6 @@ jobs: strategy: fail-fast: false matrix: - name: [ - linux-cmake, - linux-autotools, - macos-cmake, - macos-autotools, - windows-cmake - ] include: - name: linux-cmake os: ubuntu-latest @@ -38,6 +31,11 @@ jobs: build-system: cmake configure-options: -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows + - name: windows-cmake-shared + os: windows-latest + build-system: cmake + configure-options: -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DBUILD_SHARED_LIBS=ON + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 diff --git a/CMakeLists.txt b/CMakeLists.txt index f5431dab..cad37b86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,12 @@ if(LIBSAMPLERATE_EXAMPLES OR BUILD_TESTING) endif() set(HAVE_SNDFILE ${SndFile_FOUND}) + + # Windows DLLs need to be in the same folder as the executable to be found + if(WIN32 AND NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) + endif() + endif() # SampleRate library