-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
122 lines (91 loc) · 4.17 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
cmake_minimum_required (VERSION 3.20)
project (2048 LANGUAGES C VERSION 1.0)
#include(CTest)
#enable_testing()
include(${CMAKE_SOURCE_DIR}/cmake/option.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/CompilerWarnings.cmake)
set_choice (CMAKE_BUILD_TYPE "Debug;Release;MinSizeRel;RelWithDebInfo" "Debug" "Choose type of build")
set (SRCS
${CMAKE_SOURCE_DIR}/src/main.c
)
set (HEADERS
${CMAKE_SOURCE_DIR}/src/Interactions.h
${CMAKE_SOURCE_DIR}/src/GameStatus.h
)
set_sanitizer()
option(BUILD_DOC "Build documentation" ON)
if (BUILD_DOC)
add_subdirectory(${CMAKE_SOURCE_DIR}/docs)
endif()
set (CMAKE_C_STANDARD 17)
set (CMAKE_C_STANDARD_REQUIRED ON)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/GameEngine)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Game)
add_subdirectory(${CMAKE_SOURCE_DIR}/src/Interface_SDL2)
if (WIN32)
set(ICONE 2048.rc)
# Win32 SDL2 dll
# SDL2pp only for C++
# set_option(SDL2PP_DLL_DIR "SDL2PP_BINARY_DIR NOT FOUND" PATH "Path to SDL2pp.dll directory")
# configure_file(${SDL2PP_DLL_DIR}/libSDL2pp.dll libSDL2pp.dll COPYONLY)
# install(FILES ${SDL2PP_DLL_DIR}/libSDL2pp.dll DESTINATION .)
# SDL2
set_option(SDL2_DLL_DIR "SDL2_BINARY_DIR NOT FOUND" PATH "Path to SDL2.dll directory")
configure_file(${SDL2_DLL_DIR}/SDL2.dll SDL2.dll COPYONLY)
install(FILES ${SDL2_DLL_DIR}/SDL2.dll DESTINATION .)
# SDL2 ttf
set_option(SDL2_TTF_DLL_DIR "SDL2_TTF_BINARY_DIR NOT FOUND" PATH "Path to SDL2_ttf.dll directory")
configure_file(${SDL2_TTF_DLL_DIR}/SDL2_ttf.dll SDL2_ttf.dll COPYONLY)
install(FILES ${SDL2_TTF_DLL_DIR}/SDL2_ttf.dll DESTINATION .)
# set_option(SDL2_IMAGE_DLL_DIR "SDL2_IMAGE_BINARY_DIR NOT FOUND" PATH "Path to SDL2_image.dll directory")
# configure_file(${SDL2_IMAGE_DLL_DIR}/SDL2_image.dll SDL2_image.dll COPYONLY)
# install(FILES ${SDL2_IMAGE_DLL_DIR}/SDL2_image.dll DESTINATION .)
# set_option(SDL2_MIXER_DLL_DIR "SDL2_MIXER_BINARY_DIR NOT FOUND" PATH "Path to SDL2_mixer.dll directory")
# configure_file(${SDL2_MIXER_DLL_DIR}/SDL2_mixer.dll SDL2_mixer.dll COPYONLY)
# install(FILES ${SDL2_MIXER_DLL_DIR}/SDL2_mixer.dll DESTINATION .)
foreach(df ${ASSETS})
configure_file(${CMAKE_SOURCE_DIR}/${df} ${CMAKE_BINARY_DIR}/${df} COPYONLY)
endforeach()
else ()
# linux .desktop file
set (2048_DESKTOP_DIR "/usr/share/applications/")
set (2048_PIXMAPS_DIR "/usr/share/icons/")
configure_file(2048.desktop.in 2048.desktop)
install (FILES ${CMAKE_BINARY_DIR}/2048.desktop DESTINATION ${2048_DESKTOP_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/2048.svg DESTINATION ${2048_PIXMAPS_DIR})
endif()
add_executable ( ${PROJECT_NAME} ${SRCS} ${HEADERS} ${ICONE})
target_link_libraries(${PROJECT_NAME} PUBLIC Game GameEngine Interface_SDL2)
set_target_warnings(${PROJECT_NAME})
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME} RUNTIME)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_NAME ${PROJECT_NAME})
set (CPACK_PACKAGE_VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}")
set (CPACK_PACKAGE_VENDOR "Quentin Horgues")
set (CPACK_SOURCE_GENERATOR "TGZ")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set (CPACK_SOURCE_IGNORE_FILES ${CPACK_IGNORE_FILES})
set (CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
# Debian
set (CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE "x86")
set (CPACK-DEBIAN-PACKAGE-DESCRIPTION "Le jeu du 2048 en français")
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 libsdl2 libsdl2-ttf")
# RPM
set (CPACK-RPM-PACKAGE-ARCHITECTURE "x86")
set (CPACK_RPM_PACKAGE_REQUIRES "SDL2 SDL2_ttf")
# NSIS
set (CPACK_NSIS_MODIFY_PATH OFF)
set (CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/2048.ico")
set (CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/2048_uninstaler.ico")
set (CPACK_CREATE_DESKTOP_LINK ON)
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
CreateShortCut \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\"
")
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
Delete \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\"
")
include(CPack)