Skip to content

Commit 26e4a7c

Browse files
committed
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.
1 parent 4c57c7a commit 26e4a7c

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,14 @@ jobs:
751751
# Use the bash shell included with Git for Windows.
752752
shell: bash
753753
run: |
754-
cd build/src/RelWithDebInfo && file *tests.exe bench*.exe libsecp256k1-*.dll || true
754+
cd build/bin/RelWithDebInfo && file *tests.exe bench*.exe libsecp256k1-*.dll || true
755755
756756
- name: Check
757757
run: |
758758
ctest -C RelWithDebInfo --test-dir build -j ([int]$env:NUMBER_OF_PROCESSORS + 1)
759-
build\src\RelWithDebInfo\bench_ecmult.exe
760-
build\src\RelWithDebInfo\bench_internal.exe
761-
build\src\RelWithDebInfo\bench.exe
759+
build\bin\RelWithDebInfo\bench_ecmult.exe
760+
build\bin\RelWithDebInfo\bench_internal.exe
761+
build\bin\RelWithDebInfo\bench.exe
762762
763763
win64-native-headers:
764764
name: "x64 (MSVC): C++ (public headers)"

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,15 @@ if(SECP256K1_APPEND_LDFLAGS)
286286
string(APPEND CMAKE_C_LINK_EXECUTABLE " ${SECP256K1_APPEND_LDFLAGS}")
287287
endif()
288288

289+
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
290+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
291+
endif()
292+
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
293+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
294+
endif()
295+
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
296+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
297+
endif()
289298
add_subdirectory(src)
290299
if(SECP256K1_BUILD_EXAMPLES)
291300
add_subdirectory(examples)

0 commit comments

Comments
 (0)