-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
107 lines (93 loc) · 3.29 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
# HamSandwich root CMake project file.
# Minimum version is based on what is available in VS 2019.
cmake_minimum_required(VERSION 3.19.0)
project("HamSandwich")
cmake_policy(SET CMP0116 NEW) # https://cmake.org/cmake/help/latest/policy/CMP0116.html
# Global settings pertaining to installation.
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INSTALL_MESSAGE LAZY)
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/build/install")
set(CMAKE_INSTALL_DATADIR ".")
set(CMAKE_INSTALL_BINDIR ".")
set(CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_BINDIR}")
if(EMSCRIPTEN)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/build/webroot")
endif()
if(APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path")
endif()
# Include external/, possibly including dependencies of host build tools.
add_subdirectory("external")
# Include the host build tools.
if (CMAKE_CROSSCOMPILING)
# If we're cross-compiling, such as for Emscripten or Android, build the
# tools in a separate process then import them.
execute_process(
COMMAND
"${CMAKE_COMMAND}"
-E env
--unset=CXX
--unset=CC
"${CMAKE_COMMAND}"
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DCMAKE_BUILD_TYPE:STRING=Release
-B${CMAKE_CURRENT_BINARY_DIR}/host_tools
-H=${CMAKE_CURRENT_SOURCE_DIR}/tools
COMMAND_ERROR_IS_FATAL ANY
)
include("${CMAKE_CURRENT_BINARY_DIR}/host_tools/host_tools.cmake")
else()
# Not cross-compiling, so just import the tools directory outright.
add_subdirectory(tools)
endif()
# Include the source/ directories with all the actual programs.
add_subdirectory("source")
# On MinGW, install the requisite .dll files.
if(WIN32 AND CMAKE_COMPILER_IS_GNUCC)
function(install_dll dll_name)
find_program("${dll_name}" "${dll_name}" REQUIRED NO_CACHE)
install(FILES "${${dll_name}}" TYPE BIN COMPONENT generic/executables)
endfunction()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
install_dll("libgcc_s_dw2-1.dll")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
install_dll("libgcc_s_seh-1.dll")
endif()
install_dll("libstdc++-6.dll")
install_dll("libwinpthread-1.dll")
endif()
install(FILES "LICENSE.md" RENAME "LICENSE.HamSandwich.txt" TYPE BIN COMPONENT generic/executables)
# Install Itch metadata.
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT EMSCRIPTEN)
set(pathext "")
if(APPLE)
set(itch_platform "osx")
elseif(WIN32)
set(itch_platform "windows")
set(pathext ".bat")
else()
set(itch_platform "linux")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(itch_arch "386")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(itch_arch "amd64")
endif()
install(FILES "${CMAKE_SOURCE_DIR}/tools/itch/${itch_platform}.itch.toml" RENAME ".itch.toml" DESTINATION "${CMAKE_INSTALL_PREFIX}")
# Work around bug.
install(FILES "${CMAKE_SOURCE_DIR}/tools/itch/distraction.sh" RENAME "itch-bug-workaround-1.sh" DESTINATION "${CMAKE_INSTALL_PREFIX}/installers")
install(FILES "${CMAKE_SOURCE_DIR}/tools/itch/distraction.sh" RENAME "itch-bug-workaround-2.sh" DESTINATION "${CMAKE_INSTALL_PREFIX}/installers")
# Run butler-validate.
install(CODE "
execute_process(COMMAND
${CMAKE_SOURCE_DIR}/tools/bootstrap/butler${pathext} validate
--platform=${itch_platform}
--arch=${itch_arch}
\${CMAKE_INSTALL_PREFIX}
COMMAND_ERROR_IS_FATAL ANY
)
")
endif()