Skip to content

Commit e59158b

Browse files
Merge #1553: cmake: Set top-level target output locations
c232486 Revert "cmake: Set `ENVIRONMENT` property for examples on Windows" (Hennadii Stepanov) 26e4a7c cmake: Set top-level target output locations (Hennadii Stepanov) Pull request description: While testing #1551, I noticed that when cross-compiling a shared library with examples for Windows, the `ctest` fails to run examples with Wine. Adjusting the `PATH` variable in https://github.com/bitcoin-core/secp256k1/blob/4af241b32099067464e015fa66daac5096206dea/examples/CMakeLists.txt#L16-L18 does not help because `WINEPATH` is expected. Another issue with the current implementation is that the examples cannot run individually on Windows. This PR resolves both issues by reverting the implementation from #1290 in favour of the reworked and improved implementation from #1233. ACKs for top commit: theuni: Concept ACK and utACK c232486. real-or-random: utACK c232486 Tree-SHA512: 479b71d15d5d5670f6f69da3da599240c345711003383ca805c821b67065c9baaf269f987792cf1029211cdbfe799aecd401e6940a471539e3929b4a90e0781d
2 parents 18f9b96 + c232486 commit e59158b

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,14 +761,14 @@ jobs:
761761
# Use the bash shell included with Git for Windows.
762762
shell: bash
763763
run: |
764-
cd build/src/RelWithDebInfo && file *tests.exe bench*.exe libsecp256k1-*.dll || true
764+
cd build/bin/RelWithDebInfo && file *tests.exe bench*.exe libsecp256k1-*.dll || true
765765
766766
- name: Check
767767
run: |
768768
ctest -C RelWithDebInfo --test-dir build -j ([int]$env:NUMBER_OF_PROCESSORS + 1)
769-
build\src\RelWithDebInfo\bench_ecmult.exe
770-
build\src\RelWithDebInfo\bench_internal.exe
771-
build\src\RelWithDebInfo\bench.exe
769+
build\bin\RelWithDebInfo\bench_ecmult.exe
770+
build\bin\RelWithDebInfo\bench_internal.exe
771+
build\bin\RelWithDebInfo\bench.exe
772772
773773
win64-native-headers:
774774
name: "x64 (MSVC): C++ (public headers)"

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,15 @@ if(SECP256K1_APPEND_LDFLAGS)
295295
string(APPEND CMAKE_C_LINK_EXECUTABLE " ${SECP256K1_APPEND_LDFLAGS}")
296296
endif()
297297

298+
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
299+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
300+
endif()
301+
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
302+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
303+
endif()
304+
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
305+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
306+
endif()
298307
add_subdirectory(src)
299308
if(SECP256K1_BUILD_EXAMPLES)
300309
add_subdirectory(examples)

examples/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@ function(add_example name)
1010
)
1111
set(test_name ${name}_example)
1212
add_test(NAME ${test_name} COMMAND ${target_name})
13-
if(BUILD_SHARED_LIBS AND MSVC)
14-
# The DLL must reside either in the same folder where the executable is
15-
# or somewhere in PATH. Using the latter option.
16-
set_tests_properties(${test_name} PROPERTIES
17-
ENVIRONMENT "PATH=$<TARGET_FILE_DIR:secp256k1>;$ENV{PATH}"
18-
)
19-
endif()
2013
endfunction()
2114

2215
add_example(ecdsa)

0 commit comments

Comments
 (0)