Skip to content
Merged
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
31 changes: 17 additions & 14 deletions CMake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,30 @@ option(USE_UNITY_BUILD "Use unity build" ON)
option(EXPORT_COMPILE_COMMANDS "Whether to export all compile commands" OFF)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_UNITY_BUILD ${USE_UNITY_BUILD})
set(CMAKE_EXPORT_COMPILE_COMMANDS ${EXPORT_COMPILE_COMMANDS})

get_cmake_property(generator_is_multi_config GENERATOR_IS_MULTI_CONFIG)
if (${CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT})
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/Installed CACHE PATH "" FORCE)
endif()

add_definitions(-DBUILD_CONFIG_DEBUG=$<IF:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>,1,0>)

add_definitions(-DPLATFORM_WINDOWS=$<IF:$<PLATFORM_ID:Windows>,1,0>)
add_definitions(-DPLATFORM_LINUX=$<IF:$<PLATFORM_ID:Linux>,1,0>)
add_definitions(-DPLATFORM_MACOS=$<IF:$<PLATFORM_ID:Darwin>,1,0>)

add_definitions(-DCOMPILER_MSVC=$<IF:$<CXX_COMPILER_ID:MSVC>,1,0>)
add_definitions(-DCOMPILER_APPLE_CLANG=$<IF:$<CXX_COMPILER_ID:AppleClang>,1,0>)
add_definitions(-DCOMPILER_GCC=$<IF:$<CXX_COMPILER_ID:GNU>,1,0>)
add_compile_definitions(
BUILD_CONFIG_DEBUG=$<IF:$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>,1,0>
PLATFORM_WINDOWS=$<IF:$<PLATFORM_ID:Windows>,1,0>
PLATFORM_LINUX=$<IF:$<PLATFORM_ID:Linux>,1,0>
PLATFORM_MACOS=$<IF:$<PLATFORM_ID:Darwin>,1,0>
COMPILER_MSVC=$<IF:$<CXX_COMPILER_ID:MSVC>,1,0>
COMPILER_APPLE_CLANG=$<IF:$<CXX_COMPILER_ID:AppleClang>,1,0>
COMPILER_GCC=$<IF:$<CXX_COMPILER_ID:GNU>,1,0>
)

if (${MSVC})
add_compile_options(/bigobj /MD)
add_definitions(-D_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS=1)
add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-DNOMINMAX=1)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
add_compile_options(/bigobj)
add_compile_definitions(
_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS=1
WIN32_LEAN_AND_MEAN
NOMINMAX=1
)
endif ()
79 changes: 16 additions & 63 deletions CMake/Target.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ set(GENERATED_MIRROR_INFO_SRC_DIR ${GENERATED_DIR}/MirrorInfoSrc CACHE PATH "" F
set(BASE_TARGETS_FOLDER "${SUB_PROJECT_NAME}" CACHE STRING "" FORCE)
set(AUX_TARGETS_FOLDER "${BASE_TARGETS_FOLDER}/Aux" CACHE STRING "" FORCE)

get_cmake_property(with_multi_config_generator GENERATOR_IS_MULTI_CONFIG)

if (${BUILD_TEST})
enable_testing()
add_definitions(-DBUILD_TEST=1)
add_compile_definitions(BUILD_TEST=1)
else()
add_definitions(-DBUILD_TEST=0)
add_compile_definitions(BUILD_TEST=0)
endif()

if ("${SUB_PROJECT_NAME}" STREQUAL "")
Expand Down Expand Up @@ -107,7 +109,7 @@ function(exp_process_runtime_dependencies)
endif ()
if (NOT ${arg_NOT_INSTALL} AND NOT "${runtime_deps}" STREQUAL "")
install(
FILES ${runtime_deps} DESTINATION ${CMAKE_INSTALL_PREFIX}/${SUB_PROJECT_NAME}/Binaries
FILES ${runtime_deps} DESTINATION ${SUB_PROJECT_NAME}/Binaries
)
endif ()
endfunction()
Expand Down Expand Up @@ -141,8 +143,8 @@ function(exp_add_resources_copy_command)

list(APPEND copy_commands COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} $<TARGET_FILE_DIR:${arg_NAME}>/${dst})

