fix: fix cmake template of packer
This commit is contained in:
@@ -18,32 +18,45 @@ set(MyRust_LIBRARY "${_IMPORT_PREFIX}/lib/{{ artifact_dll }}")
|
||||
set(MyRust_INCLUDE_DIR "${_IMPORT_PREFIX}/include")
|
||||
|
||||
{# Create modern CMake target (IMPORTED target) -#}
|
||||
add_library({{ namespace }}::{{ target }} SHARED IMPORTED)
|
||||
set_target_properties({{ namespace }}::{{ target }} PROPERTIES
|
||||
add_library({{ target }} SHARED IMPORTED)
|
||||
add_library({{ namespace }}::{{ target }} ALIAS {{ target }})
|
||||
set_target_properties({{ target }} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
|
||||
)
|
||||
{# Handle Windows and UNIX-like respectively -#}
|
||||
if(WIN32)
|
||||
set_target_properties({{ namespace }}::{{ target }} PROPERTIES
|
||||
set_target_properties({{ target }} PROPERTIES
|
||||
IMPORTED_LOCATION "${_IMPORT_PREFIX}/bin/{{ artifact_dll }}"
|
||||
IMPORTED_IMPLIB "${_IMPORT_PREFIX}/lib/{{ artifact_lib }}"
|
||||
)
|
||||
else()
|
||||
set_target_properties({{ namespace }}::{{ target }} PROPERTIES
|
||||
set_target_properties({{ target }} PROPERTIES
|
||||
IMPORTED_LOCATION "${_IMPORT_PREFIX}/lib/{{ artifact_dll }}"
|
||||
)
|
||||
endif()
|
||||
|
||||
{# Cleanup temporary variables -#}
|
||||
set(_IMPORT_PREFIX)
|
||||
|
||||
{% if dependencies | length != 0 -%}
|
||||
{# Pull in declared dependencies and wire them into the imported target -#}
|
||||
include(CMakeFindDependencyMacro)
|
||||
{% for dep in dependencies -%}
|
||||
find_dependency({{ dep.package }})
|
||||
{% endfor -%}
|
||||
set_target_properties({{ namespace }}::{{ target }} PROPERTIES
|
||||
set_target_properties({{ target }} PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "{{ dependencies | map(attribute='target') | join(';') }}"
|
||||
)
|
||||
{%- endif %}
|
||||
|
||||
{# Cleanup temporary variables -#}
|
||||
set(_IMPORT_PREFIX)
|
||||
{# Verify component (although there is no component) -#}
|
||||
macro(check_required_components _NAME)
|
||||
foreach(comp ${${_NAME}_FIND_COMPONENTS})
|
||||
if(NOT ${_NAME}_${comp}_FOUND)
|
||||
if(${_NAME}_FIND_REQUIRED_${comp})
|
||||
set(${_NAME}_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
check_required_components({{ target }})
|
||||
|
||||
Reference in New Issue
Block a user