From bedecebdcc9206d9a34277935f9295705c0ff530 Mon Sep 17 00:00:00 2001 From: phistere Date: Fri, 7 May 2021 20:05:05 -0500 Subject: [PATCH] Configures and installs an engine.json generated from a template. Fixes HEADERONLY targets for install. Fixes locating .ico resource file. Fix infinite loop in CMake configure on new projects. --- .../Windows/launcher_project_windows.cmake | 5 +++++ cmake/LYWrappers.cmake | 2 +- cmake/Platform/Common/Install_common.cmake | 16 ++++++++++++++-- cmake/SettingsRegistry.cmake | 10 +++++++--- cmake/Version.cmake | 3 ++- cmake/install/TargetCMakeLists.txt.in | 2 +- cmake/install/engine.json.in | 7 +++++++ engine.json | 3 ++- 8 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 cmake/install/engine.json.in diff --git a/Code/LauncherUnified/Platform/Windows/launcher_project_windows.cmake b/Code/LauncherUnified/Platform/Windows/launcher_project_windows.cmake index bcef59ec5a..35c89caf15 100644 --- a/Code/LauncherUnified/Platform/Windows/launcher_project_windows.cmake +++ b/Code/LauncherUnified/Platform/Windows/launcher_project_windows.cmake @@ -10,6 +10,11 @@ # set(ICON_FILE ${project_real_path}/Gem/Resources/GameSDK.ico) +if(NOT EXISTS ${ICON_FILE}) + # Try another project-relative path + set(ICON_FILE ${project_real_path}/Resources/GameSDK.ico) +endif() + if(NOT EXISTS ${ICON_FILE}) # Try the common LauncherUnified icon instead set(ICON_FILE Resources/GameSDK.ico) diff --git a/cmake/LYWrappers.cmake b/cmake/LYWrappers.cmake index 62509582a1..73586b624f 100644 --- a/cmake/LYWrappers.cmake +++ b/cmake/LYWrappers.cmake @@ -85,7 +85,7 @@ function(ly_add_target) if(NOT ly_add_target_NAME) message(FATAL_ERROR "You must provide a name for the target") endif() - if(NOT ly_add_target_IMPORTED) + if(NOT ly_add_target_IMPORTED AND NOT ly_add_target_HEADERONLY) if(NOT ly_add_target_FILES_CMAKE) message(FATAL_ERROR "You must provide a list of _files.cmake files for the target") endif() diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index cef3251899..141f229506 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -104,6 +104,13 @@ function(ly_generate_target_find_file) unset(INCLUDE_DIRECTORIES_PLACEHOLDER) set(RUNTIME_DEPENDENCIES_PLACEHOLDER ${ly_generate_target_find_file_RUNTIME_DEPENDENCIES}) + set(TARGET_TYPE_PLACEHOLDER "IMPORTED") + #set(TARGET_TYPE_PLACEHOLDER) + get_target_property(target_type ${NAME_PLACEHOLDER} TYPE) + if(target_type STREQUAL INTERFACE_LIBRARY) + set(TARGET_TYPE_PLACEHOLDER "HEADERONLY") + endif() + # These targets will be imported. We will expose PUBLIC and INTERFACE properties as INTERFACE properties since # only INTERFACE properties can be exposed on imported targets ly_strip_private_properties(COMPILE_DEFINITIONS_PLACEHOLDER ${ly_generate_target_find_file_COMPILE_DEFINITIONS}) @@ -225,13 +232,17 @@ function(ly_setup_cmake_install) install(DIRECTORY "${CMAKE_SOURCE_DIR}/cmake" DESTINATION . COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} + PATTERN "__pycache__" EXCLUDE REGEX "Findo3de.cmake" EXCLUDE REGEX "Platform\/.*\/BuiltInPackages_.*\.cmake" EXCLUDE ) + + configure_file(${CMAKE_SOURCE_DIR}/cmake/install/engine.json.in ${CMAKE_CURRENT_BINARY_DIR}/cmake/engine.json @ONLY) + install( FILES "${CMAKE_SOURCE_DIR}/CMakeLists.txt" - "${CMAKE_SOURCE_DIR}/engine.json" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/engine.json" DESTINATION . COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) @@ -369,6 +380,7 @@ function(ly_setup_others) install(DIRECTORY "${CMAKE_SOURCE_DIR}/${dir}" DESTINATION ${install_path} COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} + PATTERN "__pycache__" EXCLUDE ) endforeach() @@ -450,7 +462,7 @@ function(ly_setup_others) get_filename_component(gem_relative_path ${gem_json_path} DIRECTORY) install(FILES ${gem_json_path} DESTINATION ${gem_relative_path} - COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} + COMPONENT ${LY_DEFAULT_INSTALL_COMPONENT} ) endforeach() diff --git a/cmake/SettingsRegistry.cmake b/cmake/SettingsRegistry.cmake index af6ef42e31..31ce36c516 100644 --- a/cmake/SettingsRegistry.cmake +++ b/cmake/SettingsRegistry.cmake @@ -125,9 +125,13 @@ function(ly_delayed_generate_settings_registry) endif() get_property(gem_relative_source_dir TARGET ${gem_target} PROPERTY SOURCE_DIR) if(gem_relative_source_dir) - # Most gems SOURCE dir is nested in the path, we need to find the path to the gem.json file - while(NOT EXISTS ${gem_relative_source_dir}/gem.json) - get_filename_component(gem_relative_source_dir ${gem_relative_source_dir} DIRECTORY) + # Most gems SOURCE dir is nested in the path, we need to find the path to the gem.json or project.json file + while(NOT EXISTS ${gem_relative_source_dir}/gem.json AND NOT EXISTS ${gem_relative_source_dir}/project.json) + get_filename_component(parent_dir ${gem_relative_source_dir} DIRECTORY) + if (${parent_dir} STREQUAL ${gem_relative_source_dir}) + message(FATAL_ERROR "Did not find gem.json or project.json while processing target ${gem_target}!") + endif() + set(gem_relative_source_dir ${parent_dir}) endwhile() file(TO_CMAKE_PATH ${LY_ROOT_FOLDER} ly_root_folder_cmake) file(RELATIVE_PATH gem_relative_source_dir ${ly_root_folder_cmake} ${gem_relative_source_dir}) diff --git a/cmake/Version.cmake b/cmake/Version.cmake index 08d79d4ce6..1d484fb059 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -12,4 +12,5 @@ string(TIMESTAMP current_year "%Y") set(LY_VERSION_COPYRIGHT_YEAR ${current_year} CACHE STRING "Open 3D Engine's copyright year") set(LY_VERSION_STRING "0.0.0.0" CACHE STRING "Open 3D Engine's version") -set(LY_VERSION_BUILD_NUMBER 0 CACHE STRING "Open 3D Engine's build number") \ No newline at end of file +set(LY_VERSION_BUILD_NUMBER 0 CACHE STRING "Open 3D Engine's build number") +set(LY_VERSION_ENGINE_NAME "o3de" CACHE STRING "Open 3D Engine's engine name") diff --git a/cmake/install/TargetCMakeLists.txt.in b/cmake/install/TargetCMakeLists.txt.in index 16263ecf30..1c2f181368 100644 --- a/cmake/install/TargetCMakeLists.txt.in +++ b/cmake/install/TargetCMakeLists.txt.in @@ -12,7 +12,7 @@ # Generated by O3DE ly_add_target( - NAME @NAME_PLACEHOLDER@ IMPORTED + NAME @NAME_PLACEHOLDER@ @TARGET_TYPE_PLACEHOLDER@ @NAMESPACE_PLACEHOLDER@ COMPILE_DEFINITIONS INTERFACE diff --git a/cmake/install/engine.json.in b/cmake/install/engine.json.in new file mode 100644 index 0000000000..9899b169ed --- /dev/null +++ b/cmake/install/engine.json.in @@ -0,0 +1,7 @@ +{ + "engine_name": "@LY_VERSION_ENGINE_NAME@", + "FileVersion": 1, + "O3DEVersion": "@LY_VERSION_STRING@", + "O3DECopyrightYear": @LY_VERSION_COPYRIGHT_YEAR@, + "O3DEBuildNumber": @LY_VERSION_BUILD_NUMBER@ +} diff --git a/engine.json b/engine.json index 5091605f4c..f933886c44 100644 --- a/engine.json +++ b/engine.json @@ -2,5 +2,6 @@ "engine_name": "o3de", "FileVersion": 1, "O3DEVersion": "0.0.0.0", - "O3DECopyrightYear": 2021 + "O3DECopyrightYear": 2021, + "O3DEBuildNumber": 0 }