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

llvm-openmp: match FindOpenMP.cmake output, add MSVC support #22353

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
805f2eb
llvm-openmp: fix missing FindOpenMP.cmake, check _OPENMP define
valgur Jan 15, 2024
def0ca9
llvm-openmp: improve exported compiler flags
valgur Jan 15, 2024
29b48ab
llvm-openmp: print runtime library info in test_package
valgur Jan 16, 2024
bb43094
llvm-openmp: match the output of FindOpenMP.cmake
valgur Jan 16, 2024
1aeeac8
llvm-openmp: add MSVC support
valgur Jan 17, 2024
8991aff
llvm-openmp: mention potential cause of the armv8 Debug issues
valgur Jan 18, 2024
6d2f002
llvm-openmp: add a comment
valgur Jan 18, 2024
86d958d
llvm-openmp: move omp to a separate component
valgur Jan 18, 2024
cdf5b09
llvm-openmp: add Conan v1 support
valgur Jan 18, 2024
bc47eb3
llvm-openmp: drop v10 and lower
valgur Jan 18, 2024
3634104
llvm-openmp: patches can be dropped
valgur Jan 18, 2024
ca4f713
llvm-openmp: libomptarget is not available on macOS and Windows
valgur Jan 18, 2024
85bb473
llvm-openmp: fix CMake 3.15 incompatibility
valgur Jan 18, 2024
ad7d7a0
llvm-openmp: .get_safe("build_libomptarget")
valgur Jan 18, 2024
6e8f491
llvm-openmp: don't use a target for linking in the module
valgur Jan 18, 2024
6982851
llvm-openmp: restore the v11 macOS armv8 patch
valgur Jan 18, 2024
06dc906
llvm-openmp: add psapi system lib dep on Windows
valgur Jan 18, 2024
934ad57
llvm-openmp: OpenMP version and spec date version can be determined d…
valgur Apr 1, 2024
635637e
llvm-openmp: re-wrap description
valgur Apr 1, 2024
905b5d7
llvm-openmp: add v18.1.3
valgur Apr 15, 2024
60ef5cf
llvm-openmp: print even more details in test_package
valgur Apr 16, 2024
cdb2c98
llvm-openmp: set OpenMP version to the minimum of compiler and runtim…
valgur Apr 16, 2024
879a9c7
llvm-openmp: add all spec date versions
valgur Apr 16, 2024
5cff80c
llvm-openmp: set shared=True by default on Windows
valgur Apr 21, 2024
38ec37d
llvm-openmp: force shared=True on Windows
valgur Apr 21, 2024
ec44120
llvm-openmp: fix try_compile() on CXX-only projects
valgur Apr 28, 2024
5aadb33
llvm-openmp: bump to v18.1.6
valgur May 25, 2024
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
148 changes: 148 additions & 0 deletions recipes/llvm-openmp/all/cmake/conan-llvm-openmp-vars.cmake.in
@@ -0,0 +1,148 @@
# Reproduces the output of https://github.com/Kitware/CMake/blob/v3.28.1/Modules/FindOpenMP.cmake

