add an option to disable support for OpenCLOn12
authorBen Ashbaugh <ben.ashbaugh@intel.com>
Thu, 30 Apr 2020 01:21:31 +0000 (18:21 -0700)
committerAlastair Murray <alastairmurray42@gmail.com>
Fri, 8 May 2020 22:01:40 +0000 (23:01 +0100)
setting this option breaks a dependency on the Windows SDK

CMakeLists.txt
README.md
loader/windows/icd_windows_apppackage.cpp

index f9f43585be04fcfcb93bc3693fc0faed17832c19..14115bb6fff42569863cb5dd0bd219d56efca877 100644 (file)
@@ -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}")
index fcea27c931e9263cb0cf3ca12531137a005b076d..9721bbc3376a8027eae8936218eb6f62b6dd9cf1 100644 (file)
--- 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.
index 0092c2a12696e109c421e255565657f12e33bc99..a8a0faa281b39fb7f8b9f453c30902d963bd7034 100644 (file)
@@ -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