diff --git a/.gitignore b/.gitignore index a28c358c5..643238df5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ -.vs/ -.idea/ +.vs +.vscode +.idea x64/ *.user build +dist installer/win64/temp/* /run_tests.bat \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 26aac0e30..b82852c00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.13) +project(NauEditor) + + if(POLICY CMP0079) cmake_policy(SET CMP0079 NEW) endif() @@ -7,6 +10,8 @@ if(POLICY CMP0091) cmake_policy(SET CMP0091 NEW) endif() + +# Compiler config set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD ON) set(QT_VERSION 6) @@ -14,45 +19,98 @@ set(CMAKE_CXX_STANDARD 20) add_compile_options($<$:/MP>) -project(NauEditor) -if(NOT DEFINED ${NauEditorFolder}) +# Required packages +find_package(Python REQUIRED) + + +# Global config +if(NOT DEFINED NauEditorFolder) set(NauEditorFolder "NauEditor") -endif(NOT DEFINED ${NauEditorFolder}) +endif() + +if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/output CACHE PATH "" FORCE) + message(STATUS "Use default install folder: ${CMAKE_INSTALL_PREFIX}") +else() + message(STATUS "Defined install folder: ${CMAKE_INSTALL_PREFIX}") +endif() # In multi-configuration IDEs, only allow Debug and Release if(CMAKE_CONFIGURATION_TYPES) - set(CMAKE_CONFIGURATION_TYPES Debug Release) - set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Build Configurations" FORCE) + set(CMAKE_CONFIGURATION_TYPES Debug Release) + set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Build Configurations" FORCE) endif() -if(NOT DEFINED NAU_ROOT_DIR) - set(NAU_ROOT_DIR "$ENV{NAU_ENGINE_SOURCE_DIR}") +if (DEFINED CMAKE_BUILD_TYPE) + message(STATUS "Build configuration: ${CMAKE_BUILD_TYPE}") +else() + if (DEFINED CMAKE_CONFIGURATION_TYPES) + message(STATUS "Use multi-configuration. Allowed configurations at build time: ${CMAKE_CONFIGURATION_TYPES}") + else() + set(CMAKE_BUILD_TYPE "Debug") + message(STATUS "Use default build configuration: ${CMAKE_BUILD_TYPE}") + endif() endif() +if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) + message(FATAL_ERROR "Toolchain not selected! Please define -DCMAKE_TOOLCHAIN_FILE") +else() + cmake_path(SET CMAKE_TOOLCHAIN_FILE NORMALIZE "${CMAKE_TOOLCHAIN_FILE}") + message(STATUS "Toolchain file: ${CMAKE_TOOLCHAIN_FILE}") +endif() + +if (NOT DEFINED NAU_ROOT_DIR) + set(NAU_ROOT_DIR "$ENV{NAU_ENGINE_SOURCE_DIR}") +endif() cmake_path(SET NAU_ROOT_DIR NORMALIZE "${NAU_ROOT_DIR}") +if (EXISTS "${NAU_ROOT_DIR}") + message(STATUS "Found Nau Engine SDK: ${NAU_ROOT_DIR}") +else() + message(FATAL_ERROR "Unable to find SDK!") +endif() +set(NauEngineFolder "${NAU_ROOT_DIR}") -set(NAU_CORE_TESTS OFF) -# Shaders are assembled in samples, so we temporarily include them in the assembly. -# TODO: Remove them from the assembly when shader generation is transferred to engine modules -set(NAU_CORE_SAMPLES ON) -set(NAU_CORE_TOOLS ON) +if (NOT DEFINED NAU_BUILD_SAMPLES) + set(NAU_BUILD_SAMPLES TRUE) +endif() +message(STATUS "Samples build: ${NAU_BUILD_SAMPLES}") + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/$) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$) set(CMAKE_MODULE_PATH - "${NAU_ROOT_DIR}/cmake" + "${NauEngineFolder}" "${CMAKE_SOURCE_DIR}/cmake/defaults" "${CMAKE_SOURCE_DIR}/cmake/macros" ) -add_subdirectory("${NAU_ROOT_DIR}" "NauEngine") -include(defaults/UsdPackages) +# Nau options +option(NAU_CORE_TESTS "Build core tests projects" OFF) +# Shaders are assembled in samples, so we temporarily include them in the assembly. +# TODO: Remove them from the assembly when shader generation is transferred to engine modules +option(NAU_CORE_TOOLS "Build core tools projects" ON) +option(NAU_CORE_SAMPLES "Build core samples projects" ON) +option(NAU_RTTI "Enable rtti support" OFF) +option(NAU_EXCEPTIONS "Enable exception support" OFF) + +# Global options +option(BUILD_SHARED_LIBS "Build shared libs" OFF) + + +include(NauEngineSDK) +include(UsdPackages) include(NauCommon) include(NauModule) include(NauGenFunctions) include(platformSpec/NauPlatformSetup) include(Packages) +if (NAU_BUILD_SAMPLES) + nau_add_samples() +endif() + add_subdirectory(editor) add_subdirectory(installer) add_subdirectory(translations) diff --git a/CMakePresets.json b/CMakePresets.json index e9ef9a63e..3fbaf9fe9 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -11,7 +11,6 @@ "CMAKE_SYSTEM_VERSION": "10.0", "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", "VCPKG_MANIFEST_MODE": true, - "NAU_BUILD_SDK": true, "BUILD_SHARED_LIBS": false, "EASTL_BUILD_BENCHMARK": false, "EASTL_BUILD_TESTS": false diff --git a/editor/source/editor-core/CMakeLists.txt b/editor/source/editor-core/CMakeLists.txt index b55daaee7..67520a57e 100644 --- a/editor/source/editor-core/CMakeLists.txt +++ b/editor/source/editor-core/CMakeLists.txt @@ -306,7 +306,7 @@ set_target_properties(NauEditorCore PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${ set_target_properties(NauEditorCore PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Release/NauEditor) if (WIN32) - set_target_properties(NauEditorCore PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=$;${PXR_ENV_PATHS};%PATH%;${PXR_DEBUGER_ENV};${PXR_DEBUGER_PLUGINPATH}") + set_target_properties(NauEditorCore PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=${NAU_ROOT_DIR};${PXR_ENV_PATHS};%PATH%;${PXR_DEBUGER_ENV};${PXR_DEBUGER_PLUGINPATH}") endif() if (NOT COCOS2DX_ROOT_PATH) diff --git a/editor/source/editor-engine/CMakeLists.txt b/editor/source/editor-engine/CMakeLists.txt index f9eb27239..6d8051374 100644 --- a/editor/source/editor-engine/CMakeLists.txt +++ b/editor/source/editor-engine/CMakeLists.txt @@ -85,7 +85,7 @@ set_target_properties(NauEditorEngine PROPERTIES AUTOMOC TRUE) set_target_properties(NauEditorEngine PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Debug/NauEditor) set_target_properties(NauEditorEngine PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Release/NauEditor) -target_compile_definitions(ui PRIVATE UI_ELEMENT_DEBUG) +#target_compile_definitions(ui PRIVATE UI_ELEMENT_DEBUG) if (TARGET NauKernel_Import AND TARGET NauFramework_Import) add_dependencies(${TargetName} NauKernel_Import NauFramework_Import) diff --git a/editor/source/editor/CMakeLists.txt b/editor/source/editor/CMakeLists.txt index 66243ca5c..4a91a876b 100644 --- a/editor/source/editor/CMakeLists.txt +++ b/editor/source/editor/CMakeLists.txt @@ -102,10 +102,9 @@ if (WIN32) COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/translations/editor_en.qm $/translations/editor_en.qm #copy engine dll`s + COMMAND ${CMAKE_COMMAND} -E copy_directory ${NAU_ROOT_DIR}/bin/$ $ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/$ $ - COMMAND ${CMAKE_COMMAND} -E copy $/plugins/NauAnimationClipAsset.dll $ - #copy usd dll's COMMAND ${CMAKE_COMMAND} -E copy_directory ${PXR_LIB_DIR}/$ $ COMMAND ${CMAKE_COMMAND} -E copy_directory ${PXR_LIB_DIR} $ @@ -118,6 +117,13 @@ if (WIN32) #copy projects templates COMMAND ${CMAKE_COMMAND} -E copy_directory ${NAU_ROOT_DIR}/project_templates $/project_templates + + #copy sdk + COMMAND ${CMAKE_COMMAND} -E copy_directory ${NAU_ROOT_DIR}/include $/NauEngineSDK/include + COMMAND ${CMAKE_COMMAND} -E copy_directory ${NAU_ROOT_DIR}/lib $/NauEngineSDK/lib + COMMAND ${CMAKE_COMMAND} -E copy_directory ${NAU_ROOT_DIR}/bin $/NauEngineSDK/bin + COMMAND ${CMAKE_COMMAND} -E copy_directory ${NAU_ROOT_DIR}/cmake $/NauEngineSDK/cmake + COMMAND ${CMAKE_COMMAND} -E copy ${NAU_ROOT_DIR}/NauEngineSDK.cmake $/NauEngineSDK/NauEngineSDK.cmake ) foreach(Qt6Lib ${Qt6_deploy_libs}) diff --git a/installer/CMakeLists.txt b/installer/CMakeLists.txt index 6d4521dcc..505d84511 100644 --- a/installer/CMakeLists.txt +++ b/installer/CMakeLists.txt @@ -4,11 +4,12 @@ file(READ "${CMAKE_SOURCE_DIR}/resources/editor/version.txt" Version) find_package (Python3 COMPONENTS Interpreter) if (Python3_FOUND) - if (WIN32) - message(NOTICE "NAU_ROOT_DIR ${NAU_ROOT_DIR}") add_custom_target(Installer ALL - COMMAND ${Python3_EXECUTABLE} installer.py win64 "$" "${CMAKE_BINARY_DIR}/$/Installer.exe" "${NAU_ROOT_DIR}" "$" "${Version}" + COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "Generation installer:" + COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "NAU_ROOT_DIR = ${NAU_ROOT_DIR}" + COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green "CMAKE_TOOLCHAIN_FILE = ${CMAKE_TOOLCHAIN_FILE}" + COMMAND ${Python3_EXECUTABLE} installer.py win64 "$" "${CMAKE_BINARY_DIR}/$/Installer.exe" "${NAU_ROOT_DIR}" "$" "${CMAKE_TOOLCHAIN_FILE}" "${Version}" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/installer VERBATIM) diff --git a/installer/installer.py b/installer/installer.py index f1fa77cdd..e385f9133 100644 --- a/installer/installer.py +++ b/installer/installer.py @@ -6,9 +6,9 @@ import pathlib import os -if len(sys.argv) < 7: - print('Usage: make_installer.py platform(win64) ' - 'EXE_DIR(where files are taken from) OUT_FILENAME(installer file name) SOURCE(path to Engine source) CONFIG(Debug or Release) VERSION(product version)') +if len(sys.argv) < 8: + print('Usage: installer.py platform(win64) ' + 'EXE_DIR(where files are taken from) OUT_FILENAME(installer file name) SOURCE(path to Engine source) CONFIG(Debug or Release) TOOLCHAIN(path to toolchain) VERSION(product version)') exit(1) def validate_path(path) : @@ -20,22 +20,25 @@ def validate_path(path) : out_filename = validate_path(sys.argv[3]) nausource = validate_path(sys.argv[4]) config = sys.argv[5] - version = sys.argv[6] - - print('make_installer.py platform({0}) EXE_DIR({1}) OUT_FILENAME({2}) SOURCE({3}) CONFIG({4}) VERSION({5})'.format(platform, exe_dir, out_filename, nausource, config, version), flush=True) + toolchain = validate_path(sys.argv[6]) + version = sys.argv[7] + print('installer.py platform({0}) EXE_DIR({1}) OUT_FILENAME({2}) SOURCE({3}) CONFIG({4}) TOOLCHAIN({5}) VERSION({6})'.format(platform, exe_dir, out_filename, nausource, config, toolchain, version), flush=True) + ''' + # TODO: check do we need this. + # For now we use prebuilded core without rebuilding it twice. platform_build_script = validate_path(os.path.join(os.getcwd(), platform, 'build.py')) if pathlib.Path(platform_build_script).exists(): print('Building SDK for platform "{0}"'.format(platform), flush=True) - ret = subprocess.call(["python", platform_build_script, nausource, exe_dir, config]) + ret = subprocess.call(["python", platform_build_script, nausource, exe_dir, config, toolchain]) if ret != 0: print('Failed to build SDK') exit(ret) else: print('For platform "{0}" SDK build tool was not implemented, skipping SDK build'.format(platform), flush=True) - + ''' platform_specified_script = validate_path(os.path.join(os.getcwd(), platform, 'make_installer.py')) diff --git a/installer/win64/Installer.vcxproj b/installer/win64/Installer.vcxproj deleted file mode 100644 index 0671be032..000000000 --- a/installer/win64/Installer.vcxproj +++ /dev/null @@ -1,167 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {c3c1992a-1c0e-4cd8-b443-09f1e08f5e0b} - Installer - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - $(ProjectDir)installer\win$(PlatformArchitecture)\$(PlatformName)\$(Configuration)\ - $(ProjectDir)installer\win$(PlatformArchitecture)\$(PlatformName)\$(Configuration)\ - - - $(ProjectDir)installer\win$(PlatformArchitecture)\$(PlatformName)\$(Configuration)\ - $(ProjectDir)installer\win$(PlatformArchitecture)\$(PlatformName)\$(Configuration)\ - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - NotSet - true - - - set /p VERSION=<"..\..\resources\editor\version.txt" -echo Retrieved product version: %VERSION% - -cd .. -python installer.py win$(PlatformArchitecture) $(SolutionDir)$(Platform)\$(Configuration) $(TargetPath) %VERSION% - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - set /p VERSION=<"..\..\resources\editor\version.txt" -echo Retrieved product version: %VERSION% - -cd .. -python installer.py win$(PlatformArchitecture) $(SolutionDir)$(Platform)\$(Configuration) $(TargetPath) %VERSION% - - - - - Document - false - - - - - - - - - - - - - \ No newline at end of file diff --git a/installer/win64/build.py b/installer/win64/build.py index 9e970e023..433c7a6fa 100644 --- a/installer/win64/build.py +++ b/installer/win64/build.py @@ -5,11 +5,12 @@ nau_engine_sdk = sys.argv[1] nau_editor_bin = sys.argv[2] config = sys.argv[3] +toolchain = sys.argv[4] def do_engine_build() : print("Building NauEngineSDK", preset, config, nau_engine_sdk, nau_editor_bin, flush=True) - result = os.system("cmake --preset "+ preset + " -DNAU_CORE_SAMPLES=OFF -DNAU_CORE_TESTS=OFF") + result = os.system("cmake --preset " + preset + " -DNAU_CORE_SAMPLES=OFF -DNAU_CORE_TESTS=OFF -DCMAKE_TOOLCHAIN_FILE=" + toolchain) if result != 0 : print("NauEngineSDK config failed with code", result, flush=True) sys.exit(result)