Skip to content

Commit

Permalink
qmake: fix sharedlinkFlags and exelinkflags (#9568)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericLemanissier committed Sep 10, 2021
1 parent ca969ba commit da49f32
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
13 changes: 8 additions & 5 deletions conans/client/generators/qmake.py
Expand Up @@ -52,8 +52,8 @@ def content(self):
'CONAN_DEFINES{dep_name}{build_type} += {deps.defines}\n'
'CONAN_QMAKE_CXXFLAGS{dep_name}{build_type} += {deps.cxxflags}\n'
'CONAN_QMAKE_CFLAGS{dep_name}{build_type} += {deps.cflags}\n'
'CONAN_QMAKE_LFLAGS{dep_name}{build_type} += {deps.sharedlinkflags}\n'
'CONAN_QMAKE_LFLAGS{dep_name}{build_type} += {deps.exelinkflags}\n')
'CONAN_QMAKE_LFLAGS_SHLIB{dep_name}{build_type} += {deps.sharedlinkflags}\n'
'CONAN_QMAKE_LFLAGS_APP{dep_name}{build_type} += {deps.exelinkflags}\n')
sections = []
template_all = template
all_flags = template_all.format(dep_name="", deps=deps, build_type="")
Expand Down Expand Up @@ -116,13 +116,16 @@ def content(self):
}
QMAKE_CXXFLAGS += $$CONAN_QMAKE_CXXFLAGS
QMAKE_CFLAGS += $$CONAN_QMAKE_CFLAGS
QMAKE_LFLAGS += $$CONAN_QMAKE_LFLAGS
QMAKE_LFLAGS_SHLIB += $$CONAN_QMAKE_LFLAGS_SHLIB
QMAKE_LFLAGS_APP += $$CONAN_QMAKE_LFLAGS_APP
QMAKE_CXXFLAGS_DEBUG += $$CONAN_QMAKE_CXXFLAGS_DEBUG
QMAKE_CFLAGS_DEBUG += $$CONAN_QMAKE_CFLAGS_DEBUG
QMAKE_LFLAGS_DEBUG += $$CONAN_QMAKE_LFLAGS_DEBUG
QMAKE_LFLAGS_SHLIB_DEBUG += $$CONAN_QMAKE_LFLAGS_SHLIB_DEBUG
QMAKE_LFLAGS_APP_DEBUG += $$CONAN_QMAKE_LFLAGS_APP_DEBUG
QMAKE_CXXFLAGS_RELEASE += $$CONAN_QMAKE_CXXFLAGS_RELEASE
QMAKE_CFLAGS_RELEASE += $$CONAN_QMAKE_CFLAGS_RELEASE
QMAKE_LFLAGS_RELEASE += $$CONAN_QMAKE_LFLAGS_RELEASE
QMAKE_LFLAGS_SHLIB_RELEASE += $$CONAN_QMAKE_LFLAGS_SHLIB_RELEASE
QMAKE_LFLAGS_APP_RELEASE += $$CONAN_QMAKE_LFLAGS_APP_RELEASE
}""")

return output
25 changes: 25 additions & 0 deletions conans/test/unittests/client/generators/qmake_test.py
Expand Up @@ -39,3 +39,28 @@ def test_frameworks(self):
qmake_lines = content.splitlines()
self.assertIn('CONAN_FRAMEWORKS += -framework HelloFramework', qmake_lines)
self.assertIn('CONAN_FRAMEWORK_PATHS += -F%s' % framework_path, qmake_lines)

def test_sharedlinkflags(self):
conanfile = ConanFile(Mock(), None)
conanfile.initialize(Settings({}), EnvValues())
framework_path = os.getcwd() # must exist, otherwise filtered by framework_paths
cpp_info = CppInfo("MyPkg", "/rootpath")
cpp_info.sharedlinkflags = ["-llibrary_for_shared"]
conanfile.deps_cpp_info.add("MyPkg", DepCppInfo(cpp_info))
generator = QmakeGenerator(conanfile)
content = generator.content
qmake_lines = content.splitlines()
self.assertIn('CONAN_QMAKE_LFLAGS_SHLIB += -llibrary_for_shared', qmake_lines)

def test_exelinkflags(self):
conanfile = ConanFile(Mock(), None)
conanfile.initialize(Settings({}), EnvValues())
framework_path = os.getcwd() # must exist, otherwise filtered by framework_paths
cpp_info = CppInfo("MyPkg", "/rootpath")
cpp_info.exelinkflags = ["-llibrary_for_exe"]
conanfile.deps_cpp_info.add("MyPkg", DepCppInfo(cpp_info))
generator = QmakeGenerator(conanfile)
content = generator.content
qmake_lines = content.splitlines()
self.assertIn('CONAN_QMAKE_LFLAGS_APP += -llibrary_for_exe', qmake_lines)

0 comments on commit da49f32

Please sign in to comment.