Skip to content

Commit dd3146f

Browse files
author
Daniel Martinez
committed
Build against sytem dependancies if available
If CLHPP, ICD-Loader, and Headers are installed on the system, use those instead of the submodules. This is beneficial when packaging the SDK for distribution, as the submodules can be built as their own seperate packages.
1 parent d405836 commit dd3146f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,20 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
3939
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE PATH "Install Path" FORCE)
4040
endif()
4141

42-
add_subdirectory(external/OpenCL-Headers)
43-
add_subdirectory(external/OpenCL-ICD-Loader)
44-
add_subdirectory(external/OpenCL-CLHPP)
42+
find_package (OpenCLHeaders)
43+
if (NOT TARGET OpenCL::Headers)
44+
add_subdirectory(external/OpenCL-Headers)
45+
endif ()
46+
47+
find_package (OpenCLICDLoader)
48+
if (NOT TARGET OpenCL::OpenCL)
49+
add_subdirectory(external/OpenCL-ICD-Loader)
50+
endif ()
51+
52+
find_package (OpenCLHeadersCpp)
53+
if (NOT TARGET OpenCL::HeadersCpp)
54+
add_subdirectory(external/OpenCL-CLHPP)
55+
endif ()
4556

4657
list(APPEND CMAKE_MODULE_PATH
4758
${PROJECT_SOURCE_DIR}/cmake

0 commit comments

Comments
 (0)