[Beignet] [PATCH] Separate the building of CL and utest

junyan.he at inbox.com junyan.he at inbox.com
Wed Jul 31 03:40:10 PDT 2013


From: Junyan He <junyan.he at linux.intel.com>

Because the utest grows bigger, to save the building time, we
separate the building into two phrases.
The CMakeList.txt in top dir will just build the libCL.so, and
the CMakeList.txt in utests is responsible for building the utest.
One shortcoming is: because the CL and utest built separated,
the env variable can not be shared. So if in out-source building
mode, you may should install the libCL to the system dir before
the utest building.

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 CMake/FindOpenCL.cmake |   34 +++++++++++++++++++++++++++++++
 CMakeLists.txt         |    2 +-
 utests/CMakeLists.txt  |   52 +++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 86 insertions(+), 2 deletions(-)
 create mode 100644 CMake/FindOpenCL.cmake

diff --git a/CMake/FindOpenCL.cmake b/CMake/FindOpenCL.cmake
new file mode 100644
index 0000000..8923c19
--- /dev/null
+++ b/CMake/FindOpenCL.cmake
@@ -0,0 +1,34 @@
+# Try to find OpenCL library and include path.
+# This logic here may be seperated into a .cmake file and
+# install to the sys's share with OpenCL lib build and install
+FIND_PATH(OPENCL_INCLUDE_PATH CL/cl.h
+    ${CL_INC_PATH}
+    ~/include/
+    /usr/include/
+    /usr/local/include/
+    /sw/include/
+    /opt/local/include/
+    DOC "The directory where OpenCL headerfile resides")
+
+FIND_LIBRARY(OPENCL_LIBRARIES
+    NAMES cl CL
+    PATHS
+    ${CL_LIB_BUILD_PATH}
+    ~/lib/
+    /usr/lib64
+    /usr/lib
+    /usr/local/lib64
+    /usr/local/lib
+    /sw/lib
+    /opt/local/lib
+    DOC "The OpenCL library")
+
+# If found, add the header path
+IF (OPENCL_INCLUDE_PATH)
+    SET (OPENCL_FOUND 1 CACHE STRING "Set to 1 if CL is found, 0 otherwise")
+ELSE (OPENCL_INCLUDE_PATH)
+    SET (OPENCL_FOUND 0 CACHE STRING "Set to 1 if CL is found, 0 otherwise")
+ENDIF (OPENCL_INCLUDE_PATH)
+
+MARK_AS_ADVANCED(OPENCL_FOUND)
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb56567..aba1696 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,5 +144,5 @@ Find_Package(PythonInterp)
 ADD_SUBDIRECTORY(include)
 ADD_SUBDIRECTORY(backend)
 ADD_SUBDIRECTORY(src)
-ADD_SUBDIRECTORY(utests)
+#ADD_SUBDIRECTORY(utests)
 
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index 5cd20c3..d3579b3 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -1,3 +1,53 @@
+#############################################################################
+#                  INTEL CORPORATION PROPRIETARY INFORMATION                #
+#     This software is supplied under the terms of a license agreement or   #
+#     nondisclosure agreement with Intel Corporation and may not be copied  #
+#     or disclosed except in accordance with the terms of that agreement.   #
+#          Copyright (C) 2009 Intel Corporation. All Rights Reserved.       #
+#############################################################################
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
+PROJECT(OCL_TEST)
+
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../CMake/")
+
+#Just assume the lib cl is built using in-source mode, if built in out-source mode,
+#you must make install before building the utest
+SET(CL_LIB_BUILD_PATH "${CMAKE_SOURCE_DIR}/../src/")
+SET(CL_INC_PATH "${CMAKE_SOURCE_DIR}/../include/")
+
+MESSAGE(STATUS "SOURCE dir is " ${OCL_TEST_SOURCE_DIR})
+MESSAGE(STATUS "BINARY dir is " ${OCL_TEST_BINARY_DIR})
+
+SET(CMAKE_VERBOSE_MAKEFILE "false")
+
+# Force Release with debug info
+IF (NOT CMAKE_BUILD_TYPE)
+    SET (CMAKE_BUILD_TYPE RelWithDebInfo)
+ENDIF (NOT CMAKE_BUILD_TYPE)
+
+SET (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "assure config" FORCE)
+MESSAGE(STATUS "Building mode: " ${CMAKE_BUILD_TYPE})
+
+# Set the c and c++ flags
+SET(CMAKE_CXX_FLAGS_DEBUGO0 "-O0 -g")
+SET(CMAKE_C_FLAGS_DEBUGO0 "-O0 -g")
+SET(CMAKE_CXX_FLAGS "-Wall -Wno-invalid-offsetof -mfpmath=sse --no-rtti -Wcast-align -std=c++0x -msse2 -msse3 -mssse3 -msse4.1 ")
+SET(CMAKE_C_FLAGS "-Wall -mfpmath=sse -msse2 -Wcast-align -msse2 -msse3 -mssse3 -msse4.1 ")
+
+# OpenGL lib
+Find_Package(OpenGL)
+# OpenCL lib
+
+Find_Package(OpenCL)
+
+IF(OPENCL_FOUND)
+    INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_PATH})
+ELSE(OPENCL_FOUND)
+    MESSAGE(FATAL_ERROR "Can not find the OpenCL")
+ENDIF(OPENCL_FOUND)
+
+
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
                     ${CMAKE_CURRENT_SOURCE_DIR}/../include)
 
@@ -132,7 +182,7 @@ endif (EGL_FOUND)
 
 ADD_LIBRARY(utests SHARED ${utests_sources})
 
-TARGET_LINK_LIBRARIES(utests cl m ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+TARGET_LINK_LIBRARIES(utests ${OPENCL_LIBRARIES} m ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
 
 ADD_EXECUTABLE(utest_run utest_run.cpp)
 TARGET_LINK_LIBRARIES(utest_run utests)
-- 
1.7.9.5



More information about the Beignet mailing list