Skip to content

Commit 23f7446

Browse files
committed
Add Windows support in CMake build
1 parent a937663 commit 23f7446

File tree

181 files changed

+76363
-426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+76363
-426
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# exclude binaries and temporary files
1010
CMakeCache.txt
11+
CMakeSettings.json
1112
cmake_install.cmake
1213
cmake-build-*
1314
install_manifest.txt

CMakeLists.txt

+69-36
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,22 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT XRAY_USE_DEFAULT_CXX_LIB)
149149
endif()
150150
endif()
151151

152-
add_compile_options(-Wno-attributes)
153-
if (APPLE)
154-
add_compile_options(-Wl,-undefined,error)
155-
else()
156-
add_compile_options(-Wl,--no-undefined)
152+
if (NOT MSVC)
153+
add_compile_options(-Wno-attributes)
154+
if (APPLE)
155+
add_compile_options(-Wl,-undefined,error)
156+
else()
157+
add_compile_options(-Wl,--no-undefined)
158+
endif()
159+
endif()
160+
161+
if (MASTER_GOLD AND MSVC)
162+
add_compile_definitions(_HAS_EXCEPTIONS=0)
163+
#add_compile_options(/EHsc)
164+
165+
message("!!! CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
166+
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
167+
message("!!! CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
157168
endif()
158169

159170
# TODO test
@@ -206,10 +217,12 @@ elseif (PROJECT_PLATFORM_PPC)
206217
)
207218
add_compile_definitions(NO_WARN_X86_INTRINSICS)
208219
else()
209-
add_compile_options(
210-
-mfpmath=sse
211-
-msse3
212-
)
220+
if (NOT MSVC)
221+
add_compile_options(
222+
-mfpmath=sse
223+
-msse3
224+
)
225+
endif()
213226
endif()
214227

215228
if (XRAY_LINKER)
@@ -229,6 +242,23 @@ add_compile_definitions(
229242
_CPPUNWIND
230243
)
231244

245+
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
246+
set(ARCH_TYPE x64)
247+
else (CMAKE_SIZEOF_VOID_P EQUAL 4)
248+
set(ARCH_TYPE x86)
249+
endif()
250+
251+
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/sdk")
252+
list(APPEND CMAKE_LIBRARY_PATH "${CMAKE_SOURCE_DIR}/sdk/libraries/${ARCH_TYPE}")
253+
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sdk/cmake")
254+
255+
set(SDL2_DIR "${CMAKE_SOURCE_DIR}/sdk/cmake")
256+
find_package(SDL2 REQUIRED CONFIG)
257+
258+
#set(CMAKE_FIND_DEBUG_MODE TRUE)
259+
find_package(OpenAL REQUIRED)
260+
#set(CMAKE_FIND_DEBUG_MODE FALSE)
261+
232262
if (NOT WIN32)
233263
find_package(SDL2 REQUIRED)
234264
# Fix to support older SDL2
@@ -241,6 +271,7 @@ if (NOT WIN32)
241271
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
242272
)
243273
endif()
274+
244275
find_package(OpenGL REQUIRED)
245276
find_package(GLEW REQUIRED)
246277
find_package(OpenAL REQUIRED)
@@ -255,6 +286,10 @@ if (NOT WIN32)
255286
find_package(mimalloc NAMES mimalloc2 mimalloc2.0 mimalloc)
256287
endif()
257288

289+
option(XRAY_USE_LUAJIT "Use LuaJIT" ON)
290+
291+
add_subdirectory(Externals)
292+
258293
# Memory allocator option
259294
if (mimalloc_FOUND)
260295
set(MEMORY_ALLOCATOR "mimalloc" CACHE STRING "Use specific memory allocator (mimalloc/standard)")
@@ -263,38 +298,36 @@ else()
263298
endif()
264299
set_property(CACHE MEMORY_ALLOCATOR PROPERTY STRINGS "mimalloc" "standard")
265300

