Skip to content

Commit

Permalink
openmp: apply improvements to test_package from llvm-openmp
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Jul 9, 2024
1 parent a48e322 commit 7e23014
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
16 changes: 9 additions & 7 deletions recipes/openmp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
11 changes: 11 additions & 0 deletions recipes/openmp/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion recipes/openmp/all/test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion recipes/openmp/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 7e23014

Please sign in to comment.