New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMakeDeps imported target multiconfig #11691
Changes from all commits
1dad411
e21bef6
470d608
fedbc2c
83dca17
cb90658
e9a4236
307bb66
9193376
5f3026a
9340ce1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ def context(self): | |
return {"pkg_name": self.pkg_name, | ||
"root_target_name": self.root_target_name, | ||
"config_suffix": self.config_suffix, | ||
"config": self.configuration.upper(), | ||
"deps_targets_names": ";".join(deps_targets_names), | ||
"components_names": components_names, | ||
"configuration": self.cmakedeps.configuration, | ||
|
@@ -60,64 +61,44 @@ def template(self): | |
conan_find_apple_frameworks({{ pkg_name }}_FRAMEWORKS_FOUND{{ config_suffix }} "{{ '${' }}{{ pkg_name }}_FRAMEWORKS{{ config_suffix }}}" "{{ '${' }}{{ pkg_name }}_FRAMEWORK_DIRS{{ config_suffix }}}") | ||
|
||
# Gather all the libraries that should be linked to the targets (do not touch existing variables) | ||
set(_{{ pkg_name }}_DEPENDENCIES{{ config_suffix }} "{{ '${' }}{{ pkg_name }}_FRAMEWORKS_FOUND{{ config_suffix }}} {{ '${' }}{{ pkg_name }}_SYSTEM_LIBS{{ config_suffix }}} {{ deps_targets_names }}") | ||
# FIXME: Why is needed to pass all the dependencies to link with the micro-targets? | ||
set(_{{ pkg_name }}_DEPENDENCIES{{ config_suffix }} "{{ deps_targets_names }}") | ||
|
||
set({{ pkg_name }}_LIBRARIES_TARGETS{{ config_suffix }} "") # Will be filled later | ||
set({{ pkg_name }}_LIBRARIES{{ config_suffix }} "") # Will be filled later | ||
conan_package_library_targets("{{ '${' }}{{ pkg_name }}_LIBS{{ config_suffix }}}" # libraries | ||
"{{ '${' }}{{ pkg_name }}_LIB_DIRS{{ config_suffix }}}" # package_libdir | ||
"{{ '${' }}_{{ pkg_name }}_DEPENDENCIES{{ config_suffix }}}" # deps | ||
{{ pkg_name }}_LIBRARIES{{ config_suffix }} # out_libraries | ||
{{ pkg_name }}_LIBRARIES_TARGETS{{ config_suffix }} # out_libraries_targets | ||
"{{ config_suffix }}" # config_suffix | ||
{{ pkg_name }}_LIBRARIES_TARGETS # out_libraries_targets | ||
"{{ config }}" # DEBUG, RELEASE ... | ||
"{{ pkg_name }}") # package_name | ||
|
||
# The XXXX_LIBRARIES_RELEASE/DEBUG is used for the module (FindXXX.cmake) | ||
foreach(_FRAMEWORK {{ '${' }}{{ pkg_name }}_FRAMEWORKS_FOUND{{ config_suffix }}}) | ||
list(APPEND {{ pkg_name }}_LIBRARIES_TARGETS{{ config_suffix }} ${_FRAMEWORK}) | ||
list(APPEND {{ pkg_name }}_LIBRARIES{{ config_suffix }} ${_FRAMEWORK}) | ||
endforeach() | ||
|
||
foreach(_SYSTEM_LIB {{ '${' }}{{ pkg_name }}_SYSTEM_LIBS{{ config_suffix }}}) | ||
list(APPEND {{ pkg_name }}_LIBRARIES_TARGETS{{ config_suffix }} ${_SYSTEM_LIB}) | ||
list(APPEND {{ pkg_name }}_LIBRARIES{{ config_suffix }} ${_SYSTEM_LIB}) | ||
endforeach() | ||
|
||
# We need to add our requirements too | ||
set({{ pkg_name }}_LIBRARIES_TARGETS{{ config_suffix }} {{ '"${' }}{{ pkg_name }}_LIBRARIES_TARGETS{{ config_suffix }}{{ '};' }}{{ deps_targets_names }}") | ||
set({{ pkg_name }}_LIBRARIES{{ config_suffix }} {{ '"${' }}{{ pkg_name }}_LIBRARIES{{ config_suffix }}{{ '};' }}{{ deps_targets_names }}") | ||
set({{ pkg_name }}_LIBRARIES{{ config_suffix }} "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, @lasote ! I think that you have broken everything here :) The variable was not cleared here before. It seems strange even when looking to several I didn't understand whole picture though. But the specific problem is: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking. |
||
list(APPEND {{ pkg_name }}_LIBRARIES{{ config_suffix }} {{ deps_targets_names }}) | ||
|
||
# FIXME: What is the result of this for multi-config? All configs adding themselves to path? | ||
set(CMAKE_MODULE_PATH {{ '${' }}{{ pkg_name }}_BUILD_DIRS{{ config_suffix }}} {{ '${' }}CMAKE_MODULE_PATH}) | ||
set(CMAKE_PREFIX_PATH {{ '${' }}{{ pkg_name }}_BUILD_DIRS{{ config_suffix }}} {{ '${' }}CMAKE_PREFIX_PATH}) | ||
|
||
{%- for comp_variable_name, comp_target_name in components_names %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved below, with the other components code to be easier. |
||
|
||
########## COMPONENT {{ comp_target_name }} FIND LIBRARIES & FRAMEWORKS / DYNAMIC VARS ############# | ||
|
||
set({{ pkg_name }}_{{ comp_variable_name }}_FRAMEWORKS_FOUND{{ config_suffix }} "") | ||
conan_find_apple_frameworks({{ pkg_name }}_{{ comp_variable_name }}_FRAMEWORKS_FOUND{{ config_suffix }} "{{ '${'+pkg_name+'_'+comp_variable_name+'_FRAMEWORKS'+config_suffix+'}' }}" "{{ '${'+pkg_name+'_'+comp_variable_name+'_FRAMEWORK_DIRS'+config_suffix+'}' }}") | ||
|
||
set({{ pkg_name }}_{{ comp_variable_name }}_LIB_TARGETS{{ config_suffix }} "") | ||
set({{ pkg_name }}_{{ comp_variable_name }}_NOT_USED{{ config_suffix }} "") | ||
set({{ pkg_name }}_{{ comp_variable_name }}_LIBS_FRAMEWORKS_DEPS{{ config_suffix }} {{ '${'+pkg_name+'_'+comp_variable_name+'_FRAMEWORKS_FOUND'+config_suffix+'}' }} {{ '${'+pkg_name+'_'+comp_variable_name+'_SYSTEM_LIBS'+config_suffix+'}' }} {{ '${'+pkg_name+'_'+comp_variable_name+'_DEPENDENCIES'+config_suffix+'}' }}) | ||
conan_package_library_targets("{{ '${'+pkg_name+'_'+comp_variable_name+'_LIBS'+config_suffix+'}' }}" | ||
"{{ '${'+pkg_name+'_'+comp_variable_name+'_LIB_DIRS'+config_suffix+'}' }}" | ||
"{{ '${'+pkg_name+'_'+comp_variable_name+'_LIBS_FRAMEWORKS_DEPS'+config_suffix+'}' }}" | ||
{{ pkg_name }}_{{ comp_variable_name }}_NOT_USED{{ config_suffix }} | ||
{{ pkg_name }}_{{ comp_variable_name }}_LIB_TARGETS{{ config_suffix }} | ||
"{{ config_suffix }}" | ||
"{{ pkg_name }}_{{ comp_variable_name }}") | ||
|
||
set({{ pkg_name }}_{{ comp_variable_name }}_LINK_LIBS{{ config_suffix }} {{ '${'+pkg_name+'_'+comp_variable_name+'_LIB_TARGETS'+config_suffix+'}' }} {{ '${'+pkg_name+'_'+comp_variable_name+'_LIBS_FRAMEWORKS_DEPS'+config_suffix+'}' }}) | ||
{%- endfor %} | ||
|
||
|
||
{% if not components_names %} | ||
########## GLOBAL TARGET PROPERTIES {{ configuration }} ######################################## | ||
set_property(TARGET {{root_target_name}} | ||
PROPERTY INTERFACE_LINK_LIBRARIES | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_OBJECTS{{config_suffix}}} | ||
${{'{'}}{{pkg_name}}_LIBRARIES_TARGETS{{config_suffix}}}> APPEND) | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_OBJECTS{{config_suffix}}}> | ||
${{'{'}}{{pkg_name}}_LIBRARIES_TARGETS} | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}_{{pkg_name}}_DEPENDENCIES{{config_suffix}}}> | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_FRAMEWORKS_FOUND{{config_suffix}}}> | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_SYSTEM_LIBS{{config_suffix}}}> | ||
APPEND) | ||
|
||
set_property(TARGET {{root_target_name}} | ||
PROPERTY INTERFACE_LINK_OPTIONS | ||
|
@@ -146,10 +127,30 @@ def template(self): | |
|
||
{%- for comp_variable_name, comp_target_name in components_names %} | ||
|
||
########## COMPONENT {{ comp_target_name }} TARGET PROPERTIES ###################################### | ||
set_property(TARGET {{ comp_target_name }} PROPERTY INTERFACE_LINK_LIBRARIES | ||
$<$<CONFIG:{{ configuration }}>:{{tvalue(pkg_name, comp_variable_name, 'OBJECTS', config_suffix)}} | ||
{{tvalue(pkg_name, comp_variable_name, 'LINK_LIBS', config_suffix)}}> APPEND) | ||
########## COMPONENT {{ comp_target_name }} FIND LIBRARIES & FRAMEWORKS / DYNAMIC VARS ############# | ||
|
||
set({{ pkg_name }}_{{ comp_variable_name }}_FRAMEWORKS_FOUND{{ config_suffix }} "") | ||
conan_find_apple_frameworks({{ pkg_name }}_{{ comp_variable_name }}_FRAMEWORKS_FOUND{{ config_suffix }} "{{ '${'+pkg_name+'_'+comp_variable_name+'_FRAMEWORKS'+config_suffix+'}' }}" "{{ '${'+pkg_name+'_'+comp_variable_name+'_FRAMEWORK_DIRS'+config_suffix+'}' }}") | ||
|
||
set({{ pkg_name }}_{{ comp_variable_name }}_LIBRARIES_TARGETS "") | ||
|
||
conan_package_library_targets("{{ '${'+pkg_name+'_'+comp_variable_name+'_LIBS'+config_suffix+'}' }}" | ||
"{{ '${'+pkg_name+'_'+comp_variable_name+'_LIB_DIRS'+config_suffix+'}' }}" | ||
"{{ '${'+pkg_name+'_'+comp_variable_name+'_DEPENDENCIES'+config_suffix+'}' }}" | ||
{{ pkg_name }}_{{ comp_variable_name }}_LIBRARIES_TARGETS | ||
"{{ config }}" # DEBUG, RELEASE... | ||
"{{ pkg_name }}_{{ comp_variable_name }}") | ||
|
||
########## COMPONENT {{ comp_target_name }} TARGET PROPERTIES ##################################### | ||
set_property(TARGET {{comp_target_name}} | ||
PROPERTY INTERFACE_LINK_LIBRARIES | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_{{comp_variable_name}}_OBJECTS{{config_suffix}}}> | ||
${{'{'}}{{pkg_name}}_{{comp_variable_name}}_LIBRARIES_TARGETS} | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_{{comp_variable_name}}_DEPENDENCIES{{config_suffix}}}> | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_{{comp_variable_name}}_FRAMEWORKS_FOUND{{config_suffix}}}> | ||
$<$<CONFIG:{{configuration}}>:${{'{'}}{{pkg_name}}_{{comp_variable_name}}_SYSTEM_LIBS{{config_suffix}}}> | ||
APPEND) | ||
|
||
set_property(TARGET {{ comp_target_name }} PROPERTY INTERFACE_LINK_OPTIONS | ||
$<$<CONFIG:{{ configuration }}>:{{tvalue(pkg_name, comp_variable_name, 'LINKER_FLAGS', config_suffix)}}> APPEND) | ||
set_property(TARGET {{ comp_target_name }} PROPERTY INTERFACE_INCLUDE_DIRECTORIES | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out_libraries
arg was not used.