Skip to content
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

Fix apple frameworks in CMake generators #6003

Merged
merged 31 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6f5a72f
Fix apple frameworks in cmake generators
danimtb Oct 30, 2019
e100f69
move macro and fixed tests
danimtb Oct 30, 2019
6757516
revert new line
danimtb Oct 30, 2019
b517c0c
fix tests
danimtb Oct 30, 2019
f09cc9b
fix more tests
danimtb Oct 30, 2019
f48c131
fix
danimtb Oct 30, 2019
9e5916b
more fixes
danimtb Oct 30, 2019
1aa0817
fix assert
danimtb Oct 30, 2019
666a4a8
sorted
danimtb Oct 30, 2019
f8a575a
fix frameworks test
danimtb Oct 31, 2019
a6a152c
fix assert
danimtb Oct 31, 2019
109af83
cast to str
danimtb Oct 31, 2019
45f5b0e
Added not found error message
danimtb Oct 31, 2019
aa0ea42
work around a failing test
jgsogo Oct 31, 2019
1d8004d
remove print function
jgsogo Oct 31, 2019
934e2cb
Merge pull request #5 from jgsogo/danimtb-feature/5909
danimtb Oct 31, 2019
f4d2aeb
Merge branch 'feature/5909' of github.com:danimtb/conan into feature/…
danimtb Oct 31, 2019
284e643
Use CONAN_PKG_LIBS
danimtb Oct 31, 2019
ef6d699
fix conan_package_library_targets() and tests
danimtb Oct 31, 2019
a38b453
Update conans/test/functional/generators/cmake_find_package_test.py
danimtb Oct 31, 2019
3a2d90c
changed message and vars
danimtb Oct 31, 2019
8345563
Merge branch 'feature/5909' of github.com:danimtb/conan into feature/…
danimtb Oct 31, 2019
12e51f3
fix brackets
danimtb Oct 31, 2019
0cccd27
remove global CONAN_LIBS_FRAMEWORKS
danimtb Oct 31, 2019
45d1ccd
Update conans/test/functional/generators/cmake_find_package_test.py
danimtb Oct 31, 2019
f8f5900
Use parameters in conan_find_apple_frameworks()
danimtb Oct 31, 2019
1ce46cc
Merge branch 'feature/5909' of github.com:danimtb/conan into feature/…
danimtb Oct 31, 2019
b12d644
fix tests
danimtb Oct 31, 2019
a850103
try to fix macro
danimtb Oct 31, 2019
a0940ae
fix macro
danimtb Oct 31, 2019
1da243e
Merge branch 'develop' into feature/5909
lasote Nov 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 4 additions & 17 deletions conans/client/generators/cmake.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conans.client.generators.cmake_common import cmake_dependencies, cmake_dependency_vars, \
cmake_global_vars, cmake_macros, cmake_package_info, cmake_settings_info, cmake_user_info_vars, \
generate_targets_section
generate_targets_section, apple_frameworks_macro
from conans.model import Generator
from conans.paths import BUILD_INFO_CMAKE

Expand Down Expand Up @@ -30,24 +30,10 @@ def join_defines(values, prefix=""):
self.bin_paths = join_paths(cpp_info.bin_paths)
self.build_paths = join_paths(cpp_info.build_paths)
self.src_paths = join_paths(cpp_info.src_paths)
self.libs_system_frameworks = join_flags(" ", cpp_info.libs + cpp_info.system_libs)
self.framework_paths = join_paths(cpp_info.framework_paths)
self.libs = join_flags(" ", cpp_info.libs)
self.system_libs = join_flags(" ", cpp_info.system_libs)

framework_paths = join_paths(cpp_info.framework_paths)
self.find_frameworks = ""
for framework in cpp_info.frameworks:
var = "CONAN_FRAMEWORK_" + framework.upper()
find_framework = "if(APPLE)\n" \
"find_library({var} {framework} " \
"PATHS {framework_paths})\n" \
"endif(APPLE)\n".format(var=var,
framework=framework,
framework_paths=framework_paths)
var = '${%s}' % var
self.libs_system_frameworks += " " + var
self.find_frameworks += find_framework

