Skip to content

Commit

Permalink
Cauldron v1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rys committed Apr 16, 2021
1 parent 5f1bc5f commit d220600
Show file tree
Hide file tree
Showing 214 changed files with 20,688 additions and 1,874 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ bld/

# Visual Studio 2015/2017 cache/options directory
.vs/
# Visual Studio code cache/options directory
.vscode/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# Visual Studio 2017 auto generated files
Generated\ Files/

# Visual Studio 2019 Open Folder default output folder
out/
CMakeSettings.json

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
Expand Down Expand Up @@ -346,4 +352,4 @@ ASALocalRun/
healthchecksdb

# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
MigrationBackup/
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variables:
CMakeConfig: -G "Visual Studio 15 2017" -A x64
CMakeConfig: -G "Visual Studio 16 2019" -A x64

stages:
- build
Expand Down
74 changes: 53 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,76 @@
cmake_minimum_required(VERSION 3.4)
set(CMAKE_GENERATOR_PLATFORM x64)
#set a debug override for the project before we change project name for Cauldron
cmake_minimum_required(VERSION 3.6)

project (Cauldron_${GFX_API})
option (GFX_API_DX12 "Build Cauldron with DX12" ON)
option (GFX_API_VK "Build Cauldron with Vulkan" ON)

if(NOT DEFINED GFX_API)
project (Cauldron)
else()
project (Cauldron_${GFX_API})

set_property(DIRECTORY ${CMAKE_PROJECT_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})

if(GFX_API STREQUAL DX12)
set(GFX_API_DX12 ON)
set(GFX_API_VK OFF)
elseif(GFX_API STREQUAL VK)
set(GFX_API_DX12 OFF)
set(GFX_API_VK ON)
else()
message(STATUS "----------------------------------------------------------------------------------------")
message(STATUS "")
message(STATUS "** Almost there!!")
message(STATUS "")
message(STATUS " This framework supports DX12 and VULKAN, you need to invoke cmake in one of these ways:")
message(STATUS "")
message(STATUS " Examples:")
message(STATUS " Generate selected one:")
message(STATUS " cmake <project_root_dir> -DGFX_API=DX12")
message(STATUS " cmake <project_root_dir> -DGFX_API=VK")
message(STATUS " Generate with switches (Default is ON):")
message(STATUS " cmake <project_root_dir> [-DGFX_API_DX12=ON|OFF] [-DGFX_API_VK=ON|OFF]")
message(STATUS "")
message(STATUS "----------------------------------------------------------------------------------------")
message(FATAL_ERROR "")
endif()
endif()

# Check MSVC toolset version, Visual Studio 2019 required
if(MSVC_TOOLSET_VERSION VERSION_LESS 142)
message(FATAL_ERROR "Cannot find MSVC toolset version 142 or greater. Please make sure Visual Studio 2019 or newer installed")
endif()

list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} )

# output exe to bin directory
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin)
# append 'd' to debug libs
set(CMAKE_DEBUG_POSTFIX d)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_HOME_DIRECTORY}/bin )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )

add_compile_options(/MP)

# reference libs used by both backends
add_subdirectory(src/Common)
add_subdirectory(libs/json)
add_subdirectory(libs/ImGUI)
add_subdirectory(libs/stb)
add_subdirectory(libs/DXC)
add_subdirectory(libs/vectormath)

if(GFX_API STREQUAL DX12)
if(GFX_API_DX12)
add_subdirectory(libs/d3d12x)
add_subdirectory(libs/ags)
add_subdirectory(src/DX12)
elseif(GFX_API STREQUAL VK)
add_subdirectory(libs/AGS)
add_subdirectory(libs/WinPixEventRuntime)
add_subdirectory(src/DX12)
endif()
if(GFX_API_VK)
find_package(Vulkan REQUIRED)
add_subdirectory(libs/VulkanMemoryAllocator)
add_subdirectory(libs/VulkanMemoryAllocator)
add_subdirectory(src/VK)
else()
message(STATUS "----------------------------------------------------------------------------------------")
message(STATUS "")
message(STATUS "** Almost there!!")
message(STATUS "")
message(STATUS " This framework supports DX12 or VULKAN, you need to invoke cmake in one of these ways:")
message(STATUS "")
message(STATUS " Examples:")
message(STATUS " cmake <project_root_dir> -DGFX_API=DX12")
message(STATUS " cmake <project_root_dir> -DGFX_API=VK")
message(STATUS "")
message(STATUS "----------------------------------------------------------------------------------------")
message(FATAL_ERROR "")
endif()

4 changes: 2 additions & 2 deletions build/GenerateSolutions.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
mkdir DX12
cd DX12
cmake ..\.. -DGFX_API=DX12
cmake -A x64 ..\.. -DGFX_API=DX12
cd ..

