fixing debug configuration and how we declare IMPORTED targets (instead of UNKNOW we use the actual type)

This commit is contained in:
pappeste
2021-05-11 19:06:07 -07:00
parent 083849b444
commit 671f26bed4
4 changed files with 46 additions and 36 deletions
+13 -13
View File
@@ -87,8 +87,8 @@ function(ly_add_target)
endif()
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()
message(FATAL_ERROR "You must provide a list of _files.cmake files for the target")
endif()
endif()
# If the GEM_MODULE tag is passed set the normal MODULE argument
@@ -114,11 +114,10 @@ function(ly_add_target)
set(linking_options ${PAL_LINKOPTION_MODULE})
set(linking_count "${linking_count}1")
endif()
if(ly_add_target_HEADERONLY)
set(linking_options INTERFACE)
set(linking_count "${linking_count}1")
endif()
endif()
if(ly_add_target_EXECUTABLE)
set(linking_options EXECUTABLE)
set(linking_count "${linking_count}1")
@@ -127,12 +126,11 @@ function(ly_add_target)
set(linking_options APPLICATION)
set(linking_count "${linking_count}1")
endif()
if(ly_add_target_IMPORTED)
set(linking_options UNKNOWN IMPORTED GLOBAL)
set(linking_count "${linking_count}1")
endif()
if(NOT ("${linking_count}" STREQUAL "1"))
message(FATAL_ERROR "More than one of the following options [STATIC | SHARED | MODULE | HEADERONLY | EXECUTABLE | APPLICATION | IMPORTED] was specified and they are mutually exclusive")
message(FATAL_ERROR "More than one of the following options [STATIC | SHARED | MODULE | HEADERONLY | EXECUTABLE | APPLICATION ] was specified and they are mutually exclusive")
endif()
if(ly_add_target_IMPORTED)
list(APPEND linking_options IMPORTED GLOBAL)
endif()
if(ly_add_target_NAMESPACE)
@@ -147,21 +145,23 @@ function(ly_add_target)
${ALLFILES} ${ly_add_target_GENERATED_FILES}
)
ly_apply_platform_properties(${ly_add_target_NAME})
if(ly_add_target_IMPORTED)
set_target_properties(${ly_add_target_NAME} PROPERTIES LINKER_LANGUAGE CXX)
endif()
elseif(ly_add_target_APPLICATION)
add_executable(${ly_add_target_NAME}
${PAL_EXECUTABLE_APPLICATION_FLAG}
${ALLFILES} ${ly_add_target_GENERATED_FILES}
)
ly_apply_platform_properties(${ly_add_target_NAME})
if(ly_add_target_IMPORTED)
set_target_properties(${ly_add_target_NAME} PROPERTIES LINKER_LANGUAGE CXX)
endif()
elseif(ly_add_target_HEADERONLY)
add_library(${ly_add_target_NAME}
${linking_options}
${ALLFILES} ${ly_add_target_GENERATED_FILES}
)
elseif(ly_add_target_IMPORTED)
add_library(${ly_add_target_NAME}
${linking_options}
)
else()
add_library(${ly_add_target_NAME}
${linking_options}
+26 -20
View File
@@ -94,10 +94,17 @@ function(ly_setup_target ALIAS_TARGET_NAME)
set(NAME_PLACEHOLDER ${TARGET_NAME})
endif()
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")
# Remove the _LIBRARY since we dont need to pass that to ly_add_targets
string(REPLACE "_LIBRARY" "" TARGET_TYPE_PLACEHOLDER ${target_type})
# For HEADER_ONLY libs we end up generating "INTERFACE" libraries, need to specify HEADERONLY instead
string(REPLACE "INTERFACE" "HEADERONLY" TARGET_TYPE_PLACEHOLDER ${TARGET_TYPE_PLACEHOLDER})
if(TARGET_TYPE_PLACEHOLDER STREQUAL "MODULE")
get_target_property(gem_module ${NAME_PLACEHOLDER} GEM_MODULE)
if(gem_module)
set(TARGET_TYPE_PLACEHOLDER "GEM_MODULE")
endif()
endif()
get_target_property(COMPILE_DEFINITIONS_PLACEHOLDER ${TARGET_NAME} INTERFACE_COMPILE_DEFINITIONS)
@@ -155,7 +162,7 @@ function(ly_setup_target ALIAS_TARGET_NAME)
DESTINATION ${target_source_dir}/${NAME_PLACEHOLDER}
COMPONENT ${ly_install_target_COMPONENT}
)
# Config file
set(target_file_contents "# Generated by O3DE install\n\n")
if(NOT target_type STREQUAL INTERFACE_LIBRARY)
@@ -163,29 +170,28 @@ function(ly_setup_target ALIAS_TARGET_NAME)
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}/$<CONFIG>/${target_runtime_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>\"")
set(target_location "\${LY_ROOT_FOLDER}/${runtime_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_runtime_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>")
elseif(target_type STREQUAL MODULE_LIBRARY)
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>\"")
set(target_location "\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>")
elseif(target_type STREQUAL SHARED_LIBRARY)
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/$<TARGET_LINKER_FILE_NAME:${TARGET_NAME}>\"")
string(APPEND target_file_contents "target_link_libraries(${TARGET_NAME} INTERFACE \"\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>\")\n")
string(APPEND target_file_contents "set_property(TARGET ${TARGET_NAME} PROPERTY IMPORTED_IMPLIB_$<CONFIG> \"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/$<TARGET_LINKER_FILE_NAME:${TARGET_NAME}>\")\n")
set(target_location "\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/${target_library_output_subdirectory}/$<TARGET_FILE_NAME:${TARGET_NAME}>")
else() # STATIC_LIBRARY, OBJECT_LIBRARY, INTERFACE_LIBRARY
string(APPEND target_location "\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/$<TARGET_LINKER_FILE_NAME:${TARGET_NAME}>\"")
set(target_location "\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$<CONFIG>/$<TARGET_LINKER_FILE_NAME:${TARGET_NAME}>")
endif()
string(APPEND target_file_contents
"set(target_location ${target_location})
set_target_properties(${TARGET_NAME}
PROPERTIES
$<$<CONFIG:profile>:IMPORTED_LOCATION \"\${target_location}\">
IMPORTED_LOCATION_$<UPPER_CASE:$<CONFIG>> \"\${target_location}\"
if(target_location)
string(APPEND target_file_contents
"set_property(TARGET ${TARGET_NAME}
APPEND_STRING PROPERTY IMPORTED_LOCATION
$<$<CONFIG:$<CONFIG>$<ANGLE-R>:${target_location}$<ANGLE-R>
)
set_property(TARGET ${TARGET_NAME}
PROPERTY IMPORTED_LOCATION_$<UPPER_CASE:$<CONFIG>>
${target_location}
)
if(EXISTS \"\${target_location}\")
set(${NAME_PLACEHOLDER}_$<CONFIG>_FOUND TRUE)
else()
set(${NAME_PLACEHOLDER}_$<CONFIG>_FOUND FALSE)
endif()
")
endif()
endif()
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/install/${NAME_PLACEHOLDER}/${NAME_PLACEHOLDER}_$<CONFIG>.cmake" CONTENT "${target_file_contents}")
@@ -61,7 +61,7 @@ function(ly_get_runtime_dependencies ly_RUNTIME_DEPENDENCIES ly_TARGET)
if(dependencies)
list(APPEND link_dependencies ${dependencies})
endif()
if(NOT target_type MATCHES "INTERFACE")
if(NOT target_type STREQUAL "INTERFACE_LIBRARY")
unset(dependencies)
get_target_property(dependencies ${ly_TARGET} LINK_LIBRARIES)
if(dependencies)
@@ -105,11 +105,15 @@ function(ly_get_runtime_dependencies ly_RUNTIME_DEPENDENCIES ly_TARGET)
set(skip_imported TRUE)
endif()
endif()
if(target_type MATCHES "(INTERFACE_LIBRARY|STATIC_LIBRARY)")
# No need to copy these dependencies since the outputs are not used at runtime
set(skip_imported TRUE)
endif()
if(NOT skip_imported)
# Add imported locations
if(target_type MATCHES "INTERFACE")
if(target_type STREQUAL "INTERFACE_LIBRARY")
set(imported_property INTERFACE_IMPORTED_LOCATION)
else()
set(imported_property IMPORTED_LOCATION)
+1 -1
View File
@@ -12,7 +12,7 @@
# Generated by O3DE
ly_add_target(
NAME @NAME_PLACEHOLDER@ @TARGET_TYPE_PLACEHOLDER@
NAME @NAME_PLACEHOLDER@ IMPORTED @TARGET_TYPE_PLACEHOLDER@
@NAMESPACE_PLACEHOLDER@
COMPILE_DEFINITIONS
INTERFACE