1cmake_minimum_required(VERSION 3.4.3) 2 3if(CMAKE_COMPILER_IS_GNUCXX) 4 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) 5 message(FATAL_ERROR "host compiler - gcc version must be > 4.8") 6 endif() 7elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 8 if (${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 3.6) 9 message(FATAL_ERROR "host compiler - clang version must be > 3.6") 10 endif() 11endif() 12 13if(MSVC) 14 set(ComputeCpp_STL_CHECK_SRC __STL_check) 15 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp 16 "#include <ios>\n" 17 "int main() { return 0; }\n") 18 execute_process( 19 COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE} 20 ${COMPUTECPP_DEVICE_COMPILER_FLAGS} 21 -isystem ${ComputeCpp_INCLUDE_DIRS} 22 -o ${ComputeCpp_STL_CHECK_SRC}.sycl 23 -c ${ComputeCpp_STL_CHECK_SRC}.cpp 24 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 25 RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT 26 ERROR_QUIET 27 OUTPUT_QUIET) 28 if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0) 29 # Try disabling compiler version checks 30 execute_process( 31 COMMAND ${ComputeCpp_DEVICE_COMPILER_EXECUTABLE} 32 ${COMPUTECPP_DEVICE_COMPILER_FLAGS} 33 -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH 34 -isystem ${ComputeCpp_INCLUDE_DIRS} 35 -o ${ComputeCpp_STL_CHECK_SRC}.cpp.sycl 36 -c ${ComputeCpp_STL_CHECK_SRC}.cpp 37 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 38 RESULT_VARIABLE ComputeCpp_STL_CHECK_RESULT 39 ERROR_QUIET 40 OUTPUT_QUIET) 41 if(NOT ${ComputeCpp_STL_CHECK_RESULT} EQUAL 0) 42 message(STATUS "Device compiler cannot consume hosted STL headers. Using any parts of the STL will likely result in device compiler errors.") 43 else() 44 message(STATUS "Device compiler does not meet certain STL version requirements. Disabling version checks and hoping for the best.") 45 list(APPEND COMPUTECPP_DEVICE_COMPILER_FLAGS -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH) 46 endif() 47 endif() 48 file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp 49 ${CMAKE_CURRENT_BINARY_DIR}/${ComputeCpp_STL_CHECK_SRC}.cpp.sycl) 50endif(MSVC) 51