From 3001148ca9ac2078b3ad425fa3003da6c03b88c0 Mon Sep 17 00:00:00 2001 From: Pierre Moreau Date: Tue, 30 Apr 2019 16:20:20 +0200 Subject: [PATCH] cl21: CMake improvements (#236) * Do not append non-existing folder to CMAKE_MODULE_PATH Fixes #221 * Add use of deprecated OpenCL 1.2 and 2.1 APIs * Define CL_TARGET_OPENCL_VERSION to 210 Fixes #227 * Define cmake_minimum_required as first operation The CMake documentation mentions that > Call the cmake_minimum_required() command at the beginning of the > top-level CMakeLists.txt file even before calling the project() > command. It is important to establish version and policy settings > before invoking other commands whose behavior they may affect. * CMake: Match both AppleClang and Clang --- CMakeLists.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd93e421..454f0a1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,5 @@ +cmake_minimum_required(VERSION 3.1) + set( CONFORMANCE_SUFFIX "" ) set(CLConform_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) @@ -18,14 +20,13 @@ set(CLConform_VERSION "${CLConform_VERSION_MAJOR}.${CLConform_VERSION_MINOR}") set(CLConform_VERSION_FULL "${CLConform_VERSION}.${CLConform_VERSION_MICRO}${CLConform_VERSION_EXTRA}") -cmake_minimum_required(VERSION 3.1) +add_definitions(-DCL_TARGET_OPENCL_VERSION=210) +add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_1_APIS=1) add_definitions(-DCL_USE_DEPRECATED_OPENCL_2_0_APIS=1) +add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_2_APIS=1) add_definitions(-DCL_USE_DEPRECATED_OPENCL_1_1_APIS=1) -# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) - # Support both VS2008 and VS2012. set(BUILD_DIR "$ENV{ADRENO_DRIVER}/build") @@ -61,7 +62,7 @@ include(CMakeVendor.txt OPTIONAL) include(CheckFunctionExists) include(CheckIncludeFiles) -if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +if(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") # -msse -mfpmath=sse to force gcc to use sse for float math, # avoiding excess precision problems that cause tests like int2float # to falsely fail. -ffloat-store also works, but WG suggested @@ -79,7 +80,7 @@ else() endif() # Clang gives C++11 narrowing warnings so suppress these for now -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(Apple)?Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-narrowing") endif()