266-
if (MEMORY_ALLOCATOR STREQUAL "mimalloc" AND NOT mimalloc_FOUND)
301+
if (MEMORY_ALLOCATOR STREQUAL "mimalloc" AND NOT (mimalloc_FOUND OR TARGET mimalloc::mimalloc))
267302
message(FATAL_ERROR "mimalloc allocator requested but not found. Please, install mimalloc package or select standard allocator.")
268303
endif()
269304

270305
message("Using ${MEMORY_ALLOCATOR} memory allocator")
271306

272-
option(XRAY_USE_LUAJIT "Use LuaJIT" ON)
273-
274-
add_subdirectory(Externals)
275-
276-
add_compile_options(
277-
-Wall
278-
#-Werror
279-
-Wextra
280-
#-pedantic
281-
-Wno-unknown-pragmas
282-
-Wno-strict-aliasing
283-
-Wno-parentheses
284-
-Wno-unused-label
285-
-Wno-unused-parameter
286-
-Wno-switch
287-
#-Wno-padded
288-
#-Wno-c++98-compat
289-
#-Wno-c++98-compat-pedantic
290-
#-Wno-c++11-compat
291-
#-Wno-c++11-compat-pedantic
292-
#-Wno-c++14-compat
293-
#-Wno-c++14-compat-pedantic
294-
#-Wno-newline-eof
295-
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
296-
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
297-
)
307+
if (NOT MSVC)
308+
add_compile_options(
309+
-Wall
310+
#-Werror
311+
-Wextra
312+
#-pedantic
313+
-Wno-unknown-pragmas
314+
-Wno-strict-aliasing
315+
-Wno-parentheses
316+
-Wno-unused-label
317+
-Wno-unused-parameter
318+
-Wno-switch
319+
#-Wno-padded
320+
#-Wno-c++98-compat
321+
#-Wno-c++98-compat-pedantic
322+
#-Wno-c++11-compat
323+
#-Wno-c++11-compat-pedantic
324+
#-Wno-c++14-compat
325+
#-Wno-c++14-compat-pedantic
326+
#-Wno-newline-eof
327+
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
328+
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
329+
)
330+
endif()
298331

299332
add_subdirectory(src)
300333
add_subdirectory(res)

