Skip to content

Commit

Permalink
Add support for cpp_info.system_libs to QMake generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ttencate committed Aug 19, 2020
1 parent 3dc4fb3 commit e6ed620
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
8 changes: 8 additions & 0 deletions conans/client/generators/qmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def multiline(field):
self.build_paths = multiline(cpp_info.build_paths)

self.libs = " ".join('-l%s' % lib for lib in cpp_info.libs)
self.system_libs = " ".join('-l%s' % lib for lib in cpp_info.system_libs)
self.defines = " \\\n ".join('"%s"' % d for d in cpp_info.defines)
self.cxxflags = " ".join(cpp_info.cxxflags)
self.cflags = " ".join(cpp_info.cflags)
Expand All @@ -38,6 +39,7 @@ def content(self):

template = ('CONAN_INCLUDEPATH{dep_name}{build_type} += {deps.include_paths}\n'
'CONAN_LIBS{dep_name}{build_type} += {deps.libs}\n'
'CONAN_SYSTEMLIBS{dep_name}{build_type} += {deps.system_libs}\n'
'CONAN_LIBDIRS{dep_name}{build_type} += {deps.lib_paths}\n'
'CONAN_BINDIRS{dep_name}{build_type} += {deps.bin_paths}\n'
'CONAN_RESDIRS{dep_name}{build_type} += {deps.res_paths}\n'
Expand Down Expand Up @@ -92,6 +94,12 @@ def content(self):
BINDIRS += $$CONAN_BINDIRS_DEBUG
DEFINES += $$CONAN_DEFINES_DEBUG
}
LIBS += $$CONAN_SYSTEMLIBS
CONFIG(release, debug|release) {
LIBS += $$CONAN_SYSTEMLIBS_RELEASE
} else {
LIBS += $$CONAN_SYSTEMLIBS_DEBUG
}
QMAKE_CXXFLAGS += $$CONAN_QMAKE_CXXFLAGS
QMAKE_CFLAGS += $$CONAN_QMAKE_CFLAGS
QMAKE_LFLAGS += $$CONAN_QMAKE_LFLAGS
Expand Down
27 changes: 27 additions & 0 deletions conans/test/unittests/client/generators/qmake_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import platform
import unittest

from conans.client.generators.qmake import QmakeGenerator
from conans.model.build_info import CppInfo, DepCppInfo
from conans.model.conan_file import ConanFile
from conans.model.env_info import EnvValues
from conans.model.settings import Settings
from conans.test.utils.mocks import TestBufferConanOutput


class QmakeGeneratorTest(unittest.TestCase):

def system_libs_test(self):
# https://github.com/conan-io/conan/issues/7558
conanfile = ConanFile(TestBufferConanOutput(), None)
conanfile.initialize(Settings({}), EnvValues())
cpp_info = CppInfo("MyPkg", "/rootpath")
cpp_info.libs = ["mypkg"]
cpp_info.system_libs = ["pthread"]
conanfile.deps_cpp_info.add("MyPkg", DepCppInfo(cpp_info))
generator = QmakeGenerator(conanfile)
content = generator.content
qmake_lines = content.splitlines()
self.assertIn('CONAN_LIBS += -lmypkg', qmake_lines)
self.assertIn('CONAN_SYSTEMLIBS += -lpthread', qmake_lines)

0 comments on commit e6ed620

Please sign in to comment.