forked from ihhub/fheroes2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
92 lines (76 loc) · 2.99 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
# For descent FetchContent()
cmake_minimum_required(VERSION 3.14)
project(fheroes2 VERSION 0.9.9 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 11)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12")
cmake_policy(SET CMP0074 NEW)
endif()
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Compile-time options
set(SDL_VERSIONS SDL SDL2)
set(USE_SDL_VERSION SDL2 CACHE STRING "SDL version")
set_property(CACHE USE_SDL_VERSION PROPERTY STRINGS ${SDL_VERSIONS})
option(ENABLE_IMAGE "Enable SDL/SDL2 Image support (requires libpng)" ON)
option(ENABLE_TOOLS "Enable additional tools" OFF)
option(GET_HOMM2_DEMO "Fetch and install HoMM II demo data" OFF)
option(USE_SYSTEM_LIBSMACKER "Use system libsmacker instead of bundled version" OFF)
option(FHEROES2_STRICT_COMPILATION "Enable -Werror strict compilation" OFF)
set(CONFIGURE_FHEROES2_DATA "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}" CACHE STRING "System fheroes2 game directory")
# Find libraries and enable/disable features
find_package(${USE_SDL_VERSION} REQUIRED)
find_package(${USE_SDL_VERSION}_mixer REQUIRED)
find_package(ZLIB REQUIRED)
find_package(Threads)
if(ENABLE_IMAGE)
find_package(${USE_SDL_VERSION}_image REQUIRED)
find_package(PNG REQUIRED)
endif(ENABLE_IMAGE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_subdirectory(src)
file(GLOB H2D_FILES ${CMAKE_SOURCE_DIR}/files/data/*.h2d)
install(
FILES ${H2D_FILES}
DESTINATION ${CONFIGURE_FHEROES2_DATA}/files/data
)
install(
FILES docs/README.txt LICENSE changelog.txt
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
if(GET_HOMM2_DEMO)
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
FetchContent_Declare(
demodata
URL https://archive.org/download/HeroesofMightandMagicIITheSuccessionWars_1020/h2demo.zip
URL_HASH SHA256=12048c8b03875c81e69534a3813aaf6340975e77b762dc1b79a4ff5514240e3c
)
FetchContent_MakeAvailable(demodata)
file(COPY ${demodata_SOURCE_DIR}/DATA/ DESTINATION data PATTERN *.*)
file(COPY ${demodata_SOURCE_DIR}/MAPS/ DESTINATION maps PATTERN *.*)
install(DIRECTORY ${demodata_SOURCE_DIR}/DATA/ DESTINATION
${CONFIGURE_FHEROES2_DATA}/data FILES_MATCHING PATTERN *.*)
install(DIRECTORY ${demodata_SOURCE_DIR}/MAPS/ DESTINATION
${CONFIGURE_FHEROES2_DATA}/maps FILES_MATCHING PATTERN *.*)
endif(GET_HOMM2_DEMO)
if(WIN32)
install(
FILES script/demo/download_demo_version.bat script/demo/download_demo_version.ps1
DESTINATION ${CMAKE_INSTALL_DOCDIR}/demo
)
install(
FILES script/homm2/extract_homm2_resources.bat script/homm2/extract_homm2_resources.ps1
DESTINATION ${CMAKE_INSTALL_DOCDIR}/homm2
)
else(WIN32)
install(
FILES script/demo/download_demo_version.sh
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
DESTINATION ${CMAKE_INSTALL_DOCDIR}/demo
)
install(
FILES script/homm2/extract_homm2_resources.sh
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
DESTINATION ${CMAKE_INSTALL_DOCDIR}/homm2
)
endif(WIN32)