self.frameworks = join_flags(" ", cpp_info.frameworks)
self.defines = join_defines(cpp_info.defines, "-D")
self.compile_definitions = join_defines(cpp_info.defines)

Expand Down Expand Up @@ -77,6 +63,7 @@ def filename(self):
@property
def content(self):
sections = ["include(CMakeParseArguments)"]
sections.append(apple_frameworks_macro)

# Per requirement variables
for _, dep_cpp_info in self.deps_build_info.dependencies:
Expand Down
69 changes: 60 additions & 9 deletions conans/client/generators/cmake_common.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
_cmake_single_dep_vars = """{deps.find_frameworks}
_cmake_single_dep_vars = """
set(CONAN_{dep}_ROOT{build_type} {deps.rootpath})
set(CONAN_INCLUDE_DIRS_{dep}{build_type} {deps.include_paths})
set(CONAN_LIB_DIRS_{dep}{build_type} {deps.lib_paths})
set(CONAN_BIN_DIRS_{dep}{build_type} {deps.bin_paths})
set(CONAN_RES_DIRS_{dep}{build_type} {deps.res_paths})
set(CONAN_SRC_DIRS_{dep}{build_type} {deps.src_paths})
set(CONAN_BUILD_DIRS_{dep}{build_type} {deps.build_paths})
set(CONAN_LIBS_{dep}{build_type} {deps.libs_system_frameworks})
set(CONAN_FRAMEWORK_DIRS_{dep}{build_type} {deps.framework_paths})
set(CONAN_LIBS_{dep}{build_type} {deps.libs})
set(CONAN_PKG_LIBS_{dep}{build_type} {deps.libs})
set(CONAN_SYSTEM_LIBS_{dep}{build_type} {deps.system_libs})
set(CONAN_FRAMEWORKS_{dep}{build_type} {deps.frameworks})
set(CONAN_FRAMEWORKS_FOUND_{dep}{build_type} "") # Will be filled later
set(CONAN_DEFINES_{dep}{build_type} {deps.defines})
set(CONAN_BUILD_MODULES_PATHS_{dep}{build_type} {deps.build_modules_paths})
# COMPILE_DEFINITIONS are equal to CONAN_DEFINES without -D, for targets
Expand All @@ -24,6 +27,13 @@
set(CONAN_CXX_FLAGS_{dep}{build_type}_LIST "{deps.cxxflags_list}")
set(CONAN_SHARED_LINKER_FLAGS_{dep}{build_type}_LIST "{deps.sharedlinkflags_list}")
set(CONAN_EXE_LINKER_FLAGS_{dep}{build_type}_LIST "{deps.exelinkflags_list}")

# Apple Frameworks
conan_find_apple_frameworks(CONAN_FRAMEWORKS_FOUND_{dep}{build_type} "${{CONAN_FRAMEWORKS_{dep}{build_type}}}")
# Append to aggregated values variable
set(CONAN_LIBS_{dep}{build_type} ${{CONAN_PKG_LIBS_{dep}{build_type}}} ${{CONAN_SYSTEM_LIBS_{dep}{build_type}}} ${{CONAN_FRAMEWORKS_FOUND_{dep}{build_type}}})
# Aggregate package libs and frameworks for conan_package_library_targets()
set(CONAN_LIBS_FRAMEWORKS_{dep}{build_type} ${{CONAN_PKG_LIBS_{dep}{build_type}}} ${{CONAN_FRAMEWORKS_FOUND_{dep}{build_type}}})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have no model to differentiate packaged frameworks from system frameworks, we are considering frameworks part of the libs of the package in order to create the targets later

