]> SALOME platform Git repositories - tools/configuration.git/commitdiff
Salome HOME
TBB detection process simplifying
authorrnv <rnv@opencascade.com>
Fri, 19 Jan 2018 07:40:27 +0000 (10:40 +0300)
committerrnv <rnv@opencascade.com>
Fri, 19 Jan 2018 07:40:27 +0000 (10:40 +0300)
cmake/FindTBB.cmake

index 0f4077fa798b28677d1c020810615c2085d21a1b..3e2266fcc344dac3ddfc3fe44628787301091771 100644 (file)
@@ -49,57 +49,54 @@ ENDIF(MACHINE_IS_64)
 
 include(CheckCXXSourceCompiles)
 
-FOREACH(_kernel cc4.1.0_libc2.4_kernel2.6.16.21 gcc4.4 gcc4.1)
-
-  FIND_LIBRARY(_tbb_library_tbb${_kernel}       NAMES tbb       PATH_SUFFIXES lib/${PLT_SUFFIX}/${_kernel})
-  FIND_LIBRARY(_tbb_library_tbbmalloc${_kernel} NAMES tbbmalloc PATH_SUFFIXES lib/${PLT_SUFFIX}/${_kernel})
-
-  SET(_tbb_libraries${_kernel} ${_tbb_library_tbb${_kernel}} ${_tbb_library_tbbmalloc${_kernel}})
-
-  IF(_tbb_libraries${_kernel})
-
-    SET(CMAKE_REQUIRED_INCLUDES_SAVE  ${CMAKE_REQUIRED_INCLUDES})
-    SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
-    SET(CMAKE_REQUIRED_INCLUDES  "${CMAKE_REQUIRED_INCLUDES} ${TBB_INCLUDE_DIRS}")
-    SET(CMAKE_REQUIRED_LIBRARIES "${_tbb_libraries${_kernel}}")
-
-    CHECK_CXX_SOURCE_COMPILES("
-      #include <tbb/tbb.h>
-      using namespace tbb;
-      size_t testme(size_t n)
-      {
-        return n*n;
-      }
-      int main(int argc, char* argv[])
-      {
-        parallel_for<size_t>( 1, 10, 1, testme );
-      }
-      "
-      _tbb_link_ok${_kernel}
-      )
+SET(_PATH_SUFFIXES)
+IF(TBB_ROOT_DIR)
+  FOREACH(_PATH cc4.1.0_libc2.4_kernel2.6.16.21 gcc4.4 gcc4.1)
+    LIST(APPEND _PATH_SUFFIXES ${PLT_SUFFIX}/${_PATH})
+  ENDFOREACH()
+ENDIF()
+
+FIND_LIBRARY(_tbb_library_tbb       
+             NAMES tbb   
+             PATH_SUFFIXES ${_PATH_SUFFIXES})
+FIND_LIBRARY(_tbb_library_tbbmalloc 
+             NAMES tbbmalloc 
+             PATH_SUFFIXES ${_PATH_SUFFIXES})
+
+SET(_tbb_libraries ${_tbb_library_tbb} ${_tbb_library_tbbmalloc})
+
+IF(_tbb_libraries)
+
+  SET(CMAKE_REQUIRED_INCLUDES_SAVE  ${CMAKE_REQUIRED_INCLUDES})
+  SET(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
+  SET(CMAKE_REQUIRED_INCLUDES  "${CMAKE_REQUIRED_INCLUDES} ${TBB_INCLUDE_DIRS}")
+  SET(CMAKE_REQUIRED_LIBRARIES "${_tbb_libraries}")
+
+  CHECK_CXX_SOURCE_COMPILES("
+    #include <tbb/tbb.h>
+    using namespace tbb;
+    size_t testme(size_t n)
+    {
+      return n*n;
+    }
+    int main(int argc, char* argv[])
+    {
+      parallel_for<size_t>( 1, 10, 1, testme );
+    }
+    "
+    _tbb_link_ok
+    )
     
-    SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
-    SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
-
-    IF(_tbb_link_ok${_kernel})
-      SET(_tbb_link_ok ${_tbb_link_ok${_kernel}})
-      SET(TBB_LIBRARY_tbb       ${_tbb_library_tbb${_kernel}}       CACHE FILEPATH "Path to a library")
-      SET(TBB_LIBRARY_tbbmalloc ${_tbb_library_tbbmalloc${_kernel}} CACHE FILEPATH "Path to a library")
-      SET(TBB_LIBRARIES ${TBB_LIBRARY_tbb} ${TBB_LIBRARY_tbbmalloc})
-    ENDIF()
-
-    UNSET(_tbb_link_ok${_kernel} CACHE)
-
-  ENDIF(_tbb_libraries${_kernel})
-
-  UNSET(_tbb_library_tbb${_kernel} CACHE)
-  UNSET(_tbb_library_tbbmalloc${_kernel} CACHE)
+  SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
+  SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
 
   IF(_tbb_link_ok)
-    BREAK()
+    SET(TBB_LIBRARY_tbb       ${_tbb_library_tbb}       CACHE FILEPATH "Path to a library")
+    SET(TBB_LIBRARY_tbbmalloc ${_tbb_library_tbbmalloc} CACHE FILEPATH "Path to a library")
+    SET(TBB_LIBRARIES ${TBB_LIBRARY_tbb} ${TBB_LIBRARY_tbbmalloc})
   ENDIF()
 
-ENDFOREACH()
+ENDIF(_tbb_libraries)
 
 INCLUDE(FindPackageHandleStandardArgs)
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(TBB REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARY_tbb TBB_LIBRARY_tbbmalloc)