-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
165 lines (146 loc) · 5.15 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# CMake build system for Tile World 2
#
# Copyright (C) 2020 by Michael Hansen, under the GNU General Public
# License. No warranty. See COPYING for details.
cmake_minimum_required(VERSION 3.1)
project(tworld)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(OSHW "qt" CACHE STRING "OS/HW Flavor to build (sdl or qt)")
set_property(CACHE OSHW PROPERTY STRINGS qt sdl)
if(OSHW STREQUAL "qt")
set(TWORLD_EXE "tworld2")
elseif(OSHW STREQUAL "sdl")
set(TWORLD_EXE "tworld")
else()
message(FATAL_ERROR "${OSHW} is not a valid OSHW setting")
endif()
# We still require SDL even for the Qt build...
find_package(SDL REQUIRED)
if(OSHW STREQUAL "qt")
set(CMAKE_AUTOUIC TRUE)
set(CMAKE_AUTOMOC TRUE)
set(CMAKE_AUTORCC TRUE)
find_package(Qt6 COMPONENTS Core Gui Widgets Xml)
if(NOT Qt6_FOUND)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Xml)
if(Qt5_FOUND AND NOT TARGET Qt::Core)
# The version-generic targets were only added in Qt 5.15
add_library(Qt::Core INTERFACE IMPORTED)
set_target_properties(Qt::Core PROPERTIES INTERFACE_LINK_LIBRARIES "Qt5::Core")
add_library(Qt::Gui INTERFACE IMPORTED)
set_target_properties(Qt::Gui PROPERTIES INTERFACE_LINK_LIBRARIES "Qt5::Gui")
add_library(Qt::Widgets INTERFACE IMPORTED)
set_target_properties(Qt::Widgets PROPERTIES INTERFACE_LINK_LIBRARIES "Qt5::Widgets")
add_library(Qt::Xml INTERFACE IMPORTED)
set_target_properties(Qt::Xml PROPERTIES INTERFACE_LINK_LIBRARIES "Qt5::Xml")
endif()
endif()
add_definitions(-DTWPLUSPLUS)
endif()
file(GLOB TW_SETS "${CMAKE_CURRENT_SOURCE_DIR}/sets/*.dac")
file(GLOB TW_DATA "${CMAKE_CURRENT_SOURCE_DIR}/data/*.dat"
"${CMAKE_CURRENT_SOURCE_DIR}/data/*.ccx")
file(GLOB TW_RES "${CMAKE_CURRENT_SOURCE_DIR}/res/rc"
"${CMAKE_CURRENT_SOURCE_DIR}/res/*.bmp"
"${CMAKE_CURRENT_SOURCE_DIR}/res/*.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/res/*.wav")
file(GLOB TW_MAN6 "${CMAKE_CURRENT_SOURCE_DIR}/docs/*.6")
file(GLOB TW_CCLP_DOCS "${CMAKE_CURRENT_SOURCE_DIR}/docs/CCLP*")
if(WIN32)
file(GLOB TW_DOCS "${CMAKE_CURRENT_SOURCE_DIR}/docs/*.html")
install(FILES ${TW_SETS} DESTINATION "${CMAKE_INSTALL_PREFIX}/sets")
install(FILES ${TW_DATA} DESTINATION "${CMAKE_INSTALL_PREFIX}/data")
install(FILES ${TW_RES} DESTINATION "${CMAKE_INSTALL_PREFIX}/res")
install(FILES ${TW_DOCS} DESTINATION "${CMAKE_INSTALL_PREFIX}/docs")
install(DIRECTORY ${TW_CCLP_DOCS} DESTINATION "${CMAKE_INSTALL_PREFIX}/docs")
else()
set(SHARE_DIR "${CMAKE_INSTALL_PREFIX}/share/tworld" CACHE STRING
"Directory for shared files")
add_definitions(-DROOTDIR="${SHARE_DIR}")
add_definitions(-Dstricmp=strcasecmp)
install(FILES ${TW_SETS} DESTINATION "${SHARE_DIR}/sets")
install(FILES ${TW_DATA} DESTINATION "${SHARE_DIR}/data")
install(FILES ${TW_RES} DESTINATION "${SHARE_DIR}/res")
install(FILES ${TW_MAN6} DESTINATION "${CMAKE_INSTALL_PREFIX}/man/man6")
install(DIRECTORY ${TW_CCLP_DOCS} DESTINATION "${SHARE_DIR}/docs")
endif()
add_subdirectory(oshw-${OSHW})
add_executable(${TWORLD_EXE} WIN32 MACOSX_BUNDLE tworld.c)
target_sources(${TWORLD_EXE} PRIVATE
cmdline.h
cmdline.c
comptime.h
defs.h
encoding.h
encoding.c
err.h
err.c
fileio.h
fileio.c
gen.h
help.h
help.c
logic.h
lxlogic.c
messages.h
messages.cpp
mslogic.c
oshw.h
play.h
play.c
random.h
random.c
res.h
res.c
score.h
score.cpp
series.h
series.c
settings.h
settings.cpp
solution.h
solution.c
state.h
unslist.h
unslist.c
ver.h
)
if(WIN32)
target_sources(${TWORLD_EXE} PRIVATE ${TWORLD_EXE}.rc)
endif()
if(OSHW STREQUAL "qt")
target_sources(${TWORLD_EXE} PRIVATE tworld2.qrc)
endif()
target_link_libraries(${TWORLD_EXE} PRIVATE oshw-${OSHW})
if(WIN32)
target_link_libraries(${TWORLD_EXE} PRIVATE $<$<CONFIG:Debug>:-mconsole>)
endif()
# Generate the current compile time
if(WIN32)
# TODO: It would be nice to use the format below on Win32 as well...
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/comptime.bat"
"echo #define COMPILE_TIME \"%DATE% %TIME%\" > comptime.h")
add_custom_command(
OUTPUT comptime.h
COMMAND comptime.bat
)
else()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/comptime.sh"
"echo \"#define COMPILE_TIME \\\"`date '+%Y %b %e %T %Z'`\\\"\" > comptime.h")
add_custom_command(
OUTPUT comptime.h
COMMAND /bin/sh comptime.sh
)
endif()
set_property(SOURCE comptime.h PROPERTY SKIP_AUTOGEN ON)
target_include_directories(${TWORLD_EXE} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
if(WIN32 OR APPLE)
install(TARGETS ${TWORLD_EXE}
RUNTIME DESTINATION .
BUNDLE DESTINATION .
)
else()
install(TARGETS ${TWORLD_EXE} RUNTIME DESTINATION bin)
endif()
add_executable(mklynxcc EXCLUDE_FROM_ALL mklynxcc.c)