"""


Expand Down Expand Up @@ -86,8 +96,12 @@ def cmake_dependencies(dependencies, build_type=""):
set(CONAN_LIB_DIRS{build_type} {deps.lib_paths} ${{CONAN_LIB_DIRS{build_type}}})
set(CONAN_BIN_DIRS{build_type} {deps.bin_paths} ${{CONAN_BIN_DIRS{build_type}}})
set(CONAN_RES_DIRS{build_type} {deps.res_paths} ${{CONAN_RES_DIRS{build_type}}})
set(CONAN_LIBS{build_type} {deps.libs_system_frameworks} ${{CONAN_LIBS{build_type}}})
set(CONAN_SYSTEM_LIBS{build_type} {deps.system_libs} ${{CONAN_SYSTEM_LIBS{build_type}}})
set(CONAN_FRAMEWORK_DIRS{build_type} {deps.framework_paths} ${{CONAN_FRAMEWORK_DIRS{build_type}}})
set(CONAN_LIBS{build_type} {deps.libs} ${{CONAN_LIBS{build_type}}})
set(CONAN_PKG_LIBS{build_type} {deps.libs} ${{CONAN_PKG_LIBS{build_type}}})
set(CONAN_SYSTEM_LIBS{build_type} {deps.system_libs})
set(CONAN_FRAMEWORKS{build_type} {deps.frameworks} ${{CONAN_FRAMEWORKS{build_type}}})
set(CONAN_FRAMEWORKS_FOUND{build_type} "") # Will be filled later
set(CONAN_DEFINES{build_type} {deps.defines} ${{CONAN_DEFINES{build_type}}})
set(CONAN_BUILD_MODULES_PATHS{build_type} {deps.build_modules_paths} ${{CONAN_BUILD_MODULES_PATHS{build_type}}})
set(CONAN_CMAKE_MODULE_PATH{build_type} {deps.build_paths} ${{CONAN_CMAKE_MODULE_PATH{build_type}}})
Expand All @@ -96,6 +110,11 @@ def cmake_dependencies(dependencies, build_type=""):
set(CONAN_SHARED_LINKER_FLAGS{build_type} "{deps.sharedlinkflags} ${{CONAN_SHARED_LINKER_FLAGS{build_type}}}")
set(CONAN_EXE_LINKER_FLAGS{build_type} "{deps.exelinkflags} ${{CONAN_EXE_LINKER_FLAGS{build_type}}}")
set(CONAN_C_FLAGS{build_type} "{deps.cflags} ${{CONAN_C_FLAGS{build_type}}}")

# Apple Frameworks
conan_find_apple_frameworks(CONAN_FRAMEWORKS_FOUND{build_type} "${{CONAN_FRAMEWORKS{build_type}}}")
# Append to aggregated values variable
set(CONAN_LIBS{build_type} ${{CONAN_PKG_LIBS{build_type}}} ${{CONAN_SYSTEM_LIBS{build_type}}} ${{CONAN_FRAMEWORKS_FOUND{build_type}}})
"""


Expand All @@ -115,19 +134,19 @@ def cmake_global_vars(deps, build_type=""):


_target_template = """
conan_package_library_targets("${{CONAN_PKG_LIBS_{uname}}}" "${{CONAN_LIB_DIRS_{uname}}}"
conan_package_library_targets("${{CONAN_LIBS_FRAMEWORKS_{uname}}}" "${{CONAN_LIB_DIRS_{uname}}}"
CONAN_PACKAGE_TARGETS_{uname} "${{CONAN_SYSTEM_LIBS_{uname}}} {deps}"
"" {pkg_name})
conan_package_library_targets("${{CONAN_PKG_LIBS_{uname}_DEBUG}}" "${{CONAN_LIB_DIRS_{uname}_DEBUG}}"
conan_package_library_targets("${{CONAN_LIBS_FRAMEWORKS_{uname}_DEBUG}}" "${{CONAN_LIB_DIRS_{uname}_DEBUG}}"
CONAN_PACKAGE_TARGETS_{uname}_DEBUG "${{CONAN_SYSTEM_LIBS_{uname}_DEBUG}} {deps}"
"debug" {pkg_name})
conan_package_library_targets("${{CONAN_PKG_LIBS_{uname}_RELEASE}}" "${{CONAN_LIB_DIRS_{uname}_RELEASE}}"
conan_package_library_targets("${{CONAN_LIBS_FRAMEWORKS_{uname}_RELEASE}}" "${{CONAN_LIB_DIRS_{uname}_RELEASE}}"
CONAN_PACKAGE_TARGETS_{uname}_RELEASE "${{CONAN_SYSTEM_LIBS_{uname}_RELEASE}} {deps}"
"release" {pkg_name})
conan_package_library_targets("${{CONAN_PKG_LIBS_{uname}_RELWITHDEBINFO}}" "${{CONAN_LIB_DIRS_{uname}_RELWITHDEBINFO}}"
conan_package_library_targets("${{CONAN_LIBS_FRAMEWORKS_{uname}_RELWITHDEBINFO}}" "${{CONAN_LIB_DIRS_{uname}_RELWITHDEBINFO}}"
CONAN_PACKAGE_TARGETS_{uname}_RELWITHDEBINFO "${{CONAN_SYSTEM_LIBS_{uname}_RELWITHDEBINFO}} {deps}"
"relwithdebinfo" {pkg_name})
conan_package_library_targets("${{CONAN_PKG_LIBS_{uname}_MINSIZEREL}}" "${{CONAN_LIB_DIRS_{uname}_MINSIZEREL}}"
conan_package_library_targets("${{CONAN_LIBS_FRAMEWORKS_{uname}_MINSIZEREL}}" "${{CONAN_LIB_DIRS_{uname}_MINSIZEREL}}"
CONAN_PACKAGE_TARGETS_{uname}_MINSIZEREL "${{CONAN_SYSTEM_LIBS_{uname}_MINSIZEREL}} {deps}"
"minsizerel" {pkg_name})

Expand Down Expand Up @@ -577,6 +596,38 @@ def generate_targets_section(dependencies):
endmacro()
"""

