Repository: conan-io/conan

Issue:
conan qmake generator uses invalid characters in variable names
conan version: 1.6.1

Conan allows package names to contain hyphens.  If you do have a hyphen in your package name, then so will all the related variables in conanbuildinfo.pri, as generated by the qmake generator.  Hyphens are not valid in qmake variable names.  I suggest that the generator should change hyphens to underscores. 


Discussion:
Yes, totally makes sense, thanks for reporting it.

Resolving patch:
diff --git a/conans/client/generators/qmake.py b/conans/client/generators/qmake.py
--- a/conans/client/generators/qmake.py
+++ b/conans/client/generators/qmake.py
@@ -59,14 +59,15 @@ def content(self):
         template_deps = template + 'CONAN{dep_name}_ROOT{build_type} = "{deps.rootpath}"\n'
 
         for dep_name, dep_cpp_info in self.deps_build_info.dependencies:
+            dep_name = "_" + dep_name.upper().replace("-", "_").replace(".", "_")
             deps = DepsCppQmake(dep_cpp_info)
-            dep_flags = template_deps.format(dep_name="_" + dep_name.upper(), deps=deps,
+            dep_flags = template_deps.format(dep_name=dep_name, deps=deps,
                                              build_type="")
             sections.append(dep_flags)
 
             for config, cpp_info in dep_cpp_info.configs.items():
                 deps = DepsCppQmake(cpp_info)
-                dep_flags = template_deps.format(dep_name="_" + dep_name.upper(), deps=deps,
+                dep_flags = template_deps.format(dep_name=dep_name, deps=deps,
                                                  build_type="_" + str(config).upper())
                 sections.append(dep_flags)
 


Test patch:
diff --git a/conans/test/generators/generators_test.py b/conans/test/generators/generators_test.py
--- a/conans/test/generators/generators_test.py
+++ b/conans/test/generators/generators_test.py
@@ -85,3 +85,40 @@ def package_info(self):
         self.assertIn("CONAN_LIBS_RELEASE += -lhellor", qmake)
         self.assertIn("CONAN_LIBS_DEBUG += -lhellod", qmake)
         self.assertIn("CONAN_LIBS += -lhello", qmake)
+
+    def test_qmake_hyphen_dot(self):
+        client = TestClient()
+        dep = """
+from conans import ConanFile
+
+class TestConan(ConanFile):
+    name = "Pkg-Name.World"
+    version = "0.1"
+
+    def package_info(self):
+        self.cpp_info.libs = ["hello"]
+        self.cpp_info.debug.includedirs = []
+        self.cpp_info.debug.libs = ["hellod"]
+        self.cpp_info.release.libs = ["hellor"]
+
+"""
+        base = '''
+[requires]
+Pkg-Name.World/0.1@lasote/testing
+[generators]
+qmake
+    '''
+        client.save({"conanfile.py": dep})
+        client.run("export . lasote/testing")
+        client.save({"conanfile.txt": base}, clean_first=True)
+        client.run("install . --build")
+
+        qmake = load(os.path.join(client.current_folder, "conanbuildinfo.pri"))
+        self.assertIn("CONAN_RESDIRS += ", qmake)
+        self.assertEqual(qmake.count("CONAN_LIBS += "), 1)
+        self.assertIn("CONAN_LIBS_PKG_NAME_WORLD_RELEASE += -lhellor", qmake)
+        self.assertIn("CONAN_LIBS_PKG_NAME_WORLD_DEBUG += -lhellod", qmake)
+        self.assertIn("CONAN_LIBS_PKG_NAME_WORLD += -lhello", qmake)
+        self.assertIn("CONAN_LIBS_RELEASE += -lhellor", qmake)
+        self.assertIn("CONAN_LIBS_DEBUG += -lhellod", qmake)
+        self.assertIn("CONAN_LIBS += -lhello", qmake)