-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
83 lines (66 loc) · 2.44 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
cmake_minimum_required (VERSION 3.5.0)
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE INTERNAL "" FORCE)
# Project name
project (gamebase)
if (WIN32)
SET(SDL2_DIR "../SDL2/cmake")
SET(SDL2_IMAGE_DIR "../SDL2_image/cmake")
endif()
find_package (SDL2 REQUIRED)
find_package (SDL2_IMAGE REQUIRED)
# Include SDL2 support for cmake
if (NOT DEFINED SDL2_INCLUDE_DIR)
if (DEFINED SDL2_INCLUDE_DIRS)
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIRS})
endif()
endif()
if (NOT DEFINED SDL2_IMAGE_INCLUDE_DIR)
if (DEFINED SDL2_IMAGE_INCLUDE_DIRS)
set(SDL2_IMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS})
endif()
endif()
include_directories(${SDL2_INCLUDE_DIR} ${SDL2_IMAGE_INCLUDE_DIR})
# Include header files
include_directories (graphics)
set(SOURCES
${PROJECT_SOURCE_DIR}/main.cpp
${PROJECT_SOURCE_DIR}/app/baseapp.cpp
${PROJECT_SOURCE_DIR}/app/baseapp.h
${PROJECT_SOURCE_DIR}/composite/composite.h
${PROJECT_SOURCE_DIR}/graphics/atlas.cpp
${PROJECT_SOURCE_DIR}/graphics/atlas.h
${PROJECT_SOURCE_DIR}/graphics/graphics.cpp
${PROJECT_SOURCE_DIR}/graphics/graphics.h
#${PROJECT_SOURCE_DIR}/snake/snake.h
${PROJECT_SOURCE_DIR}/ztyp/ztyp.h
)
add_executable(${PROJECT_NAME} ${SOURCES})
if (NOT DEFINED SDL2_LIBRARIES)
set(SDL2_LIBRARIES "SDL2::SDL2")
endif()
if (NOT DEFINED SDL2_IMAGE_LIBRARIES)
set(SDL2_IMAGE_LIBRARIES "SDL2_image::SDL2_image")
endif()
target_link_libraries(${PROJECT_NAME}
${SDL2_LIBRARIES}
${SDL2_IMAGE_LIBRARIES}
)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
if(WIN32)
get_target_property(SDL2_LIBRARY SDL2::SDL2 IMPORTED_LOCATION)
get_filename_component(SDL2_LIBRARY_NAME "${SDL2_LIBRARY}" NAME)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
MAIN_DEPENDENCY "${SDL2_LIBRARY}"
BYPRODUCTS "${SDL2_LIBRARY_NAME}"
COMMENT "Copying SDL2 DLL"
COMMAND "${CMAKE_COMMAND}" -E copy "${SDL2_LIBRARY}" "${CMAKE_BINARY_DIR}/Debug/${SDL2_LIBRARY_NAME}"
)
get_target_property(SDL2_IMAGE_LIBRARY SDL2_image::SDL2_image IMPORTED_LOCATION)
get_filename_component(SDL2_IMAGE_LIBRARY_NAME "${SDL2_IMAGE_LIBRARY}" NAME)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
MAIN_DEPENDENCY "${SDL2_IMAGE_LIBRARY}"
BYPRODUCTS "${SDL2_IMAGE_LIBRARY_NAME}"
COMMENT "Copying SDL2_image DLL"
COMMAND "${CMAKE_COMMAND}" -E copy "${SDL2_IMAGE_LIBRARY}" "${CMAKE_BINARY_DIR}/Debug/${SDL2_IMAGE_LIBRARY_NAME}"
)
endif()