Externals/BugTrap-proj/CMakeLists.txt

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
add_library(bugtrap_bugtrap SHARED)
2+
3+
add_library(BugTrap::BugTrap ALIAS bugtrap_bugtrap)
4+
5+
target_include_directories(bugtrap_bugtrap
6+
PRIVATE
7+
#../BugTrap/include
8+
../zlib
9+
../zlib/include
10+
../zlib/contrib/minizip
11+
"${CMAKE_BINARY_DIR}/Externals/zlib"
12+
)
13+
14+
target_compile_definitions(bugtrap_bugtrap
15+
PUBLIC
16+
_USRDLL
17+
BUGTRAP_EXPORTS
18+
WIN64
19+
_WINDOWS
20+
21+
)
22+
23+
target_link_libraries(bugtrap_bugtrap
24+
PRIVATE
25+
zlib::zlib
26+
ws2_32.lib
27+
comctl32.lib
28+
shlwapi.lib
29+
version.lib
30+
wininet.lib
31+
)
32+
33+
target_link_options(bugtrap_bugtrap
34+
PRIVATE
35+
/DEF:../BugTrap/source/Client/BugTrap.def
36+
nothrownew.obj
37+
)
38+
39+
#TODO add unity build
40+
41+
target_sources(bugtrap_bugtrap
42+
PRIVATE
43+
../BugTrap/source/Client/AboutDlg.cpp
44+
../BugTrap/source/Client/AboutDlg.h
45+
../BugTrap/source/Client/AnimProgressBar.cpp
46+
../BugTrap/source/Client/AnimProgressBar.h
47+
../BugTrap/source/Client/Array.h
48+
../BugTrap/source/Client/AssemblyInfo.cpp
49+
../BugTrap/source/Client/BTAtlWindow.h
50+
../BugTrap/source/Client/BTMfcWindow.h
51+
../BugTrap/source/Client/BTTrace.h
52+
../BugTrap/source/Client/BaseStream.h
53+
../BugTrap/source/Client/Buffer.h
54+
../BugTrap/source/Client/BugTrap.cpp
55+
../BugTrap/source/Client/BugTrap.h
56+
../BugTrap/source/Client/BugTrapNet.cpp
57+
../BugTrap/source/Client/BugTrapNet.h
58+
../BugTrap/source/Client/BugTrapUI.cpp
59+
../BugTrap/source/Client/BugTrapUI.h
60+
../BugTrap/source/Client/BugTrapUtils.cpp
61+
../BugTrap/source/Client/BugTrapUtils.h
62+
../BugTrap/source/Client/CMapi.cpp
63+
../BugTrap/source/Client/CMapi.h
64+
../BugTrap/source/Client/ColHelper.cpp
65+
../BugTrap/source/Client/ColHelper.h
66+
../BugTrap/source/Client/DescribeErrorDlg.cpp
67+
../BugTrap/source/Client/DescribeErrorDlg.h
68+
../BugTrap/source/Client/Encoding.cpp
69+
../BugTrap/source/Client/Encoding.h
70+
../BugTrap/source/Client/EnumProcess.cpp
71+
../BugTrap/source/Client/EnumProcess.h
72+
../BugTrap/source/Client/FileStream.cpp
73+
../BugTrap/source/Client/FileStream.h
74+
../BugTrap/source/Client/Globals.cpp
75+
../BugTrap/source/Client/Globals.h
76+
../BugTrap/source/Client/Hash.h
77+
../BugTrap/source/Client/HexView.cpp
78+
../BugTrap/source/Client/HexView.h
79+
../BugTrap/source/Client/HyperLink.cpp
80+
../BugTrap/source/Client/HyperLink.h
81+
../BugTrap/source/Client/ImageView.cpp
82+
../BugTrap/source/Client/ImageView.h
83+
../BugTrap/source/Client/InMemLogFile.cpp
84+
../BugTrap/source/Client/InMemLogFile.h
85+
../BugTrap/source/Client/InputStream.cpp
86+
../BugTrap/source/Client/InputStream.h
87+
../BugTrap/source/Client/InterfacePtr.h
88+
../BugTrap/source/Client/LayoutManager.cpp
89+
../BugTrap/source/Client/LayoutManager.h
90+
../BugTrap/source/Client/LeakWatcher.h
91+
../BugTrap/source/Client/List.h
92+
../BugTrap/source/Client/LogFile.cpp
93+
../BugTrap/source/Client/LogFile.h
94+
../BugTrap/source/Client/LogLink.h
95+
../BugTrap/source/Client/LogStream.cpp
96+
../BugTrap/source/Client/LogStream.h
97+
../BugTrap/source/Client/MachineInfoDlg.cpp
98+
../BugTrap/source/Client/MachineInfoDlg.h
99+
../BugTrap/source/Client/MachineStateDlg.cpp
100+
../BugTrap/source/Client/MachineStateDlg.h
101+
../BugTrap/source/Client/MainDlg.cpp
102+
../BugTrap/source/Client/MainDlg.h
103+
../BugTrap/source/Client/MemStream.cpp
104+
../BugTrap/source/Client/MemStream.h
105+
../BugTrap/source/Client/ModuleImportTable.cpp
106+
../BugTrap/source/Client/ModuleImportTable.h
107+
../BugTrap/source/Client/NetThunks.cpp
108+
../BugTrap/source/Client/NetThunks.h
109+
../BugTrap/source/Client/OutputStream.cpp
110+
../BugTrap/source/Client/OutputStream.h
111+
../BugTrap/source/Client/PreviewDlg.cpp
112+
../BugTrap/source/Client/PreviewDlg.h
113+
../BugTrap/source/Client/ResManager.cpp
114+
../BugTrap/source/Client/ResManager.h
115+
../BugTrap/source/Client/SendMailDlg.cpp
116+
../BugTrap/source/Client/SendMailDlg.h
117+
../BugTrap/source/Client/SimpleDlg.cpp
118+
../BugTrap/source/Client/SimpleDlg.h
119+
../BugTrap/source/Client/SmartPtr.h
120+
../BugTrap/source/Client/Splitter.cpp
121+
../BugTrap/source/Client/Splitter.h
122+
../BugTrap/source/Client/StrHolder.cpp
123+
../BugTrap/source/Client/StrHolder.h
124+
../BugTrap/source/Client/StrStream.cpp
125+
../BugTrap/source/Client/StrStream.h
126+
../BugTrap/source/Client/Stream.h
127+
../BugTrap/source/Client/SymEngine.cpp
128+
../BugTrap/source/Client/SymEngine.h
129+
../BugTrap/source/Client/SymEngineNet.cpp
130+
../BugTrap/source/Client/SymEngineNet.h
131+
../BugTrap/source/Client/TextFormat.cpp
132+
../BugTrap/source/Client/TextFormat.h
133+
../BugTrap/source/Client/TextLogFile.cpp
134+
../BugTrap/source/Client/TextLogFile.h
135+
../BugTrap/source/Client/TextView.cpp
136+
../BugTrap/source/Client/TextView.h
137+
../BugTrap/source/Client/ThemeXP.cpp
138+
../BugTrap/source/Client/ThemeXP.h
139+
../BugTrap/source/Client/TransferProgressDlg.cpp
140+
../BugTrap/source/Client/TransferProgressDlg.h
141+
../BugTrap/source/Client/VersionInfo.h
142+
../BugTrap/source/Client/VersionInfoString.h
143+
../BugTrap/source/Client/WaitCursor.cpp
144+
../BugTrap/source/Client/WaitCursor.h
145+
../BugTrap/source/Client/WaitDlg.cpp
146+
../BugTrap/source/Client/WaitDlg.h
147+
../BugTrap/source/Client/XmlLogFile.cpp
148+
../BugTrap/source/Client/XmlLogFile.h
149+
../BugTrap/source/Client/XmlReader.cpp
150+
../BugTrap/source/Client/XmlReader.h
151+
../BugTrap/source/Client/XmlWriter.cpp
152+
../BugTrap/source/Client/XmlWriter.h
153+
../BugTrap/source/Client/resource.h
154+
../BugTrap/source/Client/stdafx.cpp
155+
../BugTrap/source/Client/stdafx.h
156+
157+
../BugTrap/source/Client/res/Bug.ico
158+
../BugTrap/source/Client/res/CheckMark.bmp
159+
../BugTrap/source/Client/res/ImageToolbar.bmp
160+
../BugTrap/source/Client/res/SortArrows.bmp
161+
162+
../BugTrap/source/Client/BugTrap.def
163+
../BugTrap/source/Client/res/KeyPair.snk
164+
../BugTrap/source/Client/res/Upload.avi
165+
166+
../BugTrap/source/Client/BugTrap.rc
167+
)

Externals/CMakeLists.txt

+25
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,31 @@ add_subdirectory(GameSpy)
1515
add_subdirectory(OPCODE)
1616
add_subdirectory(ode)
1717
add_subdirectory(imgui-proj)
18+
add_subdirectory(DiscordGameSDK)
19+
20+
if (MSVC)
21+
add_subdirectory(BugTrap-proj)
22+
add_subdirectory(libtheora-proj)
23+
add_subdirectory(libvorbis-proj)
24+
add_subdirectory(lzo-proj)
25+
26+
add_subdirectory(libogg)
27+
add_library(Ogg::Ogg ALIAS ogg)
28+
29+
#set(CMAKE_FIND_DEBUG_MODE TRUE)
30+
find_package(DXSDK)
31+
#set(CMAKE_FIND_DEBUG_MODE FALSE)
32+
33+
add_subdirectory(zlib-proj)
34+
35+
find_package(mimalloc)
36+
37+
find_package(DbgHelp)
38+
find_package(FaultRep)
39+
find_package(EAX)
40+
41+
add_subdirectory(OpenAutomate-proj)
42+
endif()
1843

1944
if (NOT TARGET xrLuabind)
2045
message(FATAL_ERROR

0 commit comments

Comments
 (0)