apple_frameworks_macro = """
macro(conan_find_apple_frameworks FRAMEWORKS_FOUND FRAMEWORKS)
if(APPLE)
if(CMAKE_BUILD_TYPE)
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CONAN_FRAMEWORKS ${CONAN_FRAMEWORKS_DEBUG} ${CONAN_FRAMEWORKS})
set(CONAN_FRAMEWORK_DIRS ${CONAN_FRAMEWORK_DIRS_DEBUG} ${CONAN_FRAMEWORK_DIRS})
elseif(${CMAKE_BUILD_TYPE} MATCHES "Release")
set(CONAN_FRAMEWORKS ${CONAN_FRAMEWORKS_RELEASE} ${CONAN_BUILD_MODULES_PATHS})
set(CONAN_FRAMEWORK_DIRS ${CONAN_FRAMEWORK_DIRS_RELEASE} ${CONAN_FRAMEWORK_DIRS})
elseif(${CMAKE_BUILD_TYPE} MATCHES "RelWithDebInfo")
set(CONAN_FRAMEWORKS ${CONAN_FRAMEWORKS_RELWITHDEBINFO} ${CONAN_BUILD_MODULES_PATHS})
set(CONAN_FRAMEWORK_DIRS ${CONAN_FRAMEWORK_DIRS_RELWITHDEBINFO} ${CONAN_FRAMEWORK_DIRS})
elseif(${CMAKE_BUILD_TYPE} MATCHES "MinSizeRel")
set(CONAN_FRAMEWORKS ${CONAN_FRAMEWORKS_MINSIZEREL} ${CONAN_BUILD_MODULES_PATHS})
set(CONAN_FRAMEWORK_DIRS ${CONAN_FRAMEWORK_DIRS_MINSIZEREL} ${CONAN_FRAMEWORK_DIRS})
endif()
endif()

foreach(_FRAMEWORK ${FRAMEWORKS})
# https://cmake.org/pipermail/cmake-developers/2017-August/030199.html
find_library(CONAN_FRAMEWORK_FOUND NAME ${_FRAMEWORK} PATHS ${CONAN_FRAMEWORK_DIRS})
if(CONAN_FRAMEWORK_FOUND)
list(APPEND ${FRAMEWORKS_FOUND} ${CONAN_FRAMEWORK_FOUND})
else()
message(FATAL_ERROR "Framework library ${_FRAMEWORK} not found in paths: ${CONAN_FRAMEWORK_DIRS}")
endif()
endforeach()
endif()
endmacro()
"""


