240 lines
9.6 KiB
CMake
240 lines
9.6 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
|
|
if(POLICY CMP0141)
|
|
cmake_policy(SET CMP0141 NEW)
|
|
endif()
|
|
|
|
project(XCEngine)
|
|
|
|
if(MSVC)
|
|
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT
|
|
"$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
|
|
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:/MP>")
|
|
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
|
set(CMAKE_VS_GLOBALS "UseMultiToolTask=true")
|
|
endif()
|
|
endif()
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(XCENGINE_NANOVDB_INCLUDE_HINTS
|
|
"${CMAKE_SOURCE_DIR}/engine/third_party/nanovdb/include"
|
|
"$ENV{VCPKG_ROOT}/installed/x64-windows/include"
|
|
"D:/vcpkg/installed/x64-windows/include"
|
|
)
|
|
|
|
find_path(
|
|
XCENGINE_NANOVDB_INCLUDE_DIR
|
|
NAMES nanovdb/io/IO.h
|
|
HINTS ${XCENGINE_NANOVDB_INCLUDE_HINTS}
|
|
)
|
|
|
|
if(XCENGINE_NANOVDB_INCLUDE_DIR)
|
|
set(XCENGINE_HAS_NANOVDB ON)
|
|
message(STATUS "NanoVDB headers found: ${XCENGINE_NANOVDB_INCLUDE_DIR}")
|
|
else()
|
|
set(XCENGINE_HAS_NANOVDB OFF)
|
|
message(STATUS "NanoVDB headers not found; .nvdb source-file support will be disabled")
|
|
endif()
|
|
|
|
enable_testing()
|
|
|
|
option(XCENGINE_ENABLE_MONO_SCRIPTING "Build the Mono-based C# scripting runtime" ON)
|
|
option(XCENGINE_BUILD_XCUI_EDITOR_APP "Build the XCUI editor shell app" ON)
|
|
set(
|
|
XCENGINE_PHYSX_ROOT_DIR
|
|
"${CMAKE_SOURCE_DIR}/engine/third_party/physx"
|
|
CACHE PATH
|
|
"Path to the bundled PhysX SDK root")
|
|
set(XCENGINE_PHYSX_INCLUDE_DIR "${XCENGINE_PHYSX_ROOT_DIR}/include")
|
|
set(XCENGINE_ENABLE_PHYSX OFF)
|
|
set(XCENGINE_PHYSX_LINK_TARGETS)
|
|
set(XCENGINE_PHYSX_RUNTIME_DLL_TARGETS)
|
|
|
|
if(EXISTS "${XCENGINE_PHYSX_INCLUDE_DIR}/PxPhysicsAPI.h")
|
|
file(GLOB XCENGINE_PHYSX_BIN_ROOT_CANDIDATES_MD LIST_DIRECTORIES true
|
|
"${XCENGINE_PHYSX_ROOT_DIR}/bin/win.x86_64.vc*.md")
|
|
file(GLOB XCENGINE_PHYSX_BIN_ROOT_CANDIDATES_MT LIST_DIRECTORIES true
|
|
"${XCENGINE_PHYSX_ROOT_DIR}/bin/win.x86_64.vc*.mt")
|
|
|
|
if(XCENGINE_PHYSX_BIN_ROOT_CANDIDATES_MD)
|
|
list(SORT XCENGINE_PHYSX_BIN_ROOT_CANDIDATES_MD COMPARE NATURAL ORDER DESCENDING)
|
|
list(GET XCENGINE_PHYSX_BIN_ROOT_CANDIDATES_MD 0 XCENGINE_PHYSX_BIN_ROOT_DIR)
|
|
elseif(XCENGINE_PHYSX_BIN_ROOT_CANDIDATES_MT)
|
|
list(SORT XCENGINE_PHYSX_BIN_ROOT_CANDIDATES_MT COMPARE NATURAL ORDER DESCENDING)
|
|
list(GET XCENGINE_PHYSX_BIN_ROOT_CANDIDATES_MT 0 XCENGINE_PHYSX_BIN_ROOT_DIR)
|
|
else()
|
|
set(XCENGINE_PHYSX_BIN_ROOT_DIR "")
|
|
endif()
|
|
|
|
set(XCENGINE_PHYSX_BIN_DIR_DEBUG "${XCENGINE_PHYSX_BIN_ROOT_DIR}/debug")
|
|
set(XCENGINE_PHYSX_BIN_DIR_RELEASE "${XCENGINE_PHYSX_BIN_ROOT_DIR}/release")
|
|
set(XCENGINE_PHYSX_BIN_DIR_PROFILE "${XCENGINE_PHYSX_BIN_ROOT_DIR}/profile")
|
|
set(XCENGINE_PHYSX_BIN_DIR_CHECKED "${XCENGINE_PHYSX_BIN_ROOT_DIR}/checked")
|
|
|
|
if(WIN32 AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXFoundation_64.lib" AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXFoundation_64.dll" AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXCommon_64.lib" AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXCommon_64.dll" AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysX_64.lib" AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysX_64.dll" AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXExtensions_static_64.lib")
|
|
set(XCENGINE_ENABLE_PHYSX ON)
|
|
message(STATUS "PhysX SDK headers found: ${XCENGINE_PHYSX_INCLUDE_DIR}")
|
|
message(STATUS "PhysX SDK binaries found: ${XCENGINE_PHYSX_BIN_DIR_DEBUG}")
|
|
|
|
function(xcengine_add_physx_imported_shared target base_name)
|
|
add_library(${target} SHARED IMPORTED GLOBAL)
|
|
set(imported_configs)
|
|
|
|
foreach(config_name DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
|
|
if(config_name STREQUAL "DEBUG")
|
|
set(config_dir "${XCENGINE_PHYSX_BIN_DIR_DEBUG}")
|
|
elseif(config_name STREQUAL "RELEASE")
|
|
set(config_dir "${XCENGINE_PHYSX_BIN_DIR_RELEASE}")
|
|
elseif(config_name STREQUAL "RELWITHDEBINFO")
|
|
set(config_dir "${XCENGINE_PHYSX_BIN_DIR_PROFILE}")
|
|
else()
|
|
set(config_dir "${XCENGINE_PHYSX_BIN_DIR_CHECKED}")
|
|
endif()
|
|
|
|
set(import_lib "${config_dir}/${base_name}.lib")
|
|
set(runtime_dll "${config_dir}/${base_name}.dll")
|
|
if(EXISTS "${import_lib}" AND EXISTS "${runtime_dll}")
|
|
list(APPEND imported_configs ${config_name})
|
|
set_property(TARGET ${target} PROPERTY "IMPORTED_IMPLIB_${config_name}" "${import_lib}")
|
|
set_property(TARGET ${target} PROPERTY "IMPORTED_LOCATION_${config_name}" "${runtime_dll}")
|
|
endif()
|
|
endforeach()
|
|
|
|
if(NOT imported_configs)
|
|
message(FATAL_ERROR "PhysX target ${target} has no available runtime binaries.")
|
|
endif()
|
|
|
|
set_property(TARGET ${target} PROPERTY IMPORTED_CONFIGURATIONS "${imported_configs}")
|
|
endfunction()
|
|
|
|
function(xcengine_add_physx_imported_static target base_name)
|
|
add_library(${target} STATIC IMPORTED GLOBAL)
|
|
set(imported_configs)
|
|
|
|
foreach(config_name DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
|
|
if(config_name STREQUAL "DEBUG")
|
|
set(config_dir "${XCENGINE_PHYSX_BIN_DIR_DEBUG}")
|
|
elseif(config_name STREQUAL "RELEASE")
|
|
set(config_dir "${XCENGINE_PHYSX_BIN_DIR_RELEASE}")
|
|
elseif(config_name STREQUAL "RELWITHDEBINFO")
|
|
set(config_dir "${XCENGINE_PHYSX_BIN_DIR_PROFILE}")
|
|
else()
|
|
set(config_dir "${XCENGINE_PHYSX_BIN_DIR_CHECKED}")
|
|
endif()
|
|
|
|
set(static_lib "${config_dir}/${base_name}.lib")
|
|
if(EXISTS "${static_lib}")
|
|
list(APPEND imported_configs ${config_name})
|
|
set_property(TARGET ${target} PROPERTY "IMPORTED_LOCATION_${config_name}" "${static_lib}")
|
|
endif()
|
|
endforeach()
|
|
|
|
if(NOT imported_configs)
|
|
message(FATAL_ERROR "PhysX target ${target} has no available static libraries.")
|
|
endif()
|
|
|
|
set_property(TARGET ${target} PROPERTY IMPORTED_CONFIGURATIONS "${imported_configs}")
|
|
endfunction()
|
|
|
|
function(xcengine_copy_physx_runtime_dlls target)
|
|
foreach(physx_target IN LISTS XCENGINE_PHYSX_RUNTIME_DLL_TARGETS)
|
|
add_custom_command(TARGET ${target} POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
$<TARGET_FILE:${physx_target}>
|
|
$<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_NAME:${physx_target}>
|
|
)
|
|
endforeach()
|
|
endfunction()
|
|
|
|
xcengine_add_physx_imported_shared(XCPhysXFoundation "PhysXFoundation_64")
|
|
xcengine_add_physx_imported_shared(XCPhysXCommon "PhysXCommon_64")
|
|
xcengine_add_physx_imported_shared(XCPhysXCore "PhysX_64")
|
|
|
|
if(EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PVDRuntime_64.lib" AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PVDRuntime_64.dll")
|
|
xcengine_add_physx_imported_shared(XCPhysXPVDRuntime "PVDRuntime_64")
|
|
list(APPEND XCENGINE_PHYSX_RUNTIME_DLL_TARGETS XCPhysXPVDRuntime)
|
|
endif()
|
|
|
|
if(EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXCooking_64.lib" AND
|
|
EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXCooking_64.dll")
|
|
xcengine_add_physx_imported_shared(XCPhysXCooking "PhysXCooking_64")
|
|
list(APPEND XCENGINE_PHYSX_RUNTIME_DLL_TARGETS XCPhysXCooking)
|
|
endif()
|
|
|
|
xcengine_add_physx_imported_static(XCPhysXExtensions "PhysXExtensions_static_64")
|
|
|
|
if(EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXPvdSDK_static_64.lib")
|
|
xcengine_add_physx_imported_static(XCPhysXPvdSDK "PhysXPvdSDK_static_64")
|
|
endif()
|
|
|
|
if(EXISTS "${XCENGINE_PHYSX_BIN_DIR_DEBUG}/PhysXTask_static_64.lib")
|
|
xcengine_add_physx_imported_static(XCPhysXTask "PhysXTask_static_64")
|
|
endif()
|
|
|
|
list(APPEND XCENGINE_PHYSX_LINK_TARGETS
|
|
XCPhysXCore
|
|
XCPhysXCommon
|
|
XCPhysXFoundation
|
|
XCPhysXExtensions
|
|
)
|
|
|
|
if(TARGET XCPhysXPVDRuntime)
|
|
list(APPEND XCENGINE_PHYSX_LINK_TARGETS XCPhysXPVDRuntime)
|
|
endif()
|
|
|
|
if(TARGET XCPhysXCooking)
|
|
list(APPEND XCENGINE_PHYSX_LINK_TARGETS XCPhysXCooking)
|
|
endif()
|
|
|
|
if(TARGET XCPhysXPvdSDK)
|
|
list(APPEND XCENGINE_PHYSX_LINK_TARGETS XCPhysXPvdSDK)
|
|
endif()
|
|
|
|
if(TARGET XCPhysXTask)
|
|
list(APPEND XCENGINE_PHYSX_LINK_TARGETS XCPhysXTask)
|
|
endif()
|
|
|
|
list(APPEND XCENGINE_PHYSX_RUNTIME_DLL_TARGETS
|
|
XCPhysXFoundation
|
|
XCPhysXCommon
|
|
XCPhysXCore
|
|
)
|
|
else()
|
|
message(STATUS "PhysX SDK headers found, but required binaries are missing; native PhysX backend will stay disabled until the SDK is built")
|
|
endif()
|
|
else()
|
|
message(STATUS "PhysX SDK headers not found; PhysicsWorld will build without native PhysX backend")
|
|
endif()
|
|
|
|
set(
|
|
XCENGINE_MONO_ROOT_DIR
|
|
"${CMAKE_SOURCE_DIR}/参考/Fermion/Fermion/external/mono"
|
|
CACHE PATH
|
|
"Path to the bundled Mono distribution used by the scripting runtime")
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/engine/third_party/mono/binary/mscorlib.dll")
|
|
set(
|
|
XCENGINE_MONO_ROOT_DIR
|
|
"${CMAKE_SOURCE_DIR}/engine/third_party/mono"
|
|
CACHE PATH
|
|
"Path to the bundled Mono distribution used by the scripting runtime"
|
|
FORCE)
|
|
endif()
|
|
|
|
add_subdirectory(engine)
|
|
add_subdirectory(managed)
|
|
add_subdirectory(editor)
|
|
add_subdirectory(new_editor)
|
|
add_subdirectory(mvs/RenderDoc)
|
|
add_subdirectory(tests)
|