Mentions légales du service

Skip to content
Snippets Groups Projects
Commit bc34cfd2 authored by PRUVOST Florent's avatar PRUVOST Florent
Browse files

morse_export_imported_target: update to get also IMPORTED_LOCATION info

parent 4b72d980
No related branches found
No related tags found
No related merge requests found
...@@ -194,18 +194,19 @@ macro(morse_create_imported_target name) ...@@ -194,18 +194,19 @@ macro(morse_create_imported_target name)
endmacro() endmacro()
# export existing imported target namespace1::namespace2 in cmake file # export existing imported target ${targetname} in cmake file
# ${targetname}Targets.cmake and installed in lib/cmake/cmakesubdir/. To be used # ${targetfilename}Targets.cmake and installed in lib/cmake/${cmakesubdir}/. To be used
# by "PROJECT"Config.cmake file at installation # by "PROJECT"Config.cmake file at installation
macro(morse_export_imported_target namespace1 namespace2 targetname cmakesubdir) macro(morse_export_imported_target targetname targetfilename cmakesubdir)
if (TARGET ${namespace1}::${namespace2}) if (TARGET ${targetname})
get_target_property(_INCLUDES ${namespace1}::${namespace2} INTERFACE_INCLUDE_DIRECTORIES) get_target_property(_INCLUDES ${targetname} INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(_LIBDIRS ${namespace1}::${namespace2} INTERFACE_LINK_DIRECTORIES) get_target_property(_LIBDIRS ${targetname} INTERFACE_LINK_DIRECTORIES)
get_target_property(_LIBRARIES ${namespace1}::${namespace2} INTERFACE_LINK_LIBRARIES) get_target_property(_LIBRARIES ${targetname} INTERFACE_LINK_LIBRARIES)
get_target_property(_CFLAGS ${namespace1}::${namespace2} INTERFACE_COMPILE_OPTIONS) get_target_property(_CFLAGS ${targetname} INTERFACE_COMPILE_OPTIONS)
get_target_property(_DEFS ${namespace1}::${namespace2} INTERFACE_COMPILE_DEFINITIONS) get_target_property(_DEFS ${targetname} INTERFACE_COMPILE_DEFINITIONS)
get_target_property(_LDFLAGS ${namespace1}::${namespace2} INTERFACE_LINK_OPTIONS) get_target_property(_LDFLAGS ${targetname} INTERFACE_LINK_OPTIONS)
if (NOT _INCLUDES) if (NOT _INCLUDES)
set(_INCLUDES "") set(_INCLUDES "")
endif() endif()
...@@ -225,23 +226,40 @@ macro(morse_export_imported_target namespace1 namespace2 targetname cmakesubdir) ...@@ -225,23 +226,40 @@ macro(morse_export_imported_target namespace1 namespace2 targetname cmakesubdir)
set(_LDFLAGS "") set(_LDFLAGS "")
endif() endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${targetname}Targets.cmake" get_target_property(_IMPORTED_CONF ${targetname} IMPORTED_CONFIGURATIONS)
"if (NOT TARGET ${namespace1}::${namespace2}) if (NOT _IMPORTED_CONF)
add_library(${namespace1}::${namespace2} INTERFACE IMPORTED) set(_IMPORTED_CONF "NOCONFIG")
set_target_properties(${namespace1}::${namespace2} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${_INCLUDES}\") endif()
set_target_properties(${namespace1}::${namespace2} PROPERTIES INTERFACE_LINK_DIRECTORIES \"${_LIBDIRS}\") get_target_property(_IMPORTED_DEP ${targetname} IMPORTED_LINK_DEPENDENT_LIBRARIES_${_IMPORTED_CONF})
set_target_properties(${namespace1}::${namespace2} PROPERTIES INTERFACE_LINK_LIBRARIES \"${_LIBRARIES}\") get_target_property(_IMPORTED_LOCATION ${targetname} IMPORTED_LOCATION_${_IMPORTED_CONF})
set_target_properties(${namespace1}::${namespace2} PROPERTIES INTERFACE_COMPILE_OPTIONS \"${_CFLAGS}\") get_target_property(_IMPORTED_SONAME ${targetname} IMPORTED_SONAME_${_IMPORTED_CONF})
set_target_properties(${namespace1}::${namespace2} PROPERTIES INTERFACE_COMPILE_DEFINITIONS \"${_DEFS}\") if (_IMPORTED_DEP)
set_target_properties(${namespace1}::${namespace2} PROPERTIES INTERFACE_LINK_OPTIONS \"${_LDFLAGS}\") list(PREPEND _LIBRARIES ${_IMPORTED_DEP})
endif()
if (_IMPORTED_LOCATION)
list(PREPEND _LIBRARIES ${_IMPORTED_LOCATION})
endif()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${targetfilename}Targets.cmake"
"if (NOT TARGET ${targetname})
add_library(${targetname} INTERFACE IMPORTED)
set_target_properties(${targetname} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${_INCLUDES}\")
set_target_properties(${targetname} PROPERTIES INTERFACE_LINK_DIRECTORIES \"${_LIBDIRS}\")
set_target_properties(${targetname} PROPERTIES INTERFACE_LINK_LIBRARIES \"${_LIBRARIES}\")
set_target_properties(${targetname} PROPERTIES INTERFACE_COMPILE_OPTIONS \"${_CFLAGS}\")
set_target_properties(${targetname} PROPERTIES INTERFACE_COMPILE_DEFINITIONS \"${_DEFS}\")
set_target_properties(${targetname} PROPERTIES INTERFACE_LINK_OPTIONS \"${_LDFLAGS}\")
endif() endif()
") ")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${targetname}Targets.cmake" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${targetfilename}Targets.cmake"
DESTINATION "lib/cmake/${cmakesubdir}") DESTINATION "lib/cmake/${cmakesubdir}")
else() else()
message(WARNING "morse_export_imported_target: try to export target " set(list_var "${ARGV}")
"${namespace1}::${namespace2} but it does not exist.") if(NOT "QUIET" IN_LIST list_var)
message(WARNING "morse_export_imported_target_without_namespace: try to export target "
"${targetname} but it does not exist.")
endif()
endif() endif()
endmacro() endmacro()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment