0026903: Configuration, CMake - 3rdparty search algorithms should have the same logic
authoribs <ibs@opencascade.com>
Mon, 16 Nov 2015 11:05:54 +0000 (14:05 +0300)
committerbugmaster <bugmaster@opencascade.com>
Mon, 23 Nov 2015 10:40:43 +0000 (13:40 +0300)
the search algorithms fitted with one logic.

3rdparty_dir is not specified by-default
3rdparty_<name>_dir has higher priority than 3rdparty_dir

frameworks are considered on Mac OS;

CMake - continue method (cmake version >= 3.2) removed

vtk installation disabled

Mac OS X - link /usr/X11/lib if X11 library is linked

FILES parsing optimized

search X11 package for every time when it used on MAC

CSF_XwLibs used by a toolkit using Tk

break a package processing if all the files from FILES file have been processed

17 files changed:
CMakeLists.txt
adm/cmake/3rdparty_macro.cmake
adm/cmake/freetype.cmake
adm/cmake/occt_csf.cmake
adm/cmake/occt_defs_flags.cmake
adm/cmake/occt_macros.cmake
adm/cmake/occt_toolkit.cmake
adm/cmake/tbb.cmake
adm/cmake/tcl.cmake
adm/cmake/vardescr.cmake
adm/cmake/vtk.cmake
src/TKD3DHost/EXTERNLIB
src/TKDraw/EXTERNLIB
src/TKIVtkDraw/EXTERNLIB
src/TKOpenGl/EXTERNLIB
src/TKV3d/EXTERNLIB
src/TKViewerTest/EXTERNLIB

index 32d6bd1..6be9ffc 100644 (file)
@@ -86,6 +86,11 @@ foreach (OCCT_MODULE ${OCCT_MODULES})
   BUILD_MODULE (${OCCT_MODULE})
 endforeach()
 
+if (ANDROID AND BUILD_MODULE_Draw)
+  message (STATUS "Info. Draw module is turned off due to it is not supported on Android")
+  set (BUILD_MODULE_Draw OFF CACHE BOOL "${BUILD_MODULE_Draw_DESCR}" FORCE)
+endif()
+
 # Overview
 set (BUILD_DOC_OcctOverview OFF CACHE BOOL "${BUILD_DOC_OcctOverview_DESCR}")
 
@@ -141,17 +146,7 @@ endif()
 
 if (NOT DEFINED 3RDPARTY_DIR)
   set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_DESCR})
-endif()
-
-# search for 3rdparty dir
-if ("${3RDPARTY_DIR}" STREQUAL "")
-  if (DEFINED ENV{3RDPARTY_DIR})
-    set (3RDPARTY_DIR "$ENV{3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_DESCR} FORCE)
-  elseif (EXISTS "${CMAKE_SOURCE_DIR}/../")
-    # in version 6.7.0 and above, occt parent directory contains 3rdparties
-    get_filename_component (3RDPARTY_DIR "${CMAKE_SOURCE_DIR}/../" ABSOLUTE)
-    set (3RDPARTY_DIR "${3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_DESCR} FORCE)
-  endif()
+  get_filename_component (3RDPARTY_DIR "${3RDPARTY_DIR}" ABSOLUTE)
 endif()
 
 # search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
@@ -190,7 +185,7 @@ if (USE_VTK)
   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
 else()
   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
-  OCCT_CHECK_AND_UNSET ("INSTALL_VTK")
+  #OCCT_CHECK_AND_UNSET ("INSTALL_VTK")
 endif()
 
 # D3D
index 577ddbd..50eaef3 100644 (file)
-#
+##
 
-# include occt macros. compiler_bitness, os_wiht_bit, compiler
-OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
+if(3RDPARTY_MACRO_ALREADY_INCLUDED)
+  return()
+endif()
+set(3RDPARTY_MACRO_ALREADY_INCLUDED 1)
 
-macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME LIBRARY_NAME_DEBUG)
-
-  # define 3RDPARTY_${PRODUCT_NAME}_DIR variable is it isn't defined
-  if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DIR)
-    set (3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME}")
-  endif()
 
-  # search for product directory inside 3RDPARTY_DIR directory
-  if (NOT 3RDPARTY_${PRODUCT_NAME}_DIR AND 3RDPARTY_DIR)
-    FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" "${PRODUCT_NAME}" ${PRODUCT_NAME}_DIR_NAME)
-    if (${PRODUCT_NAME}_DIR_NAME)
-      message (STATUS "Info: ${PRODUCT_NAME}: ${${PRODUCT_NAME}_DIR_NAME} folder is used")
-      set (3RDPARTY_${PRODUCT_NAME}_DIR "${3RDPARTY_DIR}/${${PRODUCT_NAME}_DIR_NAME}" CACHE PATH "The directory containing ${PRODUCT_NAME}" FORCE)
-    endif()
-  endif()
+macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME LIBRARY_NAME_DEBUG)
 
   if (NOT DEFINED INSTALL_${PRODUCT_NAME})
-    message (STATUS "${INSTALL_${PRODUCT_NAME}_DESCR}")
-    if (NOT "${INSTALL_${PRODUCT_NAME}_DESCR}" STREQUAL "")
-      set (INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "${INSTALL_${PRODUCT_NAME}_DESCR}")
-    else()
-      set (INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "Is ${PRODUCT_NAME} required to be copied into install directory")
-    endif()
+    set (INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "${INSTALL_${PRODUCT_NAME}_DESCR}")
   endif()
 
-  # search for include directory
-  if (NOT 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
-    set (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "The directory containing the headers of the ${PRODUCT_NAME}" FORCE)
-    find_path (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} PATHS
-                                                                    "${3RDPARTY_${PRODUCT_NAME}_DIR}/include"
-                                                                    ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_HEADER}
-                                                                   NO_DEFAULT_PATH)
-    find_path (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME})
+  if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DIR)
+    set (3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME}")
   endif()
 
-  if (NOT 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
-    set (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "" CACHE FILEPATH "The directory containing the headers of the ${PRODUCT_NAME}" FORCE)
-  endif()
+  # include occt macros. compiler_bitness, os_wiht_bit, compiler
+  OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
 
-  if (NOT 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR)
-    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY "" CACHE FILEPATH "${PRODUCT_NAME} library" FORCE)
-  elseif (3RDPARTY_${PRODUCT_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
-    get_filename_component(3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR_TMP "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
-    if (NOT "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}" STREQUAL "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR_TMP}")
-      set (3RDPARTY_${PRODUCT_NAME}_LIBRARY "" CACHE FILEPATH "${PRODUCT_NAME} library" FORCE)
+  # specify product folder in connectin with 3RDPARTY_DIR
+  if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}")
+    #CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_DIR 3RDPARTY_${PRODUCT_NAME}_DIR PATH "The directory containing ${PRODUCT_NAME}")
+
+    if (NOT 3RDPARTY_${PRODUCT_NAME}_DIR OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_DIR}")
+      FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" ${PRODUCT_NAME} ${PRODUCT_NAME}_DIR_NAME)
+      if (${PRODUCT_NAME}_DIR_NAME)
+        set (3RDPARTY_${PRODUCT_NAME}_DIR "${3RDPARTY_DIR}/${${PRODUCT_NAME}_DIR_NAME}" CACHE PATH "The directory containing ${PRODUCT_NAME}" FORCE)
+      endif()
     endif()
+  else()
+    #set (3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME}" FORCE)
   endif()
 
-  # search for library
-  if (NOT 3RDPARTY_${PRODUCT_NAME}_LIBRARY OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
-    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "${PRODUCT_NAME} library" FORCE)
+  if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
+    set (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR           "" CACHE PATH "the path of ${HEADER_NAME}")
+  endif()
 
-    find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME} PATHS
-                                                                   "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}"
-                                                                   "${3RDPARTY_${PRODUCT_NAME}_DIR}/lib"
-                                                                   ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_LIB}
-                                                                   NO_DEFAULT_PATH)
-    # second search if previous one do not find anything
-    find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME})
+  if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_LIBRARY OR NOT 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY               "" CACHE FILEPATH "${PRODUCT_NAME} library" FORCE)
   endif()
 
   if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR)
-    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "" CACHE FILEPATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR           "" CACHE PATH "The directory containing ${PRODUCT_NAME} library")
   endif()
 
-  # library path
-  if (3RDPARTY_${PRODUCT_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
-    get_filename_component (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
-    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}" CACHE FILEPATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+  if (WIN32)
+    if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DLL OR NOT 3RDPARTY_${PRODUCT_NAME}_DLL_DIR OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}")
+      set (3RDPARTY_${PRODUCT_NAME}_DLL                 "" CACHE FILEPATH "${PRODUCT_NAME} shared library" FORCE)
+    endif()
   endif()
 
-  # search for shared library (just for win case)
   if (WIN32)
-    set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
-
-    if (NOT 3RDPARTY_${PRODUCT_NAME}_DLL_DIR)
-      set (3RDPARTY_${PRODUCT_NAME}_DLL "" CACHE FILEPATH "${PRODUCT_NAME} shared library" FORCE)
-    elseif (3RDPARTY_${PRODUCT_NAME}_DLL AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
-      get_filename_component(3RDPARTY_${PRODUCT_NAME}_DLL_DIR_TMP "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
-      if (NOT "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}" STREQUAL "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR_TMP}")
-        set (3RDPARTY_${PRODUCT_NAME}_DLL "" CACHE FILEPATH "${PRODUCT_NAME} shared library" FORCE)
-      endif()
+    if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DLL_DIR)
+      set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR             "" CACHE PATH "The directory containing ${PRODUCT_NAME} shared library")
     endif()
+  endif()
 
-    if (NOT 3RDPARTY_${PRODUCT_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
-      set (3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "${PRODUCT_NAME} shared library" FORCE)
-
-      find_library (3RDPARTY_${PRODUCT_NAME}_DLL "${LIBRARY_NAME}" PATHS
-                                                                   "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}"
-                                                                   "${3RDPARTY_${PRODUCT_NAME}_DIR}/bin"
-                                                                   ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_DLL}
-                                                                   NO_DEFAULT_PATH)
+  # check 3RDPARTY_${PRODUCT_NAME}_ paths for consistency with specified 3RDPARTY_${PRODUCT_NAME}_DIR
+  if (3RDPARTY_${PRODUCT_NAME}_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DIR}")
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_${PRODUCT_NAME}_DIR 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR PATH "the path to ${PRODUCT_NAME}")
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_${PRODUCT_NAME}_DIR 3RDPARTY_${PRODUCT_NAME}_LIBRARY FILEPATH "the path to ${PRODUCT_NAME} library")
 
-        # second search if previous one do not find anything
-        find_library (3RDPARTY_${PRODUCT_NAME}_DLL "${LIBRARY_NAME}")
+    if (3RDPARTY_${PRODUCT_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
+      get_filename_component (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
+      set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}" CACHE PATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+    else()
+      CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_${PRODUCT_NAME}_DIR 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR PATH "The directory containing ${PRODUCT_NAME} library")
     endif()
 
-    if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DLL_DIR)
-      set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "" CACHE FILEPATH "The directory containing ${PRODUCT_NAME} shared library" FORCE)
+    if (WIN32)
+      CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_${PRODUCT_NAME}_DIR 3RDPARTY_${PRODUCT_NAME}_DLL FILEPATH "the path to ${PRODUCT_NAME} shared library")
+
+      if (3RDPARTY_${PRODUCT_NAME}_DLL AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+        get_filename_component (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
+        set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}" CACHE PATH "The directory containing ${PRODUCT_NAME} shared library" FORCE)
+      else()
+      
+      CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_${PRODUCT_NAME}_DIR 3RDPARTY_${PRODUCT_NAME}_DLL_DIR PATH "The directory containing ${PRODUCT_NAME} shared library")
+      endif()
     endif()
+  endif()
 
-    # shared library path
-    if (3RDPARTY_${PRODUCT_NAME}_DLL AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
-      get_filename_component (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
-      set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}" CACHE FILEPATH "The directory containing ${PRODUCT_NAME} shared library" FORCE)
+  # header
+  if (NOT 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
+
+    # set 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR as notfound, otherwise find_library can't assign a new value to 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR
+    set (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "the path to ${HEADER_NAME}" FORCE)
+
+    if (3RDPARTY_${PRODUCT_NAME}_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DIR}")
+      find_path (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR NAMES ${HEADER_NAME}
+                                                      PATHS ${3RDPARTY_${PRODUCT_NAME}_DIR}
+                                                      PATH_SUFFIXES include
+                                                      CMAKE_FIND_ROOT_PATH_BOTH
+                                                      NO_DEFAULT_PATH)
+    else()
+      find_path (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR NAMES ${HEADER_NAME}
+                                                      PATH_SUFFIXES include
+                                                      CMAKE_FIND_ROOT_PATH_BOTH)
     endif()
   endif()
 
@@ -115,16 +105,79 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME LIBRARY_NAME_DEB
     list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
   else()
     list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
+
+    set (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "" CACHE FILEPATH "The path to ${HEADER_NAME}" FORCE)
+  endif()
+
+  # library
+  if (NOT 3RDPARTY_${PRODUCT_NAME}_LIBRARY OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
+    set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib)
+
+    set (${PRODUCT_NAME}_PATH_SUFFIXES lib)
+    if (ANDROID)
+      set (${PRODUCT_NAME}_PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES} libs/${ANDROID_ABI})
+    endif()
+
+    # set 3RDPARTY_${PRODUCT_NAME}_LIBRARY as notfound, otherwise find_library can't assign a new value to 3RDPARTY_${PRODUCT_NAME}_LIBRARY
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "The path to ${PRODUCT_NAME} library" FORCE)
+
+    if (3RDPARTY_${PRODUCT_NAME}_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DIR}")
+      find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY NAMES ${LIBRARY_NAME}
+                                                     PATHS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}" "${3RDPARTY_${PRODUCT_NAME}_DIR}"
+                                                     PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES}
+                                                     CMAKE_FIND_ROOT_PATH_BOTH
+                                                     NO_DEFAULT_PATH)
+    else()
+      find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY NAMES ${LIBRARY_NAME} 
+                                                     PATH_SUFFIXES ${${PRODUCT_NAME}_PATH_SUFFIXES}
+                                                     CMAKE_FIND_ROOT_PATH_BOTH)
+    endif()
+
+    if (3RDPARTY_${PRODUCT_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
+      get_filename_component (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
+      set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}" CACHE PATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+    else()
+      set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+    endif()
   endif()
 
-  if (3RDPARTY_${PRODUCT_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
+  if (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
     list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
   else()
     list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR)
+
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY "" CACHE FILEPATH "The path to ${PRODUCT_NAME} library" FORCE)
   endif()
 
+  # shared library
   if (WIN32)
-    if (3RDPARTY_${PRODUCT_NAME}_DLL OR EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+    if (NOT 3RDPARTY_${PRODUCT_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+      
+      set (CMAKE_FIND_LIBRARY_SUFFIXES .dll)
+
+      # set 3RDPARTY_${PRODUCT_NAME}_DLL as notfound, otherwise find_library can't assign a new value to 3RDPARTY_${PRODUCT_NAME}_DLL
+      set (3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "The path to ${PRODUCT_NAME} shared library" FORCE)
+
+      if (3RDPARTY_${PRODUCT_NAME}_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DIR}")
+        find_library (3RDPARTY_${PRODUCT_NAME}_DLL  NAMES ${LIBRARY_NAME}
+                                                    PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}"
+                                                    PATH_SUFFIXES bin
+                                                    NO_DEFAULT_PATH)
+      else()
+        find_library (3RDPARTY_${PRODUCT_NAME}_DLL NAMES ${LIBRARY_NAME} PATH_SUFFIXES bin)
+      endif()
+
+      if (3RDPARTY_${PRODUCT_NAME}_DLL AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+        get_filename_component (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
+        set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}" CACHE PATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+      else()
+        set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME} shared library" FORCE)
+
+        set (3RDPARTY_${PRODUCT_NAME}_DLL "" CACHE FILEPATH "${PRODUCT_NAME} shared library" FORCE)
+      endif()
+    endif()
+
+    if (3RDPARTY_${PRODUCT_NAME}_DLL_DIR OR EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}")
       list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}")
     else()
       list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL_DIR)
index 0d73251..af81501 100644 (file)
@@ -8,29 +8,27 @@ if (NOT DEFINED 3RDPARTY_FREETYPE_DIR)
   set (3RDPARTY_FREETYPE_DIR "" CACHE PATH "The directory containing freetype")
 endif()
 
-# store ENV{FREETYPE_DIR}
-SET (CACHED_FREETYPE_DIR $ENV{FREETYPE_DIR})
-
 # include occt macros. compiler_bitness, os_wiht_bit, compiler
 OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
 
 OCCT_MAKE_COMPILER_SHORT_NAME()
 OCCT_MAKE_COMPILER_BITNESS()
 
-if (NOT ENV{FREETYPE_DIR})
-  # search for freetype in user defined directory
-  if (NOT 3RDPARTY_FREETYPE_DIR AND 3RDPARTY_DIR)
-    FIND_PRODUCT_DIR("${3RDPARTY_DIR}" FREETYPE FREETYPE_DIR_NAME)
+# specify freetype folder in connectin with 3RDPARTY_DIR
+if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}")
+  #CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_DIR 3RDPARTY_FREETYPE_DIR PATH "The directory containing freetype")
+
+  if (NOT 3RDPARTY_FREETYPE_DIR OR NOT EXISTS "${3RDPARTY_FREETYPE_DIR}")
+    FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" FREETYPE FREETYPE_DIR_NAME)
     if (FREETYPE_DIR_NAME)
       set (3RDPARTY_FREETYPE_DIR "${3RDPARTY_DIR}/${FREETYPE_DIR_NAME}" CACHE PATH "The directory containing freetype" FORCE)
     endif()
   endif()
-
-  if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
-    set (ENV{FREETYPE_DIR} "${3RDPARTY_FREETYPE_DIR}")
-  endif()
+else()
+  #set (3RDPARTY_FREETYPE_DIR "" CACHE PATH "The directory containing freetype" FORCE)
 endif()
 
+# define required freetype variables
 if (NOT DEFINED 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build)
   set (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build  "" CACHE FILEPATH "the path of ft2build.h")
 endif()
@@ -39,173 +37,257 @@ if (NOT DEFINED 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2)
   set (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 "" CACHE FILEPATH "the path of freetype2")
 endif()
 
-if (NOT DEFINED 3RDPARTY_FREETYPE_LIBRARY OR NOT 3RDPARTY_FREETYPE_LIBRARY_DIR)
-  set (3RDPARTY_FREETYPE_LIBRARY               "" CACHE FILEPATH "freetype library")
+if (NOT DEFINED 3RDPARTY_FREETYPE_LIBRARY OR NOT 3RDPARTY_FREETYPE_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_FREETYPE_LIBRARY_DIR}")
+  set (3RDPARTY_FREETYPE_LIBRARY               "" CACHE FILEPATH "freetype library" FORCE)
 endif()
 
 if (NOT DEFINED 3RDPARTY_FREETYPE_LIBRARY_DIR)
-  set (3RDPARTY_FREETYPE_LIBRARY_DIR           "" CACHE FILEPATH "The directory containing freetype library")
+  set (3RDPARTY_FREETYPE_LIBRARY_DIR           "" CACHE PATH "The directory containing freetype library")
 endif()
 
 if (WIN32)
-  if (NOT DEFINED 3RDPARTY_FREETYPE_DLL OR NOT 3RDPARTY_FREETYPE_DLL_DIR)
-    set (3RDPARTY_FREETYPE_DLL                   "" CACHE FILEPATH "freetype shared library")
+  if (NOT DEFINED 3RDPARTY_FREETYPE_DLL OR NOT 3RDPARTY_FREETYPE_DLL_DIR OR NOT EXISTS "${3RDPARTY_FREETYPE_DLL_DIR}")
+    set (3RDPARTY_FREETYPE_DLL                 "" CACHE FILEPATH "freetype shared library" FORCE)
   endif()
 endif()
 
 if (WIN32)
   if (NOT DEFINED 3RDPARTY_FREETYPE_DLL_DIR)
-    set (3RDPARTY_FREETYPE_DLL_DIR               "" CACHE FILEPATH "The directory containing freetype shared library")
+    set (3RDPARTY_FREETYPE_DLL_DIR               "" CACHE PATH "The directory containing freetype shared library")
   endif()
 endif()
 
-find_package(Freetype)
+# check 3RDPARTY_FREETYPE_ paths for consistency with specified 3RDPARTY_FREETYPE_DIR
+if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
+  CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build FILEPATH "the path to ft2build.h")
+  CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 FILEPATH "the path to ftheader.h")
+  CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR 3RDPARTY_FREETYPE_LIBRARY FILEPATH "the path to freetype library")
 
-# ft2build header
-if (FREETYPE_INCLUDE_DIR_ft2build AND EXISTS "${FREETYPE_INCLUDE_DIR_ft2build}")
-  if (NOT 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build)
-    set (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build  "${FREETYPE_INCLUDE_DIR_ft2build}" CACHE FILEPATH "the path of ft2build.h" FORCE)
+  if (3RDPARTY_FREETYPE_LIBRARY AND EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")
+    get_filename_component (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY}" PATH)
+    set (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY_DIR}" CACHE PATH "The directory containing freetype library" FORCE)
+  else()
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR 3RDPARTY_FREETYPE_LIBRARY_DIR PATH "The directory containing freetype library")
   endif()
-endif()
 
-if (NOT FREETYPE_INCLUDE_DIR_freetype2 OR NOT EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}")
-  # cmake (version is < 3.0) doesn't find ftheader.h of freetype (version is >= 2.5.1)
-  # do search taking into account freetype structure of 2.5.1 version
-  find_path (FREETYPE_INCLUDE_DIR_freetype2 NAMES
-                                             freetype/config/ftheader.h
-                                             config/ftheader.h
-                                           HINTS
-                                             ENV FREETYPE_DIR
-                                           PATHS
-                                             /usr/X11R6
-                                             /usr/local/X11R6
-                                             /usr/local/X11
-                                             /usr/freeware
-                                           PATH_SUFFIXES include/freetype2 include freetype2
-                                           NO_DEFAULT_PATH)
-  find_path (FREETYPE_INCLUDE_DIR_freetype2 NAMES freetype/config/ftheader.h config/ftheader.h)
-elseif (FREETYPE_INCLUDE_DIR_freetype2 OR EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}")
-  if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
-    get_filename_component (3RDPARTY_FREETYPE_DIR_ABS "${3RDPARTY_FREETYPE_DIR}" ABSOLUTE)
-    get_filename_component (FREETYPE_INCLUDE_DIR_freetype2_ABS "${FREETYPE_INCLUDE_DIR_freetype2}" ABSOLUTE)
-
-    string (REGEX MATCH "${3RDPARTY_FREETYPE_DIR_ABS}" DOES_PATH_CONTAIN "${FREETYPE_INCLUDE_DIR_freetype2_ABS}")
-
-    if (NOT DOES_PATH_CONTAIN) # if cmake found freetype2 at different place from 3RDPARTY_FREETYPE_DIR
-      # search for freetype2 in 3RDPARTY_FREETYPE_DIR and if it will be found - replace freetyp2 path by new one
-      set (TMP_FREETYPE2 "TMP_FREETYPE2-NOTFOUND" CACHE FILEPATH "" FORCE)
-      find_path (TMP_FREETYPE2 NAMES freetype/config/ftheader.h config/ftheader.h
-                               PATHS "${3RDPARTY_FREETYPE_DIR}"
-                               PATH_SUFFIXES include/freetype2 include freetype2
-                               NO_DEFAULT_PATH)
-
-      if (TMP_FREETYPE2 OR NOT EXISTS "${TMP_FREETYPE2}")
-        set (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 "${TMP_FREETYPE2}" CACHE FILEPATH "the path of freetype2" FORCE)
-
-        # hide and remove TMP_FREETYPE2
-        mark_as_advanced (TMP_FREETYPE2)
-        unset (TMP_FREETYPE2)
-      endif()
+  if (WIN32)
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR 3RDPARTY_FREETYPE_DLL FILEPATH "the path to freetype shared library")
+
+    if (3RDPARTY_FREETYPE_DLL AND EXISTS "${3RDPARTY_FREETYPE_DLL}")
+      get_filename_component (3RDPARTY_FREETYPE_DLL_DIR "${3RDPARTY_FREETYPE_DLL}" PATH)
+      set (3RDPARTY_FREETYPE_DLL_DIR "${3RDPARTY_FREETYPE_DLL_DIR}" CACHE PATH "The directory containing freetype shared library" FORCE)
+    else()
+    
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR 3RDPARTY_FREETYPE_DLL_DIR PATH "The directory containing freetype shared library")
     endif()
   endif()
 endif()
 
-# return ENV{FREETYPE_DIR}
-SET (ENV{FREETYPE_DIR} ${CACHED_FREETYPE_DIR})
-
-# freetype2 header
-if (FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}")
-  if (NOT 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2)
-    set (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 "${FREETYPE_INCLUDE_DIR_freetype2}" CACHE FILEPATH "the path of freetype2" FORCE)
-  endif()
+# the FIRST step in search for freetype library and header folders (built-in search engine)
+
+# execute built-in search engine to seek freetype
+set (IS_BUILTIN_SEARCH_REQUIRED OFF)
+if (NOT 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build OR NOT EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build}")
+  set (IS_BUILTIN_SEARCH_REQUIRED ON)
+elseif (NOT 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 OR NOT EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2}")
+  set (IS_BUILTIN_SEARCH_REQUIRED ON)
+elseif (NOT 3RDPARTY_FREETYPE_LIBRARY OR NOT EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")
+  set (IS_BUILTIN_SEARCH_REQUIRED ON)
+#elseif (WIN32)
+  #if (NOT 3RDPARTY_FREETYPE_DLL OR NOT EXISTS "${3RDPARTY_FREETYPE_DLL}")
+  #  set (IS_BUILTIN_SEARCH_REQUIRED ON)
+  #endif()
 endif()
 
-if (NOT 3RDPARTY_FREETYPE_LIBRARY_DIR)
-  set (3RDPARTY_FREETYPE_LIBRARY "" CACHE FILEPATH "freetype library" FORCE)
-elseif (3RDPARTY_FREETYPE_LIBRARY AND EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")
-  get_filename_component(3RDPARTY_FREETYPE_LIBRARY_DIR_TMP "${3RDPARTY_FREETYPE_LIBRARY}" PATH)
-  if (NOT "${3RDPARTY_FREETYPE_LIBRARY_DIR}" STREQUAL "${3RDPARTY_FREETYPE_LIBRARY_DIR_TMP}")
-    set (3RDPARTY_FREETYPE_LIBRARY "" CACHE FILEPATH "freetype library" FORCE)
-  endif()
-endif()
+if (IS_BUILTIN_SEARCH_REQUIRED)
 
-if (WIN32)
-  if (NOT 3RDPARTY_FREETYPE_DLL_DIR)
-    set (3RDPARTY_FREETYPE_DLL "" CACHE FILEPATH "freetype shared library" FORCE)
-  elseif (3RDPARTY_FREETYPE_DLL AND EXISTS "${3RDPARTY_FREETYPE_DLL}")
-    get_filename_component(3RDPARTY_FREETYPE_DLL_DIR_TMP "${3RDPARTY_FREETYPE_DLL}" PATH)
-    if (NOT "${3RDPARTY_FREETYPE_DLL_DIR}" STREQUAL "${3RDPARTY_FREETYPE_DLL_DIR_TMP}")
-      set (3RDPARTY_FREETYPE_DLL "" CACHE FILEPATH "freetype shared library" FORCE)
-    endif()
+  # use 3RDPARTY_FREETYPE_DIR if it is specified for freetype search
+  if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
+    set (CACHED_FREETYPE_DIR $ENV{FREETYPE_DIR})
+    set (ENV{FREETYPE_DIR} "${3RDPARTY_FREETYPE_DIR}")
   endif()
-endif()
 
-# freetype library
-if (FREETYPE_LIBRARY AND EXISTS "${FREETYPE_LIBRARY}")
-  if (NOT 3RDPARTY_FREETYPE_LIBRARY)
-    set (3RDPARTY_FREETYPE_LIBRARY "${FREETYPE_LIBRARY}" CACHE FILEPATH "freetype library" FORCE)
-  endif()
+  find_package(Freetype)
 
-  if (3RDPARTY_FREETYPE_LIBRARY AND EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")
-    get_filename_component (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY}" PATH)
-    set (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY_DIR}" CACHE FILEPATH "The directory containing freetype library" FORCE)
+  # restore ENV{FREETYPE_DIR}
+  if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
+    set (ENV{FREETYPE_DIR} ${CACHED_FREETYPE_DIR})
   endif()
 
-  if (WIN32)
-    set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
+  # check the found paths for consistency with specified 3RDPARTY_FREETYPE_DIR
+  if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR FREETYPE_INCLUDE_DIR_ft2build FILEPATH "the path to ft2build.h")
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR FREETYPE_INCLUDE_DIR_freetype2 FILEPATH "the path to ftheader.h")
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_FREETYPE_DIR FREETYPE_LIBRARY FILEPATH "freetype library")
+  endif()
 
-    if (NOT 3RDPARTY_FREETYPE_DLL OR NOT EXISTS "${3RDPARTY_FREETYPE_DLL}")
-      get_filename_component (FREETYPE_LIBRARY_PARENT_DIR "${3RDPARTY_FREETYPE_LIBRARY_DIR}" PATH) # parent of the library directory
+  # assign the found paths to corresponding 3RDPARTY_FREETYPE_ variables
+  if (NOT 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build OR NOT EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build}")
+    if (FREETYPE_INCLUDE_DIR_ft2build AND EXISTS "${FREETYPE_INCLUDE_DIR_ft2build}")
+      set (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build  "${FREETYPE_INCLUDE_DIR_ft2build}" CACHE FILEPATH "the path to ft2build.h" FORCE)
+    endif()
+  endif()
 
-      set (3RDPARTY_FREETYPE_DLL "3RDPARTY_FREETYPE_DLL-NOTFOUND" CACHE FILEPATH "freetype shared library" FORCE)
-      find_library (3RDPARTY_FREETYPE_DLL freetype PATHS "${FREETYPE_LIBRARY_PARENT_DIR}/bin" NO_DEFAULT_PATH)
+  if (NOT 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 OR NOT EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2}")
+    if (FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}")
+      set (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2  "${FREETYPE_INCLUDE_DIR_freetype2}" CACHE FILEPATH "the path to ftheader.h" FORCE)
     endif()
+  endif()
 
-    if (3RDPARTY_FREETYPE_DLL AND EXISTS "${3RDPARTY_FREETYPE_DLL}")
-      get_filename_component (3RDPARTY_FREETYPE_DLL_DIR "${3RDPARTY_FREETYPE_DLL}" PATH)
-      set (3RDPARTY_FREETYPE_DLL_DIR "${3RDPARTY_FREETYPE_DLL_DIR}" CACHE FILEPATH "The directory containing freetype shared library" FORCE)
+  if (NOT 3RDPARTY_FREETYPE_LIBRARY OR NOT EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")
+    if (FREETYPE_LIBRARY AND EXISTS "${FREETYPE_LIBRARY}")
+      set (3RDPARTY_FREETYPE_LIBRARY  "${FREETYPE_LIBRARY}" CACHE FILEPATH "The path to freetype library" FORCE)
     endif()
   endif()
+
+  if (3RDPARTY_FREETYPE_LIBRARY AND EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")
+    get_filename_component (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY}" PATH)
+    set (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY_DIR}" CACHE PATH "The directory containing freetype library" FORCE)
+  else()
+    set (3RDPARTY_FREETYPE_LIBRARY_DIR "" CACHE PATH "The directory containing freetype library" FORCE)
+  endif()
 endif()
 
+# the SECOND step in search for freetype library and header folders (additional search algorithms)
 
-if (NOT 3RDPARTY_FREETYPE_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_FREETYPE_LIBRARY_DIR}")
-  set (3RDPARTY_FREETYPE_LIBRARY_DIR "" CACHE FILEPATH "The directory containing freetype library" FORCE)
-endif()
+# ft2build.h
+if (NOT 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build OR NOT EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build}")
+  set (FT2BUILD_NAMES ft2build.h config/ft2build.h freetype/config/ft2build.h)
 
-if (WIN32)
-  if (NOT 3RDPARTY_FREETYPE_DLL_DIR OR NOT EXISTS "${3RDPARTY_FREETYPE_DLL_DIR}")
-    set (3RDPARTY_FREETYPE_DLL_DIR "" CACHE FILEPATH "The directory containing shared freetype library" FORCE)
+  # set 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build as notfound, otherwise find_library can't assign a new value to 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build
+  set (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build "3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build-NOTFOUND" CACHE FILEPATH "the path to ft2build.h" FORCE)
+
+  # cmake (version < 3.0) doesn't find ft2build.h of freetype (version is >= 2.5.1)
+  # do search taking into account freetype structure of 2.5.1 version
+  if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
+    find_path (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build NAMES ${FT2BUILD_NAMES}
+                                                      PATHS ${3RDPARTY_FREETYPE_DIR}
+                                                      PATH_SUFFIXES include freetype2 include/freetype2
+                                                      CMAKE_FIND_ROOT_PATH_BOTH
+                                                      NO_DEFAULT_PATH)
+  else()
+    find_path (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build NAMES ${FT2BUILD_NAMES}
+                                                      PATHS /usr/X11R6 /usr/local/X11R6 /usr/local/X11 /usr/freeware
+                                                      PATH_SUFFIXES include/freetype2 include freetype2
+                                                      CMAKE_FIND_ROOT_PATH_BOTH)
   endif()
 endif()
 
-# include found paths to common variables
-if (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build)
+if (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build AND EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build}")
   list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build}")
 else()
   list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build)
+
+  set (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build "" CACHE FILEPATH "the path to ft2build.h" FORCE)
+endif()
+
+# ftheader.h
+if (NOT 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 OR NOT EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2}")
+  set (FTHEADER_NAMES ftheader.h config/ftheader.h freetype/config/ftheader.h)
+
+  # set 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 as notfound, otherwise find_library can't assign a new value to 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2
+  set (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 "3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2-NOTFOUND" CACHE FILEPATH "the path to ftheader.h" FORCE)
+
+  if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
+    find_path (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 NAMES ${FTHEADER_NAMES}
+                                                       HINTS ${3RDPARTY_FREETYPE_DIR}
+                                                       PATH_SUFFIXES include/freetype2 include freetype2
+                                                       CMAKE_FIND_ROOT_PATH_BOTH
+                                                       NO_DEFAULT_PATH)
+  else()
+    find_path (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 NAMES ${FTHEADER_NAMES}
+                                                       PATHS /usr/X11R6 /usr/local/X11R6 /usr/local/X11 /usr/freeware
+                                                       PATH_SUFFIXES include/freetype2 include freetype2
+                                                       CMAKE_FIND_ROOT_PATH_BOTH)
+  endif()
 endif()
 
-if (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2)
+if (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 AND EXISTS "${3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2}")
   list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2}")
 else()
   list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2)
+
+  set (3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2 "" CACHE FILEPATH "the path to ftheader.h" FORCE)
 endif()
 
-if (3RDPARTY_FREETYPE_LIBRARY)
+# freetype library
+if (NOT 3RDPARTY_FREETYPE_LIBRARY OR NOT EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")
+  set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib)
+
+  set (FREETYPE_PATH_SUFFIXES lib)
+  if (ANDROID)
+    set (FREETYPE_PATH_SUFFIXES ${FREETYPE_PATH_SUFFIXES} libs/${ANDROID_ABI})
+  endif()
+
+  # set 3RDPARTY_FREETYPE_LIBRARY as notfound, otherwise find_library can't assign a new value to 3RDPARTY_FREETYPE_LIBRARY
+  set (3RDPARTY_FREETYPE_LIBRARY "3RDPARTY_FREETYPE_LIBRARY-NOTFOUND" CACHE FILEPATH "The path to freetype library" FORCE)
+
+  if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
+    find_library (3RDPARTY_FREETYPE_LIBRARY freetype
+                                            PATHS "${3RDPARTY_FREETYPE_LIBRARY_DIR}" "${3RDPARTY_FREETYPE_DIR}"
+                                            PATH_SUFFIXES ${FREETYPE_PATH_SUFFIXES}
+                                            CMAKE_FIND_ROOT_PATH_BOTH
+                                            NO_DEFAULT_PATH)
+  else()
+    find_library (3RDPARTY_FREETYPE_LIBRARY freetype 
+                                            PATH_SUFFIXES ${FREETYPE_PATH_SUFFIXES}
+                                            CMAKE_FIND_ROOT_PATH_BOTH)
+  endif()
+
+  if (3RDPARTY_FREETYPE_LIBRARY AND EXISTS "${3RDPARTY_FREETYPE_LIBRARY}")
+    get_filename_component (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY}" PATH)
+    set (3RDPARTY_FREETYPE_LIBRARY_DIR "${3RDPARTY_FREETYPE_LIBRARY_DIR}" CACHE PATH "The directory containing freetype library" FORCE)
+  else()
+    set (3RDPARTY_FREETYPE_LIBRARY_DIR "" CACHE PATH "The directory containing freetype library" FORCE)
+  endif()
+endif()
+
+if (3RDPARTY_FREETYPE_LIBRARY_DIR AND EXISTS "${3RDPARTY_FREETYPE_LIBRARY_DIR}")
   list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_FREETYPE_LIBRARY_DIR}")
 else()
   list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_FREETYPE_LIBRARY_DIR)
+
+  set (3RDPARTY_FREETYPE_LIBRARY "" CACHE FILEPATH "The path to freetype library" FORCE)
 endif()
 
+# freetype shared library
 if (WIN32)
-  if (3RDPARTY_FREETYPE_DLL OR EXISTS "${3RDPARTY_FREETYPE_DLL}")
+  if (NOT 3RDPARTY_FREETYPE_DLL OR NOT EXISTS "${3RDPARTY_FREETYPE_DLL}")
+    
+    set (CMAKE_FIND_LIBRARY_SUFFIXES .dll)
+
+    # set 3RDPARTY_FREETYPE_DLL as notfound, otherwise find_library can't assign a new value to 3RDPARTY_FREETYPE_DLL
+    set (3RDPARTY_FREETYPE_DLL "3RDPARTY_FREETYPE_DLL-NOTFOUND" CACHE FILEPATH "The path to freetype shared library" FORCE)
+
+    if (3RDPARTY_FREETYPE_DIR AND EXISTS "${3RDPARTY_FREETYPE_DIR}")
+      find_library (3RDPARTY_FREETYPE_DLL freetype
+                                          PATHS "${3RDPARTY_FREETYPE_DIR}"
+                                          PATH_SUFFIXES bin
+                                          NO_DEFAULT_PATH)
+    else()
+      find_library (3RDPARTY_FREETYPE_DLL freetype
+                                          PATH_SUFFIXES bin)
+    endif()
+
+    if (3RDPARTY_FREETYPE_DLL AND EXISTS "${3RDPARTY_FREETYPE_DLL}")
+      get_filename_component (3RDPARTY_FREETYPE_DLL_DIR "${3RDPARTY_FREETYPE_DLL}" PATH)
+      set (3RDPARTY_FREETYPE_DLL_DIR "${3RDPARTY_FREETYPE_DLL_DIR}" CACHE PATH "The directory containing freetype library" FORCE)
+    else()
+      set (3RDPARTY_FREETYPE_DLL_DIR "" CACHE PATH "The directory containing freetype shared library" FORCE)
+
+      set (3RDPARTY_FREETYPE_DLL "" CACHE FILEPATH "freetype shared library" FORCE)
+    endif()
+  endif()
+
+  if (3RDPARTY_FREETYPE_DLL_DIR OR EXISTS "${3RDPARTY_FREETYPE_DLL_DIR}")
     list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_FREETYPE_DLL_DIR}")
   else()
     list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_FREETYPE_DLL_DIR)
   endif()
 endif()
 
+
+# install instructions
 if (INSTALL_FREETYPE)
 
   OCCT_MAKE_OS_WITH_BITNESS()
@@ -220,21 +302,21 @@ if (INSTALL_FREETYPE)
              CONFIGURATIONS Debug
              DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
   else()
-    get_filename_component(ABS_PATH ${3RDPARTY_FREETYPE_LIBRARY} REALPATH)
-    get_filename_component(FREETYPELIB ${3RDPARTY_FREETYPE_LIBRARY} NAME)
+    get_filename_component(3RDPARTY_FREETYPE_LIBRARY_ABS ${3RDPARTY_FREETYPE_LIBRARY} REALPATH)
+    get_filename_component(3RDPARTY_FREETYPE_LIBRARY_NAME ${3RDPARTY_FREETYPE_LIBRARY} NAME)
 
-    install (FILES "${ABS_PATH}"
+    install (FILES "${3RDPARTY_FREETYPE_LIBRARY_ABS}"
              CONFIGURATIONS Release
              DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
-             RENAME ${FREETYPELIB}.6)
-    install (FILES "${ABS_PATH}"
+             RENAME ${3RDPARTY_FREETYPE_LIBRARY_NAME}.6)
+    install (FILES "${3RDPARTY_FREETYPE_LIBRARY_ABS}"
              CONFIGURATIONS RelWithDebInfo
              DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libi"
-             RENAME ${FREETYPELIB}.6)
-    install (FILES "${ABS_PATH}"
+             RENAME ${3RDPARTY_FREETYPE_LIBRARY_NAME}.6)
+    install (FILES "${3RDPARTY_FREETYPE_LIBRARY_ABS}"
              CONFIGURATIONS Debug
              DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libd"
-             RENAME ${FREETYPELIB}.6)
+             RENAME ${3RDPARTY_FREETYPE_LIBRARY_NAME}.6)
   endif()
 
   set (USED_3RDPARTY_FREETYPE_DIR "")
@@ -252,4 +334,4 @@ OCCT_CHECK_AND_UNSET(FREETYPE_INCLUDE_DIR_ft2build)
 OCCT_CHECK_AND_UNSET(FREETYPE_INCLUDE_DIR_freetype2)
 OCCT_CHECK_AND_UNSET(FREETYPE_LIBRARY)
 
-mark_as_advanced (3RDPARTY_FREETYPE_LIBRARY 3RDPARTY_FREETYPE_DLL)
\ No newline at end of file
+mark_as_advanced (3RDPARTY_FREETYPE_LIBRARY 3RDPARTY_FREETYPE_DLL)
index 44d5f5b..ca2cc87 100644 (file)
@@ -1,24 +1,28 @@
 # CSF variables definition
 
+if(CSFS_ALREADY_INCLUDED)
+  return()
+endif()
+set(CSFS_ALREADY_INCLUDED 1)
+
+
 if (NOT DEFINED USE_TCL)
   OCCT_IS_PRODUCT_REQUIRED (CSF_TclLibs USE_TCL)
 endif()
 
 if (USE_TCL)
   if ("${3RDPARTY_TCL_LIBRARY_VERSION}" STREQUAL "")
-    message (WARNING "TCL version has not been specified by CSF_TclLibs defining")
-    message (WARNING "thus it will be used as 8.6")
+    message (STATUS "Warning. TCL version has not been specified by CSF_TclLibs defining thus it will be used as 8.6")
     set (3RDPARTY_TCL_LIBRARY_VERSION "8.6")
   endif()
 
   if ("${3RDPARTY_TK_LIBRARY_VERSION}" STREQUAL "")
-    message (WARNING "TK version has not been specified by CSF_TclTkLibs defining")
-    message (WARNING "thus it will be used as 8.6")
+    message (STATUS "Warning. TK version has not been specified by CSF_TclTkLibs defining thus it will be used as 8.6")
     set (3RDPARTY_TK_LIBRARY_VERSION "8.6")
   endif()
 endif()
 
-if (USE_VTK AND NOT VTK_LIBRARY_NAMES)
+if (USE_VTK AND NOT 3RDPARTY_VTK_REQUIRED_LIBRARIES)
   message (WARNING "CSF_VTK specification: VTK libraries are not defined")
 endif()
 
@@ -42,40 +46,52 @@ if (WIN32)
   endif()
 
   if (USE_VTK)
-    set (CSF_VTK "${VTK_LIBRARY_NAMES}")
+    set (CSF_VTK "${3RDPARTY_VTK_REQUIRED_LIBRARIES}")
   else()
     set (CSF_VTK)
   endif()
 
 else()
 
-  #-- Tcl/Tk configuration
-  if (USE_TCL)
-    set (CSF_TclLibs     "tcl${3RDPARTY_TCL_LIBRARY_VERSION}")
-    set (CSF_TclTkLibs   "X11 tk${3RDPARTY_TK_LIBRARY_VERSION}")
-  endif()
-
-  if(APPLE)
+  if (APPLE)
     set (CSF_objc        "objc")
 
     # frameworks
-    set (CSF_Appkit      "Appkit")
-    set (CSF_IOKit       "IOKit")
-    set (CSF_OpenGlLibs  "OpenGL")
+    find_library (Appkit_LIB NAMES Appkit)
+    set (CSF_Appkit ${Appkit_LIB})
+
+    find_library (IOKit_LIB NAMES IOKit)
+    set (CSF_IOKit ${IOKit_LIB})
+
+    OCCT_CHECK_AND_UNSET (Appkit_LIB)
+    OCCT_CHECK_AND_UNSET (IOKit_LIB)
+
+    if (USE_GLX)
+      set (CSF_OpenGlLibs GL)
+      set (CSF_XwLibs     "X11 Xext Xmu Xi")
+    else()
+      find_library (OpenGlLibs_LIB NAMES OpenGL)
+      set (CSF_OpenGlLibs ${OpenGlLibs_LIB})
+
+      OCCT_CHECK_AND_UNSET (OpenGlLibs_LIB)
+    endif()
     
-    set (CSF_TclLibs     "Tcl")
-    set (CSF_TclTkLibs   "Tk")
-  elseif(ANDROID)
+    if (USE_TCL)
+      set (CSF_TclTkLibs Tk)
+      set (CSF_TclLibs   Tcl)
+    endif()
+  elseif (ANDROID)
     set (CSF_ThreadLibs  "c")
     set (CSF_OpenGlLibs  "EGL GLESv2")
   elseif (UNIX)
     set (CSF_ThreadLibs  "pthread rt")
     set (CSF_OpenGlLibs  "GLU GL")
-  endif()
-
-  if (NOT DEFINED ANDROID)
     set (CSF_XwLibs      "X11 Xext Xmu Xi")
-    set (CSF_MotifLibs   "X11")
+
+    if (USE_TCL)
+      set (CSF_TclLibs     "tcl${3RDPARTY_TCL_LIBRARY_VERSION}")
+      set (CSF_TclTkLibs   "tk${3RDPARTY_TK_LIBRARY_VERSION}")
+    endif()
   endif()
 
   if (USE_FREETYPE)
@@ -99,7 +115,7 @@ else()
   endif()
   
   if (USE_VTK)
-    set (CSF_VTK "${VTK_LIBRARY_NAMES}")
+    set (CSF_VTK "${3RDPARTY_VTK_REQUIRED_LIBRARIES}")
   else()
     set (CSF_VTK)
   endif()
index a8d4b71..54b8073 100644 (file)
@@ -1,3 +1,10 @@
+##
+
+if(FLAGS_ALREADY_INCLUDED)
+  return()
+endif()
+set(FLAGS_ALREADY_INCLUDED 1)
+
 
 if (MSVC)
   add_definitions(/fp:precise)
index 98aed52..8597dc0 100644 (file)
@@ -1,4 +1,11 @@
-#
+##
+
+if(OCCT_MACROS_ALREADY_INCLUDED)
+  return()
+endif()
+set(OCCT_MACROS_ALREADY_INCLUDED 1)
+
+
 macro (OCCT_CHECK_AND_UNSET VARNAME)
   if (DEFINED ${VARNAME})
     unset (${VARNAME} CACHE)
@@ -91,15 +98,14 @@ function (OCCT_ORIGIN_AND_PATCHED_FILES RELATIVE_PATH SEARCH_TEMPLATE RESULT)
   file (GLOB ORIGIN_FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_PATH}/${SEARCH_TEMPLATE}")
   foreach (ORIGIN_FILE ${ORIGIN_FILES})
     # check for existence of patched version of current file
-    if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/${RELATIVE_PATH}")
+    if (NOT APPLY_OCCT_PATCH_DIR OR NOT EXISTS "${APPLY_OCCT_PATCH_DIR}/${RELATIVE_PATH}")
+      list (APPEND FOUND_FILES ${ORIGIN_FILE})
+    else()
       get_filename_component (ORIGIN_FILE_NAME "${ORIGIN_FILE}" NAME)
-      if (EXISTS "${APPLY_OCCT_PATCH_DIR}/${RELATIVE_PATH}/${ORIGIN_FILE_NAME}")
-        continue()
+      if (NOT EXISTS "${APPLY_OCCT_PATCH_DIR}/${RELATIVE_PATH}/${ORIGIN_FILE_NAME}")
+        list (APPEND FOUND_FILES ${ORIGIN_FILE})
       endif()
     endif()
-
-    # append origin version if patched one is not found
-    list (APPEND FOUND_FILES ${ORIGIN_FILE})
   endforeach()
 
   set (${RESULT} ${FOUND_FILES} PARENT_SCOPE)
@@ -135,9 +141,7 @@ function (FIND_PRODUCT_DIR ROOT_DIR PRODUCT_NAME RESULT)
   endforeach()
 
   if (LOCAL_RESULT)
-    list (LENGTH "${LOCAL_RESULT}" LOC_LEN)
-    math (EXPR LAST_ELEMENT_INDEX "${LOC_LEN}-1")
-    list (GET LOCAL_RESULT ${LAST_ELEMENT_INDEX} DUMMY)
+    list (GET LOCAL_RESULT -1 DUMMY)
     set (${RESULT} ${DUMMY} PARENT_SCOPE)
   endif()
 endfunction()
@@ -200,47 +204,71 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
   set (OCCT_HEADER_FILES_COMPLETE)
   set (OCCT_HEADER_FILE_NAMES_NOT_IN_FILES)
   set (OCCT_HEADER_FILE_WITH_PROPER_NAMES)
+
+  string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
+  message (STATUS "Info. \(${CURRENT_TIME}\) Compare FILES with files in package directories...")
+
   foreach (OCCT_PACKAGE ${OCCT_USED_PACKAGES})
-    if (NOT EXISTS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES")
-      message (WARNING "FILES has not been found in ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}")
-      continue()
-    endif()
+    if (EXISTS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES")
+      file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" OCCT_ALL_FILE_NAMES)
 
-    file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" OCCT_ALL_FILE_NAMES)
+      list (LENGTH OCCT_ALL_FILE_NAMES ALL_FILES_NB)
+      math (EXPR ALL_FILES_NB "${ALL_FILES_NB} - 1" )
 
-    # emit warnings if there is unprocessed headers
-    file (GLOB OCCT_ALL_FILES_IN_DIR "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/*.*")
-    foreach (OCCT_FILE_IN_DIR ${OCCT_ALL_FILES_IN_DIR})
-      foreach (OCCT_FILE_NAME ${OCCT_ALL_FILE_NAMES})
-        string (REGEX MATCH "${OCCT_FILE_NAME}" IS_FILE_FOUND "${OCCT_FILE_IN_DIR}")
-        if (IS_FILE_FOUND)
-          string (REGEX MATCH ".+[.]h|[lg]xx" IS_HEADER_FOUND "${OCCT_FILE_NAME}")
-          if (IS_HEADER_FOUND)
-            list (APPEND OCCT_HEADER_FILES_COMPLETE ${OCCT_HEADER_FILE_IN_DIR})
+      # emit warnings if there is unprocessed headers
+      file (GLOB OCCT_ALL_FILES_IN_DIR "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/*.*")
+      foreach (OCCT_FILE_IN_DIR ${OCCT_ALL_FILES_IN_DIR})
+        get_filename_component (OCCT_FILE_IN_DIR_NAME ${OCCT_FILE_IN_DIR} NAME)
 
-            # collect header files with name that does not contain its package one
-            string (FIND "${OCCT_FILE_NAME}" "${OCCT_PACKAGE}_" FOUND_INDEX)
-            if (NOT ${FOUND_INDEX} EQUAL 0)
-              list (APPEND OCCT_HEADER_FILE_WITH_PROPER_NAMES "${OCCT_FILE_NAME}")
-            endif()            
-          endif()
+        set (OCCT_FILE_IN_DIR_STATUS OFF)
 
+        if (${ALL_FILES_NB} LESS 0)
           break()
         endif()
-      endforeach()
 
-      if (NOT IS_FILE_FOUND)
-        message (STATUS "Warning. ${OCCT_FILE_IN_DIR} is not involved into ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES")
-        
-        string (REGEX MATCH ".+[.]h|[lg]xx" IS_HEADER_FOUND "${OCCT_FILE_NAME}")
-        if (IS_HEADER_FOUND)
-          list (APPEND OCCT_HEADER_FILE_NAMES_NOT_IN_FILES ${OCCT_FILE_NAME})
+        foreach (FILE_INDEX RANGE ${ALL_FILES_NB})
+          list (GET OCCT_ALL_FILE_NAMES ${FILE_INDEX} OCCT_FILE_NAME)
+
+          if ("${OCCT_FILE_IN_DIR_NAME}" STREQUAL "${OCCT_FILE_NAME}")
+            set (OCCT_FILE_IN_DIR_STATUS ON)
+
+            string (REGEX MATCH ".+\\.[hlg]xx|.+\\.h$" IS_HEADER_FOUND "${OCCT_FILE_NAME}")
+            if (IS_HEADER_FOUND)
+              list (APPEND OCCT_HEADER_FILES_COMPLETE ${OCCT_FILE_IN_DIR})
+
+              # collect header files with name that does not contain its package one
+              string (FIND "${OCCT_FILE_NAME}" "${OCCT_PACKAGE}_" FOUND_INDEX)
+              if (NOT ${FOUND_INDEX} EQUAL 0)
+                list (APPEND OCCT_HEADER_FILE_WITH_PROPER_NAMES "${OCCT_FILE_NAME}")
+              endif()            
+            endif()
+
+            # remove found element from list
+            list (REMOVE_AT OCCT_ALL_FILE_NAMES ${FILE_INDEX})
+            math (EXPR ALL_FILES_NB "${ALL_FILES_NB} - 1" ) # decrement number
+
+            break()
+          endif()
+        endforeach()
+
+        if (NOT OCCT_FILE_IN_DIR_STATUS)
+          message (STATUS "Warning. ${OCCT_FILE_IN_DIR} is not involved into ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES")
+          
+          string (REGEX MATCH ".+\\.[hlg]xx|.+\\.h$" IS_HEADER_FOUND "${OCCT_FILE_NAME}")
+          if (IS_HEADER_FOUND)
+            list (APPEND OCCT_HEADER_FILE_NAMES_NOT_IN_FILES ${OCCT_FILE_NAME})
+          endif()
         endif()
-      endif()
-    endforeach()
+      endforeach()
+    else()
+      message (WARNING "FILES has not been found in ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}")
+    endif()
   endforeach()
   
   # create new file including found header
+  string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
+  message (STATUS "Info. \(${CURRENT_TIME}\) Create header-links in inc folder...")
+
   foreach (OCCT_HEADER_FILE ${OCCT_HEADER_FILES_COMPLETE})
     get_filename_component (HEADER_FILE_NAME ${OCCT_HEADER_FILE} NAME)
     configure_file ("${TEMPLATE_HEADER_PATH}" "${ROOT_TARGET_OCCT_DIR}/inc/${HEADER_FILE_NAME}" @ONLY)
@@ -280,10 +308,6 @@ macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_TARGET_OCCT_DIR OCCT_BUILD_TOO
       endif()
     endif()
   endforeach()
-  
-  string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
-  message (STATUS "Info. \(${CURRENT_TIME}\) End the checking")
-
 endmacro()
 
 macro (OCCT_COPY_FILE_OR_DIR BEING_COPIED_OBJECT DESTINATION_PATH)
@@ -457,3 +481,22 @@ function (OCCT_VERSION OCCT_VERSION_VAR)
   set (${OCCT_VERSION_VAR} "${OCCT_VERSION_LOCALVAR}" PARENT_SCOPE)
 endfunction()
 
+macro (CHECK_PATH_FOR_CONSISTENCY THE_ROOT_PATH_NAME THE_BEING_CHECKED_PATH_NAME THE_VAR_TYPE THE_MESSAGE_OF_BEING_CHECKED_PATH)
+  
+  set (THE_ROOT_PATH "${${THE_ROOT_PATH_NAME}}")
+  set (THE_BEING_CHECKED_PATH "${${THE_BEING_CHECKED_PATH_NAME}}")
+
+  if (THE_BEING_CHECKED_PATH OR EXISTS "${THE_BEING_CHECKED_PATH}")
+    get_filename_component (THE_ROOT_PATH_ABS "${THE_ROOT_PATH}" ABSOLUTE)
+    get_filename_component (THE_BEING_CHECKED_PATH_ABS "${THE_BEING_CHECKED_PATH}" ABSOLUTE)
+
+    string (REGEX MATCH "${THE_ROOT_PATH_ABS}" DOES_PATH_CONTAIN "${THE_BEING_CHECKED_PATH_ABS}")
+
+    if (NOT DOES_PATH_CONTAIN) # if cmake found the being checked path at different place from THE_ROOT_PATH_ABS
+      set (${THE_BEING_CHECKED_PATH_NAME} "" CACHE ${THE_VAR_TYPE} "${THE_MESSAGE_OF_BEING_CHECKED_PATH}" FORCE)
+    endif()
+  else()
+    set (${THE_BEING_CHECKED_PATH_NAME} "" CACHE ${THE_VAR_TYPE} "${THE_MESSAGE_OF_BEING_CHECKED_PATH}" FORCE)
+  endif()
+
+endmacro()
index e7d3715..f7a845c 100644 (file)
@@ -14,104 +14,105 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES})
   
   # TKService contains platform-dependent packages: Xw and WNT
   if ((WIN32 AND "${OCCT_PACKAGE}" STREQUAL "Xw") OR (NOT WIN32 AND "${OCCT_PACKAGE}" STREQUAL "WNT"))
-    continue()
-  endif()
-
-  if (WIN32)
-    list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE}_DLL")
-  endif()
+    # do nothing
+  else()
 
-  set (SOURCE_FILES)
-  set (HEADER_FILES)
+    if (WIN32)
+      list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE}_DLL")
+    endif()
 
-  # Generate Flex and Bison files
-  if (${REBUILD_PLATFORM_DEPENDENT_CODE})
+    set (SOURCE_FILES)
+    set (HEADER_FILES)
+
+    # Generate Flex and Bison files
+    if (${REBUILD_PLATFORM_DEPENDENT_CODE})
+
+      # flex files
+      OCCT_ORIGIN_AND_PATCHED_FILES ("src/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
+      list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN)
+
+      # bison files
+      OCCT_ORIGIN_AND_PATCHED_FILES ("src/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
+      list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN)
+
+      if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0)
+      
+        list (SORT SOURCE_FILES_FLEX)
+        list (SORT SOURCE_FILES_BISON)
+
+        math (EXPR SOURCE_FILES_FLEX_LEN "${SOURCE_FILES_FLEX_LEN} - 1")
+        foreach (FLEX_FILE_INDEX RANGE ${SOURCE_FILES_FLEX_LEN})
+
+          list (GET SOURCE_FILES_FLEX ${FLEX_FILE_INDEX} CURRENT_FLEX_FILE)
+          get_filename_component (CURRENT_FLEX_FILE_NAME ${CURRENT_FLEX_FILE} NAME_WE)
+
+          list (GET SOURCE_FILES_BISON ${FLEX_FILE_INDEX} CURRENT_BISON_FILE)
+          get_filename_component (CURRENT_BISON_FILE_NAME ${CURRENT_BISON_FILE} NAME_WE)
+          
+          string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL)
+
+          if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
+            set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
+            set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
+            BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}")
+            FLEX_TARGET  (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}")
+            ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
+           
+            list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
+          endif()
+        endforeach()
+      endif()
+    endif()
 
-    # flex files
-    OCCT_ORIGIN_AND_PATCHED_FILES ("src/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX)
-    list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN)
+    # header files
+    if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES")
+      file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_M   REGEX ".+[.]h")
+      file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
+      file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
 
-    # bison files
-    OCCT_ORIGIN_AND_PATCHED_FILES ("src/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON)
-    list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN)
+      file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+      if(APPLE)
+        file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
+      endif()
+    else()
+      file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"     HEADER_FILES_M   REGEX ".+[.]h")
+      file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"     HEADER_FILES_LXX REGEX ".+[.]lxx")
+      file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"     HEADER_FILES_GXX REGEX ".+[.]gxx")
 
-    if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0)
-    
-      list (SORT SOURCE_FILES_FLEX)
-      list (SORT SOURCE_FILES_BISON)
-
-      math (EXPR SOURCE_FILES_FLEX_LEN "${SOURCE_FILES_FLEX_LEN} - 1")
-      foreach (FLEX_FILE_INDEX RANGE ${SOURCE_FILES_FLEX_LEN})
-
-        list (GET SOURCE_FILES_FLEX ${FLEX_FILE_INDEX} CURRENT_FLEX_FILE)
-        get_filename_component (CURRENT_FLEX_FILE_NAME ${CURRENT_FLEX_FILE} NAME_WE)
-
-        list (GET SOURCE_FILES_BISON ${FLEX_FILE_INDEX} CURRENT_BISON_FILE)
-        get_filename_component (CURRENT_BISON_FILE_NAME ${CURRENT_BISON_FILE} NAME_WE)
-        
-        string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL)
-
-        if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
-          set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
-          set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
-          BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}")
-          FLEX_TARGET  (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}")
-          ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
-         
-          list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})
-        endif()
-      endforeach()
+      file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"     SOURCE_FILES_C REGEX ".+[.]c")
+      if(APPLE)
+        file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"   SOURCE_FILES_M REGEX ".+[.]mm")
+      endif()
     endif()
-  endif()
-
-  # header files
-  if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES")
-    file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_M   REGEX ".+[.]h")
-    file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx")
-    file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx")
-
-    file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c")
+    
+    list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX})
+    list (APPEND SOURCE_FILES ${SOURCE_FILES_C})
     if(APPLE)
-      file (STRINGS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm")
+      list (APPEND SOURCE_FILES ${SOURCE_FILES_M})
     endif()
-  else()
-    file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"     HEADER_FILES_M   REGEX ".+[.]h")
-    file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"     HEADER_FILES_LXX REGEX ".+[.]lxx")
-    file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"     HEADER_FILES_GXX REGEX ".+[.]gxx")
 
-    file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"     SOURCE_FILES_C REGEX ".+[.]c")
-    if(APPLE)
-      file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES"   SOURCE_FILES_M REGEX ".+[.]mm")
-    endif()
-  endif()
-  
-  list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX})
-  list (APPEND SOURCE_FILES ${SOURCE_FILES_C})
-  if(APPLE)
-    list (APPEND SOURCE_FILES ${SOURCE_FILES_M})
+    foreach(HEADER_FILE ${HEADER_FILES})
+      if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
+        message (STATUS "Info. consider patched file: ${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
+        list (APPEND USED_INCFILES "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
+        SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
+      else()
+        list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
+        SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
+      endif()
+    endforeach()
+
+    foreach(SOURCE_FILE ${SOURCE_FILES})
+      if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
+        message (STATUS "Info. consider patched file: ${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
+        list (APPEND USED_SRCFILES "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
+        SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
+      else()
+        list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
+        SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
+      endif()
+    endforeach()
   endif()
-
-  foreach(HEADER_FILE ${HEADER_FILES})
-    if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
-      message (STATUS "Info. consider patched file: ${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
-      list (APPEND USED_INCFILES "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
-      SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
-    else()
-      list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
-      SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}")
-    endif()
-  endforeach()
-
-  foreach(SOURCE_FILE ${SOURCE_FILES})
-    if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
-      message (STATUS "Info. consider patched file: ${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
-      list (APPEND USED_SRCFILES "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
-      SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${APPLY_OCCT_PATCH_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
-    else()
-      list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
-      SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}")
-    endif()
-  endforeach()
 endforeach()
 string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}")
 
@@ -190,4 +191,14 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
   endif()
 endforeach()
 
+if (APPLE)
+  list (FIND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT X11 IS_X11_FOUND)
+  if (NOT ${IS_X11_FOUND} EQUAL -1)
+    find_package (X11 COMPONENTS X11 Xext Xmu Xi)
+    if (NOT X11_FOUND)
+      message (STATUS "Warning. X11 is not found. It's required to install The XQuartz project: http://www.xquartz.org")
+    endif()
+  endif()
+endif()
+
 target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
index cf6b3a7..9794517 100644 (file)
@@ -9,241 +9,268 @@ if (NOT DEFINED 3RDPARTY_TBB_DIR)
   set (3RDPARTY_TBB_DIR "" CACHE PATH "The directory containing tbb")
 endif()
 
-# tbb include directory
-if (NOT DEFINED 3RDPARTY_TBB_INCLUDE_DIR)
-  set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of the tbb")
-endif()
-
-# tbb library file (with absolute path)
-if (NOT DEFINED 3RDPARTY_TBB_LIBRARY OR NOT 3RDPARTY_TBB_LIBRARY_DIR)
-  set (3RDPARTY_TBB_LIBRARY "" CACHE FILEPATH "tbb library" FORCE)
-endif()
-
-# tbb library directory
-if (NOT DEFINED 3RDPARTY_TBB_LIBRARY_DIR)
-  set (3RDPARTY_TBB_LIBRARY_DIR "" CACHE FILEPATH "The directory containing tbb library")
+if (MSVC)
+  add_definitions (-D__TBB_NO_IMPLICIT_LINKAGE)
+  add_definitions (-D__TBBMALLOC_NO_IMPLICIT_LINKAGE)
 endif()
 
-# tbb malloc library file (with absolute path)
-if (NOT DEFINED 3RDPARTY_TBBMALLOC_LIBRARY OR NOT 3RDPARTY_TBBMALLOC_LIBRARY_DIR)
-  set (3RDPARTY_TBBMALLOC_LIBRARY "" CACHE FILEPATH "tbb malloc library" FORCE)
-endif()
+# include occt macros. compiler_bitness, os_wiht_bit, compiler
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
 
-# tbb malloc library directory
-if (NOT DEFINED 3RDPARTY_TBBMALLOC_LIBRARY_DIR)
-  set (3RDPARTY_TBBMALLOC_LIBRARY_DIR "" CACHE FILEPATH "The directory containing tbb malloc library")
-endif()
+# specify TBB folder in connectin with 3RDPARTY_DIR
+if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}")
+  #CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_DIR 3RDPARTY_TBB_DIR PATH "The directory containing tbb")
 
-# tbb shared library (with absolute path)
-if (WIN32)
-  if (NOT DEFINED 3RDPARTY_TBB_DLL OR NOT 3RDPARTY_TBB_DLL_DIR)
-    set (3RDPARTY_TBB_DLL "" CACHE FILEPATH "tbb shared library" FORCE)
+  if (NOT 3RDPARTY_TBB_DIR OR NOT EXISTS "${3RDPARTY_TBB_DIR}")
+    FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" TBB TBB_DIR_NAME)
+    if (TBB_DIR_NAME)
+      set (3RDPARTY_TBB_DIR "${3RDPARTY_DIR}/${TBB_DIR_NAME}" CACHE PATH "The directory containing tbb" FORCE)
+    endif()
   endif()
+else()
+  #set (3RDPARTY_TBB_DIR "" CACHE PATH "The directory containing TBB" FORCE)
 endif()
 
-# tbb shared library directory
-if (WIN32 AND NOT DEFINED 3RDPARTY_TBB_DLL_DIR)
-  set (3RDPARTY_TBB_DLL_DIR "" CACHE FILEPATH "The directory containing tbb shared library")
+if (NOT DEFINED 3RDPARTY_TBB_INCLUDE_DIR)
+  set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE PATH "The directory containing headers of the TBB")
 endif()
 
-# tbb malloc shared library (with absolute path)
-if (WIN32)
-  if (NOT DEFINED 3RDPARTY_TBBMALLOC_DLL OR NOT 3RDPARTY_TBBMALLOC_DLL_DIR)
-    set (3RDPARTY_TBBMALLOC_DLL "" CACHE FILEPATH "tbb malloc shared library" FORCE)
-  endif()
+if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
+    # check 3RDPARTY_TBB_INCLUDE_DIR for consictency with specified 3RDPARTY_TBB_DIR
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_TBB_INCLUDE_DIR PATH "The directory containing headers of the TBB")
 endif()
 
-# tbb malloc shared library directory
-if (WIN32 AND NOT DEFINED 3RDPARTY_TBBMALLOC_DLL_DIR)
-  set (3RDPARTY_TBBMALLOC_DLL_DIR "" CACHE FILEPATH "The directory containing tbb malloc shared library")
-endif()
+# tbb.h
+if (NOT 3RDPARTY_TBB_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}")
 
-if (MSVC)
-  add_definitions (-D__TBB_NO_IMPLICIT_LINKAGE)
-  add_definitions (-D__TBBMALLOC_NO_IMPLICIT_LINKAGE)
-endif()
+  set (HEADER_NAMES tbb.h tbb/tbb.h)
 
-# include occt macros. compiler_bitness, os_wiht_bit, compiler
-OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
+  # set 3RDPARTY_TBB_INCLUDE_DIR as notfound, otherwise find_library can't assign a new value to 3RDPARTY_TBB_INCLUDE_DIR
+  set (3RDPARTY_TBB_INCLUDE_DIR "3RDPARTY_TBB_INCLUDE_DIR-NOTFOUND" CACHE PATH "the path to tbb.h" FORCE)
 
-# search for product directory inside 3RDPARTY_DIR directory
-if (NOT 3RDPARTY_TBB_DIR AND 3RDPARTY_DIR)
-  FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" "TBB" TBB_DIR_NAME)
-  if (TBB_DIR_NAME)
-    message (STATUS "Info: TBB: ${TBB_DIR_NAME} folder is used")
-    set (3RDPARTY_TBB_DIR "${3RDPARTY_DIR}/${TBB_DIR_NAME}" CACHE PATH "The directory containing tbb" FORCE)
+  if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
+    find_path (3RDPARTY_TBB_INCLUDE_DIR NAMES ${HEADER_NAMES}
+                                              PATHS ${3RDPARTY_TBB_DIR}
+                                              PATH_SUFFIXES include
+                                              CMAKE_FIND_ROOT_PATH_BOTH
+                                              NO_DEFAULT_PATH)
+  else()
+    find_path (3RDPARTY_TBB_INCLUDE_DIR NAMES ${HEADER_NAMES}
+                                              PATH_SUFFIXES include
+                                              CMAKE_FIND_ROOT_PATH_BOTH)
   endif()
 endif()
 
-OCCT_MAKE_COMPILER_BITNESS()
-
-if (${COMPILER_BITNESS} STREQUAL 32)
-  set (TBB_ARCH_NAME ia32)
+if (3RDPARTY_TBB_INCLUDE_DIR AND EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}")
+  list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_TBB_INCLUDE_DIR}")
 else()
-  set (TBB_ARCH_NAME intel64)
-endif()
+  list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_INCLUDE_DIR)
 
-# search for include directory in defined 3rdparty directory
-if (NOT 3RDPARTY_TBB_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}")
-  set (3RDPARTY_TBB_INCLUDE_DIR "3RDPARTY_TBB_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "The directory containing the headers of tbb" FORCE)
-  find_path (3RDPARTY_TBB_INCLUDE_DIR tbb/tbb.h PATHS "${3RDPARTY_TBB_DIR}/include" NO_DEFAULT_PATH)
-  find_path (3RDPARTY_TBB_INCLUDE_DIR tbb/tbb.h PATHS "${3RDPARTY_TBB_DIR}/include")
+  set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE PATH "the path to tbb.h" FORCE)
 endif()
 
-if (NOT 3RDPARTY_TBB_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}")
-  set (3RDPARTY_TBB_INCLUDE_DIR "" CACHE FILEPATH "The directory containing the headers of tbb" FORCE)
-endif()
+# common steps for tbb and tbbmalloc
+macro (TBB_PRODUCT_SEARCH PRODUCT_NAME)
 
-OCCT_MAKE_COMPILER_SHORT_NAME()
-
-# TBB_COMPILER_FOLER
-#if (WIN32)
-  set (TBB_COMPILER_FOLER ${COMPILER})
-#else()
-#  set (TBB_COMPILER_FOLER ${COMPILER})
-#endif()
-
-# search for tbb and tbb malloc library in defined 3rdparty directory
-foreach (LIBRARY_NAME TBB TBBMALLOC)
-  if (NOT WIN32)
-    file (GLOB TBB_SUBDIRS RELATIVE ${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/ ${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/*)
-    list (SORT TBB_SUBDIRS)
-    list (REVERSE TBB_SUBDIRS)
-    list (LENGTH TBB_SUBDIRS TBB_SUBDIRS_LENGTH)
-    set (TBB_SUBDIR_FIRST "")
-    if (${TBB_SUBDIRS_LENGTH})
-      list (GET TBB_SUBDIRS 0 TBB_SUBDIR_FIRST)
-      set (3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${TBB_SUBDIR_FIRST}")
-    endif()
+  string (TOLOWER ${PRODUCT_NAME} lower_PRODUCT_NAME)
+
+  # define required tbb/tbbmalloc variables
+  if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_LIBRARY OR NOT 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY "" CACHE FILEPATH "${PRODUCT_NAME} library" FORCE)
   endif()
-  if (NOT 3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR)
-    set (3RDPARTY_${LIBRARY_NAME}_LIBRARY "" CACHE FILEPATH "${LIBRARY_NAME} library" FORCE)
-  elseif (3RDPARTY_${LIBRARY_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}")
-    get_filename_component(3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR_TMP "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}" PATH)
-    if (NOT "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}" STREQUAL "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR_TMP}")
-      set (3RDPARTY_${LIBRARY_NAME}_LIBRARY "" CACHE FILEPATH "${LIBRARY_NAME} library" FORCE)
+
+  if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR)
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME} library")
+  endif()
+
+  if (WIN32)
+    if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DLL OR NOT 3RDPARTY_${PRODUCT_NAME}_DLL_DIR OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}")
+      set (3RDPARTY_${PRODUCT_NAME}_DLL "" CACHE FILEPATH "${PRODUCT_NAME} shared library" FORCE)
     endif()
   endif()
 
-  if (NOT 3RDPARTY_${LIBRARY_NAME}_LIBRARY OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}")
-    set (3RDPARTY_${LIBRARY_NAME}_LIBRARY "3RDPARTY_${LIBRARY_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to library of ${LIBRARY_NAME}" FORCE)
+  if (WIN32 AND NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DLL_DIR)
+    set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME} shared library")
+  endif()
 
-    string (TOLOWER "${LIBRARY_NAME}" lower_LIBRARY_NAME)
-    find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${lower_LIBRARY_NAME} PATHS
-                                                                         "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}"
-                                                                         "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}"
-                                                                         NO_DEFAULT_PATH)
+  # check 3RDPARTY_${PRODUCT_NAME}_ paths for consistency with specified 3RDPARTY_TBB_DIR
+  if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_${PRODUCT_NAME}_LIBRARY FILEPATH "the path to ${PRODUCT_NAME} library")
 
-      # second search if previous one do not find anything
-      find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${LIBRARY_NAME})
-  endif()
+    if (3RDPARTY_${PRODUCT_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
+      get_filename_component (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
+      set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}" CACHE PATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+    else()
+      CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR PATH "The directory containing ${PRODUCT_NAME} library")
+    endif()
 
-  if (NOT 3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}")
-    get_filename_component(3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}" PATH)
-  endif()
-  set (3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}" CACHE FILEPATH "The directory containing ${LIBRARY_NAME} library" FORCE)
+    if (WIN32)
+      CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_${PRODUCT_NAME}_DLL FILEPATH "the path to ${PRODUCT_NAME} shared library")
 
-  # search for dll in defined 3rdparty directory (just for win case)
-  if (WIN32)
-    set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
-
-    if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL_DIR)
-      set (3RDPARTY_${LIBRARY_NAME}_DLL "" CACHE FILEPATH "${LIBRARY_NAME} shared library" FORCE)
-    elseif (3RDPARTY_${LIBRARY_NAME}_DLL AND EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}")
-      get_filename_component(3RDPARTY_${LIBRARY_NAME}_DLL_DIR_TMP "${3RDPARTY_${LIBRARY_NAME}_DLL}" PATH)
-      if (NOT "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}" STREQUAL "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR_TMP}")
-        set (3RDPARTY_${LIBRARY_NAME}_DLL "" CACHE FILEPATH "${LIBRARY_NAME} shared library" FORCE)
+      if (3RDPARTY_${PRODUCT_NAME}_DLL AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+        get_filename_component (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
+        set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}" CACHE PATH "The directory containing ${PRODUCT_NAME} shared library" FORCE)
+      else()
+
+      CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_TBB_DIR 3RDPARTY_${PRODUCT_NAME}_DLL_DIR PATH "The directory containing ${PRODUCT_NAME} shared library")
       endif()
     endif()
+  endif()
 
-    if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}")
-      set (3RDPARTY_${LIBRARY_NAME}_DLL "3RDPARTY_${LIBRARY_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Path to shared library of ${LIBRARY_NAME}" FORCE)
+  OCCT_MAKE_COMPILER_SHORT_NAME()
+  OCCT_MAKE_COMPILER_BITNESS()
 
-      find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME} PATHS
-                                                                 "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}"
-                                                                 "${3RDPARTY_TBB_DIR}/bin/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}"
-                                                                 NO_DEFAULT_PATH)
+  if (${COMPILER_BITNESS} EQUAL 32)
+    set (${PRODUCT_NAME}_ARCH_NAME ia32)
+  else()
+    set (${PRODUCT_NAME}_ARCH_NAME intel64)
+  endif()
 
-        # second search if previous one do not find anything
-        find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME})
-    endif()
+  # tbb/tbbmalloc library
+  if (NOT 3RDPARTY_${PRODUCT_NAME}_LIBRARY OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
+    
+    set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .so .dylib)
+    set (PRODUCT_PATH_SUFFIXES lib ${lower_PRODUCT_NAME})
+
+    # set 3RDPARTY_${PRODUCT_NAME}_LIBRARY as notfound, otherwise find_library can't assign a new value to 3RDPARTY_${PRODUCT_NAME}_LIBRARY
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "The path to ${PRODUCT_NAME} library" FORCE)
+
+    if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
+      if (NOT EXISTS "${3RDPARTY_TBB_DIR}/lib/${${PRODUCT_NAME}_ARCH_NAME}/${COMPILER}")
+        if (EXISTS "${3RDPARTY_TBB_DIR}/lib/${${PRODUCT_NAME}_ARCH_NAME}")
+          file (GLOB ${PRODUCT_NAME}_COMPILER_LIST "${3RDPARTY_TBB_DIR}/lib/${${PRODUCT_NAME}_ARCH_NAME}/*")
+          if (${PRODUCT_NAME}_COMPILER_LIST)
+            list (GET ${PRODUCT_NAME}_COMPILER_LIST -1 THE_MOST_FRESH_COMPILER_VERSION)
+            if (THE_MOST_FRESH_COMPILER_VERSION)
+              get_filename_component (THE_MOST_FRESH_COMPILER_VERSION_NAME "${THE_MOST_FRESH_COMPILER_VERSION}" NAME)
+              set (PRODUCT_PATH_SUFFIXES lib ${lower_PRODUCT_NAME} lib/${${PRODUCT_NAME}_ARCH_NAME}/${THE_MOST_FRESH_COMPILER_VERSION_NAME})
+            endif()
+          endif()
+        endif()
+      else()
+        set (PRODUCT_PATH_SUFFIXES lib ${lower_PRODUCT_NAME} lib/${${PRODUCT_NAME}_ARCH_NAME}/${COMPILER})
+      endif()
 
-    if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL_DIR OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}")
-      get_filename_component(3RDPARTY_${LIBRARY_NAME}_DLL_DIR "${3RDPARTY_${LIBRARY_NAME}_DLL}" PATH)
-      set (3RDPARTY_${LIBRARY_NAME}_DLL_DIR "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}" CACHE FILEPATH "The directory containing ${LIBRARY_NAME} shared library" FORCE)
+      find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY ${lower_PRODUCT_NAME}
+                                         PATHS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}" "${3RDPARTY_TBB_DIR}"
+                                         PATH_SUFFIXES ${PRODUCT_PATH_SUFFIXES}
+                                         CMAKE_FIND_ROOT_PATH_BOTH
+                                         NO_DEFAULT_PATH)
+    else()
+      find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY ${lower_PRODUCT_NAME} 
+                                         PATH_SUFFIXES ${PRODUCT_PATH_SUFFIXES}
+                                         CMAKE_FIND_ROOT_PATH_BOTH)
     endif()
-  endif() # end dll search
-endforeach() # end tbb / tbbmalloc
 
-# include found paths to common variables
-if (3RDPARTY_TBB_INCLUDE_DIR AND EXISTS "${3RDPARTY_TBB_INCLUDE_DIR}")
-  list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_TBB_INCLUDE_DIR}")
-else()
-  list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_INCLUDE_DIR)
-endif()
+    if (3RDPARTY_${PRODUCT_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
+      get_filename_component (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
+      set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}" CACHE PATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+    else()
+      set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+    endif()
+  endif()
 
-foreach (LIBRARY_NAME TBB TBBMALLOC)
-  if (3RDPARTY_${LIBRARY_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY}")
-    list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}")
+  if (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
+    list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
   else()
-    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR)
+    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR)
+
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY "" CACHE FILEPATH "The path to ${PRODUCT_NAME} library" FORCE)
   endif()
 
+  # tbb/tbbmalloc shared library
   if (WIN32)
-    if (3RDPARTY_${LIBRARY_NAME}_DLL OR EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}")
-      list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}")
+    if (NOT 3RDPARTY_${PRODUCT_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+      set (CMAKE_FIND_LIBRARY_SUFFIXES .dll)
+      set (PRODUCT_PATH_SUFFIXES bin)
+
+      # set 3RDPARTY_${PRODUCT_NAME}_DLL as notfound, otherwise find_library can't assign a new value to 3RDPARTY_${PRODUCT_NAME}_DLL
+      set (3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "${PRODUCT_NAME} shared library" FORCE)
+
+      if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
+        if (NOT EXISTS "${3RDPARTY_TBB_DIR}/bin/${${PRODUCT_NAME}_ARCH_NAME}/${COMPILER}")
+          if (EXISTS "${3RDPARTY_TBB_DIR}/bin/${${PRODUCT_NAME}_ARCH_NAME}")
+            file (GLOB ${PRODUCT_NAME}_COMPILER_LIST "${3RDPARTY_TBB_DIR}/bin/${${PRODUCT_NAME}_ARCH_NAME}/*")
+            if (${PRODUCT_NAME}_COMPILER_LIST)
+              list (GET ${PRODUCT_NAME}_COMPILER_LIST -1 THE_MOST_FRESH_COMPILER_VERSION)
+              if (THE_MOST_FRESH_COMPILER_VERSION)
+                get_filename_component (THE_MOST_FRESH_COMPILER_VERSION_NAME "${THE_MOST_FRESH_COMPILER_VERSION}" NAME)
+                set (PRODUCT_PATH_SUFFIXES bin bin/${${PRODUCT_NAME}_ARCH_NAME}/${THE_MOST_FRESH_COMPILER_VERSION_NAME})
+              endif()
+            endif()
+          endif()
+        else()
+          set (PRODUCT_PATH_SUFFIXES bin bin/${${PRODUCT_NAME}_ARCH_NAME}/${COMPILER})
+        endif()
+
+        if (3RDPARTY_TBB_DIR AND EXISTS "${3RDPARTY_TBB_DIR}")
+          find_library (3RDPARTY_${PRODUCT_NAME}_DLL ${lower_PRODUCT_NAME}
+                                         PATHS "${3RDPARTY_TBB_DIR}"
+                                         PATH_SUFFIXES ${PRODUCT_PATH_SUFFIXES}
+                                         NO_DEFAULT_PATH)
+        else()
+          find_library (3RDPARTY_${PRODUCT_NAME}_DLL ${lower_PRODUCT_NAME} PATH_SUFFIXES ${PRODUCT_PATH_SUFFIXES})
+        endif()
+
+        if (3RDPARTY_${PRODUCT_NAME}_DLL AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+          get_filename_component (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
+          set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}" CACHE PATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+        else()
+          set (3RDPARTY_${PRODUCT_NAME}_DLL_DIR "" CACHE PATH "The directory containing ${PRODUCT_NAME} shared library" FORCE)
+
+          set (3RDPARTY_${PRODUCT_NAME}_DLL "" CACHE FILEPATH "${PRODUCT_NAME} shared library" FORCE)
+        endif()
+      endif()
+    endif()
+
+    if (3RDPARTY_${PRODUCT_NAME}_DLL_DIR OR EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}")
+      list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}")
     else()
-      list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBRARY_NAME}_DLL_DIR)
+      list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL_DIR)
     endif()
   endif()
-endforeach()
-
-# install tbb
-if (INSTALL_TBB)
-  OCCT_MAKE_OS_WITH_BITNESS()
-  OCCT_MAKE_COMPILER_SHORT_NAME()
 
-  if (WIN32)
-    install (FILES ${3RDPARTY_TBB_DLL} ${3RDPARTY_TBBMALLOC_DLL}
-             CONFIGURATIONS Release
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
-    install (FILES ${3RDPARTY_TBB_DLL} ${3RDPARTY_TBBMALLOC_DLL}
-             CONFIGURATIONS RelWithDebInfo
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
-    install (FILES ${3RDPARTY_TBB_DLL} ${3RDPARTY_TBBMALLOC_DLL}
-             CONFIGURATIONS Debug
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
-  else()
-    get_filename_component(TBBLIB ${3RDPARTY_TBB_LIBRARY} NAME)
-    get_filename_component(TBBMALLOCLIB ${3RDPARTY_TBBMALLOC_LIBRARY} NAME)
-
-    install (FILES ${3RDPARTY_TBB_LIBRARY}.2
-             CONFIGURATIONS Release
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
-             RENAME ${TBBLIB}.2)
-    install (FILES ${3RDPARTY_TBB_LIBRARY}.2
-             CONFIGURATIONS RelWithDebInfo
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libi"
-             RENAME ${TBBLIB}.2)
-    install (FILES ${3RDPARTY_TBB_LIBRARY}.2
-             CONFIGURATIONS Debug
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libd"
-             RENAME ${TBBLIB}.2)
-
-    install (FILES ${3RDPARTY_TBBMALLOC_LIBRARY}.2
-             CONFIGURATIONS Release
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
-             RENAME ${TBBMALLOCLIB}.2)
-    install (FILES ${3RDPARTY_TBBMALLOC_LIBRARY}.2
-             CONFIGURATIONS RelWithDebInfo
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libi"
-             RENAME ${TBBMALLOCLIB}.2)
-    install (FILES ${3RDPARTY_TBBMALLOC_LIBRARY}.2
-             CONFIGURATIONS Debug
-             DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libd"
-             RENAME ${TBBMALLOCLIB}.2)
+  # install tbb/tbbmalloc
+  if (INSTALL_${PRODUCT_NAME})
+    OCCT_MAKE_OS_WITH_BITNESS()
+    OCCT_MAKE_COMPILER_SHORT_NAME()
+
+    if (WIN32)
+      install (FILES ${3RDPARTY_${PRODUCT_NAME}_DLL}
+               CONFIGURATIONS Release
+               DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
+      install (FILES ${3RDPARTY_${PRODUCT_NAME}_DLL}
+               CONFIGURATIONS RelWithDebInfo
+               DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
+      install (FILES ${3RDPARTY_${PRODUCT_NAME}_DLL}
+               CONFIGURATIONS Debug
+               DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
+    else()
+      get_filename_component (PRODUCT_LIBRARY_NAME ${3RDPARTY_${PRODUCT_NAME}_LIBRARY} NAME)
+
+      install (FILES ${3RDPARTY_${PRODUCT_NAME}_LIBRARY}.2
+               CONFIGURATIONS Release
+               DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
+               RENAME ${PRODUCT_LIBRARY_NAME}.2)
+      install (FILES ${3RDPARTY_${PRODUCT_NAME}_LIBRARY}.2
+               CONFIGURATIONS RelWithDebInfo
+               DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libi"
+               RENAME ${PRODUCT_LIBRARY_NAME}.2)
+      install (FILES ${3RDPARTY_${PRODUCT_NAME}_LIBRARY}.2
+               CONFIGURATIONS Debug
+               DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libd"
+               RENAME ${PRODUCT_LIBRARY_NAME}.2)
+    endif()
   endif()
+  mark_as_advanced (3RDPARTY_${PRODUCT_NAME}_LIBRARY 3RDPARTY_${PRODUCT_NAME}_DLL)
+endmacro()
+
 
+TBB_PRODUCT_SEARCH (TBB)
+TBB_PRODUCT_SEARCH (TBBMALLOC)
+
+
+if (INSTALL_TBB)
   set (USED_3RDPARTY_TBB_DIR "")
 else()
   # the library directory for using by the executable
@@ -253,5 +280,3 @@ else()
     set (USED_3RDPARTY_TBB_DIR ${3RDPARTY_TBB_LIBRARY_DIR})
   endif()
 endif()
-
-mark_as_advanced (3RDPARTY_TBB_LIBRARY 3RDPARTY_TBBMALLOC_LIBRARY 3RDPARTY_TBB_DLL 3RDPARTY_TBBMALLOC_DLL)
index a5e1e86..859f176 100644 (file)
@@ -77,7 +77,7 @@ endif()
 
 if (WIN32)
   if (NOT 3RDPARTY_TCL_DLL)
-    set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
+    set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll)
 
     set (DLL_FOLDER_FOR_SEARCH "")
     if (3RDPARTY_TCL_DLL_DIR)
@@ -142,7 +142,7 @@ endif()
 
 if (WIN32)
   if (NOT 3RDPARTY_TCL_DLL)
-    set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
+    set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .dll)
 
     set (DLL_FOLDER_FOR_SEARCH "")
     if (3RDPARTY_TCL_DLL_DIR)
index 8e29c01..2bf0ca3 100644 (file)
@@ -44,7 +44,7 @@ INSTALL_MESSAGE (INSTALL_GL2PS            "GL2PS binaries")
 INSTALL_MESSAGE (INSTALL_TBB              "TBB binaries")
 INSTALL_MESSAGE (INSTALL_TCL              "TCL binaries")
 INSTALL_MESSAGE (INSTALL_TK               "TK binaries")
-INSTALL_MESSAGE (INSTALL_VTK              "VTK binaries ")
+#INSTALL_MESSAGE (INSTALL_VTK              "VTK binaries ")
 
 # build variables
 macro (BUILD_MODULE_MESSAGE BUILD_MODULE_TARGET_VARIABLE BUILD_MODULE_TARGET_STRING)
index 9446260..c463535 100644 (file)
 # vtk
 
-if (NOT DEFINED INSTALL_VTK)
-  set (INSTALL_VTK OFF CACHE BOOL "${INSTALL_VTK_DESCR}")
-endif()
+#if (NOT DEFINED INSTALL_VTK)
+#  set (INSTALL_VTK OFF CACHE BOOL "${INSTALL_VTK_DESCR}")
+#endif()
 
 # vtk directory
 if (NOT DEFINED 3RDPARTY_VTK_DIR)
-  set (3RDPARTY_VTK_DIR "" CACHE PATH "The directory containing vtk")
+  set (3RDPARTY_VTK_DIR "" CACHE PATH "The directory containing VTK")
+endif()
+
+set (3RDPARTY_VTK_REQUIRED_LIBRARIES vtkCommonCore
+                                     vtkCommonDataModel
+                                     vtkCommonExecutionModel
+                                     vtkCommonMath
+                                     vtkCommonTransforms
+                                     vtkRenderingCore
+                                     vtkRenderingFreeType
+                                     vtkRenderingFreeTypeOpenGL
+                                     vtkRenderingOpenGL
+                                     vtkFiltersGeneral
+                                     vtkIOCore
+                                     vtkIOImage
+                                     vtkImagingCore
+                                     vtkInteractionStyle)
+
+# include occt macros. compiler_bitness, os_wiht_bit, compiler
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
+
+# specify VTK folder in connectin with 3RDPARTY_DIR
+if (3RDPARTY_DIR AND EXISTS "${3RDPARTY_DIR}")
+  #CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_DIR 3RDPARTY_VTK_DIR PATH "The directory containing VTK")
+
+  if (NOT 3RDPARTY_VTK_DIR OR NOT EXISTS "${3RDPARTY_VTK_DIR}")
+    FIND_PRODUCT_DIR ("${3RDPARTY_DIR}" VTK VTK_DIR_NAME)
+    if (VTK_DIR_NAME)
+      set (3RDPARTY_VTK_DIR "${3RDPARTY_DIR}/${VTK_DIR_NAME}" CACHE PATH "The directory containing VTK" FORCE)
+    endif()
+  endif()
+else()
+  #set (3RDPARTY_VTK_DIR "" CACHE PATH "The directory containing VTK" FORCE)
 endif()
 
 # vtk include directory
 if (NOT DEFINED 3RDPARTY_VTK_INCLUDE_DIR)
-  set (3RDPARTY_VTK_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of vtk")
+  set (3RDPARTY_VTK_INCLUDE_DIR "" CACHE PATH "The directory containing headers of VTK")
 endif()
 
 # vtk library directory
 if (NOT DEFINED 3RDPARTY_VTK_LIBRARY_DIR)
-  set (3RDPARTY_VTK_LIBRARY_DIR "" CACHE FILEPATH "The directory containing vtk library")
+  set (3RDPARTY_VTK_LIBRARY_DIR "" CACHE PATH "The directory containing VTK libraries")
 endif()
 
 # vtk dll directory
 if (WIN32 AND NOT DEFINED 3RDPARTY_VTK_DLL_DIR)
-  set (3RDPARTY_VTK_DLL_DIR "" CACHE FILEPATH "The directory containing VTK dll")
+  set (3RDPARTY_VTK_DLL_DIR "" CACHE PATH "The directory containing VTK shared libraries")
 endif()
 
-# search for vtk in user defined directory
-if (NOT 3RDPARTY_VTK_DIR AND 3RDPARTY_DIR)
-  FIND_PRODUCT_DIR("${3RDPARTY_DIR}" vtk VTK_DIR_NAME)
-  if (VTK_DIR_NAME)
-    set (3RDPARTY_VTK_DIR "${3RDPARTY_DIR}/${VTK_DIR_NAME}" CACHE PATH "The directory containing vtk product" FORCE)
+# check 3RDPARTY_VTK_ paths for consistency with specified 3RDPARTY_VTK_DIR
+if (3RDPARTY_VTK_DIR AND EXISTS "${3RDPARTY_VTK_DIR}")
+  CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_VTK_DIR 3RDPARTY_VTK_INCLUDE_DIR PATH "The directory containing headers of VTK")
+  CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_VTK_DIR 3RDPARTY_VTK_LIBRARY_DIR PATH "The directory containing VTK libraries")
+
+  if (WIN32)
+    CHECK_PATH_FOR_CONSISTENCY (3RDPARTY_VTK_DIR 3RDPARTY_VTK_DLL_DIR PATH "The directory containing VTK shared library")
   endif()
 endif()
 
-# find installed vtk
+if (3RDPARTY_VTK_DIR AND EXISTS "${3RDPARTY_VTK_DIR}")
+  set (CACHED_VTK_DIR $ENV{VTK_DIR})
+  set (ENV{VTK_DIR} "${3RDPARTY_VTK_DIR}")
+endif()
+
 find_package(VTK QUIET)
 
-# find native vtk
-if (NOT VTK_FOUND)
-  find_package(VTK QUIET PATHS "${3RDPARTY_VTK_DIR}")
+if (3RDPARTY_VTK_DIR AND EXISTS "${3RDPARTY_VTK_DIR}")
+  set (ENV{VTK_DIR} ${CACHED_VTK_DIR})
 endif()
 
-if (NOT VTK_FOUND AND NOT 3RDPARTY_VTK_DIR OR NOT EXISTS "${3RDPARTY_VTK_DIR}")
-  message(SEND_ERROR "VTK not found. Set the 3RDPARTY_VTK_DIR cmake cache entry to the directory containing VTK.")
-  set (3RDPARTY_VTK_DIR "3RDPARTY_VTK_DIR-NOTFOUND" CACHE PATH "The directory containing vtk product" FORCE)
-endif()
+if (VTK_FOUND)
 
-set(VTK_VERSION "")
-if (3RDPARTY_VTK_DIR AND EXISTS "${3RDPARTY_VTK_DIR}")
-  get_filename_component(3RDPARTY_VTK_DIR_NAME "${3RDPARTY_VTK_DIR}" NAME)
-  string(REGEX MATCH "^VTK-([0-9].[0-9])" VTK_VERSION "${3RDPARTY_VTK_DIR_NAME}")
-  set(VTK_VERSION "${CMAKE_MATCH_1}")
-  if (NOT 3RDPARTY_VTK_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_VTK_INCLUDE_DIR}")
-    set (3RDPARTY_VTK_INCLUDE_DIR "${3RDPARTY_VTK_DIR}/include/vtk-${VTK_VERSION}" CACHE FILEPATH "The directory containing includes of VTK" FORCE)
+  # add compiler flags, preprocessor definitions, include and link dirs
+  include (${VTK_USE_FILE})
+
+  set (ALL_REQUIRED_VTK_LIBRARIES_FOUND ON)
+  if (VTK_LIBRARIES)
+
+    set (3RDPARTY_VTK_INCLUDE_DIRS)
+    set (3RDPARTY_VTK_LIBRARY_DIRS)
+    set (3RDPARTY_VTK_DLL_DIRS)
+
+    foreach (VTK_REQUIRED_LIBRARY ${3RDPARTY_VTK_REQUIRED_LIBRARIES})
+      list (FIND VTK_LIBRARIES ${VTK_REQUIRED_LIBRARY} FOUND_INDEX)
+      if (${FOUND_INDEX} EQUAL -1)
+        message (WARNING "VTK: required ${VTK_REQUIRED_LIBRARY} library is not found")
+        set (ALL_REQUIRED_VTK_LIBRARIES_FOUND OFF)
+      else()
+        # get paths from corresponding variables
+        if (${VTK_REQUIRED_LIBRARY}_INCLUDE_DIRS AND EXISTS "${${VTK_REQUIRED_LIBRARY}_INCLUDE_DIRS}")
+          list (APPEND 3RDPARTY_VTK_INCLUDE_DIRS "${${VTK_REQUIRED_LIBRARY}_INCLUDE_DIRS}")
+        endif()
+
+        if (${VTK_REQUIRED_LIBRARY}_LIBRARY_DIRS AND EXISTS "${${VTK_REQUIRED_LIBRARY}_LIBRARY_DIRS}")
+          list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_REQUIRED_LIBRARY}_LIBRARY_DIRS}")
+        endif()
+
+        if (${VTK_REQUIRED_LIBRARY}_RUNTIME_LIBRARY_DIRS AND EXISTS "${${VTK_REQUIRED_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
+          list (APPEND 3RDPARTY_VTK_DLL_DIRS "${${VTK_REQUIRED_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
+          if (NOT WIN32)
+            list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_REQUIRED_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
+          endif()
+        endif()
+
+        # get paths from corresponding properties
+        get_property (TARGET_VTK_IMPORT_CONFS TARGET ${VTK_REQUIRED_LIBRARY} PROPERTY IMPORTED_CONFIGURATIONS)
+
+        if (TARGET_VTK_IMPORT_CONFS)
+          list (GET TARGET_VTK_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
+          
+          # todo: choose configuration in connection with the build type
+          #if (CMAKE_BUILD_TYPE)
+          #  foreach (IMPORT_CONF ${TARGET_VTK_IMPORT_CONFS})
+          #  endforeach()
+          #endif()
+
+          get_property (TARGET_PROPERTY_IMP_PATH TARGET ${VTK_REQUIRED_LIBRARY} PROPERTY IMPORTED_IMPLIB_${CHOSEN_IMPORT_CONF})
+          if(TARGET_PROPERTY_IMP_PATH AND EXISTS "${TARGET_PROPERTY_IMP_PATH}")
+            get_filename_component (TARGET_PROPERTY_IMP_DIR "${TARGET_PROPERTY_IMP_PATH}" PATH)
+            list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_IMP_DIR}")
+          endif()
+
+          get_property (TARGET_PROPERTY_LOCATION_PATH TARGET ${VTK_REQUIRED_LIBRARY} PROPERTY IMPORTED_LOCATION_${CHOSEN_IMPORT_CONF})
+          if(TARGET_PROPERTY_LOCATION_PATH AND EXISTS "${TARGET_PROPERTY_LOCATION_PATH}")
+            get_filename_component (TARGET_PROPERTY_LOCATION_DIR "${TARGET_PROPERTY_LOCATION_PATH}" PATH)
+
+            if (WIN32)
+              list (APPEND 3RDPARTY_VTK_DLL_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
+            else()
+              list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
+            endif()
+          endif()
+        endif()
+      endif()
+      
+    endforeach()
+  else()  
+    set (ALL_REQUIRED_VTK_LIBRARIES_FOUND OFF)
   endif()
-  if (NOT 3RDPARTY_VTK_LIBRARY_DIR OR NOT EXISTS "${3RDPARTY_VTK_LIBRARY_DIR}")
-    if(EXISTS "${3RDPARTY_VTK_DIR}/lib")
-      set (3RDPARTY_VTK_LIBRARY_DIR "${3RDPARTY_VTK_DIR}/lib" CACHE FILEPATH "The directory containing libs of VTK" FORCE)
-    elseif (EXISTS "${3RDPARTY_VTK_DIR}/lib")
-      set (3RDPARTY_VTK_LIBRARY_DIR "${3RDPARTY_VTK_DIR}/lib" CACHE FILEPATH "The directory containing libs of VTK" FORCE)
+
+  if (ALL_REQUIRED_VTK_LIBRARIES_FOUND)
+
+    if (3RDPARTY_VTK_INCLUDE_DIRS)
+      list (REMOVE_DUPLICATES 3RDPARTY_VTK_INCLUDE_DIRS)
+      list (APPEND 3RDPARTY_INCLUDE_DIRS ${3RDPARTY_VTK_INCLUDE_DIRS})
+
+      list (GET 3RDPARTY_VTK_INCLUDE_DIRS 0 3RDPARTY_VTK_INCLUDE_DIR)
+      set (3RDPARTY_VTK_INCLUDE_DIR "${3RDPARTY_VTK_INCLUDE_DIR}" CACHE PATH "The directory containing headers of VTK" FORCE)
     endif()
-  endif()
-  if(3RDPARTY_VTK_LIBRARY_DIR)
-    list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_VTK_LIBRARY_DIR}")
-  endif()
-endif()
 
-# vtk libraries
-set (VTK_LIB_EXTENSION so.1)
-set (VTK_DLL_EXTENSION so.1)
-if (WIN32)
-  set (VTK_LIB_EXTENSION lib)
-  set (VTK_DLL_EXTENSION dll)
-endif()
+    if (3RDPARTY_VTK_LIBRARY_DIRS)
+      list (REMOVE_DUPLICATES 3RDPARTY_VTK_LIBRARY_DIRS)
+      list (APPEND 3RDPARTY_LIBRARY_DIRS ${3RDPARTY_VTK_LIBRARY_DIRS})
 
-set (VTK_LIBRARY_NAMES vtkCommonCore-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkCommonDataModel-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkCommonExecutionModel-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkCommonMath-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkCommonTransforms-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkRenderingCore-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkRenderingOpenGL-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkFiltersGeneral-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkIOCore-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkIOImage-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkImagingCore-${VTK_VERSION}.${VTK_LIB_EXTENSION}
-                       vtkInteractionStyle-${VTK_VERSION}.${VTK_LIB_EXTENSION})
-
-#dll
-set (VTK_DLL_NAMES vtkCommonComputationalGeometry-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkCommonCore-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkCommonDataModel-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkCommonExecutionModel-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkCommonMath-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkCommonMisc-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkCommonSystem-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkCommonTransforms-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkDICOMParser-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkFiltersCore-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkFiltersExtraction-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkFiltersGeneral-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkFiltersGeometry-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkFiltersSources-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkFiltersStatistics-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkIOCore-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkIOImage-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkImagingCore-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkImagingFourier-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkImagingHybrid-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkInteractionStyle-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkRenderingCore-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkRenderingOpenGL-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkalglib-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkjpeg-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkmetaio-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkpng-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtksys-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtktiff-${VTK_VERSION}.${VTK_DLL_EXTENSION}
-                   vtkzlib-${VTK_VERSION}.${VTK_DLL_EXTENSION} )
-
-# search for dll directory
-if (WIN32)
-  if (NOT 3RDPARTY_VTK_DLL_DIR OR NOT EXISTS "${3RDPARTY_VTK_DLL_DIR}")
-    if(EXISTS "${3RDPARTY_VTK_DIR}/bin")
-      set (3RDPARTY_VTK_DLL_DIR "${3RDPARTY_VTK_DIR}/bin" CACHE FILEPATH "The directory containing dll of VTK" FORCE)
-    elseif (EXISTS "${3RDPARTY_VTK_DIR}/bind")
-      set (3RDPARTY_VTK_DLL_DIR "${3RDPARTY_VTK_DIR}/bind" CACHE FILEPATH "The directory containing dll of VTK" FORCE)
+      list (GET 3RDPARTY_VTK_LIBRARY_DIRS 0 3RDPARTY_VTK_LIBRARY_DIR)
+      set (3RDPARTY_VTK_LIBRARY_DIR "${3RDPARTY_VTK_LIBRARY_DIR}" CACHE PATH "The directory containing VTK libraries" FORCE)
     endif()
-  endif()
 
-  if (3RDPARTY_VTK_DLL_DIR OR EXISTS "${3RDPARTY_VTK_DLL_DIR}")
-    list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_VTK_DLL_DIR}")
-  endif()
-endif() 
+    if (WIN32)
+      if (3RDPARTY_VTK_DLL_DIRS)
+        list (REMOVE_DUPLICATES 3RDPARTY_VTK_DLL_DIRS)
+        list (APPEND 3RDPARTY_DLL_DIRS ${3RDPARTY_VTK_DLL_DIRS})
 
-OCCT_CHECK_AND_UNSET(VTK_DIR)
+        list (GET 3RDPARTY_VTK_DLL_DIRS 0 3RDPARTY_VTK_DLL_DIR)
+        set (3RDPARTY_VTK_DLL_DIR "${3RDPARTY_VTK_DLL_DIR}" CACHE PATH "The directory containing VTK shared libraries" FORCE)
+      endif()
+    endif()
+  endif()
+endif()
 
 if (3RDPARTY_VTK_INCLUDE_DIR AND EXISTS "${3RDPARTY_VTK_INCLUDE_DIR}")
-  list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_VTK_INCLUDE_DIR}")
+  list (APPEND 3RDPARTY_INCLUDE_DIRS ${3RDPARTY_VTK_INCLUDE_DIR})
 else()
   list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_VTK_INCLUDE_DIR)
 endif()
 
-if (INSTALL_VTK)
-  OCCT_MAKE_OS_WITH_BITNESS()
-  OCCT_MAKE_COMPILER_SHORT_NAME()
+if (3RDPARTY_VTK_LIBRARY_DIR AND EXISTS "${3RDPARTY_VTK_LIBRARY_DIR}")
+  list (APPEND 3RDPARTY_LIBRARY_DIRS ${3RDPARTY_VTK_LIBRARY_DIR})
+else()
+  list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_VTK_LIBRARY_DIR)
+endif()
 
-  if (WIN32)
-    if(3RDPARTY_VTK_DLL_DIR AND EXISTS "${3RDPARTY_VTK_DLL_DIR}")
-      set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
-      foreach(VTK_DLL_NAME ${VTK_DLL_NAMES})
-        
-        set (3RDPARTY_VTK_DLL "3RDPARTY_VTK_DLL-NOTFOUND" CACHE FILEPATH "VTK shared library" FORCE)
-        find_library(3RDPARTY_VTK_DLL "${VTK_DLL_NAME}" PATHS "${3RDPARTY_VTK_DLL_DIR}" NO_DEFAULT_PATH)
-        
-        if (NOT 3RDPARTY_VTK_DLL OR NOT EXISTS "${3RDPARTY_VTK_DLL}")
-          list (APPEND 3RDPARTY_NOT_INCLUDED "${3RDPARTY_VTK_DLL}")
-        else()
-          install (FILES ${3RDPARTY_VTK_DLL}
-                   CONFIGURATIONS Release
-                   DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin")
-          install (FILES ${3RDPARTY_VTK_DLL}
-                   CONFIGURATIONS RelWithDebInfo
-                   DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bini")
-          install (FILES ${3RDPARTY_VTK_DLL}
-                   CONFIGURATIONS Debug
-                   DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bind")
-        endif()
-      endforeach()
-      OCCT_CHECK_AND_UNSET(3RDPARTY_VTK_DLL)
-    endif()
-  else ()
-    foreach(VTK_DLL_NAME ${VTK_DLL_NAMES})
-      install(FILES "${3RDPARTY_VTK_LIBRARY_DIR}/lib${VTK_DLL_NAME}"
-              CONFIGURATIONS Release
-              DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib"
-              RENAME "lib${VTK_DLL_NAME}")
-      install(FILES "${3RDPARTY_VTK_LIBRARY_DIR}/lib${VTK_DLL_NAME}"
-              CONFIGURATIONS RelWithDebInfo
-              DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libi"
-              RENAME "lib${VTK_DLL_NAME}")
-      install(FILES "${3RDPARTY_VTK_LIBRARY_DIR}/lib${VTK_DLL_NAME}"
-              CONFIGURATIONS Debug
-              DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/libd"
-              RENAME "lib${VTK_DLL_NAME}")
-    endforeach()
+if (WIN32)
+  if (3RDPARTY_VTK_DLL_DIR OR EXISTS "${3RDPARTY_VTK_DLL_DIR}")
+    list (APPEND 3RDPARTY_DLL_DIRS ${3RDPARTY_VTK_DLL_DIR})
+  else()
+    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_VTK_DLL_DIR)
   endif()
+endif()
 
-  set (USED_3RDPARTY_VTK_DIR "")
+# the library directory for using by the executable
+if (WIN32)
+  set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_DLL_DIR})
 else()
-  # the library directory for using by the executable
-  if (WIN32)
-    set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_DLL_DIR})
-  else()
-    set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_LIBRARY_DIR})
-  endif()
+  set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_LIBRARY_DIR})
 endif()
 
 mark_as_advanced (VTK_INCLUDE_DIRS VTK_LIBRARY_DIRS VTK_DIR)
index c369ad6..43447d8 100644 (file)
@@ -3,6 +3,7 @@ TKService
 TKMath
 TKV3d
 TKOpenGl
+CSF_XwLibs
 CSF_OpenGlLibs
 CSF_user32
 CSF_gdi32
index 4eabe06..951aa23 100755 (executable)
@@ -11,6 +11,7 @@ TKService
 TKHLR
 CSF_TclLibs
 CSF_TclTkLibs
+CSF_XwLibs
 CSF_gdi32
 CSF_advapi32
 CSF_user32
index fc1f509..3e297e2 100644 (file)
@@ -1,6 +1,7 @@
 CSF_VTK
 CSF_TclLibs
 CSF_TclTkLibs
+CSF_XwLibs
 TKernel
 TKBRep
 TKDraw
index 078b54b..ebaf119 100755 (executable)
@@ -3,6 +3,7 @@ TKService
 TKMath
 TKV3d
 CSF_OpenGlLibs
+CSF_XwLibs
 CSF_objc
 CSF_Appkit
 CSF_IOKit
index 94e3890..998bb75 100755 (executable)
@@ -13,4 +13,5 @@ TKHLR
 CSF_user32
 CSF_gdi32
 CSF_OpenGlLibs
+CSF_XwLibs
 CSF_FREETYPE
index dab8295..9181318 100755 (executable)
@@ -20,6 +20,7 @@ TKDraw
 TKOpenGl
 CSF_TclLibs
 CSF_TclTkLibs
+CSF_XwLibs
 CSF_user32
 CSF_gdi32
 CSF_OpenGlLibs