Skip to content

Commit

Permalink
add an option to disable support for OpenCLOn12
Browse files Browse the repository at this point in the history
setting this option breaks a dependency on the Windows SDK
  • Loading branch information
bashbaug authored and alycm committed May 8, 2020
1 parent 23475bd commit bb98ad9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions loader/windows/icd_windows_apppackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -164,4 +168,5 @@ extern "C" bool khrIcdOsVendorsEnumerateAppPackage()
return true;
}
return false;
#endif
}

0 comments on commit bb98ad9

Please sign in to comment.