0024153: Adding OpenCL to OCCT prerequisites
authoribs <ibs@opencascade.com>
Thu, 31 Oct 2013 11:43:38 +0000 (15:43 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 31 Oct 2013 14:02:13 +0000 (18:02 +0400)
OpenCL is supported by CMake OCCT solution
3rdparty directory is changed to <occt root>
3rdparty seeking in additional places if 3rdparty dir isn't defined

CMakeLists.txt

index 9764bd5..8184967 100644 (file)
@@ -189,7 +189,7 @@ ELSE()
   SET(DLL_SO_PREFIX "lib")
 ENDIF()
 
-SET(3RDPARTY_DIR "" CACHE PATH "Directory contains required 3rdparty products")
+SET(3RDPARTY_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory contains required 3rdparty products")
 SET(3RDPARTY_INCLUDE_DIRS "")
 SET(3RDPARTY_NOT_INCLUDED)
 
@@ -200,6 +200,7 @@ ENDIF()
 SET(3RDPARTY_USE_GL2PS OFF CACHE BOOL "whether use gl2ps product or not")
 SET(3RDPARTY_USE_FREEIMAGE OFF CACHE BOOL "whether use freeimage product or not")
 SET(3RDPARTY_USE_TBB OFF CACHE BOOL "whether use tbb product or not")
+SET(3RDPARTY_USE_OPENCL OFF CACHE BOOL "whether use OpenCL or not")
 
 SET(INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
 
@@ -223,32 +224,39 @@ MACRO(THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME)
     IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
       SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
       FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/include" NO_DEFAULT_PATH)
-      
-      IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
-        FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME})
-      ENDIF()
-      
     ENDIF()
     
     IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
       SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Directory contains library of the ${PRODUCT_NAME} product" FORCE)
       FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME}  PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/lib" NO_DEFAULT_PATH)
-      
-      # check default path for library search
-      IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
-        FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME})
-      ENDIF()
     ENDIF()
     
     IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
       SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Directory contains shared library of the ${PRODUCT_NAME} product" FORCE)
       FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}"  PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/${DLL_SO_FOLDER}" NO_DEFAULT_PATH)
-      
-      IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
-        FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}")
-      ENDIF()
     ENDIF()
+    
     MARK_AS_ADVANCED(3RDPARTY_${PRODUCT_NAME}_DIR)
+  ELSE()
+  
+  ENDIF()
+  
+  # check default path (with additions) for header search
+  IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
+    SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
+    FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_HEADER})
+  ENDIF()
+
+  # check default path (with additions) for library search
+  IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
+    SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Directory contains library of the ${PRODUCT_NAME} product" FORCE)
+    FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_LIB})
+  ENDIF()
+
+  # check default path (with additions) for DLL search
+  IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
+    SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Directory contains shared library of the ${PRODUCT_NAME} product" FORCE)
+    FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}" ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_DLL})
   ENDIF()
 
   IF(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
@@ -361,6 +369,36 @@ IF(3RDPARTY_USE_GL2PS)
   THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps${BUILD_SUFFIX}")
 ENDIF()
 
+# OPENCL
+IF(3RDPARTY_USE_OPENCL)
+  ADD_DEFINITIONS(-DHAVE_OPENCL) 
+  
+  SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER $ENV{AMDAPPSDKROOT}/include
+                                                  $ENV{INTELOCLSDKROOT}/include
+                                                  $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc
+                                                  $ENV{ATISTREAMSDKROOT}/include)
+                                                  
+                                                  
+  IF(${COMPILER_BITNESS} STREQUAL 32)
+    SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86
+                                                 $ENV{INTELOCLSDKROOT}/lib/x86
+                                                 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32
+                                                 $ENV{ATISTREAMSDKROOT}/lib/x86)
+  ELSEIF(${COMPILER_BITNESS} STREQUAL 64)
+    SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86_64
+                                                 $ENV{INTELOCLSDKROOT}/lib/x64
+                                                 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64
+                                                 $ENV{ATISTREAMSDKROOT}/lib/x86_64)
+  ENDIF()
+  
+  THIRDPARTY_PRODUCT("OPENCL" "CL/cl.h" "OpenCL${BUILD_SUFFIX}")
+  
+  # if CL/cl.h isn't found (and 3RDPARTY_OPENCL_INCLUDE_DIR isn't defined) 
+  # then try to find OpenCL/cl.h (all other variable won't be changed)
+  THIRDPARTY_PRODUCT("OPENCL" "OpenCL/cl.h" "OpenCL${BUILD_SUFFIX}")
+ENDIF()
+
 # TBB
 IF (3RDPARTY_USE_TBB)
   ADD_DEFINITIONS(-DHAVE_TBB)