1cmake_minimum_required(VERSION 3.5.1) 2 3set( CONFORMANCE_SUFFIX "" ) 4set(CLConform_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 5 6project(CLConform${CONFORMANCE_SUFFIX}) 7 8set(CMAKE_C_STANDARD 99) 9set(CMAKE_C_STANDARD_REQUIRED ON) 10set(CMAKE_CXX_STANDARD 11) 11set(CMAKE_CXX_STANDARD_REQUIRED ON) 12 13add_definitions(-DCL_TARGET_OPENCL_VERSION=300) 14add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_2_APIS=1) 15add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_1_APIS=1) 16add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_0_APIS=1) 17add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_2_APIS=1) 18add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS=1) 19add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_0_APIS=1) 20 21option(USE_CL_EXPERIMENTAL "Use Experimental definitions" OFF) 22if(USE_CL_EXPERIMENTAL) 23 add_definitions(-DCL_EXPERIMENTAL) 24endif(USE_CL_EXPERIMENTAL) 25 26#----------------------------------------------------------- 27# Default Configurable Test Set 28#----------------------------------------------------------- 29option(D3D10_IS_SUPPORTED "Run DirectX 10 interop tests" OFF) 30option(D3D11_IS_SUPPORTED "Run DirectX 11 interop tests" OFF) 31option(GL_IS_SUPPORTED "Run OpenGL interop tests" OFF) 32option(GLES_IS_SUPPORTED "Run OpenGL ES interop tests" OFF) 33 34 35#----------------------------------------------------------- 36# Tests prefix and suffix 37#----------------------------------------------------------- 38# Set the prefix and suffix for the generated executables 39# For example, if you want the api executable to be test_conformance_api_12 40# Set prefix to "test_conformance_" and suffix to "_12" 41set(CONFORMANCE_PREFIX "test_" ) 42set(CONFORMANCE_SUFFIX "" ) 43 44#----------------------------------------------------------- 45# Vendor Customization 46#----------------------------------------------------------- 47#Vendor Customization File can be included here to provide a way to automatically 48#build driver as a dependency of the conformance tests, or other such CMake customization 49include(CMakeVendor.txt OPTIONAL) 50 51# CL_INCLUDE_DIR - path to dir with OpenCL headers 52if(CL_INCLUDE_DIR AND CL_LIB_DIR) 53 link_directories(${CL_LIB_DIR}) 54else(CL_INCLUDE_DIR AND CL_LIB_DIR) 55 message(STATUS "OpenCL hasn't been found!") 56 message(FATAL_ERROR "Either install OpenCL or pass -DCL_INCLUDE_DIR and -DCL_LIB_DIR") 57endif(CL_INCLUDE_DIR AND CL_LIB_DIR) 58 59# CLConform_GL_LIBRARIES_DIR - path to OpenGL libraries 60if(GL_IS_SUPPORTED AND CLConform_GL_LIBRARIES_DIR) 61 link_directories(${CLConform_GL_LIBRARIES_DIR}) 62endif (GL_IS_SUPPORTED AND CLConform_GL_LIBRARIES_DIR) 63 64include(CheckFunctionExists) 65include(CheckIncludeFiles) 66include(CheckCXXCompilerFlag) 67 68if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)") 69 set(CLConform_TARGET_ARCH ARM) 70elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") 71 set(CLConform_TARGET_ARCH ARM64) 72elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") 73 set(CLConform_TARGET_ARCH x86_64) 74elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*") 75 set(CLConform_TARGET_ARCH x86) 76endif() 77 78if(NOT DEFINED CLConform_TARGET_ARCH) 79 message (FATAL_ERROR "Target architecture not recognised. Exiting.") 80endif() 81 82macro(add_cxx_flag_if_supported flag) 83 string(REGEX REPLACE "[-=+]" "" FLAG_NO_SIGNS ${flag}) 84 check_cxx_compiler_flag(${flag} COMPILER_SUPPORTS_${FLAG_NO_SIGNS}) 85 if(COMPILER_SUPPORTS_${FLAG_NO_SIGNS}) 86 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") 87 endif() 88endmacro(add_cxx_flag_if_supported) 89 90if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") 91 add_cxx_flag_if_supported(-Wmisleading-indentation) 92 add_cxx_flag_if_supported(-Wunused-variable) 93 add_cxx_flag_if_supported(-Wno-narrowing) 94 add_cxx_flag_if_supported(-Wno-format) 95 add_cxx_flag_if_supported(-Werror) 96 add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive 97 add_cxx_flag_if_supported(-Wno-error=unknown-pragmas) # Issue #785 98 add_cxx_flag_if_supported(-Wno-error=asm-operand-widths) # Issue #784 99 100 # -msse -mfpmath=sse to force gcc to use sse for float math, 101 # avoiding excess precision problems that cause tests like int2float 102 # to falsely fail. -ffloat-store also works, but WG suggested 103 # that sse would be better. 104 if(${CLConform_TARGET_ARCH} STREQUAL "x86_64" OR ${CLConform_TARGET_ARCH} 105 STREQUAL "x86") 106 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -mfpmath=sse") 107 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -mfpmath=sse") 108 109 add_cxx_flag_if_supported(-frounding-math) 110 endif() 111else() 112 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE__") 113 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__SSE__") 114endif() 115 116# Set a module's COMPILE_FLAGS if using gcc or clang. 117macro(set_gnulike_module_compile_flags flags) 118 if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") 119 SET_SOURCE_FILES_PROPERTIES( 120 ${${MODULE_NAME}_SOURCES} 121 PROPERTIES 122 COMPILE_FLAGS ${flags} 123 ) 124 endif() 125endmacro(set_gnulike_module_compile_flags) 126 127if(MSVC) 128 # Don't warn when using standard non-secure functions. 129 add_compile_definitions(_CRT_SECURE_NO_WARNINGS) 130 # Don't warn about using the portable "strdup" function. 131 add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE) 132 # Fix std::min and std::max handling with windows.harness. 133 add_compile_definitions(NOMINMAX) 134endif() 135 136if( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" ) 137 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qlong-double -Qpc80 /DWIN32 /D_WINDOWS /W3 /GR /EHsc -nologo -Od -D_CRT_NONSTDC_NO_WARNINGS -EHsc -Wall -Qdiag-disable:68,111,177,186,161,869,1028,2259,2553,181,239,265,1188 -fp:strict -fp:source") 138 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qlong-double -Qpc80 /DWIN32 /D_WINDOWS /W3 /GR /EHsc -nologo -Od -D_CRT_NONSTDC_NO_WARNINGS -EHsc -Wall -Qdiag-disable:68,111,177,186,161,869,1028,2259,2553,181,239,265,1188 -fp:strict -fp:source") 139endif() 140 141list(APPEND CLConform_LIBRARIES ${OPENCL_LIBRARIES}) 142if(ANDROID) 143 list(APPEND CLConform_LIBRARIES m) 144endif() 145if(NOT DEFINED LINK_PTHREAD) 146 if(ANDROID OR WIN32) 147 set(LINK_PTHREAD OFF) 148 else() 149 set(LINK_PTHREAD ON) 150 endif() 151endif() 152if(LINK_PTHREAD) 153 list(APPEND CLConform_LIBRARIES pthread) 154endif() 155 156if(APPLE) 157 find_library(corefoundation CoreFoundation) 158 find_library(iokit IOKit) 159 list(APPEND CLConform_LIBRARIES ${corefoundation}) 160 list(APPEND CLConform_LIBRARIES ${iokit}) 161endif(APPLE) 162 163include_directories(SYSTEM ${CL_INCLUDE_DIR}) 164include_directories(${CLConform_SOURCE_DIR}/test_common/harness 165 ${CLConform_SOURCE_DIR}/test_common/gles 166 ${CLConform_SOURCE_DIR}/test_common/gl 167 ${CLConform_SOURCE_DIR}/test_common) 168 169add_subdirectory(test_common) 170add_subdirectory(test_conformance) 171