From a60c4b2e9637547321d5fb90a314eda5ae6d6156 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Wed, 3 Nov 2021 18:21:45 +0100 Subject: [PATCH 1/7] Adding tests for shared link flags --- .../templates/target_configuration.py | 7 ++- .../test_cmakedeps_and_linker_flags.py | 55 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py diff --git a/conan/tools/cmake/cmakedeps/templates/target_configuration.py b/conan/tools/cmake/cmakedeps/templates/target_configuration.py index 1d094692b1d..60cf4e307e3 100644 --- a/conan/tools/cmake/cmakedeps/templates/target_configuration.py +++ b/conan/tools/cmake/cmakedeps/templates/target_configuration.py @@ -110,8 +110,10 @@ def template(self): set_property(TARGET {{target_namespace}}::{{global_target_name}} PROPERTY INTERFACE_LINK_LIBRARIES $<$:${{'{'}}{{pkg_name}}_LIBRARIES_TARGETS{{config_suffix}}} - ${{'{'}}{{pkg_name}}_LINKER_FLAGS{{config_suffix}}} ${{'{'}}{{pkg_name}}_OBJECTS{{config_suffix}}}> APPEND) + set_property(TARGET {{target_namespace}}::{{global_target_name}} + PROPERTY INTERFACE_LINK_OPTIONS + $<$:${{'{'}}{{pkg_name}}_LINKER_FLAGS{{config_suffix}}}> APPEND) set_property(TARGET {{target_namespace}}::{{global_target_name}} PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<$:${{'{'}}{{pkg_name}}_INCLUDE_DIRS{{config_suffix}}}> APPEND) @@ -129,8 +131,9 @@ def template(self): ########## COMPONENT {{ comp_name }} TARGET PROPERTIES ###################################### set_property(TARGET {{ target_namespace }}::{{ comp_name }} PROPERTY INTERFACE_LINK_LIBRARIES $<$:{{tvalue(pkg_name, comp_name, 'LINK_LIBS', config_suffix)}} - {{tvalue(pkg_name, comp_name, 'LINKER_FLAGS', config_suffix)}} {{tvalue(pkg_name, comp_name, 'OBJECTS', config_suffix)}}> APPEND) + set_property(TARGET {{ target_namespace }}::{{ comp_name }} PROPERTY INTERFACE_LINK_OPTIONS + $<$:{{tvalue(pkg_name, comp_name, 'LINKER_FLAGS', config_suffix)}}> APPEND) set_property(TARGET {{ target_namespace }}::{{ comp_name }} PROPERTY INTERFACE_INCLUDE_DIRECTORIES $<$:{{tvalue(pkg_name, comp_name, 'INCLUDE_DIRS', config_suffix)}}> APPEND) set_property(TARGET {{ target_namespace }}::{{ comp_name }} PROPERTY INTERFACE_COMPILE_DEFINITIONS diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py new file mode 100644 index 00000000000..e955f68a328 --- /dev/null +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py @@ -0,0 +1,55 @@ +import platform +import textwrap + +import pytest + +from conans.test.utils.tools import TestClient + + +@pytest.mark.skipif(platform.system() != "Linux", reason="Only Linux") +@pytest.mark.tool_cmake +def test_shared_link_flags(): + """ + Testing CMakeDeps and linker flags injection + + Issue: https://github.com/conan-io/conan/issues/9936 + """ + conanfile = textwrap.dedent(""" +from conans import ConanFile +from conan.tools.cmake import CMake +from conan.tools.layout import cmake_layout + + +class HelloConan(ConanFile): + name = "hello" + version = "1.0" + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False]} + default_options = {"shared": False} + exports_sources = "CMakeLists.txt", "src/*" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["hello"] + self.cpp_info.sharedlinkflags = ["-z now", "-z relro"] + self.cpp_info.exelinkflags = ["-z now", "-z relro"] + """) + + client = TestClient() + client.run("new hello/1.0 -m cmake_lib") + client.save({"conanfile.py": conanfile}) + client.run("create .") + assert "hello link libraries: hello::hello" in client.out + From ff21ddf03cb7be28707ab0d6646a94b5c87e82c1 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Mon, 8 Nov 2021 12:59:08 +0100 Subject: [PATCH 2/7] Added quotes to handle several link options injection --- conan/tools/cmake/cmakedeps/templates/target_data.py | 4 ++-- .../cmake/cmakedeps/test_cmakedeps_and_linker_flags.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/conan/tools/cmake/cmakedeps/templates/target_data.py b/conan/tools/cmake/cmakedeps/templates/target_data.py index 7c2bca54eaa..781e30b588e 100644 --- a/conan/tools/cmake/cmakedeps/templates/target_data.py +++ b/conan/tools/cmake/cmakedeps/templates/target_data.py @@ -64,8 +64,8 @@ def template(self): set({{ pkg_name }}_INCLUDE_DIRS{{ config_suffix }} {{ global_cpp.include_paths }}) set({{ pkg_name }}_RES_DIRS{{ config_suffix }} {{ global_cpp.res_paths }}) set({{ pkg_name }}_DEFINITIONS{{ config_suffix }} {{ global_cpp.defines }}) - set({{ pkg_name }}_SHARED_LINK_FLAGS{{ config_suffix }} {{ global_cpp.sharedlinkflags_list }}) - set({{ pkg_name }}_EXE_LINK_FLAGS{{ config_suffix }} {{ global_cpp.exelinkflags_list }}) + set({{ pkg_name }}_SHARED_LINK_FLAGS{{ config_suffix }} "{{ global_cpp.sharedlinkflags_list }}") + set({{ pkg_name }}_EXE_LINK_FLAGS{{ config_suffix }} "{{ global_cpp.exelinkflags_list }}") set({{ pkg_name }}_OBJECTS{{ config_suffix }} {{ global_cpp.objects_list }}) set({{ pkg_name }}_COMPILE_DEFINITIONS{{ config_suffix }} {{ global_cpp.compile_definitions }}) set({{ pkg_name }}_COMPILE_OPTIONS_C{{ config_suffix }} {{ global_cpp.cflags_list }}) diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py index e955f68a328..fa36d65b70c 100644 --- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py @@ -1,3 +1,4 @@ +import os import platform import textwrap @@ -51,5 +52,8 @@ def package_info(self): client.run("new hello/1.0 -m cmake_lib") client.save({"conanfile.py": conanfile}) client.run("create .") - assert "hello link libraries: hello::hello" in client.out - + t = os.path.join("test_package", "cmake-build-release", "conan", "hello-release-x86_64-data.cmake") + target_data_cmake_content = client.load(t) + assert 'set(hello_SHARED_LINK_FLAGS_RELEASE "-z now;-z relro")' in target_data_cmake_content + assert 'set(hello_EXE_LINK_FLAGS_RELEASE "-z now;-z relro")' in target_data_cmake_content + assert "hello/0.1: Hello World Release!" in client.out From 2eb13e906cbcf741cb75b8ce623278c7d4875a5a Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Mon, 8 Nov 2021 13:07:54 +0100 Subject: [PATCH 3/7] Fixed test --- .../cmake/cmakedeps/test_cmakedeps_and_linker_flags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py index fa36d65b70c..07b6f86d98f 100644 --- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py @@ -56,4 +56,4 @@ def package_info(self): target_data_cmake_content = client.load(t) assert 'set(hello_SHARED_LINK_FLAGS_RELEASE "-z now;-z relro")' in target_data_cmake_content assert 'set(hello_EXE_LINK_FLAGS_RELEASE "-z now;-z relro")' in target_data_cmake_content - assert "hello/0.1: Hello World Release!" in client.out + assert "hello/1.0: Hello World Release!" in client.out From e2969b8eda4abfe084db9a03d55172b83b32cee0 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Wed, 10 Nov 2021 15:35:17 +0100 Subject: [PATCH 4/7] Fixed failing tests --- .../cmake/cmakedeps/templates/target_data.py | 17 ++++++++++------- .../cmake/cmakedeps/test_cmakedeps.py | 11 +++-------- .../cmakedeps/test_cmakedeps_components.py | 18 ++++++++++-------- .../cmake/cmakedeps/test_cmakedeps.py | 2 -- .../unittests/tools/cmake/test_cmakedeps.py | 4 ++-- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/conan/tools/cmake/cmakedeps/templates/target_data.py b/conan/tools/cmake/cmakedeps/templates/target_data.py index 781e30b588e..630032a1cbe 100644 --- a/conan/tools/cmake/cmakedeps/templates/target_data.py +++ b/conan/tools/cmake/cmakedeps/templates/target_data.py @@ -64,8 +64,8 @@ def template(self): set({{ pkg_name }}_INCLUDE_DIRS{{ config_suffix }} {{ global_cpp.include_paths }}) set({{ pkg_name }}_RES_DIRS{{ config_suffix }} {{ global_cpp.res_paths }}) set({{ pkg_name }}_DEFINITIONS{{ config_suffix }} {{ global_cpp.defines }}) - set({{ pkg_name }}_SHARED_LINK_FLAGS{{ config_suffix }} "{{ global_cpp.sharedlinkflags_list }}") - set({{ pkg_name }}_EXE_LINK_FLAGS{{ config_suffix }} "{{ global_cpp.exelinkflags_list }}") + set({{ pkg_name }}_SHARED_LINK_FLAGS{{ config_suffix }} {{ global_cpp.sharedlinkflags_list }}) + set({{ pkg_name }}_EXE_LINK_FLAGS{{ config_suffix }} {{ global_cpp.exelinkflags_list }}) set({{ pkg_name }}_OBJECTS{{ config_suffix }} {{ global_cpp.objects_list }}) set({{ pkg_name }}_COMPILE_DEFINITIONS{{ config_suffix }} {{ global_cpp.compile_definitions }}) set({{ pkg_name }}_COMPILE_OPTIONS_C{{ config_suffix }} {{ global_cpp.cflags_list }}) @@ -174,10 +174,13 @@ def join_paths(paths): ret.append('"${%s}/%s"' % (pfolder_var_name, norm_path)) return "\n\t\t\t".join(ret) - def join_flags(separator, values): + def join_flags(separator, values, as_string=False): # Flags have to be escaped - return separator.join(v.replace('\\', '\\\\').replace('$', '\\$').replace('"', '\\"') - for v in values) + ret = separator.join(v.replace('\\', '\\\\').replace('$', '\\$').replace('"', '\\"') + for v in values) + if as_string: + ret = '"%s"' % ret + return ret def join_defines(values, prefix=""): # Defines have to be escaped, included spaces @@ -215,8 +218,8 @@ def join_paths_single_var(values): # linker flags without magic: trying to mess with - and / => # https://github.com/conan-io/conan/issues/8811 # frameworks should be declared with cppinfo.frameworks not "-framework Foundation" - self.sharedlinkflags_list = join_flags(";", cpp_info.sharedlinkflags) - self.exelinkflags_list = join_flags(";", cpp_info.exelinkflags) + self.sharedlinkflags_list = join_flags(";", cpp_info.sharedlinkflags, as_string=True) + self.exelinkflags_list = join_flags(";", cpp_info.exelinkflags, as_string=True) self.objects_list = join_paths(cpp_info.objects) diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py index 2b337fb3496..6b34380cbf0 100644 --- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps.py @@ -151,17 +151,12 @@ def package_info(self): if build_type == "Release": assert "System libs release: %s" % library_name in client.out assert "Libraries to Link release: lib1" in client.out - target_libs = ("$<$:CONAN_LIB::Test_lib1_RELEASE;sys1;" - "$<$,SHARED_LIBRARY>:>;" - "$<$,MODULE_LIBRARY>:>;" - "$<$,EXECUTABLE>:>;>") + target_libs = "$<$:CONAN_LIB::Test_lib1_RELEASE;sys1;" else: assert "System libs debug: %s" % library_name in client.out assert "Libraries to Link debug: lib1" in client.out - target_libs = ("$<$:CONAN_LIB::Test_lib1_DEBUG;sys1d;" - "$<$,SHARED_LIBRARY>:>;" - "$<$,MODULE_LIBRARY>:>;" - "$<$,EXECUTABLE>:>;>") + target_libs = "$<$:CONAN_LIB::Test_lib1_DEBUG;sys1d;" + assert "Target libs: %s" % target_libs in client.out diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py index 2cc2fc761b2..88ab665c2a5 100644 --- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py @@ -199,17 +199,19 @@ def build(self): project(consumer) cmake_minimum_required(VERSION 3.1) find_package(requirement) - get_target_property(tmp requirement::component INTERFACE_LINK_LIBRARIES) - message("component libs: ${tmp}") + get_target_property(tmp_libs requirement::component INTERFACE_LINK_LIBRARIES) + get_target_property(tmp_options requirement::component INTERFACE_LINK_OPTIONS) + message("component libs: ${tmp_libs}") + message("component options: ${tmp_options}") """) t.save({"conanfile.py": conanfile, "CMakeLists.txt": cmakelists}) t.run("create . --build missing -s build_type=Release") - - assert ("component libs: " - "$<$:system_lib_component;" - "$<$,SHARED_LIBRARY>:>;" - "$<$,MODULE_LIBRARY>:>;" - "$<$,EXECUTABLE>:>;>") in t.out + assert 'component libs: $<$:system_lib_component;>' in t.out + assert ('component options: ' + '$<$:' + '$<$,SHARED_LIBRARY>:"">;' + '$<$,MODULE_LIBRARY>:"">;' + '$<$,EXECUTABLE>:"">>') in t.out # NOTE: If there is no "conan install -s build_type=Debug", the properties won't contain the # diff --git a/conans/test/integration/toolchains/cmake/cmakedeps/test_cmakedeps.py b/conans/test/integration/toolchains/cmake/cmakedeps/test_cmakedeps.py index b51b53482db..ef90bb2f5ed 100644 --- a/conans/test/integration/toolchains/cmake/cmakedeps/test_cmakedeps.py +++ b/conans/test/integration/toolchains/cmake/cmakedeps/test_cmakedeps.py @@ -104,12 +104,10 @@ def package_info(self): content = f.read() assert """set_property(TARGET hello::say PROPERTY INTERFACE_LINK_LIBRARIES $<$:${hello_say_LINK_LIBS_RELEASE} - ${hello_say_LINKER_FLAGS_RELEASE} ${hello_say_OBJECTS_RELEASE}> APPEND)""" in content assert """set_property(TARGET hello::hello PROPERTY INTERFACE_LINK_LIBRARIES $<$:${hello_LIBRARIES_TARGETS_RELEASE} - ${hello_LINKER_FLAGS_RELEASE} ${hello_OBJECTS_RELEASE}> APPEND)""" in content with open(os.path.join(client.current_folder, "hello-release-x86_64-data.cmake")) as f: diff --git a/conans/test/unittests/tools/cmake/test_cmakedeps.py b/conans/test/unittests/tools/cmake/test_cmakedeps.py index 9995eee7517..1284b655af4 100644 --- a/conans/test/unittests/tools/cmake/test_cmakedeps.py +++ b/conans/test/unittests/tools/cmake/test_cmakedeps.py @@ -116,8 +116,8 @@ def test_cmake_deps_links_flags(): cmakedeps = CMakeDeps(conanfile) files = cmakedeps.content data_cmake = files["mypkg-release-x86-data.cmake"] - assert "set(mypkg_SHARED_LINK_FLAGS_RELEASE -NODEFAULTLIB;-OTHERFLAG)" in data_cmake - assert "set(mypkg_EXE_LINK_FLAGS_RELEASE -OPT:NOICF)" in data_cmake + assert 'set(mypkg_SHARED_LINK_FLAGS_RELEASE "-NODEFAULTLIB;-OTHERFLAG")' in data_cmake + assert 'set(mypkg_EXE_LINK_FLAGS_RELEASE "-OPT:NOICF")' in data_cmake assert 'set(mypkg_OBJECTS_RELEASE "${mypkg_PACKAGE_FOLDER_RELEASE}/myobject.o")' in data_cmake From f0db58b4169457e57d949672e7ac00475aa656c6 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Wed, 10 Nov 2021 17:07:54 +0100 Subject: [PATCH 5/7] Returning a string in case of having values --- conan/tools/cmake/cmakedeps/templates/target_data.py | 2 +- .../toolchains/cmake/cmakedeps/test_cmakedeps_components.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conan/tools/cmake/cmakedeps/templates/target_data.py b/conan/tools/cmake/cmakedeps/templates/target_data.py index 630032a1cbe..7bb65943bfb 100644 --- a/conan/tools/cmake/cmakedeps/templates/target_data.py +++ b/conan/tools/cmake/cmakedeps/templates/target_data.py @@ -178,7 +178,7 @@ def join_flags(separator, values, as_string=False): # Flags have to be escaped ret = separator.join(v.replace('\\', '\\\\').replace('$', '\\$').replace('"', '\\"') for v in values) - if as_string: + if ret and as_string is True: ret = '"%s"' % ret return ret diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py index 88ab665c2a5..c99348f1d27 100644 --- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_components.py @@ -210,8 +210,8 @@ def build(self): assert 'component libs: $<$:system_lib_component;>' in t.out assert ('component options: ' '$<$:' - '$<$,SHARED_LIBRARY>:"">;' - '$<$,MODULE_LIBRARY>:"">;' - '$<$,EXECUTABLE>:"">>') in t.out + '$<$,SHARED_LIBRARY>:>;' + '$<$,MODULE_LIBRARY>:>;' + '$<$,EXECUTABLE>:>>') in t.out # NOTE: If there is no "conan install -s build_type=Debug", the properties won't contain the # From b1f9c5361f2251b94a4ae7761f8abd1591247dd9 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Mon, 15 Nov 2021 17:45:16 +0100 Subject: [PATCH 6/7] Bad indentation --- .../test_cmakedeps_and_linker_flags.py | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py index 07b6f86d98f..073f0058659 100644 --- a/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py +++ b/conans/test/functional/toolchains/cmake/cmakedeps/test_cmakedeps_and_linker_flags.py @@ -16,36 +16,36 @@ def test_shared_link_flags(): Issue: https://github.com/conan-io/conan/issues/9936 """ conanfile = textwrap.dedent(""" -from conans import ConanFile -from conan.tools.cmake import CMake -from conan.tools.layout import cmake_layout - - -class HelloConan(ConanFile): - name = "hello" - version = "1.0" - settings = "os", "compiler", "build_type", "arch" - options = {"shared": [True, False]} - default_options = {"shared": False} - exports_sources = "CMakeLists.txt", "src/*" - generators = "CMakeDeps", "CMakeToolchain" - - def layout(self): - cmake_layout(self) - - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() - - def package(self): - cmake = CMake(self) - cmake.install() - - def package_info(self): - self.cpp_info.libs = ["hello"] - self.cpp_info.sharedlinkflags = ["-z now", "-z relro"] - self.cpp_info.exelinkflags = ["-z now", "-z relro"] + from conans import ConanFile + from conan.tools.cmake import CMake + from conan.tools.layout import cmake_layout + + + class HelloConan(ConanFile): + name = "hello" + version = "1.0" + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False]} + default_options = {"shared": False} + exports_sources = "CMakeLists.txt", "src/*" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = ["hello"] + self.cpp_info.sharedlinkflags = ["-z now", "-z relro"] + self.cpp_info.exelinkflags = ["-z now", "-z relro"] """) client = TestClient() From f560ced03de97798f3ac206dd67898ae6aceb5e6 Mon Sep 17 00:00:00 2001 From: Francisco Ramirez de Anton Date: Tue, 16 Nov 2021 10:34:12 +0100 Subject: [PATCH 7/7] Formatting directly to string --- conan/tools/cmake/cmakedeps/templates/target_data.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/conan/tools/cmake/cmakedeps/templates/target_data.py b/conan/tools/cmake/cmakedeps/templates/target_data.py index 7bb65943bfb..9b48891f3c9 100644 --- a/conan/tools/cmake/cmakedeps/templates/target_data.py +++ b/conan/tools/cmake/cmakedeps/templates/target_data.py @@ -174,12 +174,10 @@ def join_paths(paths): ret.append('"${%s}/%s"' % (pfolder_var_name, norm_path)) return "\n\t\t\t".join(ret) - def join_flags(separator, values, as_string=False): + def join_flags(separator, values): # Flags have to be escaped ret = separator.join(v.replace('\\', '\\\\').replace('$', '\\$').replace('"', '\\"') for v in values) - if ret and as_string is True: - ret = '"%s"' % ret return ret def join_defines(values, prefix=""): @@ -218,8 +216,10 @@ def join_paths_single_var(values): # linker flags without magic: trying to mess with - and / => # https://github.com/conan-io/conan/issues/8811 # frameworks should be declared with cppinfo.frameworks not "-framework Foundation" - self.sharedlinkflags_list = join_flags(";", cpp_info.sharedlinkflags, as_string=True) - self.exelinkflags_list = join_flags(";", cpp_info.exelinkflags, as_string=True) + self.sharedlinkflags_list = '"{}"'.format(join_flags(";", cpp_info.sharedlinkflags)) \ + if cpp_info.sharedlinkflags else '' + self.exelinkflags_list = '"{}"'.format(join_flags(";", cpp_info.exelinkflags)) \ + if cpp_info.exelinkflags else '' self.objects_list = join_paths(cpp_info.objects)