forked from CedarvilleCS/CedarLogic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
172 lines (143 loc) · 5.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
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
166
167
168
169
170
171
172
# Note: updating to 3.15 breaks ms_static_runtime_libs or something around it such that we get a bunch of
# linker errors where the MT and MD mismatch. Below 3.11 breaks the FetchContent capability used to pull in
# Catch2, the unit testing framework.
cmake_minimum_required(VERSION 3.11)
# Name project, and set version. If updating version, change it here, and then re-generate your Visual
# Studio solution.
project(CedarLogic VERSION 2.3.7)
# This configure file is where we store version info that's auto-populated by cmake configure.
# This file is not considered part of the source code and it's stored in the build directory
# It is made visible as an external header when we add PROJECT_BINARY_DIR (build) in
# target_include_directories. This may seem odd, but it's how they do it in the official cmake tutorial.
configure_file(CedarLogic.h.in CedarLogic.h)
# CMake modules, that is, files specifying functions we can use in CMake
# each is a .cmake file in the CMAKE_MODULE_PATH and we include them below
# so we can use their functions later on.
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/module")
include(LibraryTools)
include(ResourceTools)
include(VsSourceGroups)
include(MsStaticRuntimeLibs)
##
# Connect external libraries
##
# Use static runtime libs.
ms_static_runtime_libs()
# Read environment variable, but if it is not set, use installer default location.
if ("$ENV{WXWIN}" STREQUAL "")
set(ENV{WXWIN} "C:/wxWidgets-2.8.12")
endif()
set(wxwin "$ENV{WXWIN}" CACHE STRING "Path to wxWidgets install folder.")
# Set special variables read-in by functions from LibraryTools module.
set(wx_widgets_include
"${wxwin}/include"
)
set(wx_widgets_linklibs
"comctl32.lib"
"rpcrt4.lib"
"winmm.lib"
"wsock32.lib"
"opengl32.lib"
"glu32.lib"
)
# Use the variables above to define the cmake library targets.
set(Libraries
wx_widgets
)
import_libraries(${Libraries})
###
### Build Config.
###
link_directories("${wxwin}/lib/vc_lib" Logic)
# Glob all the source files to be added when CedarLogic executable is added later.
file(GLOB SRC_FILES
"${PROJECT_SOURCE_DIR}/src/*.cpp"
"${PROJECT_SOURCE_DIR}/src/gui/*.cpp"
"${PROJECT_SOURCE_DIR}/src/logic/*.cpp"
"${PROJECT_SOURCE_DIR}/src/gui/command/*.cpp"
"${PROJECT_SOURCE_DIR}/src/gui/GLFont/*.cpp"
"${PROJECT_SOURCE_DIR}/include/*.h"
"${PROJECT_SOURCE_DIR}/include/gui/*.h"
"${PROJECT_SOURCE_DIR}/include/logic/*.h"
"${PROJECT_SOURCE_DIR}/include/gui/command/*.h"
"${PROJECT_SOURCE_DIR}/include/gui/GLFont/*.h"
)
add_executable(CedarLogic WIN32 "${SRC_FILES}")
# Add the external libraries for CedarLogic
target_link_libraries(CedarLogic PRIVATE
${Libraries}
Logic
)
# This is for internal headers
include_directories(
"${PROJECT_SOURCE_DIR}/include/"
"${PROJECT_SOURCE_DIR}/include/gui/"
"${PROJECT_SOURCE_DIR}/include/logic/"
"${PROJECT_SOURCE_DIR}/include/gui/command/"
"${PROJECT_SOURCE_DIR}/include/gui/GLFont/"
)
add_subdirectory(
"${PROJECT_SOURCE_DIR}/logic/"
)
# These are for external headers
# Including PROJECT_BINARY_DIR gets CedarLogic.h with the version info.
target_include_directories(CedarLogic
PRIVATE
"${PROJECT_BINARY_DIR}"
"${wxwin}/include/msvc"
"${wxwin}/contrib/include"
)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
target_compile_options(CedarLogic
PRIVATE
/FI"${wxwin}/include/msvc/wx/setup.h"
/FI"${wxwin}/include/wx/wxprec.h"
/MP
)
target_compile_definitions(CedarLogic
PRIVATE
"_PRODUCTION_"
"WIN32"
"STRICT"
"__WXMSW__"
"__WX__"
"__WXDEBUG__"
"_WINDOWS"
"_CRT_SECURE_NO_DEPRECATE"
)
###
### Dev Setup.
###
copy_resources(CedarLogic res)
vs_source_groups(src ${Sources})
###
### Installation.
###
install(TARGETS CedarLogic RUNTIME DESTINATION ".")
install_resources(res)
set(CPACK_PACKAGE_NAME "CedarLogic")
# This exceptionally weird line is hard to understand even with the documentation.
# CMake thinks my executable is in the 'bin' subdirectory of the installation folder.
# I don't like to put it there, so I need to manually tell it my programs are up one level.
# Also, the combination of CMAKE and NSIS requires quadruple backslashes sometimes :(
# UPDATE: You can change 'bin' to '.' by setting CPACK_NSIS_EXECUTABLES_DIRECTORY.
set(CPACK_PACKAGE_EXECUTABLES ..\\\\CedarLogic "CedarLogic" ..\\\\Uninstall "Uninstall CedarLogic")
set(CPACK_PACKAGE_VENDOR "Cedarville University")
# set(CPACK_PACKAGE_VERSION_MAJOR "${CEDARLOGIC_MAJOR}")
# set(CPACK_PACKAGE_VERSION_MINOR "${CEDARLOGIC_MINOR}")
# set(CPACK_PACKAGE_VERSION_PATCH "${CEDARLOGIC_PATCH}")
set(CPACK_PACKAGE_ICON ${CMAKE_SOURCE_DIR}/cmake\\\\InstallSmall.bmp)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/res/LICENSE.txt)
set(CPACK_NSIS_MUI_ICON ${CMAKE_SOURCE_DIR}/cmake\\\\icon.ico)
set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP ${CMAKE_SOURCE_DIR}/cmake\\\\InstallLarge.bmp)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
"!include \\\"${CMAKE_SOURCE_DIR}/cmake/cpack\\\\FileAssociation.nsh\\\"
\\\${registerExtension} \\\"$INSTDIR\\\\CedarLogic.exe\\\" \\\".cdl\\\" \\\"CedarLogic Project\\\""
)
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
"\\\${unregisterExtension} \\\".cdl\\\" \\\"CedarLogic Project\\\""
)
include(CPack)