get_filename_component(absolute_dst ${CMAKE_INSTALL_PREFIX}/${SUB_PROJECT_NAME}/Binaries/${dst} ABSOLUTE)
get_filename_component(dst_dir ${absolute_dst} DIRECTORY)
cmake_path(SET dst_path NORMALIZE "${SUB_PROJECT_NAME}/Binaries/${dst}")
cmake_path(GET dst_path PARENT_PATH dst_dir)
if (NOT ${arg_NOT_INSTALL})
install(FILES ${src} DESTINATION ${dst_dir})
endif ()
Expand All @@ -166,6 +168,7 @@ function(exp_gather_target_libs)
string(REGEX MATCH "\\$\\<BUILD_INTERFACE.+\\>" match ${arg_NAME})
if (match)
set(${arg_OUTPUT} "" PARENT_SCOPE)
return()
endif ()

get_target_property(target_libs ${arg_NAME} LINK_LIBRARIES)
Expand Down Expand Up @@ -309,8 +312,7 @@ function(exp_add_executable)
set_target_properties(${arg_NAME} PROPERTIES FOLDER ${BASE_TARGETS_FOLDER})
endif ()

get_cmake_property(generated_is_multi_config GENERATOR_IS_MULTI_CONFIG)
if (${generated_is_multi_config})
if (${with_multi_config_generator})
set(runtime_output_dir ${CMAKE_BINARY_DIR}/Dist/$<CONFIG>/${SUB_PROJECT_NAME}/Binaries)
else ()
set(runtime_output_dir ${CMAKE_BINARY_DIR}/Dist/${SUB_PROJECT_NAME}/Binaries)
Expand Down Expand Up @@ -411,8 +413,7 @@ function(exp_add_library)
${arg_NAME}
PRIVATE ${arg_SRC} ${generated_src}
)
get_cmake_property(generator_is_multi_config GENERATOR_IS_MULTI_CONFIG)
if (${generator_is_multi_config})
if (${with_multi_config_generator})
set(runtime_output_dir ${CMAKE_BINARY_DIR}/Targets/${SUB_PROJECT_NAME}/${arg_NAME}/$<CONFIG>/Binaries)
set(library_output_dir ${CMAKE_BINARY_DIR}/Targets/${SUB_PROJECT_NAME}/${arg_NAME}/$<CONFIG>/Binaries)
set(archive_output_directory ${CMAKE_BINARY_DIR}/Targets/${SUB_PROJECT_NAME}/${arg_NAME}/$<CONFIG>/Lib)
Expand Down Expand Up @@ -504,65 +505,17 @@ function(exp_add_test)
set(multiValueArgs SRC INC LINK LIB DEP_TARGET RES REFLECT)
cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN})

if (DEFINED arg_REFLECT)
exp_add_mirror_info_source_generation_target(
NAME ${arg_NAME}
OUTPUT_SRC generated_src
OUTPUT_TARGET_NAME generated_target
SEARCH_DIR ${arg_REFLECT}
PRIVATE_INC ${arg_INC}
LIB ${arg_LIB}
)
endif()

add_executable(${arg_NAME})
set_target_properties(${arg_NAME} PROPERTIES FOLDER ${BASE_TARGETS_FOLDER})

