Skip to content

Commit

Permalink
Merge pull request #13 from KhronosGroup/master
Browse files Browse the repository at this point in the history
Merge latest Khronos:OpenCL-ICD-Loader master into nikhiljnv:OpenCL-ICD-Loader/master
  • Loading branch information
nikhiljnv authored Sep 28, 2020
2 parents 8f7f56d + 97f0eb5 commit 4dd5078
Show file tree
Hide file tree
Showing 32 changed files with 4,122 additions and 4,200 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ before_build:
- cmake -DOPENCL_ICD_LOADER_HEADERS_DIR=inc/OpenCL-Headers -H. -Bbuild -A%PLATFORM%

build:
project: build\OPENCL_ICD_LOADER.sln
project: build\OpenCL-ICD-Loader.sln
parallel: true
verbosity: normal
79 changes: 54 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 2.8.11)
cmake_minimum_required (VERSION 3.1)

project (OPENCL_ICD_LOADER)
project (OpenCL-ICD-Loader VERSION 1.2)
include (GNUInstallDirs)
find_package (Threads REQUIRED)

Expand Down Expand Up @@ -34,6 +34,11 @@ find_package (Threads REQUIRED)
# advance. Use it with discretion.
option (BUILD_SHARED_LIBS "Build shared libs" ON)

# This option enables support for OpenCL 3.0 Provisional in the ICD loader. It
# is currently off by default while the specification is provisional, as it may
# change.
option (ENABLE_OPENCL30_PROVISIONAL "Enable 3.0 provisional entry points" OFF)

include(CheckFunctionExists)
check_function_exists(secure_getenv HAVE_SECURE_GETENV)
check_function_exists(__secure_getenv HAVE___SECURE_GETENV)
Expand All @@ -45,19 +50,34 @@ set (OPENCL_ICD_LOADER_SOURCES
loader/icd.h
loader/icd_dispatch.c
loader/icd_dispatch.h
loader/icd_dispatch_generated.c
loader/icd_envvars.h
loader/icd_platform.h)

if (WIN32)
# By default don't include OpenCL 3.0 symbol definitions (i.e. comment them
# out), but include them for OpenCL 3.0 builds. Once the symbols are no
# longer provisional then they may be included unconditionally.
set(ENABLE_OPENCL30_SYMBOLS ";")
if (ENABLE_OPENCL30_PROVISIONAL)
set(ENABLE_OPENCL30_SYMBOLS "")
endif ()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/loader/windows/OpenCL.def.in
${CMAKE_CURRENT_BINARY_DIR}/loader/windows/OpenCL.def)

list (APPEND OPENCL_ICD_LOADER_SOURCES
loader/windows/adapter.h
loader/windows/icd_windows.c
loader/windows/icd_windows.h
loader/windows/icd_windows_dxgk.c
loader/windows/icd_windows_dxgk.h
loader/windows/icd_windows_envvars.c
loader/windows/icd_windows_hkr.c
loader/windows/icd_windows_hkr.h
loader/windows/OpenCL.def
loader/windows/icd_windows_apppackage.cpp
loader/windows/icd_windows_apppackage.h
${CMAKE_CURRENT_BINARY_DIR}/loader/windows/OpenCL.def
loader/windows/OpenCL.rc)
# Only add the DXSDK include directory if the environment variable is
# defined. Since the DXSDK has merged into the Windows SDK, this is
Expand All @@ -67,37 +87,38 @@ if (WIN32)
include_directories ($ENV{WDK}/km)
endif ()
else ()
# By default don't include OpenCL 3.0 symbol definitions (i.e. comment them
# out), but include them for OpenCL 3.0 builds. Once the symbols are no
# longer provisional then they may be included unconditionally.
set(ENABLE_OPENCL30_SYMBOLS_START "/*")
set(ENABLE_OPENCL30_SYMBOLS_END "*/")
if (ENABLE_OPENCL30_PROVISIONAL)
set(ENABLE_OPENCL30_SYMBOLS_START "")
set(ENABLE_OPENCL30_SYMBOLS_END "")
endif ()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map.in
${CMAKE_CURRENT_BINARY_DIR}/loader/linux/icd_exports.map)