# For Conan v1 compatibility
foreach(_suffix RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
if(DEFINED OpenMP_OpenMP_INCLUDE_DIRS_${_suffix})
set(_v1_suffix _${_suffix})
endif()
endforeach()

set(OpenMP_C_FLAGS "@OpenMP_FLAGS@")
set(OpenMP_C_INCLUDE_DIR "${OpenMP_INCLUDE_DIR${_v1_suffix}}")
set(OpenMP_C_INCLUDE_DIRS "${OpenMP_INCLUDE_DIRS${_v1_suffix}}")
set(OpenMP_C_LIB_NAMES "@OpenMP_LIB_NAMES@")
set(OpenMP_C_LIBRARIES "${OpenMP_LIBRARIES${_v1_suffix}}")
set(OpenMP_C_DEFINITIONS "${OpenMP_DEFINITIONS${_v1_suffix}}")

set(OpenMP_CXX_FLAGS "${OpenMP_C_FLAGS}")
set(OpenMP_CXX_INCLUDE_DIR "${OpenMP_C_INCLUDE_DIR}")
set(OpenMP_CXX_INCLUDE_DIRS "${OpenMP_C_INCLUDE_DIRS}")
set(OpenMP_CXX_LIB_NAMES "${OpenMP_C_LIB_NAMES}")
set(OpenMP_CXX_LIBRARIES "${OpenMP_C_LIBRARIES}")
set(OpenMP_CXX_DEFINITIONS "${OpenMP_C_DEFINITIONS}")

set(OpenMP_omp_LIBRARY "${OpenMP_C_LIBRARIES}")

# Determine OpenMP specification date and version supported by the compiler.
function(_openmp_get_compiler_spec_date)
set(BUILD_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP")
set(SRC_FILE "${BUILD_DIR}/ompver.c")
if(NOT CMAKE_C_COMPILER_LOADED)
set(SRC_FILE "${BUILD_DIR}/ompver.cpp")
endif()
set(BIN_FILE "${BUILD_DIR}/ompver.bin")
file(WRITE "${SRC_FILE}" "
#include <stdio.h>
#define STRINGIFY(x) #x
#define TO_STRING(x) STRINGIFY(x)
const char ompver_str[] = \"INFO:OpenMP-date[\" TO_STRING(_OPENMP) \"]\";
int main(void)
{
puts(ompver_str);
return 0;
}
")
try_compile(OpenMP_SPECTEST ${BUILD_DIR}
SOURCES "${SRC_FILE}"
COMPILE_DEFINITIONS "${OpenMP_C_FLAGS}"
COPY_FILE "${BIN_FILE}"
)
if(NOT OpenMP_SPECTEST)
if(OpenMP_FIND_REQUIRED)
message(FATAL_ERROR "Failed to build OpenMP test executable for specification date detection")
elseif(NOT OpenMP_FIND_QUIETLY)
message(SEND_ERROR "Failed to build OpenMP test executable for specification date detection")
endif()
return()
endif()
file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenMP-date")
if(specstr MATCHES ".*INFO:OpenMP-date\\[0*([^]]*)\\].*")
set(OpenMP_SPEC_DATE ${CMAKE_MATCH_1} PARENT_SCOPE)
else()
if(OpenMP_FIND_REQUIRED)
message(FATAL_ERROR "Failed to detect OpenMP specification date")
elseif(NOT OpenMP_FIND_QUIETLY)
message(SEND_ERROR "Failed to detect OpenMP specification date")
endif()
return()
endif()
endfunction()

function(_openmp_set_version_by_spec_date)
set(OpenMP_SPEC_DATE_MAP
"202111=5.2"
"202011=5.1"
"201811=5.0"
"201611=5.0"
"201511=4.5"
"201307=4.0"
"201107=3.1"
"200805=3.0"
"200505=2.5"
"200203=2.0"
"200011=2.0"
"199911=1.1"
"199810=1.0"
"199710=1.0"
)
if(OpenMP_SPEC_DATE_MAP MATCHES "${OpenMP_SPEC_DATE}=([0-9]+)\\.([0-9]+)")
set(major "${CMAKE_MATCH_1}")
set(minor "${CMAKE_MATCH_2}")
else()
if(OpenMP_FIND_REQUIRED)
message(FATAL_ERROR "Failed to detect OpenMP specification version")
elseif(NOT OpenMP_FIND_QUIETLY)
message(SEND_ERROR "Failed to detect OpenMP specification version")
endif()
return()
endif()
set(OpenMP_VERSION_MAJOR "${major}" PARENT_SCOPE)
set(OpenMP_VERSION_MINOR "${minor}" PARENT_SCOPE)
set(OpenMP_VERSION "${major}.${minor}" PARENT_SCOPE)
endfunction()

# Compare the OpenMP API version supported by the compiler to
# the version supported by the LLVM OMP runtime and use the lower of the two.
# Note that this differs from the CMake's FindOpenMP.cmake implementation,
# which checks only the version supported by the compiler, and appears to be an oversight on CMake's part.
_openmp_get_compiler_spec_date()
if(OpenMP_SPEC_DATE GREATER @OpenMP_SPEC_DATE@)
set(OpenMP_SPEC_DATE @OpenMP_SPEC_DATE@)
set(OpenMP_VERSION_MAJOR @OpenMP_VERSION_MAJOR@)
set(OpenMP_VERSION_MINOR @OpenMP_VERSION_MINOR@)
set(OpenMP_VERSION @OpenMP_VERSION@)
else()
_openmp_set_version_by_spec_date()
endif()

set(OpenMP_C_FOUND TRUE)
set(OpenMP_C_SPEC_DATE "${OpenMP_SPEC_DATE}")
set(OpenMP_C_VERSION_MAJOR "${OpenMP_VERSION_MAJOR}")
set(OpenMP_C_VERSION_MINOR "${OpenMP_VERSION_MINOR}")
set(OpenMP_C_VERSION "${OpenMP_VERSION}")

set(OpenMP_CXX_FOUND TRUE)
set(OpenMP_CXX_SPEC_DATE "${OpenMP_SPEC_DATE}")
set(OpenMP_CXX_VERSION_MAJOR "${OpenMP_VERSION_MAJOR}")
set(OpenMP_CXX_VERSION_MINOR "${OpenMP_VERSION_MINOR}")
set(OpenMP_CXX_VERSION "${OpenMP_VERSION}")

# Check specification version against the requested min version, validate components
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenMP
VERSION_VAR OpenMP_C_VERSION
REQUIRED_VARS
OpenMP_C_FLAGS
OpenMP_C_LIB_NAMES
OpenMP_C_SPEC_DATE
OpenMP_C_VERSION
OpenMP_CXX_FLAGS
OpenMP_CXX_LIB_NAMES
OpenMP_CXX_SPEC_DATE
OpenMP_CXX_VERSION
HANDLE_COMPONENTS
)

set(OPENMP_FOUND ${OpenMP_FOUND})
set(OpenMP_C_FOUND ${OpenMP_FOUND})
set(OpenMP_CXX_FOUND ${OpenMP_FOUND})
55 changes: 7 additions & 48 deletions recipes/llvm-openmp/all/conandata.yml
@@ -1,4 +1,11 @@
sources:
"18.1.6":
openmp:
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.6/openmp-18.1.6.src.tar.xz"
sha256: "24ffd900fc7b707fda3a2d3b4aa011289d5a5fedff19c348dfdc4351f7063aae"
cmake:
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-18.1.6/cmake-18.1.6.src.tar.xz"
sha256: "a643261ed98ff76ab10f1a7039291fa841c292435ba1cfe11e235c2231b95cdb"
"17.0.6":
openmp:
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.6/openmp-17.0.6.src.tar.xz"
Expand Down Expand Up @@ -39,56 +46,8 @@ sources:
"11.1.0":
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-11.1.0/openmp-11.1.0.src.tar.xz"
sha256: "d187483b75b39acb3ff8ea1b7d98524d95322e3cb148842957e9b0fbb866052e"
"10.0.0":
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/openmp-10.0.0.src.tar.xz"
sha256: "3b9ff29a45d0509a1e9667a0feb43538ef402ea8cfc7df3758a01f20df08adfa"
"9.0.1":
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-9.0.1/openmp-9.0.1.src.tar.xz"
sha256: "5c94060f846f965698574d9ce22975c0e9f04c9b14088c3af5f03870af75cace"
"8.0.1":
url: "https://github.com/llvm/llvm-project/releases/download/llvmorg-8.0.1/openmp-8.0.1.src.tar.xz"
sha256: "3e85dd3cad41117b7c89a41de72f2e6aa756ea7b4ef63bb10dcddf8561a7722c"
patches:
"17.0.4":
- patch_file: "patches/17/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
"16.0.6":
- patch_file: "patches/16/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
"15.0.7":
- patch_file: "patches/15/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
"14.0.6":
- patch_file: "patches/14/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
"13.0.1":
- patch_file: "patches/13/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
"12.0.1":
- patch_file: "patches/12/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
"11.1.0":
- patch_file: "patches/11/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
- patch_file: "patches/11/0002-fix-armv8-build.patch"
patch_description: "Fix build issues on armv8 architecture"
patch_type: "portability"
"10.0.0":
- patch_file: "patches/10/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
"9.0.1":
- patch_file: "patches/8/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"
"8.0.1":
- patch_file: "patches/8/0001-disable-build-testing.patch"
patch_description: "Disable building of tools, gdb-plugin, tests and docs"
patch_type: "conan"