From 522d52177176822d60a2c3e127132b348faa5b5e Mon Sep 17 00:00:00 2001 From: Guillaume Paran Date: Mon, 2 Nov 2020 18:05:10 +0100 Subject: [PATCH] [CMake] FIX non-existent target with sofa_add_plugin sofa_add_plugin required the "name" argument to be the target We can now handle non-target names, aliases and custom OUTPUT_NAME --- .../SofaFramework/SofaMacrosConfigure.cmake | 30 +++++++++++-------- .../runSofa/cmake/GeneratePluginConfig.cmake | 9 +++++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/SofaKernel/SofaFramework/SofaMacrosConfigure.cmake b/SofaKernel/SofaFramework/SofaMacrosConfigure.cmake index c9732e245e8..bbc9fb7dfc8 100644 --- a/SofaKernel/SofaFramework/SofaMacrosConfigure.cmake +++ b/SofaKernel/SofaFramework/SofaMacrosConfigure.cmake @@ -109,23 +109,27 @@ macro(sofa_add_generic directory name type) if(${option}) message("Adding ${type_lower} ${name}") add_subdirectory(${directory}) - #Check if the target has been successfully added - if(TARGET ${name}) - set_target_properties(${name} PROPERTIES FOLDER ${type}s) # IDE folder - set_target_properties(${name} PROPERTIES DEBUG_POSTFIX "_d") - endif() endif() - # Add current target in the internal list only if not present already - get_property(_allTargets GLOBAL PROPERTY __GlobalTargetList__) - get_property(_allTargetNames GLOBAL PROPERTY __GlobalTargetNameList__) + if(TARGET ${name}) + set(target ${name}) + get_target_property(aliased_target ${target} ALIASED_TARGET) + if(aliased_target) + set(target ${aliased_target}) + endif() - if(NOT ${name} IN_LIST _allTargets) - set_property(GLOBAL APPEND PROPERTY __GlobalTargetList__ ${name}) - endif() + set_target_properties(${target} PROPERTIES FOLDER ${type}s) # IDE folder + set_target_properties(${target} PROPERTIES DEBUG_POSTFIX "_d") - if(NOT ${option} IN_LIST _allTargetNames) - set_property(GLOBAL APPEND PROPERTY __GlobalTargetNameList__ ${option}) + # Add current target in the internal list only if not present already + get_property(_allTargets GLOBAL PROPERTY __GlobalTargetList__) + get_property(_allTargetNames GLOBAL PROPERTY __GlobalTargetNameList__) + if(NOT ${target} IN_LIST _allTargets) + set_property(GLOBAL APPEND PROPERTY __GlobalTargetList__ ${target}) + endif() + if(NOT ${option} IN_LIST _allTargetNames) + set_property(GLOBAL APPEND PROPERTY __GlobalTargetNameList__ ${option}) + endif() endif() else() message("The ${type_lower} ${name} (${CMAKE_CURRENT_LIST_DIR}/${directory}) does not exist and will be ignored.") diff --git a/applications/projects/runSofa/cmake/GeneratePluginConfig.cmake b/applications/projects/runSofa/cmake/GeneratePluginConfig.cmake index 1875db48da0..33c1929eaaf 100644 --- a/applications/projects/runSofa/cmake/GeneratePluginConfig.cmake +++ b/applications/projects/runSofa/cmake/GeneratePluginConfig.cmake @@ -23,7 +23,14 @@ macro(sofa_generate_plugin_config config_filename) if(${_version} MATCHES ".*NOTFOUND") set(_version "NO_VERSION") endif() - string(CONCAT _pluginConfig "${_pluginConfig}\n${_target} ${_version}") + + set(_target_filename ${_target}) + get_target_property(target_output_name ${_target} OUTPUT_NAME) + if(target_output_name) + set(_target_filename ${target_output_name}) + endif() + + string(CONCAT _pluginConfig "${_pluginConfig}\n${_target_filename} ${_version}") endif() endif() endforeach()