brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.3 KiB · fe08a42 Raw
127 lines · plain
1#===============================================================================2# Setup Project3#===============================================================================4cmake_minimum_required(VERSION 3.20.0)5 6set(LLVM_SUBPROJECT_TITLE "libsycl")7 8set(LIBSYCL_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})9set(LIBSYCL_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})10 11set(CMAKE_CXX_STANDARD 17)12set(CMAKE_CXX_STANDARD_REQUIRED YES)13set(CMAKE_CXX_EXTENSIONS OFF)14 15#===============================================================================16# Limitations17#===============================================================================18 19if (CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT MSVC)20# Build with other compilers is not configured, not guaranteed and not tested.21    message(FATAL_ERROR22      "When compiling for Windows, libsycl requires a"23      " version of Microsoft Visual C++ or another compiler"24      " that uses the Visual C++ cl command-line syntax.")25endif()26 27#===============================================================================28# Setup CMake Options29#===============================================================================30 31option(LIBSYCL_ENABLE_WERROR "Treat all warnings as errors in the libsycl project" OFF)32option(LIBSYCL_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)33 34#===============================================================================35# Configure System36#===============================================================================37 38set_property(GLOBAL PROPERTY USE_FOLDERS ON)39 40set(LIBSYCL_SHARED_OUTPUT_NAME "sycl" CACHE STRING "Output name for the shared libsycl runtime library.")41 42if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)43  set(LIBSYCL_TARGET_SUBDIR ${LLVM_DEFAULT_TARGET_TRIPLE})44  if(LIBSYCL_LIBDIR_SUBDIR)45    string(APPEND LIBSYCL_TARGET_SUBDIR /${LIBSYCL_LIBDIR_SUBDIR})46  endif()47  cmake_path(NORMAL_PATH LIBSYCL_TARGET_SUBDIR)48  set(LIBSYCL_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LIBSYCL_TARGET_SUBDIR})49  set(LIBSYCL_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LIBSYCL_TARGET_SUBDIR} CACHE STRING50      "Path where built libsycl libraries should be installed.")51  unset(LIBSYCL_TARGET_SUBDIR)52else()53  if(LLVM_LIBRARY_OUTPUT_INTDIR)54    set(LIBSYCL_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})55  else()56    set(LIBSYCL_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBSYCL_LIBDIR_SUFFIX})57  endif()58  set(LIBSYCL_INSTALL_LIBRARY_DIR lib${LIBSYCL_LIBDIR_SUFFIX} CACHE STRING59      "Path where built libsycl libraries should be installed.")60endif()61 62set(LIBSYCL_INCLUDE_DIR include)63set(LIBSYCL_BUILD_INCLUDE_DIR ${LLVM_BINARY_DIR}/${LIBSYCL_INCLUDE_DIR})64set(LIBSYCL_SOURCE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)65 66set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR})67set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR})68set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBSYCL_LIBRARY_DIR})69 70set(LIBSYCL_MAJOR_VERSION 0)71set(LIBSYCL_MINOR_VERSION 1)72set(LIBSYCL_PATCH_VERSION 0)73set(LIBSYCL_VERSION_STRING "${LIBSYCL_MAJOR_VERSION}.${LIBSYCL_MINOR_VERSION}.${LIBSYCL_PATCH_VERSION}")74set(LIBSYCL_ABI_NAMESPACE "__V${LIBSYCL_MAJOR_VERSION}" CACHE STRING75    "The inline ABI namespace used by libsycl. It defaults to __Vn where `n` is the current ABI version.")76if (NOT LIBSYCL_ABI_NAMESPACE MATCHES "__V.*")77   message(FATAL_ERROR "LIBSYCL_ABI_NAMESPACE must be a reserved identifier, got '${LIBSYCL_ABI_NAMESPACE}'.")78endif()79 80#===============================================================================81# Setup build & install rules82#===============================================================================83 84# Generate headers85configure_file("${LIBSYCL_SOURCE_DIR}/src/version.hpp.in" "${LIBSYCL_BUILD_INCLUDE_DIR}/sycl/__impl/version.hpp")86 87# Install generated headers.88install(FILES89  "${LIBSYCL_BUILD_INCLUDE_DIR}/sycl/__impl/version.hpp"90  DESTINATION "${LIBSYCL_INCLUDE_DIR}/sycl/__impl"91  COMPONENT sycl-headers)92 93# This is a workaround to detect changes (add or modify) in subtree which94# are not detected by copy_directory command.95file(GLOB_RECURSE HEADERS_IN_SYCL_DIR CONFIGURE_DEPENDS "${LIBSYCL_SOURCE_INCLUDE_DIR}/sycl/*")96file(GLOB_RECURSE HEADERS_IN_CL_DIR CONFIGURE_DEPENDS "${LIBSYCL_SOURCE_INCLUDE_DIR}/CL/*")97 98string(REPLACE "${LIBSYCL_SOURCE_INCLUDE_DIR}" "${LIBSYCL_BUILD_INCLUDE_DIR}"99  OUT_HEADERS_IN_SYCL_DIR "${HEADERS_IN_SYCL_DIR}")100string(REPLACE "${LIBSYCL_SOURCE_INCLUDE_DIR}/CL" "${LIBSYCL_BUILD_INCLUDE_DIR}/CL"101  OUT_HEADERS_IN_CL_DIR "${HEADERS_IN_CL_DIR}")102 103# Copy SYCL headers from sources to build directory104add_custom_target(sycl-headers105  DEPENDS ${OUT_HEADERS_IN_SYCL_DIR}106          ${OUT_HEADERS_IN_CL_DIR})107 108add_custom_command(109  OUTPUT  ${OUT_HEADERS_IN_SYCL_DIR}110          ${OUT_HEADERS_IN_CL_DIR}111  DEPENDS ${HEADERS_IN_SYCL_DIR}112          ${HEADERS_IN_CL_DIR}113  COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBSYCL_SOURCE_INCLUDE_DIR}/sycl ${LIBSYCL_BUILD_INCLUDE_DIR}/sycl114  COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBSYCL_SOURCE_INCLUDE_DIR}/CL ${LIBSYCL_BUILD_INCLUDE_DIR}/CL115  COMMENT "Copying SYCL headers...")116 117install(DIRECTORY "${LIBSYCL_SOURCE_INCLUDE_DIR}/sycl" DESTINATION ${LIBSYCL_INCLUDE_DIR} COMPONENT sycl-headers)118install(DIRECTORY "${LIBSYCL_SOURCE_INCLUDE_DIR}/CL" DESTINATION ${LIBSYCL_INCLUDE_DIR} COMPONENT sycl-headers)119 120set(LIBSYCL_RT_LIBS ${LIBSYCL_SHARED_OUTPUT_NAME})121 122add_subdirectory(src)123 124add_custom_target(libsycl-runtime-libraries125  DEPENDS ${LIBSYCL_RT_LIBS}126)127