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 13if(CMAKE_BUILD_TYPE STREQUAL "release") 14 set (BUILD_FLAVOR "release") 15else(CMAKE_BUILD_TYPE STREQUAL "release") 16 set (BUILD_FLAVOR "debug") 17endif(CMAKE_BUILD_TYPE STREQUAL "release") 18 19add_definitions(-DCL_TARGET_OPENCL_VERSION=300) 20add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_2_APIS=1) 21add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_1_APIS=1) 22add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_0_APIS=1) 23add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_2_APIS=1) 24add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS=1) 25add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_0_APIS=1) 26 27option(USE_CL_EXPERIMENTAL "Use Experimental definitions" OFF) 28if(USE_CL_EXPERIMENTAL) 29 add_definitions(-DCL_EXPERIMENTAL) 30endif(USE_CL_EXPERIMENTAL) 31 32# Support both VS2008 and VS2012. 33set(BUILD_DIR "$ENV{ADRENO_DRIVER}/build") 34if(MSVC90) 35 set(VS_BUILD_DIR "${BUILD_DIR}/vs2008") 36else(MSVC110) 37 set(VS_BUILD_DIR "${BUILD_DIR}/vs2012") 38endif(MSVC90) 39 40#----------------------------------------------------------- 41# Default Configurable Test Set 42#----------------------------------------------------------- 43option(D3D10_IS_SUPPORTED "Run DirectX 10 interop tests" OFF) 44option(D3D11_IS_SUPPORTED "Run DirectX 11 interop tests" OFF) 45option(GL_IS_SUPPORTED "Run OpenGL interop tests" OFF) 46option(GLES_IS_SUPPORTED "Run OpenGL ES interop tests" OFF) 47 48 49#----------------------------------------------------------- 50# Tests prefix and suffix 51#----------------------------------------------------------- 52# Set the prefix and suffix for the generated executables 53# For example, if you want the api executable to be test_conformance_api_12 54# Set prefix to "test_conformance_" and suffix to "_12" 55set(CONFORMANCE_PREFIX "test_" ) 56set(CONFORMANCE_SUFFIX "" ) 57 58#----------------------------------------------------------- 59# Vendor Customization 60#----------------------------------------------------------- 61#Vendor Customization File can be included here to provide a way to automatically 62#build driver as a dependency of the conformance tests, or other such CMake customization 63include(CMakeVendor.txt OPTIONAL) 64 65# CL_INCLUDE_DIR - path to dir with OpenCL headers 66if(CL_INCLUDE_DIR AND CL_LIB_DIR) 67 link_directories(${CL_LIB_DIR}) 68else(CL_INCLUDE_DIR AND CL_LIB_DIR) 69 message(STATUS "OpenCL hasn't been found!") 70 message(FATAL_ERROR "Either install OpenCL or pass -DCL_INCLUDE_DIR and -DCL_LIB_DIR") 71endif(CL_INCLUDE_DIR AND CL_LIB_DIR) 72 73# CLConform_GL_LIBRARIES_DIR - path to OpenGL libraries 74if(GL_IS_SUPPORTED AND CLConform_GL_LIBRARIES_DIR) 75 link_directories(${CLConform_GL_LIBRARIES_DIR}) 76endif (GL_IS_SUPPORTED AND CLConform_GL_LIBRARIES_DIR) 77 78include(CheckFunctionExists) 79include(CheckIncludeFiles) 80include(CheckCXXCompilerFlag) 81 82if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)") 83 set(CLConform_TARGET_ARCH ARM) 84elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*|arm64.*|ARM64.*)") 85 set(CLConform_TARGET_ARCH ARM64) 86elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*") 87 set(CLConform_TARGET_ARCH x86_64) 88elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*") 89 set(CLConform_TARGET_ARCH x86) 90endif() 91 92if(NOT DEFINED CLConform_TARGET_ARCH) 93 message (FATAL_ERROR "Target architecture not recognised. Exiting.") 94endif() 95 96macro(add_cxx_flag_if_supported flag) 97 string(REGEX REPLACE "[-=+]" "" FLAG_NO_SIGNS ${flag}) 98 check_cxx_compiler_flag(${flag} COMPILER_SUPPORTS_${FLAG_NO_SIGNS}) 99 if(COMPILER_SUPPORTS_${FLAG_NO_SIGNS}) 100 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") 101 endif() 102endmacro(add_cxx_flag_if_supported) 103 104if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") 105 add_cxx_flag_if_supported(-Wno-narrowing) 106 add_cxx_flag_if_supported(-Wno-format) 107 add_cxx_flag_if_supported(-Werror) 108 add_cxx_flag_if_supported(-Wno-error=cpp) # Allow #warning directive 109 add_cxx_flag_if_supported(-Wno-error=absolute-value) # Issue 783 110 add_cxx_flag_if_supported(-Wno-error=unknown-pragmas) # Issue #785 111 add_cxx_flag_if_supported(-Wno-error=asm-operand-widths) # Issue #784 112 add_cxx_flag_if_supported(-Wno-error=overflow) # Fixed by #699 113 114 # -msse -mfpmath=sse to force gcc to use sse for float math, 115 # avoiding excess precision problems that cause tests like int2float 116 # to falsely fail. -ffloat-store also works, but WG suggested 117 # that sse would be better. 118 if(${CLConform_TARGET_ARCH} STREQUAL "x86_64" OR ${CLConform_TARGET_ARCH} 119 STREQUAL "x86") 120 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -mfpmath=sse") 121 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -mfpmath=sse") 122 123 add_cxx_flag_if_supported(-frounding-math) 124 endif() 125else() 126 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D__SSE__") 127 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__SSE__") 128endif() 129 130if(MSVC) 131 # Don't warn when using standard non-secure functions. 132 add_compile_definitions(_CRT_SECURE_NO_WARNINGS) 133endif() 134 135if( WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" ) 136 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") 137 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") 138endif() 139 140list(APPEND CLConform_LIBRARIES ${OPENCL_LIBRARIES}) 141if(ANDROID) 142 list(APPEND CLConform_LIBRARIES m) 143endif() 144if(NOT DEFINED LINK_PTHREAD) 145 if(ANDROID OR WIN32) 146 set(LINK_PTHREAD OFF) 147 else() 148 set(LINK_PTHREAD ON) 149 endif() 150endif() 151if(LINK_PTHREAD) 152 list(APPEND CLConform_LIBRARIES pthread) 153endif() 154 155if(DEFINED USE_GLES3) 156 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLES3") 157endif() 158 159if(APPLE) 160 find_library(corefoundation CoreFoundation) 161 find_library(iokit IOKit) 162 list(APPEND CLConform_LIBRARIES ${corefoundation}) 163 list(APPEND CLConform_LIBRARIES ${iokit}) 164endif(APPLE) 165 166include_directories(SYSTEM ${CL_INCLUDE_DIR}) 167include_directories(${CLConform_SOURCE_DIR}/test_common/harness 168 ${CLConform_SOURCE_DIR}/test_common/gles 169 ${CLConform_SOURCE_DIR}/test_common/gl 170 ${CLConform_SOURCE_DIR}/test_common) 171 172if(CMAKE_BUILD_TYPE STREQUAL "release") 173 set (BUILD_FLAVOR "release") 174elseif (CMAKE_BUILD_TYPE STREQUAL "debug") 175 set (BUILD_FLAVOR "debug") 176endif(CMAKE_BUILD_TYPE STREQUAL "release") 177 178 179add_subdirectory(test_common) 180add_subdirectory(test_conformance) 181 182# Support both VS2008 and VS2012. 183set (DLL_FILES "${VS_BUILD_DIR}/Debug/*.dll") 184set (DST_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/") 185 186if (WIN32) 187 set (COPY "echo") 188 add_custom_target(COPY_DLL${CONFORMANCE_SUFFIX} ALL 189 COMMAND ${COPY} "${DLL_FILES}" "${DST_DIR}" 190 COMMENT "Copying dll files.. ") 191else (WIN32) 192 set (COPY cp) 193 add_custom_target(COPY_DLL${CONFORMANCE_SUFFIX}) 194endif(WIN32) 195 196set_property(TARGET COPY_DLL${CONFORMANCE_SUFFIX} PROPERTY FOLDER "CONFORMANCE${CONFORMANCE_SUFFIX}") 197 198if(WIN32) 199 add_custom_target( COPY_FILES${CONFORMANCE_SUFFIX} ALL 200 COMMAND ${COPY} ${DLL_FILES} ${DST_DIR} 201 COMMENT "Copying other files to output folder..." ) 202else(WIN32) 203 add_custom_target( COPY_FILES${CONFORMANCE_SUFFIX} ) 204endif(WIN32) 205 206set_property(TARGET COPY_FILES${CONFORMANCE_SUFFIX} PROPERTY FOLDER "CONFORMANCE${CONFORMANCE_SUFFIX}") 207