1 cmake_minimum_required(VERSION 3.22.1) 2 project(opencl_backend) 3 4 set(CMAKE_CXX_STANDARD 14) 5 6 find_package(OpenCL) 7 if(OPENCL_FOUND) 8 message("OPENCL") 9 if ("${OPENCL_BACKEND}EMPTY" STREQUAL "EMPTY") 10 set (OPENCL_BACKEND "${CMAKE_SOURCE_DIR}") 11 message("OPENCL_BACKEND=${OPENCL_BACKEND}") 12 endif() 13 14 if ("${SHARED_BACKEND}EMPTY" STREQUAL "EMPTY") 15 set (SHARED_BACKEND "${CMAKE_SOURCE_DIR}/../shared") 16 message("SHARED_BACKEND=${SHARED_BACKEND}") 17 endif() 18 19 if (APPLE) 20 set(OPENCL_INCLUDE_DIR "-framework OpenCL") 21 set(OPENCL_LIB "-framework OpenCL") 22 else() 23 set(OPENCL_LIB "OpenCL") 24 endif() 25 26 include_directories( 27 ${OPENCL_BACKEND}/include 28 ${SHARED_BACKEND}/include 29 ${OPENCL_INCLUDE_DIR} 30 ) 31 link_directories( 32 ${CMAKE_BINARY_DIR} 33 ) 34 35 add_library(opencl_backend SHARED 36 ${SHARED_BACKEND}/cpp/shared.cpp 37 ${OPENCL_BACKEND}/cpp/opencl_backend.cpp 38 ) 39 40 target_link_libraries(opencl_backend 41 ${OPENCL_LIB} 42 ) 43 44 add_executable(opencl_info 45 ${OPENCL_BACKEND}/cpp/info.cpp 46 ) 47 48 target_link_libraries(opencl_info 49 opencl_backend 50 ${OPENCL_LIB} 51 ) 52 53 endif()