5656# ENABLE_CDFT: Enables cluster DFT library in MKL::MKL
5757# ENABLE_SCALAPACK: Enables cluster LAPACK library in MKL::MKL
5858# ENABLE_OMP_OFFLOAD: Enables OpenMP Offload functionality in MKL::MKL
59- # ENABLE_TRY_SYCL_COMPILE: Enables compiling a test program that calls a oneMKL DPC++ API
59+ # ENABLE_TRY_SYCL_COMPILE: Enables compiling a test program that calls a oneMKL SYCL API
60+ #-----------------------------------
61+ # Special options (AUTO by default)
62+ #-----------------------------------
63+ # ENABLE_SYCL_COMPILER: Enables or disables treating the C++ compiler as a SYCL compiler.
64+ # By default, the compiler will be checked if it is a SYCL compiler.
6065#
6166#==================
6267# Output parameters
@@ -150,13 +155,16 @@ foreach(lang ${languages})
150155endforeach ()
151156list (REMOVE_DUPLICATES CURR_LANGS)
152157
153- option (ENABLE_BLAS95 "Enables BLAS Fortran95 API" OFF )
154- option (ENABLE_LAPACK95 "Enables LAPACK Fortran95 API" OFF )
155- option (ENABLE_BLACS "Enables cluster BLAS library" OFF )
156- option (ENABLE_CDFT "Enables cluster DFT library" OFF )
157- option (ENABLE_SCALAPACK "Enables cluster LAPACK library" OFF )
158- option (ENABLE_OMP_OFFLOAD "Enables OpenMP Offload functionality" OFF )
159- option (ENABLE_TRY_SYCL_COMPILE "Enables compiling a oneMKL DPC++ test program" OFF )
158+ option (ENABLE_BLAS95 "Enables BLAS Fortran95 API" OFF )
159+ option (ENABLE_LAPACK95 "Enables LAPACK Fortran95 API" OFF )
160+ option (ENABLE_BLACS "Enables cluster BLAS library" OFF )
161+ option (ENABLE_CDFT "Enables cluster DFT library" OFF )
162+ option (ENABLE_SCALAPACK "Enables cluster LAPACK library" OFF )
163+ option (ENABLE_OMP_OFFLOAD "Enables OpenMP Offload functionality" OFF )
164+ option (ENABLE_TRY_SYCL_COMPILE "Enables compiling a oneMKL SYCL test program" OFF )
165+
166+ set (ENABLE_SYCL_COMPILER AUTO CACHE STRING "Enable SYCL compiler support" )
167+ set_property (CACHE ENABLE_SYCL_COMPILER PROPERTY STRINGS AUTO ON OFF )
160168
161169# Use MPI if any of these are enabled
162170if (ENABLE_BLACS OR ENABLE_CDFT OR ENABLE_SCALAPACK)
@@ -225,11 +233,38 @@ if(CMAKE_Fortran_COMPILER)
225233endif ()
226234
227235# Determine Compiler Family
228- if (CXX_COMPILER_NAME STREQUAL "dpcpp" OR CXX_COMPILER_NAME STREQUAL "dpcpp.exe"
229- OR CXX_COMPILER_NAME STREQUAL "icpx" OR CXX_COMPILER_NAME STREQUAL "icx.exe"
230- OR CXX_COMPILER_NAME STREQUAL "mpiicpx" OR CXX_COMPILER_NAME STREQUAL "mpiicx.bat" )
231- set (SYCL_COMPILER ON )
232- endif ()
236+ if (ENABLE_SYCL_COMPILER STREQUAL "AUTO" ) # default
237+ # Check Intel oneAPI Compiler binary name for SYCL support
238+ if (CXX_COMPILER_NAME STREQUAL "dpcpp" OR CXX_COMPILER_NAME STREQUAL "dpcpp.exe"
239+ OR CXX_COMPILER_NAME STREQUAL "icpx" OR CXX_COMPILER_NAME STREQUAL "icx.exe"
240+ OR CXX_COMPILER_NAME STREQUAL "mpiicpx" OR CXX_COMPILER_NAME STREQUAL "mpiicx.bat" )
241+ set (SYCL_COMPILER ON )
242+ else () # Non-Intel oneAPI Compilers
243+ # Slower but robust check for SYCL support in non-Intel oneAPI compilers
244+ if ("CXX" IN_LIST CURR_LANGS AND
245+ (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" ))
246+ include (CheckCXXCompilerFlag)
247+ include (CheckIncludeFileCXX)
248+ # Check SYCL flag support by the compiler
249+ check_cxx_compiler_flag("-fsycl" COMPILER_FSYCL_SUPPORT)
250+ if (COMPILER_FSYCL_SUPPORT)
251+ # Check SYCL header support by the compiler
252+ CHECK_INCLUDE_FILE_CXX("sycl/sycl.hpp" SYCL_SYCL_HPP "-fsycl" )
253+ if (NOT SYCL_SYCL_HPP)
254+ CHECK_INCLUDE_FILE_CXX("CL/sycl.hpp" SYCL_CL_HPP "-fsycl" )
255+ endif ()
256+ if (SYCL_SYCL_HPP OR SYCL_CL_HPP)
257+ set (SYCL_COMPILER ON )
258+ endif ()
259+ endif () # COMPILER_FSYCL_SUPPORT
260+ endif () # CXX IN_LIST CURR_LANGS
261+ endif () # CXX_COMPILER_NAME
262+ elseif (ENABLE_SYCL_COMPILER)
263+ # Using the "ON" option with a non-SYCL compiler may lead to unexpected behavior.
264+ set (SYCL_COMPILER ON )
265+ else ()
266+ set (SYCL_COMPILER OFF )
267+ endif () # ENABLE_SYCL_COMPILER
233268if (C_COMPILER_NAME MATCHES "^clang" OR CXX_COMPILER_NAME MATCHES "^clang" )
234269 set (CLANG_COMPILER ON )
235270endif ()
@@ -365,6 +400,15 @@ endif()
365400define_param(MKL_LINK DEFAULT_MKL_LINK MKL_LINK_LIST)
366401check_required_vars(MKL_LINK)
367402
403+ if (MKL_LINK STREQUAL "static" AND ENABLE_OMP_OFFLOAD)
404+ mkl_message(WARNING "oneMKL SYCL static library is deprecated and will be removed in the oneMKL 2026.0 release" )
405+ elseif (MKL_SYCL_LINK AND MKL_SYCL_LINK STREQUAL "static" )
406+ mkl_message(STATUS "oneMKL SYCL static library is deprecated and will be removed in the oneMKL 2026.0 release" )
407+ add_custom_target (MKL_SYCL_STATIC_MESSAGE
408+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red
409+ "Warning: oneMKL SYCL static library is deprecated and will be removed in the oneMKL 2026.0 release" )
410+ endif ()
411+
368412# Define MKL_INTERFACE
369413if (SYCL_COMPILER)
370414 if (MKL_INTERFACE AND NOT DEFINED MKL_SYCL_INTERFACE_FULL)
@@ -793,24 +837,24 @@ foreach(lib ${MKL_REQUESTED_LIBRARIES})
793837 endif ()
794838 string (TOUPPER ${MKL_SYCL_DOMAIN} MKL_SYCL_DOMAIN)
795839 if (MKL_SYCL_DOMAIN STREQUAL "DFT" )
796- mkl_message(STATUS "Could NOT find MKL ${lib} for targets MKL::MKL_SYCL::${MKL_SYCL_DOMAIN} and MKL::MKL_SYCL_DISTRIBUTED_DFT" )
840+ mkl_message(STATUS "Could NOT find ${lib} for targets MKL::MKL_SYCL::${MKL_SYCL_DOMAIN} and MKL::MKL_SYCL_DISTRIBUTED_DFT" )
797841 else ()
798- mkl_message(STATUS "Could NOT find MKL ${lib} for target MKL::MKL_SYCL::${MKL_SYCL_DOMAIN} " )
842+ mkl_message(STATUS "Could NOT find ${lib} for target MKL::MKL_SYCL::${MKL_SYCL_DOMAIN} " )
799843 endif ()
800844 else ()
801845 if (NOT USE_MPI AND (${lib} MATCHES "mkl_scalapack" OR ${lib} MATCHES "mkl_blacs" OR ${lib} MATCHES "mkl_cdft" OR ${lib} STREQUAL "mkl_sycl_distributed_dft" )
802846 AND ${${lib} _file} STREQUAL "${lib} _file-NOTFOUND" )
803847 if (${lib} MATCHES "mkl_scalapack" )
804- mkl_message(STATUS "Could NOT find MKL ${lib} for target MKL::MKL_SCALAPACK" )
848+ mkl_message(STATUS "Could NOT find ${lib} for target MKL::MKL_SCALAPACK" )
805849 endif ()
806850 if (${lib} MATCHES "mkl_cdft" )
807- mkl_message(STATUS "Could NOT find MKL ${lib} for target MKL::MKL_CDFT" )
851+ mkl_message(STATUS "Could NOT find ${lib} for target MKL::MKL_CDFT" )
808852 endif ()
809853 if (${lib} MATCHES "mkl_blacs" )
810- mkl_message(STATUS "Could NOT find MKL ${lib} for targets MKL::MKL_SCALAPACK, MKL::MKL_CDFT, and MKL::MKL_BLACS" )
854+ mkl_message(STATUS "Could NOT find ${lib} for targets MKL::MKL_SCALAPACK, MKL::MKL_CDFT, and MKL::MKL_BLACS" )
811855 endif ()
812856 if (${lib} STREQUAL "mkl_sycl_distributed_dft" )
813- mkl_message(STATUS "Could NOT find MKL ${lib} for target MKL::MKL_SYCL_DISTRIBUTED_DFT" )
857+ mkl_message(STATUS "Could NOT find ${lib} for target MKL::MKL_SYCL_DISTRIBUTED_DFT" )
814858 endif ()
815859 else ()
816860 check_required_vars(${lib} _file)
@@ -1027,6 +1071,7 @@ if(SYCL_COMPILER)
10271071 if (NOT TARGET MKL::MKL_SYCL)
10281072 add_library (MKL::MKL_SYCL INTERFACE IMPORTED GLOBAL )
10291073 add_library (MKL::MKL_DPCPP ALIAS MKL::MKL_SYCL)
1074+ add_dependencies (MKL::MKL_SYCL MKL_SYCL_STATIC_MESSAGE)
10301075 endif ()
10311076 target_compile_options (MKL::MKL_SYCL INTERFACE $<$<COMPILE_LANGUAGE:CXX>:${MKL_SYCL_COPT} >)
10321077 target_link_libraries (MKL::MKL_SYCL INTERFACE ${MKL_SYCL_LINK_LINE} ${MKL_SYCL_THREAD_LIB} ${MKL_SYCL_SUPP_LINK} )
@@ -1039,6 +1084,7 @@ if(SYCL_COMPILER)
10391084 endif ()
10401085 string (TOUPPER ${MKL_SYCL_DOMAIN} MKL_SYCL_DOMAIN)
10411086 add_library (MKL::MKL_SYCL::${MKL_SYCL_DOMAIN} INTERFACE IMPORTED GLOBAL )
1087+ add_dependencies (MKL::MKL_SYCL::${MKL_SYCL_DOMAIN} MKL_SYCL_STATIC_MESSAGE)
10421088 target_compile_options (MKL::MKL_SYCL::${MKL_SYCL_DOMAIN} INTERFACE $<$<COMPILE_LANGUAGE:CXX>:${MKL_SYCL_COPT} >)
10431089 # Only dynamic link has domain specific libraries
10441090 # Domain specific targets still use mkl_sycl for static
@@ -1279,7 +1325,7 @@ if(ENABLE_TRY_SYCL_COMPILE AND "CXX" IN_LIST CURR_LANGS AND SYCL_COMPILER AND MK
12791325 unset (CMAKE_REQUIRED_LIBRARIES)
12801326 if (NOT MKL_TRY_SYCL_COMPILE)
12811327 mkl_not_found_and_return("The SYCL compiler \" ${CMAKE_CXX_COMPILER} \" is not able to \
1282- compile a simple test program that calls a oneMKL DPC++ API. \
1328+ compile a simple test program that calls a oneMKL SYCL API. \
12831329 See \" CMakeError.log\" for details. Besides environment issues, \
12841330 this could be caused by a compiler version that is incompatible \
12851331 with oneMKL ${${CMAKE_FIND_PACKAGE_NAME} _VERSION}." )
0 commit comments