Skip to content

Commit 668902e

Browse files
Fix CMake output directories (build/bin) and GitHub Actions paths
- Updated `src/c/CMakeLists.txt` to strictly enforce `CMAKE_RUNTIME_OUTPUT_DIRECTORY` to `build/bin` for all configurations. - Updated `.github/workflows/build_and_release.yml` to package binaries from `build/bin` instead of default CMake locations. - Ensured `enable_testing()` is called correctly and `add_test` uses `$<TARGET_FILE:run_tests>`.
1 parent 7137d30 commit 668902e

2 files changed

Lines changed: 25 additions & 10 deletions

File tree

.github/workflows/build_and_release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ jobs:
4444
run: |
4545
mkdir -p dist
4646
if [ "${{ runner.os }}" == "Windows" ]; then
47-
# Windows CMake builds output to Debug/Release subdirs
48-
zip -j dist/pyraview-win-x64.zip build/Release/*.dll build/Release/*.exe
47+
# Windows CMake builds output to bin due to our CMakeLists.txt fix
48+
zip -j dist/pyraview-win-x64.zip build/bin/*.dll build/bin/*.exe
4949
elif [ "${{ runner.os }}" == "macOS" ]; then
50-
zip -j dist/pyraview-mac-arm.zip build/*.dylib build/tests/run_tests
50+
zip -j dist/pyraview-mac-arm.zip build/bin/*.dylib build/bin/run_tests
5151
else
52-
zip -j dist/pyraview-linux-x64.zip build/*.so build/tests/run_tests
52+
zip -j dist/pyraview-linux-x64.zip build/bin/*.so build/bin/run_tests
5353
fi
5454
5555
- name: Upload Artifacts

src/c/CMakeLists.txt

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@ project(pyraview C)
33

44
find_package(OpenMP)
55

6-
include_directories(../../include)
6+
# Use absolute path for include to avoid relative path headaches
7+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include)
8+
9+
# --- OUTPUT DIRECTORY FIX ---
10+
# This forces Windows/MSVC to put everything in /bin instead of /bin/Release
11+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
12+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
13+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
14+
15+
foreach(config ${CMAKE_CONFIGURATION_TYPES})
16+
string(TOUPPER ${config} CONFIG)
17+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG} ${CMAKE_BINARY_DIR}/bin)
18+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG} ${CMAKE_BINARY_DIR}/bin)
19+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG} ${CMAKE_BINARY_DIR}/bin)
20+
endforeach()
21+
# -----------------------------
722

823
add_library(pyraview SHARED pyraview.c)
924

@@ -13,18 +28,18 @@ else()
1328
message(WARNING "OpenMP not found. Compiling without parallel support.")
1429
endif()
1530

16-
# Link standard math library (not needed on Windows)
1731
if(NOT WIN32)
1832
target_link_libraries(pyraview PRIVATE m)
1933
endif()
2034

2135
# Tests
2236
add_executable(run_tests tests/test_main.c)
37+
target_link_libraries(run_tests PRIVATE pyraview)
38+
2339
if(NOT WIN32)
24-
target_link_libraries(run_tests PRIVATE pyraview m)
25-
else()
26-
target_link_libraries(run_tests PRIVATE pyraview)
40+
target_link_libraries(run_tests PRIVATE m)
2741
endif()
2842

29-
# Use generator expression to handle multi-config paths (Debug/Release) correctly
43+
# Enable testing must be called before add_test
44+
enable_testing()
3045
add_test(NAME run_tests COMMAND $<TARGET_FILE:run_tests>)

0 commit comments

Comments
 (0)