Files
salmanoff/compile/CMakeLists.txt
T

53 lines
1.8 KiB
CMake
Raw Normal View History

option(COMPILE_CL_CHECKS "Compile CL checks" OFF)
2025-10-25 03:39:42 -04:00
if(COMPILE_CL_CHECKS)
# Find OpenCL: try find_package first, fall back to pkg-config
find_package(OpenCL QUIET)
if(OpenCL_FOUND)
# Normalize find_package variables to match pkg_check_modules naming
set(OPENCL_FOUND TRUE)
set(OPENCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIRS})
# Handle both OpenCL_LIBRARY (singular) and OpenCL_LIBRARIES (plural)
if(OpenCL_LIBRARIES)
set(OPENCL_LIBRARIES ${OpenCL_LIBRARIES})
else()
set(OPENCL_LIBRARIES ${OpenCL_LIBRARY})
endif()
set(OPENCL_LIBRARY_DIRS "")
message(STATUS "Found OpenCL using find_package")
else()
# Fall back to pkg-config
pkg_check_modules(OPENCL OpenCL)
if(NOT OPENCL_FOUND)
message(FATAL_ERROR
"Failed to find OpenCL: both find_package and "
"pkg_check_modules failed. Try installing the "
"'ocl-icd-opencl-dev' package (or the appropriate "
"OpenCL development package for your system)."
)
endif()
message(STATUS "Found OpenCL using pkg-config")
endif()
2025-10-25 03:39:42 -04:00
add_executable(clhostshmemptrcheck clhostshmemptrcheck.cpp)
target_include_directories(clhostshmemptrcheck
PUBLIC ${OPENCL_INCLUDE_DIRS})
target_link_libraries(clhostshmemptrcheck
${OPENCL_LIBRARIES})
2025-10-25 03:39:42 -04:00
add_executable(clshmemlatency clshmemlatency.cpp)
target_include_directories(clshmemlatency
PUBLIC ${OPENCL_INCLUDE_DIRS})
2025-10-25 03:39:42 -04:00
target_link_libraries(clshmemlatency
${OPENCL_LIBRARIES})
2025-10-25 03:39:42 -04:00
add_executable(clshmemcheck clshmemcheck.cpp)
target_include_directories(clshmemcheck
PUBLIC ${OPENCL_INCLUDE_DIRS})
2025-10-25 03:39:42 -04:00
target_link_libraries(clshmemcheck
${OPENCL_LIBRARIES})
2025-10-25 03:39:42 -04:00
add_executable(clzerocopycheck clzerocopycheck.cpp)
target_include_directories(clzerocopycheck
PUBLIC ${OPENCL_INCLUDE_DIRS})
2025-10-25 03:39:42 -04:00
target_link_libraries(clzerocopycheck
${OPENCL_LIBRARIES})
2025-10-25 03:39:42 -04:00
endif()