Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

[draft] CMake support #130

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
exception*.txt
options.ini

# CMake
build/

# Visual Studio
[Dd]ebug
[Rr]elease
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
[submodule "Libraries/tinyxml2"]
path = Libraries/tinyxml2
url = [email protected]:SCP-CBN/tinyxml2.git
[submodule "Libraries/assimp"]
path = Libraries/assimp
url = [email protected]:assimp/assimp.git
44 changes: 44 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 3.21)
project(scpcb)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BUILD_RPATH})

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)

set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "")
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "")

option(PGE_D3D "DirectX(11) (Windows Only)" ON)
option(PGE_VKR "Vulkan (Windows & Linux)" ON)
option(PGE_OGL "OpenGL(3)" ON)

if(WIN32 AND PGE_D3D)
add_compile_definitions(PGE_D3D)
endif()
if(PGE_VKR)
find_package(Vulkan REQUIRED FATAL_ERROR)
add_compile_definitions(PGE_VKR)
endif()
if(PGE_OGL)
add_compile_definitions(PGE_OGL)
endif()

# add_compile_definitions(PGE_DEBUG)

if(UNIX AND NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") # angelscript
add_compile_definitions(LINUX)
endif()

add_compile_definitions(ANGELSCRIPT_EXPORT)

add_subdirectory(Engine)
add_subdirectory(Libraries/assimp)
add_subdirectory(Libraries/freetype)
add_subdirectory(Libraries/angelscript/sdk/angelscript/projects/cmake)
# add_subdirectory(Libraries/tinyxml2) # this seems to break cmake for some reason
add_subdirectory(Src)
1 change: 1 addition & 0 deletions Libraries/assimp
Submodule assimp added at 4d451f
169 changes: 169 additions & 0 deletions Src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# PS> Get-ChildItem -Recurse | Resolve-Path -Relative > out.txt
add_executable(scpcb
${CMAKE_CURRENT_SOURCE_DIR}/../Libraries/angelscript/sdk/add_on/scriptarray/scriptarray.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../Libraries/tinyxml2/tinyxml2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../Engine/Src/Init/Init.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Collision/Collider.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Collision/Collider.h
${CMAKE_CURRENT_SOURCE_DIR}/Collision/Collision.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Collision/Collision.h
${CMAKE_CURRENT_SOURCE_DIR}/Collision/CollisionMesh.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Collision/CollisionMesh.h
${CMAKE_CURRENT_SOURCE_DIR}/Collision/CollisionMeshCollection.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Collision/CollisionMeshCollection.h
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/Billboard.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/Billboard.h
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/Camera.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/Camera.h
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/DebugGraphics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/DebugGraphics.h
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/Font.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/Font.h
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/GraphicsResources.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/GraphicsResources.h
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/ModelImageGenerator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/ModelImageGenerator.h
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/UIMesh.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Graphics/UIMesh.h
${CMAKE_CURRENT_SOURCE_DIR}/Input/Input.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Input/Input.h
${CMAKE_CURRENT_SOURCE_DIR}/Input/KeyBinds.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Input/KeyBinds.h
${CMAKE_CURRENT_SOURCE_DIR}/Input/MouseData.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Input/MouseData.h
${CMAKE_CURRENT_SOURCE_DIR}/Models/CBR.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Models/CBR.h
${CMAKE_CURRENT_SOURCE_DIR}/Models/Model.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Models/Model.h
${CMAKE_CURRENT_SOURCE_DIR}/Models/RM2.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Models/RM2.h
${CMAKE_CURRENT_SOURCE_DIR}/PlayerController/PlayerController.cpp
${CMAKE_CURRENT_SOURCE_DIR}/PlayerController/PlayerController.h
${CMAKE_CURRENT_SOURCE_DIR}/Save/Config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Save/Config.h
${CMAKE_CURRENT_SOURCE_DIR}/Save/ConfigValues.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Save/ConfigValues.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/CachedArgument.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/CachedArgument.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinition.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinition.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/RefCounter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/RefCounter.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/Script.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/Script.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptClass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptClass.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptFunction.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptFunction.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptGlobal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptGlobal.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptManager.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptModule.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptModule.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptObject.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/ScriptObject.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/StringFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/StringFactory.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/Type.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/Type.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/BillboardDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/BillboardDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/CollisionDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/CollisionDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ColorDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ColorDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ConsoleDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ConsoleDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/EventDefinition.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/EventDefinition.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/InputDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/InputDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/LocalizationDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/LocalizationDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/MathDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/MathDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/MementoDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/MementoDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ModelDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ModelDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ModelImageGeneratorDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ModelImageGeneratorDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/PickableDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/PickableDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/PlayerControllerDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/PlayerControllerDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/RandomDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/RandomDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ReflectionDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/ReflectionDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/RM2Definitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/RM2Definitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/TextureDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/TextureDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/UIDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/UIDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/WorldDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Scripting/NativeDefinitions/WorldDefinitions.h
${CMAKE_CURRENT_SOURCE_DIR}/Serialize/IntProperty.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Serialize/IntProperty.h
${CMAKE_CURRENT_SOURCE_DIR}/Serialize/ScriptSerializer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Serialize/ScriptSerializer.h
${CMAKE_CURRENT_SOURCE_DIR}/Serialize/XMLProperty.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Serialize/XMLProperty.h
${CMAKE_CURRENT_SOURCE_DIR}/Utils/INI.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Utils/INI.h
${CMAKE_CURRENT_SOURCE_DIR}/Utils/LocalizationManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Utils/LocalizationManager.h
${CMAKE_CURRENT_SOURCE_DIR}/Utils/ResourcePackManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Utils/ResourcePackManager.h
${CMAKE_CURRENT_SOURCE_DIR}/Utils/TextureUtil.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Utils/TextureUtil.h
${CMAKE_CURRENT_SOURCE_DIR}/World/DataInterpolator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/World/DataInterpolator.h
${CMAKE_CURRENT_SOURCE_DIR}/World/Pickable.cpp
${CMAKE_CURRENT_SOURCE_DIR}/World/Pickable.h
${CMAKE_CURRENT_SOURCE_DIR}/World/ScriptWorld.cpp
${CMAKE_CURRENT_SOURCE_DIR}/World/ScriptWorld.h
${CMAKE_CURRENT_SOURCE_DIR}/World/Timing.cpp
${CMAKE_CURRENT_SOURCE_DIR}/World/Timing.h
# ${CMAKE_CURRENT_SOURCE_DIR}/World/VRManager.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/World/VRManager.h
${CMAKE_CURRENT_SOURCE_DIR}/World/World.cpp
${CMAKE_CURRENT_SOURCE_DIR}/World/World.h
)

add_compile_definitions(STB_IMAGE_IMPLEMENTATION STBI_WINDOWS_UTF8 STBI_FAILURE_USERMSG) # stb_image
add_compile_definitions(SDL_MAIN_HANDLED)

target_compile_definitions(scpcb PUBLIC "$<$<CONFIG:DEBUG>:DEBUG>")

target_link_libraries(scpcb PUBLIC
${SDL2_LIBRARIES}
Engine
assimp
freetype
angelscript
)

target_include_directories(scpcb PUBLIC
${SDL2_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/../Libraries/angelscript/sdk/angelscript/include
${CMAKE_CURRENT_SOURCE_DIR}/../Libraries/angelscript/sdk/add_on
${CMAKE_CURRENT_SOURCE_DIR}/../Libraries/freetype/include
${CMAKE_CURRENT_SOURCE_DIR}/../Libraries/stb_image
${CMAKE_CURRENT_SOURCE_DIR}/../Libraries/tinyxml2
)

add_custom_command(TARGET scpcb POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:scpcb> $<TARGET_FILE_DIR:scpcb>
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../Content $<TARGET_FILE_DIR:scpcb>
COMMAND_EXPAND_LISTS
)

add_dependencies(scpcb BuildShaders)
add_custom_command(TARGET scpcb POST_BUILD
COMMAND $<TARGET_FILE:BuildShaders> $<TARGET_FILE_DIR:scpcb>
COMMAND_EXPAND_LISTS
)