list (APPEND OPENCL_ICD_LOADER_SOURCES
loader/linux/icd_linux.c
loader/linux/icd_linux_envvars.c
loader/linux/icd_exports.map)
${CMAKE_CURRENT_BINARY_DIR}/loader/linux/icd_exports.map)
endif ()

set (OPENCL_ICD_LOADER_HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/inc CACHE PATH "Path to OpenCL Headers")

add_library (OpenCL ${OPENCL_ICD_LOADER_SOURCES})
set_target_properties (OpenCL PROPERTIES VERSION "1.2" SOVERSION "1")
target_include_directories(OpenCL SYSTEM PUBLIC ${OPENCL_ICD_LOADER_HEADERS_DIR})

if (WIN32)
target_link_libraries (OpenCL cfgmgr32.lib)

if(DEFINED ENV{WDKContentRoot})
file(GLOB D3DKMT_HEADER "$ENV{WDKContentRoot}/Include/*/km/d3dkmthk.h")
else()
file(GLOB D3DKMT_HEADER "$ENV{HOMEDRIVE}/Program Files */Windows Kits/10/Include/*/km/d3dkmthk.h")
endif()
target_link_libraries (OpenCL cfgmgr32.lib runtimeobject.lib)

if(D3DKMT_HEADER)
list(GET D3DKMT_HEADER -1 LATEST_D3DKMT_HEADER)
get_filename_component(WDK_DIRECTORY ${LATEST_D3DKMT_HEADER} DIRECTORY)
get_filename_component(WDK_DIRECTORY ${WDK_DIRECTORY} DIRECTORY)
message(STATUS "Found the Windows WDK in: ${WDK_DIRECTORY}")
target_compile_definitions(OpenCL PRIVATE OPENCL_ICD_LOADER_REQUIRE_WDK)
target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/um)
target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/km)
target_include_directories(OpenCL PRIVATE ${WDK_DIRECTORY}/shared)
else()
message(FATAL_ERROR "The Windows WDK was not found. Consider disabling OPENCL_ICD_LOADER_REQUIRE_WDK. Aborting.")
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)
Expand All @@ -114,19 +135,27 @@ else()
if (APPLE)
target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
else ()
set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_SOURCE_DIR}/loader/linux/icd_exports.map")
set_target_properties (OpenCL PROPERTIES LINK_FLAGS "-Wl,--version-script -Wl,${CMAKE_CURRENT_BINARY_DIR}/loader/linux/icd_exports.map")
target_link_libraries (OpenCL ${CMAKE_THREAD_LIBS_INIT})
endif ()
endif ()

include_directories (${OPENCL_ICD_LOADER_HEADERS_DIR})
add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
if (ENABLE_OPENCL30_PROVISIONAL)
add_definitions (-DCL_TARGET_OPENCL_VERSION=300)
else()
add_definitions (-DCL_TARGET_OPENCL_VERSION=220)
endif()

target_include_directories (OpenCL PRIVATE ${CMAKE_CURRENT_BINARY_DIR} loader)
target_link_libraries (OpenCL ${CMAKE_DL_LIBS})

include (CTest)
if (BUILD_TESTING)
option (OPENCL_ICD_LOADER_BUILD_TESTING "Enable support for OpenCL ICD Loader testing." OFF)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_ICD_LOADER_BUILD_TESTING)
include(CTest)
endif()
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR OPENCL_ICD_LOADER_BUILD_TESTING) AND BUILD_TESTING)
add_subdirectory (test)
endif()

Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@ The OpenCL ICD Loader requires OpenCL Headers.
To use system OpenCL Headers, please specify the OpenCL Header location using the CMake variable `OPENCL_ICD_LOADER_HEADERS_DIR`.
By default, the OpenCL ICD Loader will look for OpenCL Headers in the `inc` directory.

OpenCL ICD Loader on Windows now requires the Windows Driver Kit (WDK).
While WDK headers are sufficient to be able to build OpenCL ICD Loader, you will need WDK libraries for it to function correctly.
Not having WDK installed may prevent the OpenCL ICD Loader from enumerating some OpenCL implementations on latest Windows versions.
So, we advise that you install recent Windows WDK currently available at -
* https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk

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
Loading

0 comments on commit 4dd5078

Please sign in to comment.