123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- function(ly_include_cmake_file_list file)
- set(UNITY_AUTO_EXCLUSIONS)
- include(${file})
- get_filename_component(file_path "${file}" PATH)
- if(file_path)
- foreach(f ${FILES})
- cmake_path(IS_RELATIVE f is_relative)
- if(is_relative)
- string(PREPEND f ${file_path}/)
- endif()
- list(APPEND TRANSFORMED_FILES ${f})
- endforeach()
- set(FILES ${TRANSFORMED_FILES})
- endif()
- foreach(f ${FILES})
- get_filename_component(absolute_path ${f} ABSOLUTE)
- if(NOT EXISTS ${absolute_path})
- message(SEND_ERROR "File ${absolute_path} referenced in ${file} not found")
- endif()
-
- if (PAL_TRAIT_BUILD_UNITY_EXCLUDE_EXTENSIONS)
- get_filename_component(file_extension ${f} LAST_EXT)
- if (${file_extension} IN_LIST PAL_TRAIT_BUILD_UNITY_EXCLUDE_EXTENSIONS)
- list(APPEND UNITY_AUTO_EXCLUSIONS ${f})
- endif()
- endif()
- endforeach()
- list(APPEND FILES ${file})
- if(file_path)
- foreach(f ${SKIP_UNITY_BUILD_INCLUSION_FILES})
- cmake_path(IS_RELATIVE f is_relative)
- if(is_relative)
- string(PREPEND f ${file_path}/)
- endif()
- list(APPEND SKIP_UNITY_BUILD_INCLUSION_TRANSFORMED_FILES ${f})
- endforeach()
- set(SKIP_UNITY_BUILD_INCLUSION_FILES ${SKIP_UNITY_BUILD_INCLUSION_TRANSFORMED_FILES})
- endif()
-
- foreach(f ${SKIP_UNITY_BUILD_INCLUSION_FILES})
- get_filename_component(absolute_path ${f} ABSOLUTE)
- if(NOT EXISTS ${absolute_path})
- message(FATAL_ERROR "File ${absolute_path} for SKIP_UNITY_BUILD_INCLUSION_FILES referenced in ${file} not found")
- endif()
- if(NOT f IN_LIST FILES)
- list(APPEND FILES ${f})
- endif()
- endforeach()
-
- if (LY_UNITY_BUILD)
- set_source_files_properties(
- ${UNITY_AUTO_EXCLUSIONS}
- ${SKIP_UNITY_BUILD_INCLUSION_FILES}
- PROPERTIES
- SKIP_UNITY_BUILD_INCLUSION ON
- )
- endif()
- set(ALLFILES ${ALLFILES} ${FILES} PARENT_SCOPE)
- endfunction()
- function(ly_source_groups_from_folders files)
- foreach(file IN LISTS files)
- if(IS_ABSOLUTE ${file})
- file(RELATIVE_PATH file ${CMAKE_CURRENT_SOURCE_DIR} ${file})
- endif()
- get_filename_component(file_path "${file}" PATH)
- string(REPLACE "/" "\\" file_filters "${file_path}")
- source_group("${file_filters}" FILES "${file}")
- endforeach()
- endfunction()
- get_property(O3DE_PROJECTS_NAME GLOBAL PROPERTY O3DE_PROJECTS_NAME)
- function(ly_update_platform_settings)
-
- set(ly_platform_last_path "${CMAKE_BINARY_DIR}/platform.settings")
- string(TIMESTAMP ly_last_generation_timestamp "%Y-%m-%dT%H:%M:%S")
- file(WRITE ${ly_platform_last_path} "# Auto Generated from last cmake project generation (${ly_last_generation_timestamp})
- [settings]
- platform=${PAL_PLATFORM_NAME}
- game_projects=${O3DE_PROJECTS_NAME}
- asset_deploy_mode=${LY_ASSET_DEPLOY_MODE}
- asset_deploy_type=${LY_ASSET_DEPLOY_ASSET_TYPE}
- override_pak_root=${LY_ASSET_OVERRIDE_PAK_FOLDER_ROOT}
- ")
- endfunction()
- function(ly_file_read path content)
- unset(file_content)
- file(READ ${path} file_content)
- set(${content} ${file_content} PARENT_SCOPE)
- set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${path})
- endfunction()
- function(o3de_file_read_cache path content)
- unset(file_content)
- cmake_path(SET path "${path}")
- cmake_path(NORMAL_PATH path)
- set(file_cache_var_name "O3DE_FILE_CACHE_${path}")
- get_property(file_content GLOBAL PROPERTY ${file_cache_var_name})
- if(NOT file_content)
- ly_file_read(${path} file_content)
- set_property(GLOBAL PROPERTY ${file_cache_var_name} ${file_content})
- endif()
- set(${content} ${file_content} PARENT_SCOPE)
- endfunction()
- function(ly_get_last_path_segment_concat_sha256 absolute_path output_path)
- string(SHA256 target_source_hash ${absolute_path})
- string(SUBSTRING ${target_source_hash} 0 8 target_source_hash)
- cmake_path(GET absolute_path FILENAME last_path_segment)
- cmake_path(SET last_path_segment_sha256_path "${last_path_segment}-${target_source_hash}")
- set(${output_path} ${last_path_segment_sha256_path} PARENT_SCOPE)
- endfunction()
- function(ly_get_root_subdirectory_which_is_parent absolute_path output_path)
-
-
- cmake_path(SET candidate_path ${absolute_path})
- get_property(parent_subdir DIRECTORY ${candidate_path} PROPERTY PARENT_DIRECTORY)
- cmake_path(IS_PREFIX parent_subdir ${candidate_path} is_parent_subdir)
- while(parent_subdir AND is_parent_subdir)
- cmake_path(SET candidate_path "${parent_subdir}")
- get_property(parent_subdir DIRECTORY ${candidate_path} PROPERTY PARENT_DIRECTORY)
- cmake_path(IS_PREFIX parent_subdir ${candidate_path} is_parent_subdir)
- endwhile()
- message(DEBUG "Root subdirectory of path \"${absolute_path}\" is \"${candidate_path}\"")
- set(${output_path} ${candidate_path} PARENT_SCOPE)
- endfunction()
- function(ly_get_engine_relative_source_dir absolute_target_source_dir output_source_dir)
- set(options)
- set(oneValueArgs BASE_DIRECTORY)
- set(multiValueArgs)
- cmake_parse_arguments(ly_get_engine_relative_source_dir "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
- if(NOT ly_get_engine_relative_source_dir_BASE_DIRECTORY)
- set(ly_get_engine_relative_source_dir_BASE_DIRECTORY ${LY_ROOT_FOLDER})
- endif()
-
-
- ly_get_root_subdirectory_which_is_parent(${absolute_target_source_dir} root_subdir_of_target)
- cmake_path(RELATIVE_PATH absolute_target_source_dir BASE_DIRECTORY ${root_subdir_of_target} OUTPUT_VARIABLE relative_target_source_dir)
- cmake_path(IS_PREFIX LY_ROOT_FOLDER ${absolute_target_source_dir} is_target_source_dir_subdirectory_of_engine)
- if(NOT is_target_source_dir_subdirectory_of_engine)
- cmake_path(GET root_subdir_of_target FILENAME root_subdir_dirname)
- set(relative_subdir ${relative_target_source_dir})
- unset(relative_target_source_dir)
- cmake_path(APPEND relative_target_source_dir "External" ${root_subdir_dirname} ${relative_subdir})
- endif()
- set(${output_source_dir} ${relative_target_source_dir} PARENT_SCOPE)
- endfunction()
|