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

qmake: fix sharedlinkFlags and exelinkflags #9568

Merged
merged 1 commit into from Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)