-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
68 lines (55 loc) · 2.06 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.0)
project(snake VERSION 1.0.0)
file(GLOB SOURCES src/*.h src/*.cpp)
if(BUILD MATCHES "GBA")
file(GLOB PORT_SOURCES src/gba/* src/gba/SuperCrateBox-GBA/* img/small/*.c img/small/*.h)
list(APPEND SOURCES ${PORT_SOURCES})
else()
file(GLOB PORT_SOURCES src/sdl/*)
list(APPEND SOURCES ${PORT_SOURCES})
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}/cmake-modules)
if(NOT EXISTS "${CMAKE_BINARY_DIR}/cmake-modules/FindSDL2.cmake")
file(DOWNLOAD
"https://github.com/tcbrindle/sdl2-cmake-scripts/raw/master/FindSDL2.cmake"
"${CMAKE_BINARY_DIR}/cmake-modules/FindSDL2.cmake")
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/cmake-modules/FindSDL2_image.cmake")
file(DOWNLOAD
"https://github.com/tcbrindle/sdl2-cmake-scripts/raw/master/FindSDL2_image.cmake"
"${CMAKE_BINARY_DIR}/cmake-modules/FindSDL2_image.cmake")
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/cmake-modules/FindSDL2_ttf.cmake")
file(DOWNLOAD
"https://github.com/tcbrindle/sdl2-cmake-scripts/raw/master/FindSDL2_ttf.cmake"
"${CMAKE_BINARY_DIR}/cmake-modules/FindSDL2_ttf.cmake")
endif()
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
endif()
add_executable(${PROJECT_NAME} ${SOURCES})
target_include_directories(${PROJECT_NAME} PRIVATE
src/
)
if(BUILD MATCHES "GBA")
target_include_directories(${PROJECT_NAME}
PRIVATE
img/small/
)
target_compile_definitions(${PROJECT_NAME} PRIVATE GBA_BUILD=1)
add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ARGS -O binary ${PROJECT_NAME} ${PROJECT_NAME}.gba)
else()
target_include_directories(${PROJECT_NAME}
SYSTEM PRIVATE
${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIRS}
${SDL2_TTF_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
${SDL2_LIBRARY}
${SDL2_IMAGE_LIBRARIES}
${SDL2_TTF_LIBRARIES}
)
endif()