Skip to content

Commit

Permalink
Add Windows support in CMake build
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterkatze committed Apr 23, 2024
1 parent a937663 commit 23f7446
Show file tree
Hide file tree
Showing 181 changed files with 76,363 additions and 426 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# exclude binaries and temporary files
CMakeCache.txt
CMakeSettings.json
cmake_install.cmake
cmake-build-*
install_manifest.txt
Expand Down
105 changes: 69 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,22 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT XRAY_USE_DEFAULT_CXX_LIB)
endif()
endif()

add_compile_options(-Wno-attributes)
if (APPLE)
add_compile_options(-Wl,-undefined,error)
else()
add_compile_options(-Wl,--no-undefined)
if (NOT MSVC)
add_compile_options(-Wno-attributes)
if (APPLE)
add_compile_options(-Wl,-undefined,error)
else()
add_compile_options(-Wl,--no-undefined)
endif()
endif()

if (MASTER_GOLD AND MSVC)
add_compile_definitions(_HAS_EXCEPTIONS=0)
#add_compile_options(/EHsc)

message("!!! CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
message("!!! CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
endif()

# TODO test
Expand Down Expand Up @@ -206,10 +217,12 @@ elseif (PROJECT_PLATFORM_PPC)
)
add_compile_definitions(NO_WARN_X86_INTRINSICS)
else()
add_compile_options(
-mfpmath=sse
-msse3
)
if (NOT MSVC)
add_compile_options(
-mfpmath=sse
-msse3
)
endif()
endif()

if (XRAY_LINKER)
Expand All @@ -229,6 +242,23 @@ add_compile_definitions(
_CPPUNWIND
)

if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH_TYPE x64)
else (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCH_TYPE x86)
endif()

list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/sdk")
list(APPEND CMAKE_LIBRARY_PATH "${CMAKE_SOURCE_DIR}/sdk/libraries/${ARCH_TYPE}")
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/sdk/cmake")

set(SDL2_DIR "${CMAKE_SOURCE_DIR}/sdk/cmake")
find_package(SDL2 REQUIRED CONFIG)

#set(CMAKE_FIND_DEBUG_MODE TRUE)
find_package(OpenAL REQUIRED)
#set(CMAKE_FIND_DEBUG_MODE FALSE)

if (NOT WIN32)
find_package(SDL2 REQUIRED)
# Fix to support older SDL2
Expand All @@ -241,6 +271,7 @@ if (NOT WIN32)
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
)
endif()

find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(OpenAL REQUIRED)
Expand All @@ -255,6 +286,10 @@ if (NOT WIN32)
find_package(mimalloc NAMES mimalloc2 mimalloc2.0 mimalloc)
endif()

option(XRAY_USE_LUAJIT "Use LuaJIT" ON)

add_subdirectory(Externals)

# Memory allocator option
if (mimalloc_FOUND)
set(MEMORY_ALLOCATOR "mimalloc" CACHE STRING "Use specific memory allocator (mimalloc/standard)")
Expand All @@ -263,38 +298,36 @@ else()
endif()
set_property(CACHE MEMORY_ALLOCATOR PROPERTY STRINGS "mimalloc" "standard")

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

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

option(XRAY_USE_LUAJIT "Use LuaJIT" ON)

add_subdirectory(Externals)

add_compile_options(
-Wall
#-Werror
-Wextra
#-pedantic
-Wno-unknown-pragmas
-Wno-strict-aliasing
-Wno-parentheses
-Wno-unused-label
-Wno-unused-parameter
-Wno-switch
#-Wno-padded
#-Wno-c++98-compat
#-Wno-c++98-compat-pedantic
#-Wno-c++11-compat
#-Wno-c++11-compat-pedantic
#-Wno-c++14-compat
#-Wno-c++14-compat-pedantic
#-Wno-newline-eof
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
)
if (NOT MSVC)
add_compile_options(
-Wall
#-Werror
-Wextra
#-pedantic
-Wno-unknown-pragmas
-Wno-strict-aliasing
-Wno-parentheses
-Wno-unused-label
-Wno-unused-parameter
-Wno-switch
#-Wno-padded
#-Wno-c++98-compat
#-Wno-c++98-compat-pedantic
#-Wno-c++11-compat
#-Wno-c++11-compat-pedantic
#-Wno-c++14-compat
#-Wno-c++14-compat-pedantic
#-Wno-newline-eof
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>>
$<$<CXX_COMPILER_ID:GNU>:$<$<COMPILE_LANGUAGE:CXX>:-Wno-interference-size>>
)
endif()

