如何在Windows 10的Clion中使用intel opencl sdk?

时间:2019-06-25 09:24:57

标签: c++ opencl intel clion

我已经为Windows安装了Intel opencl sdk,并将opencl变量添加到环境变量中。我想将此Cld ide与我的sdk一起使用,由于找不到CL / cl.hpp,因此我无法将其包含在当前项目中。如何将其添加到Clion的项目中?

Cl / cl.hpp位于C:\Program Files(x86)\IntelSWTools\OpenCL\sdk\include\CL

以下是我的CMakeLists.txt


project(tpch_framework)

# enable c++11
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_BUILD_TYPE "Release")

find_package(OpenMP REQUIRED)
find_package(OpenCL REQUIRED)

if (OPENMP_FOUND)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif() 

# Configure required Boost libraries
set(BOOST_ROOT "" CACHE PATH "Boost build root (useful on Windows)")
option(Boost_USE_STATIC_LIBS
       "Search for static boost libs" OFF)
option(Boost_USE_MULTITHREADED
       "Search for multithreaded boost libs" ON)
option(Boost_USE_STATIC_RUNTIME
       "Search for boost libs linked against static C++ runtime" OFF)
find_package(Boost 1.47.0 REQUIRED filesystem system)

# ensure that dependant libraries not explicitly specified here
# are found by the linker:
link_directories(${Boost_LIBRARY_DIRS})
include_directories(${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})

#Bring the headers into the project
include_directories(include)

FILE(GLOB_RECURSE INC_ALL "include/*.hpp")

#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")

add_library(tpch_framework ${SOURCES})
add_executable(framework main.cpp ${INC_ALL})
target_link_libraries(framework tpch_framework)
#target_link_libraries(framework stdc++fs)
target_link_libraries(framework ${LIBS})

1 个答案:

答案 0 :(得分:0)

您需要提供有关OpenCL标头的包含目录的信息,就像您为Boost标头提供的信息一样。另外,您需要将OpenCL库与目标链接。

在您的CMakeLists中...

对于包含和链接目录:

link_directories(${Boost_LIBRARY_DIRS} ${OpenCL_LIBRARY})
include_directories(${Boost_INCLUDE_DIRS} ${OpenCL_INCLUDE_DIRS})

用于链接库:

set(LIBS ${LIBS} ${Boost_LIBRARIES} ${OpenCL_LIBRARY})