diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt index e7a26b13a67ff..94152f98d30f6 100644 --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -41,13 +41,26 @@ else() "Path where built OpenMP libraries should be installed.") endif() -if (NOT MSVC) - set(OPENMP_TEST_C_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang) - set(OPENMP_TEST_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang++) -else() - set(OPENMP_TEST_C_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang.exe) - set(OPENMP_TEST_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang++.exe) +set(OPENMP_TEST_C_COMPILER_default "${LLVM_TOOLS_BINARY_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX}") +set(OPENMP_TEST_CXX_COMPILER_default "${LLVM_TOOLS_BINARY_DIR}/clang++${CMAKE_EXECUTABLE_SUFFIX}") +set(OPENMP_TEST_Fortran_COMPILER_default "${LLVM_TOOLS_BINARY_DIR}/flang${CMAKE_EXECUTABLE_SUFFIX}") +if (NOT TARGET "clang") + set(OPENMP_TEST_C_COMPILER_default "${CMAKE_C_COMPILER}") + set(OPENMP_TEST_CXX_COMPILER_default "${CMAKE_CXX_COMPILER}") +endif() +if (NOT TARGET "flang") + if (CMAKE_Fortran_COMPILER) + set(OPENMP_TEST_Fortran_COMPILER_default "${CMAKE_Fortran_COMPILER}") + else() + unset(OPENMP_TEST_Fortran_COMPILER_default) + endif() endif() +set(OPENMP_TEST_C_COMPILER "${OPENMP_TEST_C_COMPILER_default}" CACHE STRING + "C compiler to use for testing OpenMP runtime libraries.") +set(OPENMP_TEST_CXX_COMPILER "${OPENMP_TEST_CXX_COMPILER_default}" CACHE STRING + "C++ compiler to use for testing OpenMP runtime libraries.") +set(OPENMP_TEST_Fortran_COMPILER "${OPENMP_TEST_Fortran_COMPILER_default}" CACHE STRING + "Fortran compiler to use for testing OpenMP runtime libraries.") # Set fortran test compiler if flang is found if (EXISTS "${OPENMP_TEST_Fortran_COMPILER}") @@ -85,14 +98,6 @@ math(EXPR LIBOMP_VERSION_BUILD_MONTH_DAY "${LIBOMP_VERSION_BUILD}%10000") set(LIBOMP_BUILD_DATE "No_Timestamp") -# Check for flang -set(OPENMP_TEST_Fortran_COMPILER_default "") -if (CMAKE_Fortran_COMPILER) - set(OPENMP_TEST_Fortran_COMPILER_default "${CMAKE_Fortran_COMPILER}") -endif () -set(OPENMP_TEST_Fortran_COMPILER "${OPENMP_TEST_Fortran_COMPILER_default}" CACHE STRING - "Fortran compiler to use for testing OpenMP runtime libraries.") - set(LIBOMP_FORTRAN_MODULES FALSE CACHE BOOL "Create Fortran module files? (requires fortran compiler)") diff --git a/openmp/cmake/OpenMPTesting.cmake b/openmp/cmake/OpenMPTesting.cmake index b1ee5bb664e1d..e6eb444c5f90f 100644 --- a/openmp/cmake/OpenMPTesting.cmake +++ b/openmp/cmake/OpenMPTesting.cmake @@ -127,19 +127,23 @@ function(add_openmp_testsuite target comment) set_property(GLOBAL APPEND PROPERTY OPENMP_LIT_DEPENDS ${ARG_DEPENDS}) endif() + set(EXTRA_CHECK_DEPENDS "") + if (TARGET "clang") + list(APPEND EXTRA_CHECK_DEPENDS clang) + endif() if (ARG_EXCLUDE_FROM_CHECK_ALL) add_lit_testsuite(${target} ${comment} ${ARG_UNPARSED_ARGUMENTS} EXCLUDE_FROM_CHECK_ALL - DEPENDS clang FileCheck not ${ARG_DEPENDS} + DEPENDS ${EXTRA_CHECK_DEPENDS} FileCheck not ${ARG_DEPENDS} ARGS ${ARG_ARGS} ) else() add_lit_testsuite(${target} ${comment} ${ARG_UNPARSED_ARGUMENTS} - DEPENDS clang FileCheck not ${ARG_DEPENDS} + DEPENDS ${EXTRA_CHECK_DEPENDS} FileCheck not ${ARG_DEPENDS} ARGS ${ARG_ARGS} ) endif() diff --git a/openmp/docs/Building.md b/openmp/docs/Building.md index c023a6e6717df..460d4f03915f1 100644 --- a/openmp/docs/Building.md +++ b/openmp/docs/Building.md @@ -136,8 +136,8 @@ is expected to have been built from the same Git commit as OpenMP. It will, however, use the compiler detected by CMake, usually gcc. To also make it use Clang, add `-DCMAKE_C_COMPILER=../build/bin/clang -DCMAKE_C_COMPILER=../build/bin/clang++`. -In any case, it will use Clang from `LLVM_BINARY_DIR` for running the regression -tests. `LLVM_BINARY_DIR` can also be omitted in which case testing +Clang/Flang from `LLVM_BINARY_DIR` will be used for testing if available, otherwise `CMAKE_C_COMPILER`/`CMAKE_CXX_COMPILER`/`CMAKE_Fortran_COMPILER`. Tests are also only expected to work with Clang/Flang built from the same Git commit, so `OPENMP_TEST_C_COMPILER`/`OPENMP_TEST_CXX_COMPILER`/`OPENMP_TEST_Fortran_COMPILER` can be used to explicitly set the test compilers. +`LLVM_BINARY_DIR` can also be omitted in which case testing (`ninja check-openmp`) is disabled. The `CMAKE_INSTALL_PREFIX` can be the same, but does not need to. Using the same @@ -269,6 +269,14 @@ tests. : Location, relative to [`CMAKE_INSTALL_PREFIX`][CMAKE_INSTALL_PREFIX], where to install the OpenMP libraries (`.a` and `.so`) +**OPENMP_TEST_C_COMPILER**:STRING (default: Clang built in the same build configuration, or **CMAKE_C_COMPILER**) +: C compiler to use for testing OpenMP runtime libraries. + +**OPENMP_TEST_CXX_COMPILER**:STRING (default: Clang built in the same build configuration, or **CMAKE_CXX_COMPILER**) +: C++ compiler to use for testing OpenMP runtime libraries. + +**OPENMP_TEST_Fortran_COMPILER**:STRING (default: Flang built in the same build configuration, or **CMAKE_Fortran_COMPILER**) +: Fortran compiler to use for testing OpenMP runtime libraries. ### Options for `libomp`