add_subdirectory(src)
add_subdirectory(res)
Expand Down
167 changes: 167 additions & 0 deletions Externals/BugTrap-proj/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
add_library(bugtrap_bugtrap SHARED)

add_library(BugTrap::BugTrap ALIAS bugtrap_bugtrap)

target_include_directories(bugtrap_bugtrap
PRIVATE
#../BugTrap/include
../zlib
../zlib/include
../zlib/contrib/minizip
"${CMAKE_BINARY_DIR}/Externals/zlib"
)

target_compile_definitions(bugtrap_bugtrap
PUBLIC
_USRDLL
BUGTRAP_EXPORTS
WIN64
_WINDOWS

)

target_link_libraries(bugtrap_bugtrap
PRIVATE
zlib::zlib
ws2_32.lib
comctl32.lib
shlwapi.lib
version.lib
wininet.lib
)

target_link_options(bugtrap_bugtrap
PRIVATE
/DEF:../BugTrap/source/Client/BugTrap.def
nothrownew.obj
)

#TODO add unity build

target_sources(bugtrap_bugtrap
PRIVATE
../BugTrap/source/Client/AboutDlg.cpp
../BugTrap/source/Client/AboutDlg.h
../BugTrap/source/Client/AnimProgressBar.cpp
../BugTrap/source/Client/AnimProgressBar.h
../BugTrap/source/Client/Array.h
../BugTrap/source/Client/AssemblyInfo.cpp
../BugTrap/source/Client/BTAtlWindow.h
../BugTrap/source/Client/BTMfcWindow.h
../BugTrap/source/Client/BTTrace.h
../BugTrap/source/Client/BaseStream.h
../BugTrap/source/Client/Buffer.h
../BugTrap/source/Client/BugTrap.cpp
../BugTrap/source/Client/BugTrap.h
../BugTrap/source/Client/BugTrapNet.cpp
../BugTrap/source/Client/BugTrapNet.h
../BugTrap/source/Client/BugTrapUI.cpp
../BugTrap/source/Client/BugTrapUI.h
../BugTrap/source/Client/BugTrapUtils.cpp
../BugTrap/source/Client/BugTrapUtils.h
../BugTrap/source/Client/CMapi.cpp
../BugTrap/source/Client/CMapi.h
../BugTrap/source/Client/ColHelper.cpp
../BugTrap/source/Client/ColHelper.h
../BugTrap/source/Client/DescribeErrorDlg.cpp
../BugTrap/source/Client/DescribeErrorDlg.h
../BugTrap/source/Client/Encoding.cpp
../BugTrap/source/Client/Encoding.h
../BugTrap/source/Client/EnumProcess.cpp
../BugTrap/source/Client/EnumProcess.h
../BugTrap/source/Client/FileStream.cpp
../BugTrap/source/Client/FileStream.h
../BugTrap/source/Client/Globals.cpp
../BugTrap/source/Client/Globals.h
../BugTrap/source/Client/Hash.h
../BugTrap/source/Client/HexView.cpp
../BugTrap/source/Client/HexView.h
../BugTrap/source/Client/HyperLink.cpp
../BugTrap/source/Client/HyperLink.h
../BugTrap/source/Client/ImageView.cpp
../BugTrap/source/Client/ImageView.h
../BugTrap/source/Client/InMemLogFile.cpp
../BugTrap/source/Client/InMemLogFile.h
../BugTrap/source/Client/InputStream.cpp
../BugTrap/source/Client/InputStream.h
../BugTrap/source/Client/InterfacePtr.h
../BugTrap/source/Client/LayoutManager.cpp
../BugTrap/source/Client/LayoutManager.h
../BugTrap/source/Client/LeakWatcher.h
../BugTrap/source/Client/List.h
../BugTrap/source/Client/LogFile.cpp
../BugTrap/source/Client/LogFile.h
../BugTrap/source/Client/LogLink.h
../BugTrap/source/Client/LogStream.cpp
../BugTrap/source/Client/LogStream.h
../BugTrap/source/Client/MachineInfoDlg.cpp
../BugTrap/source/Client/MachineInfoDlg.h
../BugTrap/source/Client/MachineStateDlg.cpp
../BugTrap/source/Client/MachineStateDlg.h
../BugTrap/source/Client/MainDlg.cpp
../BugTrap/source/Client/MainDlg.h
../BugTrap/source/Client/MemStream.cpp
../BugTrap/source/Client/MemStream.h
../BugTrap/source/Client/ModuleImportTable.cpp
../BugTrap/source/Client/ModuleImportTable.h
../BugTrap/source/Client/NetThunks.cpp
../BugTrap/source/Client/NetThunks.h
../BugTrap/source/Client/OutputStream.cpp
../BugTrap/source/Client/OutputStream.h
../BugTrap/source/Client/PreviewDlg.cpp
../BugTrap/source/Client/PreviewDlg.h
../BugTrap/source/Client/ResManager.cpp
../BugTrap/source/Client/ResManager.h
../BugTrap/source/Client/SendMailDlg.cpp
../BugTrap/source/Client/SendMailDlg.h
../BugTrap/source/Client/SimpleDlg.cpp
../BugTrap/source/Client/SimpleDlg.h
../BugTrap/source/Client/SmartPtr.h
../BugTrap/source/Client/Splitter.cpp
../BugTrap/source/Client/Splitter.h
../BugTrap/source/Client/StrHolder.cpp
../BugTrap/source/Client/StrHolder.h
../BugTrap/source/Client/StrStream.cpp
../BugTrap/source/Client/StrStream.h
../BugTrap/source/Client/Stream.h
../BugTrap/source/Client/SymEngine.cpp
../BugTrap/source/Client/SymEngine.h
../BugTrap/source/Client/SymEngineNet.cpp
../BugTrap/source/Client/SymEngineNet.h
../BugTrap/source/Client/TextFormat.cpp
../BugTrap/source/Client/TextFormat.h
../BugTrap/source/Client/TextLogFile.cpp
../BugTrap/source/Client/TextLogFile.h
../BugTrap/source/Client/TextView.cpp
../BugTrap/source/Client/TextView.h
../BugTrap/source/Client/ThemeXP.cpp
../BugTrap/source/Client/ThemeXP.h
../BugTrap/source/Client/TransferProgressDlg.cpp
../BugTrap/source/Client/TransferProgressDlg.h
../BugTrap/source/Client/VersionInfo.h
../BugTrap/source/Client/VersionInfoString.h
../BugTrap/source/Client/WaitCursor.cpp
../BugTrap/source/Client/WaitCursor.h
../BugTrap/source/Client/WaitDlg.cpp
../BugTrap/source/Client/WaitDlg.h
../BugTrap/source/Client/XmlLogFile.cpp
../BugTrap/source/Client/XmlLogFile.h
../BugTrap/source/Client/XmlReader.cpp
../BugTrap/source/Client/XmlReader.h
../BugTrap/source/Client/XmlWriter.cpp
../BugTrap/source/Client/XmlWriter.h
../BugTrap/source/Client/resource.h
../BugTrap/source/Client/stdafx.cpp
../BugTrap/source/Client/stdafx.h

../BugTrap/source/Client/res/Bug.ico
../BugTrap/source/Client/res/CheckMark.bmp
../BugTrap/source/Client/res/ImageToolbar.bmp
../BugTrap/source/Client/res/SortArrows.bmp

../BugTrap/source/Client/BugTrap.def
../BugTrap/source/Client/res/KeyPair.snk
../BugTrap/source/Client/res/Upload.avi

../BugTrap/source/Client/BugTrap.rc
)
25 changes: 25 additions & 0 deletions Externals/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ add_subdirectory(GameSpy)
add_subdirectory(OPCODE)
add_subdirectory(ode)
add_subdirectory(imgui-proj)
add_subdirectory(DiscordGameSDK)

if (MSVC)
add_subdirectory(BugTrap-proj)
add_subdirectory(libtheora-proj)
add_subdirectory(libvorbis-proj)
add_subdirectory(lzo-proj)

add_subdirectory(libogg)
add_library(Ogg::Ogg ALIAS ogg)

#set(CMAKE_FIND_DEBUG_MODE TRUE)
find_package(DXSDK)
#set(CMAKE_FIND_DEBUG_MODE FALSE)

add_subdirectory(zlib-proj)

find_package(mimalloc)

find_package(DbgHelp)
find_package(FaultRep)
find_package(EAX)

add_subdirectory(OpenAutomate-proj)
endif()

if (NOT TARGET xrLuabind)
message(FATAL_ERROR
Expand Down
Loading

0 comments on commit 23f7446

Please sign in to comment.