Skip to content

CMakelist improvements: add deploy target, Install OpenCL headers, some minor cleanup. #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 59 additions & 5 deletions sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if( NOT OpenCL_LIBRARIES )
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/icd_build"
CONFIGURE_COMMAND ${CMAKE_COMMAND} "${CMAKE_CURRENT_BINARY_DIR}/OpenCL/icd" -DCMAKE_INSTALL_LIBDIR:PATH=lib -DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
BUILD_COMMAND make C_INCLUDE_PATH=${CMAKE_CURRENT_BINARY_DIR}/OpenCL/inc
INSTALL_COMMAND make install
INSTALL_COMMAND make install
STEP_TARGETS configure,build,install
DEPENDS ocl-headers
)
Expand All @@ -84,6 +84,16 @@ endif()

set(OPENCL_INCLUDE "${OpenCL_INCLUDE_DIRS}")

add_library (OpenCL-Headers INTERFACE)
add_library (OpenCL::Headers ALIAS OpenCL-Headers)
target_include_directories(OpenCL-Headers
INTERFACE ${OPENCL_INCLUDE}
)
install(DIRECTORY ${OPENCL_INCLUDE}/CL
DESTINATION ${LLVM_INST_INC_DIRECTORY}
COMPONENT opencl-headers
)

# Configure SYCL version macro
set(sycl_inc_dir ${CMAKE_CURRENT_SOURCE_DIR}/include)
string(TIMESTAMP __SYCL_COMPILER_VERSION "%Y%m%d")
Expand All @@ -98,10 +108,6 @@ COMMENT "Copying SYCL headers ...")
# Configure SYCL headers
install(DIRECTORY "${sycl_inc_dir}/." DESTINATION "${LLVM_INST_INC_DIRECTORY}" COMPONENT sycl-headers)

# Configure OpenCL header and ICD loader
include_directories(AFTER "${sycl_inc_dir}" "${OpenCL_INCLUDE_DIRS}")
link_libraries(${OpenCL_LIBRARIES})

# SYCL runtime library
add_subdirectory(source)

Expand All @@ -126,3 +132,51 @@ add_custom_target( sycl-toolchain
add_subdirectory( test )
add_subdirectory( unittests )
add_subdirectory( tools )

# Package deploy support
# Listed here are component names contributing the package
set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS
clang
clang-offload-wrapper
clang-offload-bundler
llc
llvm-as
llvm-ar
llvm-dis
llvm-no-spir-kernel
llvm-spirv
llvm-link
llvm-objcopy
opt
clang-resource-headers
opencl-headers
sycl-headers
)

# Use it as fake dependency in order to force another command(s) to execute.
add_custom_command(OUTPUT __force_it
COMMAND "${CMAKE_COMMAND}" -E echo
)
#Serialize installation to avoid missing components due to build race conditions
set(__chain_dep __force_it)

set(manifest_list)
foreach( comp ${SYCL_TOOLCHAIN_DEPLOY_COMPONENTS} )
message( STATUS "Adding component ${comp} to deploy")

set (manifest_file ${CMAKE_CURRENT_BINARY_DIR}/install_manifest_${comp}.txt)
add_custom_command(OUTPUT ${manifest_file}
COMMAND "${CMAKE_COMMAND}"
"-DCMAKE_INSTALL_COMPONENT=${comp}"
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake"
DEPENDS ${__chain_dep}
COMMENT "Deploying component ${comp}"
USES_TERMINAL
)
list(APPEND manifest_list ${manifest_file})
set(__chain_dep ${manifest_file})
endforeach( comp )

add_custom_target(deploy-sycl-toolchain
DEPENDS sycl-toolchain ${manifest_list}
)
19 changes: 13 additions & 6 deletions sycl/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
#cmake_policy(SET CMP0057 NEW)
#include(AddLLVM)

if(MSVC)
add_definitions(-D__SYCL_BUILD_SYCL_DLL)
endif()

add_library(sycl SHARED
"${sycl_inc_dir}/CL/sycl.hpp"
"detail/builtins_common.cpp"
Expand Down Expand Up @@ -69,6 +65,14 @@ add_dependencies(sycl

set_target_properties(sycl PROPERTIES LINKER_LANGUAGE CXX)

if (MSVC)
target_compile_definitions(sycl PRIVATE __SYCL_BUILD_SYCL_DLL )
endif()
target_include_directories(sycl PRIVATE "${sycl_inc_dir}")
target_link_libraries(sycl
PRIVATE OpenCL::Headers
PRIVATE ${OpenCL_LIBRARIES}
)
if (SYCL_USE_LIBCXX)
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
Expand All @@ -88,9 +92,12 @@ else()
# More information https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
target_link_libraries(sycl gcc_s gcc)
target_link_libraries(sycl PRIVATE gcc_s gcc)
endif()

endif()

install(TARGETS sycl DESTINATION "lib" COMPONENT sycl)
install(TARGETS sycl
ARCHIVE DESTINATION "lib" COMPONENT sycl
LIBRARY DESTINATION "lib" COMPONENT sycl
RUNTIME DESTINATION "bin" COMPONENT sycl)
2 changes: 1 addition & 1 deletion sycl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ configure_lit_site_cfg(
add_lit_testsuite(check-sycl "Running the SYCL regression tests"
${CMAKE_CURRENT_BINARY_DIR}
ARGS ${RT_TEST_ARGS}
DEPENDS sycl-toolchain FileCheck get_device_count_by_type
DEPENDS sycl-toolchain FileCheck get_device_count_by_type llvm-config
)
set_target_properties(check-sycl PROPERTIES FOLDER "SYCL tests")
19 changes: 15 additions & 4 deletions sycl/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(get_device_count_by_type get_device_count_by_type.cpp)
add_dependencies(get_device_count_by_type ocl-headers ocl-icd)
#Minimum supported version of Intel's OCL GPU and CPU devices
add_definitions(-D MIN_INTEL_OCL_GPU_VERSION=\\"18.47.11882\\")
add_definitions(-D MIN_INTEL_OCL_CPU_VERSION=\\"18.1.0.0901\\",\\"7.6.0.1202\\")
target_link_libraries(get_device_count_by_type
PRIVATE OpenCL::Headers
PRIVATE ${OpenCL_LIBRARIES}
)

add_executable(sycl-check sycl-check.cpp)
add_dependencies(sycl-check sycl)
target_link_libraries(sycl-check sycl)
target_include_directories(sycl-check PRIVATE "${sycl_inc_dir}")
target_link_libraries(sycl-check
PRIVATE sycl
PRIVATE OpenCL::Headers
PRIVATE ${OpenCL_LIBRARIES})

#Minimum supported version of Intel's OCL GPU and CPU devices
target_compile_definitions(sycl-check
PRIVATE MIN_INTEL_OCL_GPU_VERSION=\"18.47.11882\"
PRIVATE MIN_INTEL_OCL_CPU_VERSION=\"18.1.0.0901\",\"7.6.0.1202\"
)