def _conan_basic_setup_common(addtional_macros, cmake_multi=False):
output_dirs_section = """
Expand Down
26 changes: 25 additions & 1 deletion conans/client/generators/cmake_find_package_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,23 @@
set({name}_LIBRARIES{build_type_suffix} "") # Will be filled later
set({name}_LIBS{build_type_suffix} "") # Same as {name}_LIBRARIES
set({name}_SYSTEM_LIBS{build_type_suffix} {deps.system_libs})
set({name}_FRAMEWORK_DIRS{build_type_suffix} {deps.framework_paths})
set({name}_FRAMEWORKS{build_type_suffix} {deps.frameworks})
set({name}_FRAMEWORKS_FOUND{build_type_suffix} "") # Will be filled later
set({name}_BUILD_MODULES_PATHS{build_type_suffix} {deps.build_modules_paths})

{deps.find_frameworks}
# Apple frameworks
if(APPLE)
foreach(_FRAMEWORK ${{{name}_FRAMEWORKS{build_type_suffix}}})
# https://cmake.org/pipermail/cmake-developers/2017-August/030199.html
find_library(CONAN_FRAMEWORK_FOUND NAME ${{_FRAMEWORK}} PATHS ${{{name}_FRAMEWORK_DIRS{build_type_suffix}}})
if(CONAN_FRAMEWORK_FOUND)
list(APPEND {name}_FRAMEWORKS_FOUND{build_type_suffix} ${{CONAN_FRAMEWORK_FOUND}})
else()
message(FATAL_ERROR "Framework library ${{_FRAMEWORK}} not found in paths: ${{{name}_FRAMEWORK_DIRS{build_type_suffix}}}")
endif()
endforeach()
endif()

mark_as_advanced({name}_INCLUDE_DIRS{build_type_suffix}
{name}_INCLUDES{build_type_suffix}
Expand Down Expand Up @@ -53,6 +67,16 @@
endforeach()
set({name}_LIBS{build_type_suffix} ${{{name}_LIBRARIES{build_type_suffix}}})

foreach(_FRAMEWORK ${{{name}_FRAMEWORKS_FOUND{build_type_suffix}}})
list(APPEND {name}_LIBRARIES_TARGETS{build_type_suffix} ${{_FRAMEWORK}})
list(APPEND {name}_LIBRARIES{build_type_suffix} ${{_FRAMEWORK}})
endforeach()

foreach(_SYSTEM_LIB ${{{name}_SYSTEM_LIB{build_type_suffix}}})
list(APPEND {name}_LIBRARIES_TARGETS{build_type_suffix} ${{_SYSTEM_LIB}})
list(APPEND {name}_LIBRARIES{build_type_suffix} ${{_SYSTEM_LIB}})
endforeach()

set(CMAKE_MODULE_PATH {deps.build_paths} ${{CMAKE_MODULE_PATH}})
set(CMAKE_PREFIX_PATH {deps.build_paths} ${{CMAKE_PREFIX_PATH}})

Expand Down
3 changes: 2 additions & 1 deletion conans/client/generators/cmake_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from conans.client.generators.cmake_common import (cmake_dependencies, cmake_dependency_vars,
cmake_global_vars, cmake_macros_multi,
cmake_package_info, cmake_user_info_vars,
generate_targets_section)
generate_targets_section, apple_frameworks_macro)
from conans.model import Generator
from conans.model.build_info import CppInfo

Expand Down Expand Up @@ -73,6 +73,7 @@ def _content_type(self, build_type):
@property
def _content_multi(self):
sections = ["include(CMakeParseArguments)"]
sections.append(apple_frameworks_macro)

# USER DECLARED VARS
sections.append("\n### Definition of user declared vars (user_info) ###\n")
Expand Down
27 changes: 19 additions & 8 deletions conans/test/functional/generators/cmake_find_package_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import os
import platform
import textwrap

import six
import textwrap
import unittest

import six
from nose.plugins.attrib import attr

from conans.client.tools import replace_in_file
Expand Down Expand Up @@ -292,19 +290,32 @@ def build(self):
project(consumer)
cmake_minimum_required(VERSION 3.1)
find_package(Test)
message("Libraries to Link: ${Test_LIBS}")
message("Libraries to link: ${Test_LIBS}")
message("Version: ${Test_VERSION}")
message("Frameworks: ${Test_FRAMEWORKS}")
message("Frameworks found: ${Test_FRAMEWORKS_FOUND}")

get_target_property(tmp Test::Test INTERFACE_LINK_LIBRARIES)
message("Target libs: ${tmp}")
"""
client.save({"conanfile.py": conanfile, "CMakeLists.txt": cmakelists})
client.run("create . user/channel --build missing")
six.assertRegex(self, str(client.out), "-- Library .*Foundation\\.framework not "
"found in package, might be system one")
six.assertRegex(self, str(client.out), "Libraries to Link: .*Foundation\\.framework")
six.assertRegex(self, str(client.out), "Target libs: .*Foundation\\.framework")
self.assertIn("Libraries to link:", client.out)
self.assertIn('Found Test: 0.1 (found version "0.1")', client.out)
self.assertIn("Version: 0.1", client.out)
self.assertIn("Frameworks: Foundation", client.out)
six.assertRegex(self, str(client.out),
r"Frameworks found: [^\s]*/System/Library/Frameworks/Foundation.framework")
six.assertRegex(self, str(client.out),
r"Target libs: [^\s]*/System/Library/Frameworks/Foundation.framework;;")

