From c600d853f63d3bd5fafb8141eb9d0c4619fda81c Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 17 Jul 2024 11:35:28 +0300 Subject: [PATCH] openmp: extend the list of supported compilers --- recipes/openmp/all/conanfile.py | 50 +++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/recipes/openmp/all/conanfile.py b/recipes/openmp/all/conanfile.py index 6228b222aebae3..da9a58b92fecee 100644 --- a/recipes/openmp/all/conanfile.py +++ b/recipes/openmp/all/conanfile.py @@ -1,6 +1,7 @@ from conan import ConanFile from conan.errors import ConanInvalidConfiguration from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version required_conan_version = ">=1.52.0" @@ -39,7 +40,7 @@ def package_id(self): self.info.clear() def validate(self): - if self.options.provider == "native" and self._openmp_flags() is None: + if self.options.provider == "native" and self._openmp_flags is None: raise ConanInvalidConfiguration( f"{self.settings.compiler} is not supported by this recipe. Contributions are welcome!" ) @@ -52,20 +53,53 @@ def validate(self): "Make sure you avoid accidental linking against the native implementation through external libraries." ) + @property def _openmp_flags(self): - # Based on https://github.com/Kitware/CMake/blob/v3.28.1/Modules/FindOpenMP.cmake#L104-L135 - if self.settings.compiler == "clang": + # Based on https://github.com/Kitware/CMake/blob/v3.30.0/Modules/FindOpenMP.cmake#L119-L154 + if self.settings.compiler == "gcc": + return ["-fopenmp"] + elif self.settings.compiler == "clang": return ["-fopenmp=libomp"] elif self.settings.compiler == "apple-clang": return ["-Xclang", "-fopenmp"] - elif self.settings.compiler == "gcc": - return ["-fopenmp"] + elif is_msvc(self): + return ["-openmp"] elif self.settings.compiler == "intel-cc": - return ["-Qopenmp"] + if self.settings.os == "Windows": + return ["-Qopenmp"] + else: + return ["-qopenmp"] elif self.settings.compiler == "sun-cc": return ["-xopenmp"] - elif is_msvc(self): + + # The following compilers are not currently covered by settings.yml, + # but are included for completeness. + elif self.settings.compiler == "hp": + return ["+Oopenmp"] + elif self.settings.compiler == "intel-llvm": + if self.settings.get_safe("compiler.frontend") == "msvc": + return ["-Qiopenmp"] + else: + return ["-fiopenmp"] + elif self.settings.compiler == "pathscale": + return ["-openmp"] + elif self.settings.compiler == "nag": + return ["-openmp"] + elif self.settings.compiler == "absoft": return ["-openmp"] + elif self.settings.compiler == "nvhpc": + return ["-mp"] + elif self.settings.compiler == "pgi": + return ["-mp"] + elif self.settings.compiler == "xl": + return ["-qsmp=omp"] + elif self.settings.compiler == "cray": + return ["-h", "omp"] + elif self.settings.compiler == "fujitsu": + return ["-Kopenmp"] + elif self.settings.compiler == "fujitsu-clang": + return ["-fopenmp"] + return None def package_info(self): @@ -79,7 +113,7 @@ def package_info(self): if self.options.provider == "native": # Rely on CMake's FindOpenMP.cmake and an OpenMP implementation provided by the compiler. # Export appropriate flags for the transitive use case. - openmp_flags = self._openmp_flags() + openmp_flags = self._openmp_flags self.cpp_info.sharedlinkflags = openmp_flags self.cpp_info.exelinkflags = openmp_flags self.cpp_info.cflags = openmp_flags