From 7e230140d5e1a81e2f9e99f8f071c7712bc945df Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 9 Jul 2024 16:14:21 +0300 Subject: [PATCH] openmp: apply improvements to test_package from llvm-openmp --- recipes/openmp/all/test_package/CMakeLists.txt | 16 +++++++++------- recipes/openmp/all/test_package/conanfile.py | 11 +++++++++++ recipes/openmp/all/test_package/test_package.c | 2 +- recipes/openmp/all/test_package/test_package.cpp | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/recipes/openmp/all/test_package/CMakeLists.txt b/recipes/openmp/all/test_package/CMakeLists.txt index b7b9e47fa98a22..4ec635c0c531de 100644 --- a/recipes/openmp/all/test_package/CMakeLists.txt +++ b/recipes/openmp/all/test_package/CMakeLists.txt @@ -1,20 +1,22 @@ cmake_minimum_required(VERSION 3.15) project(PackageTest CXX C) -find_package(OpenMP MODULE REQUIRED) +find_package(OpenMP REQUIRED) message("OpenMP_FOUND: ${OpenMP_CXX_FOUND}") +message("OpenMP_VERSION: ${OpenMP_VERSION}") +message("OpenMP_C_FOUND: ${OpenMP_CXX_FOUND}") message("OpenMP_CXX_FOUND: ${OpenMP_CXX_FOUND}") message("OpenMP_CXX_VERSION: ${OpenMP_CXX_VERSION}") message("OpenMP_CXX_SPEC_DATE: ${OpenMP_CXX_SPEC_DATE}") message("OpenMP_CXX_INCLUDE_DIRS: ${OpenMP_CXX_INCLUDE_DIRS}") -message("OpenMP_INCLUDE_DIRS: ${OpenMP_CXX_INCLUDE_DIRS}") +message("OpenMP_CXX_LIB_NAMES: ${OpenMP_CXX_LIB_NAMES}") +message("OpenMP_CXX_LIBRARIES: ${OpenMP_CXX_LIBRARIES}") +message("OpenMP_CXX_FLAGS: ${OpenMP_CXX_FLAGS}") +message("OpenMP_omp_LIBRARY: ${OpenMP_omp_LIBRARY}") -if(NOT DEFINED OpenMP_C_INCLUDE_DIRS) - message(FATAL_ERROR "OpenMP_C_INCLUDE_DIRS is not defined") -endif() -if(NOT DEFINED OpenMP_CXX_INCLUDE_DIRS) - message(FATAL_ERROR "OpenMP_CXX_INCLUDE_DIRS is not defined") +if(NOT DEFINED OpenMP_CXX_SPEC_DATE) + message(FATAL_ERROR "FindOpenMP.cmake did not set all variables correctly.") endif() add_executable(test_package_cxx test_package.cpp) diff --git a/recipes/openmp/all/test_package/conanfile.py b/recipes/openmp/all/test_package/conanfile.py index b9c17185d658e4..6dfdd10386483f 100644 --- a/recipes/openmp/all/test_package/conanfile.py +++ b/recipes/openmp/all/test_package/conanfile.py @@ -1,6 +1,7 @@ from conan import ConanFile from conan.tools.build import can_run from conan.tools.cmake import cmake_layout, CMake +from conan.tools.env import Environment import os @@ -15,6 +16,16 @@ def requirements(self): def layout(self): cmake_layout(self) + def generate(self): + env = Environment() + # Trigger printing of runtime version info on startup. + # Should state "LLVM OMP" as the runtime library ID if everything is configured correctly. + env.define("KMP_VERSION", "TRUE") + # Display general OpenMP parameters in a standardized format. + # https://www.openmp.org/spec-html/5.0/openmpse60.html + env.define("OMP_DISPLAY_ENV", "TRUE") + env.vars(self, scope="run").save_script("conan_openmp_version") + def build(self): cmake = CMake(self) cmake.configure() diff --git a/recipes/openmp/all/test_package/test_package.c b/recipes/openmp/all/test_package/test_package.c index bfe815ccece150..68ce5b735cb442 100644 --- a/recipes/openmp/all/test_package/test_package.c +++ b/recipes/openmp/all/test_package/test_package.c @@ -21,6 +21,6 @@ int main() printf("There are probably missing compiler flags.\n"); return 1; } - printf("OpenMP year-month version: %d", _OPENMP); + printf("OpenMP API version supported by the compiler: %d\n", _OPENMP); return 0; } diff --git a/recipes/openmp/all/test_package/test_package.cpp b/recipes/openmp/all/test_package/test_package.cpp index 73084444023cc8..f6af1cdfb670ca 100644 --- a/recipes/openmp/all/test_package/test_package.cpp +++ b/recipes/openmp/all/test_package/test_package.cpp @@ -19,6 +19,6 @@ int main() std::cout << "There are probably missing compiler flags.\n"; return 1; } - std::cout << "OpenMP year-month version: " << _OPENMP << "\n"; + std::cout << "OpenMP API version supported by the compiler: " << _OPENMP << "\n"; return 0; }