self.assertNotIn("Foundation.framework not found in package, might be system one",
client.out)
if six.PY2:
self.assertNotRegexpMatches(str(client.out),
r"Libraries to link: .*Foundation\.framework")
else:
self.assertNotRegex(str(client.out), r"Libraries to link: .*Foundation\.framework")

def build_modules_test(self):
conanfile = textwrap.dedent("""
Expand Down
21 changes: 15 additions & 6 deletions conans/test/functional/generators/cmake_multi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,27 @@ class Consumer(ConanFile):
client.run("create conanfile_mylib.py mylib/1.0@us/ch")
client.run("install conanfile_consumer.py -s build_type=Release")
content = client.load("conanbuildinfo_release.cmake")
self.assertIn("set(CONAN_LIBS_RELEASE lib1 lib1release sys1 ${CONAN_LIBS_RELEASE})", content)
self.assertIn("set(CONAN_LIBS_MYLIB_RELEASE lib1 lib1release sys1)", content)
self.assertIn("set(CONAN_LIBS_RELEASE ${CONAN_PKG_LIBS_RELEASE} ${CONAN_SYSTEM_LIBS_RELEASE}"
" ${CONAN_FRAMEWORKS_FOUND_RELEASE})", content)
self.assertIn("set(CONAN_PKG_LIBS_RELEASE lib1 lib1release ${CONAN_PKG_LIBS_RELEASE})",
content)
self.assertIn("set(CONAN_LIBS_MYLIB_RELEASE ${CONAN_PKG_LIBS_MYLIB_RELEASE} "
"${CONAN_SYSTEM_LIBS_MYLIB_RELEASE} ${CONAN_FRAMEWORKS_FOUND_MYLIB_RELEASE})",
content)
self.assertIn("set(CONAN_PKG_LIBS_MYLIB_RELEASE lib1 lib1release)", content)
self.assertIn("set(CONAN_SYSTEM_LIBS_RELEASE sys1 ${CONAN_SYSTEM_LIBS_RELEASE})", content)
self.assertIn("set(CONAN_SYSTEM_LIBS_RELEASE sys1)", content)
self.assertIn("set(CONAN_SYSTEM_LIBS_MYLIB_RELEASE sys1)", content)

client.run("install conanfile_consumer.py -s build_type=Debug")
content = client.load("conanbuildinfo_debug.cmake")
self.assertIn("set(CONAN_LIBS_DEBUG lib1 lib1debug sys1d ${CONAN_LIBS_DEBUG})", content)
self.assertIn("set(CONAN_LIBS_MYLIB_DEBUG lib1 lib1debug sys1d)", content)
self.assertIn("set(CONAN_LIBS_DEBUG ${CONAN_PKG_LIBS_DEBUG} ${CONAN_SYSTEM_LIBS_DEBUG} "
"${CONAN_FRAMEWORKS_FOUND_DEBUG})", content)
self.assertIn("set(CONAN_LIBS_MYLIB_DEBUG ${CONAN_PKG_LIBS_MYLIB_DEBUG} "
"${CONAN_SYSTEM_LIBS_MYLIB_DEBUG} ${CONAN_FRAMEWORKS_FOUND_MYLIB_DEBUG})",
content)
self.assertIn("set(CONAN_PKG_LIBS_DEBUG lib1 lib1debug ${CONAN_PKG_LIBS_DEBUG})", content)
self.assertIn("set(CONAN_PKG_LIBS_MYLIB_DEBUG lib1 lib1debug)", content)
self.assertIn("set(CONAN_SYSTEM_LIBS_DEBUG sys1d ${CONAN_SYSTEM_LIBS_DEBUG})", content)
self.assertIn("set(CONAN_SYSTEM_LIBS_DEBUG sys1d)", content)
self.assertIn("set(CONAN_SYSTEM_LIBS_MYLIB_DEBUG sys1d)", content)


Expand Down
9 changes: 5 additions & 4 deletions conans/test/functional/generators/cmake_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,18 @@ class Consumer(ConanFile):
client.run("install conanfile_consumer.py")

content = client.load("conanbuildinfo.cmake")
self.assertIn("set(CONAN_LIBS lib1 sys1 ${CONAN_LIBS})", content)
self.assertIn("set(CONAN_LIBS_MYLIB lib1 sys1)", content)
self.assertIn("set(CONAN_LIBS ${CONAN_PKG_LIBS} ${CONAN_SYSTEM_LIBS} ${CONAN_FRAMEWORKS_FOUND})",
content)
self.assertIn("set(CONAN_LIBS_MYLIB ${CONAN_PKG_LIBS_MYLIB} ${CONAN_SYSTEM_LIBS_MYLIB} ${CONAN_FRAMEWORKS_FOUND_MYLIB})",
content)
self.assertIn("set(CONAN_PKG_LIBS_MYLIB lib1)", content)
self.assertIn("set(CONAN_SYSTEM_LIBS sys1 ${CONAN_SYSTEM_LIBS})", content)
self.assertIn("set(CONAN_SYSTEM_LIBS sys1)", content)
self.assertIn("set(CONAN_SYSTEM_LIBS_MYLIB sys1)", content)

# Check target has libraries and system deps available
client.run_command("cmake .")
self.assertIn("Target libs: CONAN_LIB::mylib_lib1;", client.out)
self.assertIn("CONAN_LIB::mylib_lib1 system libs: sys1", client.out)
print(client.out)

def targets_system_libs_test(self):
mylib = GenConanfile().with_package_info(cpp_info={"libs": ["lib1", "lib11"],
Expand Down
14 changes: 6 additions & 8 deletions conans/test/unittests/client/generators/cmake_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,12 @@ def apple_frameworks_test(self):

generator = CMakeGenerator(conanfile)
content = generator.content
self.assertIn('find_library(CONAN_FRAMEWORK_OPENGL OpenGL PATHS '
'"path/to/Frameworks1"\n\t\t\t"path/to/Frameworks2")', content)
self.assertIn('find_library(CONAN_FRAMEWORK_OPENCL OpenCL PATHS '
'"path/to/Frameworks1"\n\t\t\t"path/to/Frameworks2")', content)
self.assertIn('set(CONAN_LIBS_MYPKG ${CONAN_FRAMEWORK_OPENGL} ${CONAN_FRAMEWORK_OPENCL})',
content) #FIXME: Add a CONAN_FRAMEWORKS_MYPKG
self.assertIn('set(CONAN_LIBS ${CONAN_FRAMEWORK_OPENGL} '
'${CONAN_FRAMEWORK_OPENCL} ${CONAN_LIBS})', content)
self.assertIn('find_library(CONAN_FRAMEWORK_FOUND NAME ${_FRAMEWORK} PATHS '
'${CONAN_FRAMEWORK_DIRS})', content)
self.assertIn('set(CONAN_FRAMEWORK_DIRS "path/to/Frameworks1"\n\t\t\t"path/to/Frameworks2" '
'${CONAN_FRAMEWORK_DIRS})', content)
self.assertIn('set(CONAN_LIBS ${CONAN_PKG_LIBS} ${CONAN_SYSTEM_LIBS} '
'${CONAN_FRAMEWORKS_FOUND})', content)


class CMakeCppInfoNameTest(unittest.TestCase):
Expand Down