diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..757fee3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e69de29..2f4fd5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_LIST_DIR}) + cmake_minimum_required(VERSION 3.16) + # cmake_policy(SET CMP0141 NEW) + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:Embedded>") + project(Renderive) + set(Renderive_VERSION 1.0.0) + set(CMAKE_CXX_STANDARD 20) + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + include(third_party/build_infra/start.cmake) + include(third_party/CPP_Core/main.cmake) + include(${CMAKE_SOURCE_DIR}/main.cmake) + include(third_party/build_infra/end.cmake) +else () +endif () + + + + + + diff --git a/CMakeUserPresets.json b/CMakeUserPresets.json new file mode 100644 index 0000000..730e33c --- /dev/null +++ b/CMakeUserPresets.json @@ -0,0 +1,7 @@ +{ + "version": 4, + "include": [ + "toolchain/vs2022.json", + "toolchain/vs2019.json" + ] +} \ No newline at end of file diff --git a/main.cmake b/main.cmake index 3cce43d..d2b1bd7 100644 --- a/main.cmake +++ b/main.cmake @@ -13,18 +13,20 @@ set(renderive_dependencies ${Psc_Core_dependencies} ) #rcl_generate_registered_cmake_library() -rcl_load_dependency_environment(${renderive_dependencies}) + library_is_installed_with_rely(renderive_dependencies_installed ${renderive_dependencies}) if (NOT renderive_dependencies_installed) set(log "[FATAL_ERROR] Renderive 依赖未安装,请先构建 renderive_env 目标") rcl_log_append("${log}") rcl_add_dependency_action_targets(renderive_env ${renderive_dependencies}) return() -else () - find_package(Drogon) - find_package(spdlog CONFIG REQUIRED) - find_package(LibDataChannel CONFIG REQUIRED) endif () +rcl_load_dependency_environment(${renderive_dependencies}) +find_package(Drogon) +find_package(spdlog CONFIG REQUIRED) +find_package(LibDataChannel CONFIG REQUIRED) + + find_package(Qt5 MODULE REQUIRED COMPONENTS Core Gui Widgets Svg Xml PrintSupport QuickWidgets Multimedia ) @@ -129,7 +131,15 @@ endif () if (NOT TARGET Adminive::Nlohmann) set(renderive_saved_build_testing "${BUILD_TESTING}") set(BUILD_TESTING OFF) - add_subdirectory("${root_dir}/../Adminive" + + + if (CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR) + set(3rd_dir "${CMAKE_SOURCE_DIR}/third_party") + else () + set(3rd_dir "${root_dir}/..") + endif () + + add_subdirectory("${3rd_dir}/Adminive" "${CMAKE_CURRENT_BINARY_DIR}/third_party/Adminive" EXCLUDE_FROM_ALL) set(BUILD_TESTING "${renderive_saved_build_testing}") diff --git a/third_party/init.bash b/third_party/init.bash new file mode 100644 index 0000000..0e7dc8f --- /dev/null +++ b/third_party/init.bash @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +set -euo pipefail +root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$root" +origin="$(git remote get-url origin)" +origin="${origin%/}" +remote_root="$(printf '%s\n' "$origin" | sed -E 's#/[^/]+(\.git)?$##')" +remote_root="${remote_root%/*}" +echo "remote_root: $remote_root" +get_default_branch() { + local repo="$1" + local branch + branch="$(git ls-remote --symref "$repo" HEAD | awk '$1 == "ref:" { + sub("^refs/heads/", "", $2) + print $2 + exit + }')" + if [ -z "$branch" ]; then + printf '无法获取远程仓库默认分支: %s\n' "$repo" >&2 + return 1 + fi + printf '%s\n' "$branch" +} +fetch_repo() { + local repo="$1" + local dir="$2" + local branch="${3-}" + if [ -z "$branch" ]; then + branch="$(get_default_branch "$repo")" + fi + if [ -d "$dir" ]; then + git -C "$dir" rev-parse --is-inside-work-tree >/dev/null + git -C "$dir" remote set-url origin "$repo" + git -C "$dir" fetch origin "$branch" + git -C "$dir" checkout "$branch" + git -C "$dir" pull --ff-only origin "$branch" + else + git clone --branch "$branch" --single-branch "$repo" "$dir" + fi +} +fetch_repo_ex() { + local name="$1" + local branch="${2-}" + local repo="${remote_root}/${name}" + local dir="${name##*/}" + fetch_repo "$repo" "third_party/${dir}" "$branch" +} +fetch_repo_ex "ae/build_infra" +fetch_repo_ex "ae/CPP_Core" +fetch_repo_ex "psc/Structive" +fetch_repo_ex "psc/Adminive" + diff --git a/toolchain/vs2019.cmake b/toolchain/vs2019.cmake new file mode 100644 index 0000000..3aa7fd1 --- /dev/null +++ b/toolchain/vs2019.cmake @@ -0,0 +1,40 @@ +include_guard(GLOBAL) +#set(base_dir "C:/Program Files/Microsoft Visual Studio/18/Enterprise/VC/Tools/MSVC/14.50.35717/bin/Hostx64/x64") +#set(CMAKE_C_COMPILER "${base_dir}/cl.bat" CACHE FILEPATH "") +#set(CMAKE_CXX_COMPILER "{${base_dir}}/cl.bat" CACHE FILEPATH "") +#set(CMAKE_MAKE_PROGRAM "C:/Program Files/Microsoft Visual Studio/18/Enterprise/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe" CACHE FILEPATH "") +function(_append_msvc_init_options variable) + set(value "${${variable}}") + separate_arguments(existing_options WINDOWS_COMMAND "${value}") + foreach (option IN LISTS ARGN) + list(FIND existing_options "${option}" option_index) + if (option_index EQUAL -1) + list(APPEND existing_options "${option}") + endif () + endforeach () + list(JOIN existing_options " " value) + set(${variable} "${value}" PARENT_SCOPE) +endfunction() +_append_msvc_init_options( + CMAKE_CXX_FLAGS_INIT + /wd4819 + /utf-8 + /Zc:preprocessor + /DNOMINMAX + /D_USE_MATH_DEFINES + /EHsc + /bigobj + /DWIN32_LEAN_AND_MEAN +) +_append_msvc_init_options( + CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT + /PROFILE +) +_append_msvc_init_options( + CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT + /PROFILE +) +_append_msvc_init_options( + CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT + /PROFILE +) diff --git a/toolchain/vs2019.json b/toolchain/vs2019.json new file mode 100644 index 0000000..4693bba --- /dev/null +++ b/toolchain/vs2019.json @@ -0,0 +1,38 @@ +{ + "version": 10, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21, + "patch": 0 + }, + "configurePresets": [ + { + "name": "vs2019", + "hidden": true, + "graphviz": "${sourceDir}/../build/${presetName}/graphviz/yc.dot", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/toolchain/vs2019.cmake" + }, + "vendor": { + "jetbrains.com/clion": { + "toolchain": "vs2019" + } + } + }, + { + "name": "vs2019_Debug", + "inherits": "vs2019", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "vs2019_Release", + "inherits": "vs2019", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + } + ] +} diff --git a/toolchain/vs2022.cmake b/toolchain/vs2022.cmake new file mode 100644 index 0000000..193d1b6 --- /dev/null +++ b/toolchain/vs2022.cmake @@ -0,0 +1,13 @@ + +set(dir "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64") + +set(CMAKE_CXX_COMPILER "${dir}/cl.bat") +set(CMAKE_C_COMPILER "${dir}/cl.bat") +set(CMAKE_LINKER "${dir}/link.bat") + +#set(CMAKE_CXX_COMPILER "${dir}/cl.exe") +#set(CMAKE_C_COMPILER "${dir}/cl.exe") +#set(CMAKE_LINKER "${dir}/link.exe") + +# [2/2] C:\Windows\system32\cmd.exe /C "cd . && "C:\Program Files\JetBrains\CLion 2025.3.4\bin\cmake\win\x64\bin\cmake.exe" -E vs_link_exe --msvc-ver=1944 --intdir=CMakeFiles\radio.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\x64\mt.exe --manifests -- C:\PROGRA~1\MICROS~1\2022\ENTERP~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\LINK_2~1.BAT /nologo @CMakeFiles\radio.rsp /out:radio.exe /implib:radio.lib /pdb:radio.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console && cd ." + diff --git a/toolchain/vs2022.json b/toolchain/vs2022.json new file mode 100644 index 0000000..bf55b51 --- /dev/null +++ b/toolchain/vs2022.json @@ -0,0 +1,38 @@ +{ + "version": 10, + "cmakeMinimumRequired": { + "major": 3, + "minor": 21, + "patch": 0 + }, + "configurePresets": [ + { + "name": "vs2022", + "hidden": true, + "graphviz": "${sourceDir}/../build/${presetName}/graphviz/yc.dot", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/toolchain/vs2022.cmake" + }, + "vendor": { + "jetbrains.com/clion": { + "toolchain": "vs2022" + } + } + }, + { + "name": "vs2022_debug", + "inherits": "vs2022", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "vs2022_release", + "inherits": "vs2022", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + } + ] +} \ No newline at end of file