mkdir VK
cd VK
cmake ..\.. -DGFX_API=VK
cmake -A x64 ..\.. -DGFX_API=VK
cd ..
47 changes: 43 additions & 4 deletions common.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,59 @@
#
# Copies a set of files to a directory (only if they already don't exist or are different)
# Usage example:
# set(media_src ${CMAKE_CURRENT_SOURCE_DIR}/../../media/brdfLut.dds )
# set(media_src ${CMAKE_CURRENT_SOURCE_DIR}/../../media/brdfLut.dds )
# copyCommand("${media_src}" ${CMAKE_HOME_DIRECTORY}/bin)
#
# Sometimes a proper dependency between target and copied files cannot be created
# and you should try copyTargetCommand() below instead
#
function(copyCommand list dest)
foreach(fullFileName ${list})
foreach(fullFileName ${list})
get_filename_component(file ${fullFileName} NAME)
message("Generating custom command for ${fullFileName}")
add_custom_command(
OUTPUT ${dest}/${file}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${dest}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${fullFileName} ${dest}
MAIN_DEPENDENCY ${fullFileName}
COMMENT "Updating ${file} into ${dest}"
)
list(APPEND dest_files ${dest}/${file})
endforeach()

#return output file list
set(copyCommand_dest_files ${dest_files} PARENT_SCOPE)
endfunction()

#
# Same as copyCommand() but you can give a target name
# This custom target will depend on all those copied files
# Then the target can be properly set as a dependency of other executable or library
# Usage example:
# add_library(my_lib ...)
# set(media_src ${CMAKE_CURRENT_SOURCE_DIR}/../../media/brdfLut.dds )
# copyTargetCommand("${media_src}" ${CMAKE_HOME_DIRECTORY}/bin copied_media_src)
# add_dependencies(my_lib copied_media_src)
#
function(copyTargetCommand list dest returned_target_name)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

foreach(fullFileName ${list})
get_filename_component(file ${fullFileName} NAME)
message("Generating custom command for ${fullFileName}")
add_custom_command(
OUTPUT ${dest}/${file}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${dest}
COMMAND ${CMAKE_COMMAND} -E copy ${fullFileName} ${dest}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${fullFileName} ${dest}
MAIN_DEPENDENCY ${fullFileName}
COMMENT "Updating ${file} into ${dest}"
)
endforeach()
list(APPEND dest_list ${dest}/${file})
endforeach()

add_custom_target(${returned_target_name} DEPENDS "${dest_list}")

set_target_properties(${returned_target_name} PROPERTIES FOLDER CopyTargets)
endfunction()
5 changes: 4 additions & 1 deletion libs/AGS/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
include(common)

add_library(amd_ags SHARED IMPORTED GLOBAL)
set_property(TARGET amd_ags PROPERTY IMPORTED_IMPLIB ${CMAKE_CURRENT_SOURCE_DIR}/amd_ags_x64.lib)

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/amd_ags_x64.dll DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
copyTargetCommand(${CMAKE_CURRENT_SOURCE_DIR}/amd_ags_x64.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} copied_amd_ags_bin)
add_dependencies(amd_ags copied_amd_ags_bin)
18 changes: 9 additions & 9 deletions libs/DXC/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
project (DXC)
include(common)

add_library(${PROJECT_NAME} SHARED IMPORTED GLOBAL)
add_library(DXC INTERFACE)
target_include_directories(DXC INTERFACE BEFORE "inc/")

set_property(TARGET ${PROJECT_NAME} PROPERTY IMPORTED_IMPLIB dxcompiler.lib)
set(DXC_BIN
"${CMAKE_CURRENT_SOURCE_DIR}/bin/x64/dxcompiler.dll"
"${CMAKE_CURRENT_SOURCE_DIR}/bin/x64/dxil.dll"
)

set( SC_DEST_DIR ${CMAKE_HOME_DIRECTORY}/bin)

file(MAKE_DIRECTORY ${SC_DEST_DIR})

set(DXC_dlls bin/dxil.dll bin/dxcompiler.dll)
file(COPY ${DXC_dlls} DESTINATION ${SC_DEST_DIR})
copyTargetCommand("${DXC_BIN}" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} copied_dxc_bin)
add_dependencies(DXC copied_dxc_bin)
Binary file added libs/DXC/bin/x64/dxc.exe
Binary file not shown.
Binary file added libs/DXC/bin/x64/dxcompiler.dll
Binary file not shown.
Binary file added libs/DXC/bin/x64/dxil.dll
Binary file not shown.
Loading

0 comments on commit d220600

Please sign in to comment.