-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (105 loc) · 3.98 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
cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)
project(BearEmuChip8 VERSION 0.1.0 LANGUAGES CXX C)
# Let's ensure -std=c++xx instead of -std=g++xx
set(CMAKE_CXX_EXTENSIONS OFF)
# INSTALL DIRECTORY ##################################################
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"${PROJECT_SOURCE_DIR}/compiled"
CACHE PATH
"Set the destination of installed packages."
FORCE)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# UPX COMPRESSION ####################################################
find_package(SelfPackers REQUIRED)
message(STATUS "${SELF_PACKER_FOR_EXECUTABLE}")
# APP FILES ##########################################################
file(GLOB
SOURCE_FILES
CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/src/*.cpp")
file(GLOB
HEADER_FILES
CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/include/*.hpp")
# WINTOAST LIB #######################################################
file(GLOB
BEARLIBTERMINAL_HEADER_FILES
CONFIGURE_DEPENDS
"${PROJECT_SOURCE_DIR}/libs/bearlibterminal/*.h")
# BEARLIBTERMINAL LIBRARY ############################################
add_library(bearlibterminal STATIC IMPORTED)
set_target_properties(bearlibterminal PROPERTIES
IMPORTED_LOCATION
"${CMAKE_CURRENT_SOURCE_DIR}/libs/bearlibterminal/BearLibTerminal.lib")
# ENFORCE UTF-8 COMPATIBILITY ########################################
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
# EXECUTABLE #########################################################
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
add_executable(BearEmuChip8
"${SOURCE_FILES}" "${HEADER_FILES}"
"${BEARLIBTERMINAL_HEADER_FILES}"
)
target_include_directories(BearEmuChip8 PUBLIC
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/libs/bearlibterminal"
)
target_link_libraries(BearEmuChip8 PUBLIC
bearlibterminal
)
set_target_properties(BearEmuChip8 PROPERTIES CXX_STANDARD 17)
add_custom_command(
TARGET BearEmuChip8 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_SOURCE_DIR}/libs/bearlibterminal/BearLibTerminal.dll
$<TARGET_FILE_DIR:BearEmuChip8>
)
add_custom_command(
TARGET BearEmuChip8 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/roms
$<TARGET_FILE_DIR:BearEmuChip8>/roms
)
# DOCUMENTATION ######################################################
find_package(Doxygen
REQUIRED dot
OPTIONAL_COMPONENTS mscgen dia)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "README.md")
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_GENERATE_LATEX YES)
set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/docs")
doxygen_add_docs(
documentation
"${PROJECT_SOURCE_DIR}/README.md"
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/include"
COMMENT "Generating API documentation with Doxygen"
)
# INSTALLING #########################################################
include(InstallRequiredSystemLibraries)
install(TARGETS BearEmuChip8
RUNTIME DESTINATION "bin" COMPONENT "BearEmuChip8")
# CPACK ##############################################################
set(CPACK_GENERATOR "NSIS")
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_OUTPUT_CONFIG_FILE "CPackConfig.cmake")
set(CPACK_OUTPUT_FILE_PREFIX
"${CMAKE_SOURCE_DIR}/installers")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VERSION "0.1.0")
# set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.html")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
# set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/README.html")
set(CPACK_SOURCE_IGNORE_FILES
"${CMAKE_SOURCE_DIR}/build/;${CMAKE_SOURCE_DIR}/.git/")
set(CPACK_PACKAGE_EXECUTABLES
"BearEmuChip8" "Bear Emulator CHIP-8")
set(CPACK_CREATE_DESKTOP_LINKS
"BearEmuChip8")
set(CPACK_PACKAGE_CHECKSUM "MD5")
include(CPack)