Skip to content

Commit 5a1dbbf

Browse files
committed
cmake fix
1 parent 37ed489 commit 5a1dbbf

15 files changed

Lines changed: 89 additions & 2844 deletions

.github/workflows/build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build (Windows & Linux)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
include:
15+
- os: ubuntu-latest
16+
build_type: Release
17+
- os: windows-latest
18+
build_type: Debug
19+
20+
runs-on: ${{ matrix.os }}
21+
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v6
25+
26+
- name: Install Linux dependencies
27+
if: runner.os == 'Linux'
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y \
31+
ninja-build \
32+
libgl1-mesa-dev \
33+
libx11-dev \
34+
libxrandr-dev \
35+
libxi-dev \
36+
libxinerama-dev \
37+
libxcursor-dev \
38+
libxxf86vm-dev
39+
- name: Configure CMake
40+
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
41+
42+
- name: Build
43+
run: cmake --build build --config ${{ matrix.build_type }} --parallel
44+
45+
- name: Upload artifact (Windows)
46+
if: runner.os == 'Windows'
47+
uses: actions/upload-artifact@v7
48+
with:
49+
name: QuarkEngine-windows-${{ matrix.build_type }}
50+
path: |
51+
build/bin/${{ matrix.build_type }}/QuarkEngine.exe
52+
build/bin/${{ matrix.build_type }}/raylib.dll
53+
build/bin/${{ matrix.build_type }}/assets/**
54+
if-no-files-found: warn
55+
56+
- name: Upload artifact (Linux)
57+
if: runner.os == 'Linux'
58+
uses: actions/upload-artifact@v7
59+
with:
60+
name: QuarkEngine-linux-${{ matrix.build_type }}
61+
path: |
62+
build/bin/QuarkEngine
63+
build/bin/assets/**
64+
if-no-files-found: warn
65+

CMakeLists.txt

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,39 @@ set(SOURCE_FILES
2929

3030
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
3131

32-
target_link_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/quark-libs/raylib/lib)
32+
set(RAYLIB_LIB_DIR "${CMAKE_SOURCE_DIR}/quark-libs/raylib/lib")
3333

34-
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
35-
COMMAND ${CMAKE_COMMAND} -E copy_directory
36-
${CMAKE_SOURCE_DIR}/assets
37-
$<TARGET_FILE_DIR:${PROJECT_NAME}>/assets
38-
COMMENT "Copying assets to output directory"
39-
)
34+
set(ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets")
35+
if(EXISTS "${ASSETS_DIR}")
36+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
37+
COMMAND ${CMAKE_COMMAND} -E copy_directory
38+
"${ASSETS_DIR}"
39+
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/assets"
40+
COMMENT "Copying assets to output directory"
41+
)
42+
else()
43+
message(WARNING "Assets directory not found: ${ASSETS_DIR}. Skipping asset copy step.")
44+
endif()
4045

4146
if(WIN32)
47+
target_link_directories(${PROJECT_NAME} PRIVATE ${RAYLIB_LIB_DIR})
4248
target_link_libraries(${PROJECT_NAME}
4349
raylib
4450
winmm
4551
gdi32
4652
opengl32
4753
)
4854
elseif(UNIX AND NOT APPLE)
55+
if(EXISTS "${RAYLIB_LIB_DIR}/libraylib.a")
56+
set(RAYLIB_LIB "${RAYLIB_LIB_DIR}/libraylib.a")
57+
elseif(EXISTS "${RAYLIB_LIB_DIR}/libraylib.so.5.5.0")
58+
set(RAYLIB_LIB "${RAYLIB_LIB_DIR}/libraylib.so.5.5.0")
59+
else()
60+
set(RAYLIB_LIB raylib)
61+
endif()
62+
4963
target_link_libraries(${PROJECT_NAME}
50-
raylib
64+
${RAYLIB_LIB}
5165
GL
5266
m
5367
pthread
@@ -57,6 +71,7 @@ elseif(UNIX AND NOT APPLE)
5771
)
5872
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
5973
elseif(APPLE)
74+
target_link_directories(${PROJECT_NAME} PRIVATE ${RAYLIB_LIB_DIR})
6075
target_link_libraries(${PROJECT_NAME}
6176
raylib
6277
"-framework Cocoa"
@@ -65,4 +80,4 @@ elseif(APPLE)
6580
"-framework CoreAudio"
6681
"-framework CoreVideo"
6782
)
68-
endif()
83+
endif()

0 commit comments

Comments
 (0)