target_sources(
${arg_NAME}
PRIVATE ${arg_SRC} ${generated_src}
)
get_cmake_property(generator_is_multi_config GENERATOR_IS_MULTI_CONFIG)
if (${generator_is_multi_config})
set_target_properties(
${arg_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Dist/$<CONFIG>/${SUB_PROJECT_NAME}/Binaries
)
else ()
set_target_properties(
${arg_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Dist/${SUB_PROJECT_NAME}/Binaries
)
endif ()

target_include_directories(
${arg_NAME}
PRIVATE ${arg_INC}
)
target_link_directories(
${arg_NAME}
PRIVATE ${arg_LINK}
)
target_link_libraries(
${arg_NAME}
PRIVATE Test ${arg_LIB}
)
exp_process_runtime_dependencies(
exp_add_executable(
NAME ${arg_NAME}
SRC ${arg_SRC}
INC ${arg_INC}
LINK ${arg_LINK}
LIB Test ${arg_LIB}
DEP_TARGET ${arg_DEP_TARGET}
NOT_INSTALL
)
exp_add_resources_copy_command(
NAME ${arg_NAME}
RES ${arg_RES}
REFLECT ${arg_REFLECT}
NOT_INSTALL
)
if (DEFINED arg_DEP_TARGET)
add_dependencies(${arg_NAME} ${arg_DEP_TARGET})
endif()
if (DEFINED arg_REFLECT)
add_dependencies(${arg_NAME} ${generated_target})
endif()

add_test(
NAME ${arg_NAME}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG "Release" CACHE STRING "" FORCE)
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release" CACHE STRING "" FORCE)
set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL "Release" CACHE STRING "" FORCE)

add_definitions(-DBUILD_EDITOR=$<BOOL:BUILD_EDITOR>)
add_compile_definitions(BUILD_EDITOR=$<BOOL:${BUILD_EDITOR}>)

include(CMake/Common.cmake)
include(CMake/Target.cmake)
Expand Down
14 changes: 4 additions & 10 deletions Editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,19 @@ qt_standard_project_setup()

if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(platform_executable_hint MACOSX_BUNDLE)
set(bundle_install_dest BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/${SUB_PROJECT_NAME}/Binaries)
set(bundle_install_dest BUNDLE DESTINATION ${SUB_PROJECT_NAME}/Binaries)
set(platform_fwk_dir ${QT_ROOT}/lib)
endif ()

set(editor_includes Include)
set(editor_qt_libs Qt6::Core Qt6::Gui Qt6::Widgets Qt6::WebEngineWidgets)
set(editor_libs Core RHI Runtime httplib::httplib ${editor_qt_libs})

foreach (QT_LIB ${editor_qt_libs})
string(REPLACE "::" "" QT_RAW_LIB ${QT_LIB})
list(APPEND editor_includes ${${QT_RAW_LIB}_INCLUDE_DIRS})
endforeach ()

exp_add_mirror_info_source_generation_target(
NAME Editor
OUTPUT_SRC EDITOR_MIRROR_GENERATED_SRC
OUTPUT_TARGET_NAME EDITOR_MIRROR_GENERATED_TARGET
SEARCH_DIR Include
PRIVATE_INC ${editor_includes}
PRIVATE_INC Include
LIB ${editor_libs}
FRAMEWORK_DIR ${platform_fwk_dir}
)
Expand All @@ -49,7 +43,7 @@ else ()
)
endif ()

target_include_directories(Editor PRIVATE ${editor_includes})
target_include_directories(Editor PRIVATE Include)
target_link_libraries(Editor PRIVATE ${editor_libs})

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
Expand All @@ -65,7 +59,7 @@ exp_process_runtime_dependencies(
)
install(
TARGETS Editor
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${SUB_PROJECT_NAME}/Binaries
RUNTIME DESTINATION ${SUB_PROJECT_NAME}/Binaries
${bundle_install_dest}
)
export(
Expand Down
29 changes: 11 additions & 18 deletions Editor/Include/Editor/Qt/JsonSerialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
#include <Mirror/Mirror.h>
#include <Editor/Qt/MirrorTemplateView.h>

// TODO
#pragma optimize("", off)

namespace Editor {
template <typename T> struct QtJsonSerializer {};
template <typename T> concept QtJsonSerializable = requires(
Expand Down Expand Up @@ -320,7 +317,7 @@ namespace Editor {
}
if (jsonObject.contains("value")) {
const QJsonValue jsonValue = jsonObject["value"];
QtJsonSerializer<K>::QtJsonDeserialize(jsonValue, outValue.second);
QtJsonSerializer<V>::QtJsonDeserialize(jsonValue, outValue.second);
}
}
};
Expand Down Expand Up @@ -378,7 +375,7 @@ namespace Editor {
for (const auto& jsonElement : jsonArray) {
T element;
QtJsonSerializer<T>::QtJsonDeserialize(jsonElement, element);
outValue.emplaceback(std::move(element));
outValue.emplace_back(std::move(element));
}
}
};
Expand All @@ -404,7 +401,6 @@ namespace Editor {

const QJsonArray jsonArray = inJsonValue.toArray();
outValue.clear();
outValue.reserve(jsonArray.size());
for (const auto& jsonElement : jsonArray) {
T element;
QtJsonSerializer<T>::QtJsonDeserialize(jsonElement, element);
Expand Down Expand Up @@ -464,7 +460,6 @@ namespace Editor {

const QJsonArray jsonArray = inJsonValue.toArray();
outValue.clear();
outValue.reserve(jsonArray.size());
for (const auto& jsonElement : jsonArray) {
T element;
QtJsonSerializer<T>::QtJsonDeserialize(jsonElement, element);
Expand Down Expand Up @@ -497,7 +492,7 @@ namespace Editor {
outValue.reserve(jsonArray.size());
for (const auto& jsonPair : jsonArray) {
std::pair<K, V> pair;
QtJsonSerializer<std::pair<K, V>>::QtJsonSerialize(jsonPair, pair);
QtJsonSerializer<std::pair<K, V>>::QtJsonDeserialize(jsonPair, pair);
outValue.emplace(std::move(pair));
}
}
Expand All @@ -524,10 +519,9 @@ namespace Editor {

const QJsonArray jsonArray = inJsonValue.toArray();
outValue.clear();
outValue.reserve(jsonArray.size());
for (const auto& jsonPair : jsonArray) {
std::pair<K, V> pair;
QtJsonSerializer<std::pair<K, V>>::QtJsonSerialize(jsonPair, pair);
QtJsonSerializer<std::pair<K, V>>::QtJsonDeserialize(jsonPair, pair);
outValue.emplace(std::move(pair));
}
}
Expand All @@ -553,7 +547,7 @@ namespace Editor {
{
(void) std::initializer_list<int> { ([&]() -> void {
const auto key = std::to_string(I);
const QJsonValue jsonValue = inJsonObject[key];
const QJsonValue jsonValue = inJsonObject[QString::fromStdString(key)];
if (jsonValue.isNull()) {
return;
}
Expand Down Expand Up @@ -623,7 +617,7 @@ namespace Editor {
const QJsonValue jsonType = jsonObject["type"];
const QJsonValue jsonContent = jsonObject["content"];

uint64_t aspectIndex;
uint64_t aspectIndex = 0;
QtJsonSerializer<uint64_t>::QtJsonDeserialize(jsonType, aspectIndex);
QtJsonDeserializeInternal(jsonContent, outValue, aspectIndex, std::make_index_sequence<sizeof...(T)> {});
}
Expand Down Expand Up @@ -652,8 +646,7 @@ namespace Editor {
return;
}
for (auto i = 0; i < L; i++) {
QJsonValue jsonElement;
QtJsonSerializer<T>::QtJsonDeserialize(jsonElement, jsonArray[i]);
QtJsonSerializer<T>::QtJsonDeserialize(jsonArray[i], outValue[i]);
}
}
};
Expand Down Expand Up @@ -903,7 +896,7 @@ namespace Editor {
for (const auto& jsonElement : jsonArray) {
T element;
QtJsonSerializer<T>::QtJsonDeserialize(jsonElement, element);
outValue.emplaceBack(std::move(element));
outValue.insert(std::move(element));
}
}
};
Expand Down Expand Up @@ -1124,7 +1117,7 @@ namespace Editor {
QJsonObject jsonObject;
jsonObject["key"] = jsonKey;
jsonObject["value"] = jsonValue;
outJsonValue = std::move(jsonValue);
outJsonValue = std::move(jsonObject);
}

static void DeserializeDynWithView(const QJsonValue& inJsonValue, const Mirror::StdPairView& inView)
Expand Down Expand Up @@ -1404,14 +1397,14 @@ namespace Editor {
return;
}
const QJsonObject jsonObject = inJsonValue.toObject();
if (!jsonObject.contains("type") || jsonObject.contains("content")) {
if (!jsonObject.contains("type") || !jsonObject.contains("content")) {
return;
}

const QJsonValue typeJson = jsonObject["type"];
const QJsonValue contentJson = jsonObject["content"];

uint64_t type;
uint64_t type = 0;
QtJsonSerializer<uint64_t>::QtJsonDeserialize(typeJson, type);

Mirror::Any tempObj = inView.CreateElement(type);
Expand Down
1 change: 1 addition & 0 deletions Editor/Include/Editor/Widget/ProjectHub.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Editor {

public Q_SLOTS:
void CreateProject() const;
QString BrowseDirectory() const;

private:
QString GetEngineVersion() const;
Expand Down
7 changes: 7 additions & 0 deletions Editor/Src/Widget/ProjectHub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Created by johnk on 2025/8/3.
//

#include <QFileDialog>

#include <Editor/Widget/ProjectHub.h>
#include <Editor/Widget/moc_ProjectHub.cpp>
#include <Core/Log.h>
Expand Down Expand Up @@ -41,6 +43,11 @@ namespace Editor {
LogInfo(ProjectHub, "ProjectHubBridge::CreateProject");
}

QString ProjectHubBackend::BrowseDirectory() const // NOLINT
{
return QFileDialog::getExistingDirectory(nullptr, "Select Project Directory", QDir::rootPath());
}

QString ProjectHubBackend::GetEngineVersion() const
{
return QString::fromStdString(engineVersion);
Expand Down
Loading