mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 01:06:06 +00:00

Previously, we tried to check whether the -std=c++17 option was supported and manually add the flag. That doesn't work for compilers that do support C++17 but use a different option syntax, like clang-cl. OpenMP itself probably doesn't specifically require C++17, therefore CXX_STANDARD_REQUIRED is left off, but in some cases, we may have code that only works in C++17 mode. In particular, 46262cab24312c71717ca70a9d0700481aa59152 made a refactoring that works when built with Clang in C++17 mode, but not in C++14 mode. MSVC accepts the construct in both language modes. For libomptarget, we've had specific checks that require C++17 (or the -std=c++17 option) to be supported. It's doubtful that libomptarget has got any code which more specifically requires C++17; this seems to be a remnant from when libomptarget was added originally in 2467df6e4f04e3d0e8e78d662473ba1b87c0a885 / D14031. At that point, the rest of OpenMP didn't require C++11, while libomptarget did require it. Now, it's unlikely that anyone attempts building it with a toolchain that doesn't support C++11. At this point, we could also probably just set CXX_STANDARD_REQUIRED to true, requiring C++17 as baseline for all the OpenMP libraries. This fixes building OpenMP with clang-cl after 46262cab24312c71717ca70a9d0700481aa59152. Differential Revision: https://reviews.llvm.org/D149726
39 lines
1.8 KiB
CMake
39 lines
1.8 KiB
CMake
include(CheckCXXCompilerFlag)
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
# Check for oneAPI compiler (some older CMake versions detect as Clang)
|
|
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
check_cxx_source_compiles("#if (defined(__INTEL_CLANG_COMPILER) || defined(__INTEL_LLVM_COMPILER))
|
|
int main() { return 0; }
|
|
#else
|
|
not oneAPI
|
|
#endif" OPENMP_HAVE_ONEAPI_COMPILER)
|
|
if (OPENMP_HAVE_ONEAPI_COMPILER)
|
|
# According to CMake documentation, the compiler id should
|
|
# be IntelLLVM when detected oneAPI
|
|
set(CMAKE_C_COMPILER_ID "IntelLLVM")
|
|
set(CMAKE_CXX_COMPILER_ID "IntelLLVM")
|
|
endif()
|
|
endif()
|
|
|
|
check_cxx_compiler_flag(-Wall OPENMP_HAVE_WALL_FLAG)
|
|
check_cxx_compiler_flag(-Werror OPENMP_HAVE_WERROR_FLAG)
|
|
|
|
# Additional warnings that are not enabled by -Wall.
|
|
check_cxx_compiler_flag(-Wcast-qual OPENMP_HAVE_WCAST_QUAL_FLAG)
|
|
check_cxx_compiler_flag(-Wformat-pedantic OPENMP_HAVE_WFORMAT_PEDANTIC_FLAG)
|
|
check_cxx_compiler_flag(-Wimplicit-fallthrough OPENMP_HAVE_WIMPLICIT_FALLTHROUGH_FLAG)
|
|
check_cxx_compiler_flag(-Wsign-compare OPENMP_HAVE_WSIGN_COMPARE_FLAG)
|
|
|
|
# Warnings that we want to disable because they are too verbose or fragile.
|
|
|
|
# GCC silently accepts any -Wno-<foo> option, but warns about those options
|
|
# being unrecognized only if the compilation triggers other warnings to be
|
|
# printed. Therefore, check for whether the compiler supports options in the
|
|
# form -W<foo>, and if supported, add the corresponding -Wno-<foo> option.
|
|
|
|
check_cxx_compiler_flag(-Wenum-constexpr-conversion OPENMP_HAVE_WENUM_CONSTEXPR_CONVERSION_FLAG)
|
|
check_cxx_compiler_flag(-Wextra OPENMP_HAVE_WEXTRA_FLAG)
|
|
check_cxx_compiler_flag(-Wpedantic OPENMP_HAVE_WPEDANTIC_FLAG)
|
|
check_cxx_compiler_flag(-Wmaybe-uninitialized OPENMP_HAVE_WMAYBE_UNINITIALIZED_FLAG)
|