diff --git a/CMakeLists.txt b/CMakeLists.txt index f9f43585..14115bb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,11 @@ set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1") if (WIN32) target_link_libraries (OpenCL cfgmgr32.lib RuntimeObject.lib) + option (OPENCL_ICD_LOADER_DISABLE_OPENCLON12 "Disable support for OpenCLOn12. Support for OpenCLOn12 should only be disabled when building an import lib to link with, and must be enabled when building an ICD loader for distribution!" OFF) + if (OPENCL_ICD_LOADER_DISABLE_OPENCLON12) + target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_DISABLE_OPENCLON12) + endif() + if(NOT USE_DYNAMIC_VCXX_RUNTIME) string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") diff --git a/README.md b/README.md index fcea27c9..9721bbc3 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,10 @@ By default, the OpenCL ICD Loader will look for OpenCL Headers in the `inc` dire The OpenCL ICD Loader uses CMake for its build system. If CMake is not provided by your build system or OS package manager, please consult the [CMake website](https://cmake.org). +The Windows OpenCL ICD Loader requires the Windows SDK to check for and enumerate the OpenCLOn12 ICD. +An OpenCL ICD Loader can be built without a dependency on the Windows SDK using the CMake variable `OPENCL_ICD_LOADER_DISABLE_OPENCLON12`. +This variable should only be used when building an import lib to link with, and must be enabled when building an OpenCL ICD Loader for distribution! + ### Build and Install Directories A common convention is to place the `build` directory in the top directory of the repository and to place the `install` directory as a child of the `build` directory. diff --git a/loader/windows/icd_windows_apppackage.cpp b/loader/windows/icd_windows_apppackage.cpp index 0092c2a1..a8a0faa2 100644 --- a/loader/windows/icd_windows_apppackage.cpp +++ b/loader/windows/icd_windows_apppackage.cpp @@ -48,6 +48,10 @@ using namespace Microsoft::WRL::Wrappers; extern "C" bool khrIcdOsVendorsEnumerateAppPackage() { +#ifdef OPENCL_ICD_LOADER_DISABLE_OPENCLON12 + KHR_ICD_TRACE("OpenCLOn12 is disabled\n"); + return false; +#else HRESULT hrInit = Windows::Foundation::Initialize(RO_INIT_MULTITHREADED); if (hrInit == RPC_E_CHANGED_MODE) { @@ -164,4 +168,5 @@ extern "C" bool khrIcdOsVendorsEnumerateAppPackage() return true; } return false; +#endif } \ No newline at end of file