From 5d13ad963a5dacbfd7fef336e921eb59c3f3da5f Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Fri, 23 Apr 2021 14:41:18 -0700 Subject: [PATCH] SPEC-6437 Dlls should go to bin instead of profile (#287) * renaming and organizing files * removed unused files * Removing unnecessary file * moved file * reverting movement of 3rdparty associations from gems to global * removing unnecessary calls to ly_add_external_target_path * fixing install prefix of ci_build * Fixes to get 3rdparties declared in gems to be installed * Allowing to install just one configuration * Adding empty line at the end * removing commented code * setting IMPORETD_LOCATION_ and defaulting IMPORTED_LOCATION to the profile config in case other configs are not installed * putting dlls/exe in the right place, with the right output subdirectory * setting runtime dependencies for the dlls that we link against * singular target location * code review comments/fixes * Fixing identation --- CMakeLists.txt | 1 + cmake/GeneralSettings.cmake | 2 - cmake/Platform/Common/Install_common.cmake | 66 ++++++++++++++-------- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e685c8501b..ad5cd9f431 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ if(CMAKE_VERSION VERSION_EQUAL 3.19) cmake_policy(SET CMP0111 OLD) endif() +include(cmake/LySet.cmake) include(cmake/Version.cmake) include(cmake/OutputDirectory.cmake) diff --git a/cmake/GeneralSettings.cmake b/cmake/GeneralSettings.cmake index 2083981291..a7e6849119 100644 --- a/cmake/GeneralSettings.cmake +++ b/cmake/GeneralSettings.cmake @@ -9,8 +9,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -include(cmake/LySet.cmake) - # Turn on the ability to create folders to organize projects (.vcproj) # It creates "CMakePredefinedTargets" folder by default and adds CMake # defined projects like INSTALL.vcproj and ZERO_CHECK.vcproj diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 3daddabaa6..b1a6da012b 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -18,6 +18,7 @@ ly_set(LY_DEFAULT_INSTALL_COMPONENT "Core") # \arg:NAME name of the target # \arg:COMPONENT the grouping string of the target used for splitting up the install # into smaller packages. +# All other parameters are forwarded to ly_generate_target_find_file function(ly_install_target ly_install_target_NAME) set(options) @@ -39,27 +40,41 @@ function(ly_install_target ly_install_target_NAME) string(APPEND include_location "/${relative_path}") endif() - ly_generate_target_find_file( - NAME ${ly_install_target_NAME} - ${ARGN} - ) + # Get the output folders, archive is always the same, but runtime/library can be in subfolders defined per target + file(RELATIVE_PATH archive_output_directory ${CMAKE_BINARY_DIR} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) + + get_target_property(target_runtime_output_directory ${ly_install_target_NAME} RUNTIME_OUTPUT_DIRECTORY) + if(target_runtime_output_directory) + file(RELATIVE_PATH target_runtime_output_subdirectory ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${target_runtime_output_directory}) + endif() + file(RELATIVE_PATH runtime_output_directory ${CMAKE_BINARY_DIR} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + + get_target_property(target_library_output_directory ${ly_install_target_NAME} LIBRARY_OUTPUT_DIRECTORY) + if(target_library_output_directory) + file(RELATIVE_PATH target_library_output_subdirectory ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${target_library_output_directory}) + endif() + file(RELATIVE_PATH library_output_directory ${CMAKE_BINARY_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) install( TARGETS ${ly_install_target_NAME} - LIBRARY - DESTINATION lib/$ - COMPONENT ${ly_install_target_COMPONENT} ARCHIVE - DESTINATION lib/$ + DESTINATION ${archive_output_directory}/${PAL_PLATFORM_NAME}/$ + COMPONENT ${ly_install_target_COMPONENT} + LIBRARY + DESTINATION ${library_output_directory}/${PAL_PLATFORM_NAME}/$/${target_library_output_subdirectory} COMPONENT ${ly_install_target_COMPONENT} RUNTIME - DESTINATION bin/$ + DESTINATION ${runtime_output_directory}/${PAL_PLATFORM_NAME}/$/${target_runtime_output_subdirectory} COMPONENT ${ly_install_target_COMPONENT} PUBLIC_HEADER DESTINATION ${include_location} COMPONENT ${ly_install_target_COMPONENT} ) + ly_generate_target_find_file( + NAME ${ly_install_target_NAME} + ${ARGN} + ) ly_generate_target_config_file(${ly_install_target_NAME}) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${ly_install_target_NAME}_$.cmake" DESTINATION cmake_autogen/${ly_install_target_NAME} @@ -134,26 +149,27 @@ function(ly_generate_target_config_file NAME) get_target_property(target_type ${NAME} TYPE) - unset(target_file_contents) + set(target_file_contents "# Generated by O3DE install\n\n") if(NOT target_type STREQUAL INTERFACE_LIBRARY) - set(BINARY_DIR_OUTPUTS EXECUTABLE APPLICATION) - set(target_file_contents "") - if(${target_type} IN_LIST BINARY_DIR_OUTPUTS) - set(out_file_generator TARGET_FILE_NAME) - set(out_dir bin) - else() - set(out_file_generator TARGET_LINKER_FILE_NAME) - set(out_dir lib) + unset(target_location) + set(runtime_types EXECUTABLE APPLICATION) + if(target_type IN_LIST runtime_types) + string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${runtime_output_directory}/${PAL_PLATFORM_NAME}/$/${target_runtime_output_subdirectory}/$\"") + elseif(target_type STREQUAL MODULE_LIBRARY) + string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$/${target_library_output_subdirectory}/$\"") + elseif(target_type STREQUAL SHARED_LIBRARY) + string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$/$\"") + string(APPEND target_file_contents "ly_add_dependencies(${NAME} \"\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$/${target_library_output_subdirectory}/$\")\n") + else() # STATIC_LIBRARY, OBJECT_LIBRARY, INTERFACE_LIBRARY + string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$/$\"") endif() - string(APPEND target_file_contents -"# Generated by O3DE install - -set(target_location \"\${LY_ROOT_FOLDER}/${out_dir}/$/$<${out_file_generator}:${NAME}>\") -set_target_properties(${NAME} + string(APPEND target_file_contents +"set(target_location ${target_location}) +set_target_properties(${NAME} PROPERTIES - $<$:IMPORTED_LOCATION \"\${target_location}>\" + $<$:IMPORTED_LOCATION \"\${target_location}\"> IMPORTED_LOCATION_$> \"\${target_location}\" ) if(EXISTS \"\${target_location}\") @@ -270,7 +286,7 @@ endfunction() function(ly_setup_others) # List of directories we want to install relative to engine root - set(DIRECTORIES_TO_INSTALL Tools/LyTestTools Tools/RemoteConsole ctest_scripts scripts) + set(DIRECTORIES_TO_INSTALL Tools/LyTestTools Tools/RemoteConsole scripts) foreach(dir ${DIRECTORIES_TO_INSTALL}) get_filename_component(install_path ${dir} DIRECTORY)