From 26e4a7c2146d581af47f02fc69e0728c7adb3bd8 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 26 Jun 2024 00:29:50 +0100 Subject: [PATCH 1/2] cmake: Set top-level target output locations This change: 1. Collects build artifacts in dedicated locations. 2. Allows to run individual examples with a shared library on Windows. 3. Is compatible with Wine when testing cross-compiled Windows binaries on Linux. 4. Is compatible with integration the project into a larger project hierarchy. --- .github/workflows/ci.yml | 8 ++++---- CMakeLists.txt | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fc104d29b..71bb3e9e57 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -751,14 +751,14 @@ jobs: # Use the bash shell included with Git for Windows. shell: bash run: | - cd build/src/RelWithDebInfo && file *tests.exe bench*.exe libsecp256k1-*.dll || true + cd build/bin/RelWithDebInfo && file *tests.exe bench*.exe libsecp256k1-*.dll || true - name: Check run: | ctest -C RelWithDebInfo --test-dir build -j ([int]$env:NUMBER_OF_PROCESSORS + 1) - build\src\RelWithDebInfo\bench_ecmult.exe - build\src\RelWithDebInfo\bench_internal.exe - build\src\RelWithDebInfo\bench.exe + build\bin\RelWithDebInfo\bench_ecmult.exe + build\bin\RelWithDebInfo\bench_internal.exe + build\bin\RelWithDebInfo\bench.exe win64-native-headers: name: "x64 (MSVC): C++ (public headers)" diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e2b779d98..0c4798f4b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -286,6 +286,15 @@ if(SECP256K1_APPEND_LDFLAGS) string(APPEND CMAKE_C_LINK_EXECUTABLE " ${SECP256K1_APPEND_LDFLAGS}") endif() +if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) +endif() +if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +endif() +if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +endif() add_subdirectory(src) if(SECP256K1_BUILD_EXAMPLES) add_subdirectory(examples) From c232486d84e21ece78b6cc956cd233cdf1bf8eee Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Wed, 26 Jun 2024 00:44:02 +0100 Subject: [PATCH 2/2] Revert "cmake: Set `ENVIRONMENT` property for examples on Windows" This reverts commit 116d2ab3df630455f23a7b21f50237689879ecc0. --- examples/CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index fd1ebce395..a7a5adbf35 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -10,13 +10,6 @@ function(add_example name) ) set(test_name ${name}_example) add_test(NAME ${test_name} COMMAND ${target_name}) - if(BUILD_SHARED_LIBS AND MSVC) - # The DLL must reside either in the same folder where the executable is - # or somewhere in PATH. Using the latter option. - set_tests_properties(${test_name} PROPERTIES - ENVIRONMENT "PATH=$;$ENV{PATH}" - ) - endif() endfunction() add_example(ecdsa)