0024888: Refactoring of OCCT CMake meta-project
authoribs <ibs@opencascade.com>
Thu, 18 Sep 2014 11:22:02 +0000 (15:22 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 18 Sep 2014 11:22:41 +0000 (15:22 +0400)
user sees just dirs of libs, shared libs and headers of 3rdparty products
documentation updated

3rdparty search priority was fixed: 1. user paths; 2. system paths
3rdparty debug usage fixed
vtk search introduced
occt information, generated by wok, was divided onto two files: occt_toolkits.cmake and occt_inc_toolkits.cmake
additional behavior of cmake search for freetype 2.5.1 and above

CMake (version < 3.0) don't know about new place of config/ftheader.h in freetype 2.5.1. There are cases when cmake seeks config/ftheader.h in defined place (3RDPARTY_FREETYPE_DIR variable), doesn't find it and start new search in system places. If system has own freetype header- cmake will find it and 3RDPARTY_FREETYPE* variables will point to different places. This situation is avoided

tcl, freetype, vtk are checked before usage of it (CSF variables usage)
tbb search mechanism was refactored
freetype search is processed by default cmake mechanism
tcl search is processed by default cmake mechanism

3rdparty macro seeks debug libraries (and release if debug ones aren't found); 3rdparty dll is sought in win case only

ADD_SUBDIRECTORY preferred to SUBDIRS

gendoc.bat search for tclsh.exe in user's system

0025141: CMake / MinGW: link recipe fails due to long command

0025146: Porting to Android

OCCT documentation updated. "Building with CMake and ADT for Android" article added

[CMAKE] custom.sh.in uses library variables instead unused dll ones.

-DDEBUG remove from CMAKE_CXX_FLAGS_DEBUG and CMAKE_C_FLAGS_DEBUG

hide unused 3rdparty in android case

also messages of freetype search mechanism slightly updated

46 files changed:
CMakeLists.txt
adm/templates/3rdparty_macro.cmake [new file with mode: 0644]
adm/templates/custom.bat.in
adm/templates/custom.bat.main
adm/templates/custom.sh.in
adm/templates/custom.sh.main
adm/templates/env.bat.in
adm/templates/env.sh.in
adm/templates/freeimage.cmake [new file with mode: 0644]
adm/templates/freeimageplus.cmake [new file with mode: 0644]
adm/templates/freetype.cmake [new file with mode: 0644]
adm/templates/gl2ps.cmake [new file with mode: 0644]
adm/templates/glx.cmake [new file with mode: 0644]
adm/templates/occt_defs_flags.cmake [new file with mode: 0644]
adm/templates/occt_macros.cmake [new file with mode: 0644]
adm/templates/opencl.cmake [new file with mode: 0644]
adm/templates/tbb.cmake
adm/templates/tcl.cmake
dox/FILES_HTML.txt
dox/dev_guides/building/android/android.md [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image001.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image002.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image003.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image004.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image005.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image006.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image007.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image008.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image009.png [new file with mode: 0644]
dox/dev_guides/building/android/images/android_image010.png [new file with mode: 0644]
dox/dev_guides/building/building.md
dox/dev_guides/building/cmake/cmake.md
dox/dev_guides/building/cmake/images/cmake_image006.png [deleted file]
dox/overview/overview.md
gendoc.bat
samples/mfc/standard/01_Geometry/CMakeLists.txt
samples/mfc/standard/02_Modeling/CMakeLists.txt
samples/mfc/standard/03_Viewer2d/CMakeLists.txt
samples/mfc/standard/04_Viewer3d/CMakeLists.txt
samples/mfc/standard/05_ImportExport/CMakeLists.txt
samples/mfc/standard/06_Ocaf/CMakeLists.txt
samples/mfc/standard/07_Triangulation/CMakeLists.txt
samples/mfc/standard/08_HLR/CMakeLists.txt
samples/mfc/standard/09_Animation/CMakeLists.txt
samples/mfc/standard/10_Convert/CMakeLists.txt
samples/mfc/standard/mfcsample/CMakeLists.txt

index 4c841d1..6236d42 100644 (file)
-cmake_minimum_required ( VERSION 2.6)
+cmake_minimum_required (VERSION 2.8.10 FATAL_ERROR)
 
 set (CMAKE_SUPPRESS_REGENERATION TRUE)
 
+# set build configurations list
 if (NOT BUILD_CONFIGURATION)
-  set(BUILD_CONFIGURATION "Release" CACHE STRING "Build type of OCCT" FORCE)
+  set (BUILD_CONFIGURATION "Release" CACHE STRING "Build type of OCCT" FORCE)
   SET_PROPERTY(CACHE BUILD_CONFIGURATION PROPERTY STRINGS Release Debug RelWithDebInfo)
 endif()
 
-set(CMAKE_CONFIGURATION_TYPES ${BUILD_CONFIGURATION} CACHE INTERNAL "" FORCE)
+set (CMAKE_CONFIGURATION_TYPES ${BUILD_CONFIGURATION} CACHE INTERNAL "" FORCE)
 
-project(OCCT)
+# the name of the project
+project (OCCT)
 
-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+# Solution folder property
+set_property (GLOBAL PROPERTY USE_FOLDERS ON)
 
-set(BUILD_SHARED_LIBS ON)
+set (CMAKE_BUILD_TYPE ${BUILD_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
 
-IF("${BUILD_CONFIGURATION}" STREQUAL "${CMAKE_BUILD_TYPE}")
-  SET(CHANGES_ARE_NEEDED OFF)
-ELSE()
-  SET(CHANGES_ARE_NEEDED ON)
-ENDIF()
-
-MATH(EXPR COMPILER_BITNESS "32 + 32*(${CMAKE_SIZEOF_VOID_P}/8)")
-
-SET(CMAKE_BUILD_TYPE ${BUILD_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
+# install dir of the built project
+set (INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
+set (CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
 
-SET(INSTALL_DIR "" CACHE PATH "Directory that will contain install files of OCCT" )
-SET(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "" FORCE )
+# whether install test bundle or not
+set (INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
 
-set(BUILD_PATCH_DIR "" CACHE PATH "directory with occt patch")
+set (BUILD_PATCH_DIR "" CACHE PATH "directory with OCCT patch")
 
+# the list of being built toolkits
 set (BUILD_TOOLKITS "" CACHE STRING "Toolkits are also included in OCCT")
-separate_arguments(BUILD_TOOLKITS)
-
-IF(MSVC)
-  SET(BUILD_Samples OFF CACHE BOOL "OCCT samples building")
-ENDIF()
-
-# consider for patch existence
-SET (IS_PATCH_CURRENT "NO")
-SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
-IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "")
-  SET (IS_PATCH_CURRENT "YES")
-  SET (TK_ROOT_DIR ${BUILD_PATCH_DIR})
-ENDIF()
-
-# include the list of patch modules if the one exists
-# or include the list of original modules
-IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/CMakeModules.txt")
-  MESSAGE(STATUS "Info: the list of patched modules is included")
-  include(${BUILD_PATCH_DIR}/adm/cmake/CMakeModules.txt)
-ELSE()
-  include(adm/cmake/CMakeModules.txt)
-ENDIF()
-
-if (WIN32)
-  set(SCRIPT_EXT bat)
-else()
-  set(SCRIPT_EXT sh)
-endif()
+separate_arguments (BUILD_TOOLKITS)
 
 if (MSVC)
-  add_definitions(/fp:precise)
-endif()
-
-# choose SSE2 option for appropriate MSVC compilers
-if (MSVC80 OR MSVC90 OR MSVC10)
-  if (${COMPILER_BITNESS} STREQUAL 32)
-    add_definitions(/arch:SSE2)
-  endif()
+  set (BUILD_MFC_SAMPLES OFF CACHE BOOL "OCCT samples building")
 endif()
 
-# set compiler short name
-if (MSVC)
-  if (MSVC70)
-    set (COMPILER vc7)
-  elseif (MSVC80)
-    set (COMPILER vc8)
-  elseif (MSVC90)
-    set (COMPILER vc9)
-  elseif (MSVC10)
-    set (COMPILER vc10)
-  elseif (MSVC11)
-    set (COMPILER vc11)
-  elseif (MSVC12)
-    set (COMPILER vc12)
-  endif()
-elseif (DEFINED CMAKE_COMPILER_IS_GNUCC)
-  set (COMPILER gcc)
-elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
-  set (COMPILER gxx)
-elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
-  set (COMPILER clang)
-elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
-  set (COMPILER icc)
-else()
-  set (COMPILER ${CMAKE_GENERATOR})
-  string (REGEX REPLACE " " "" COMPILER ${COMPILER})
+# whether use optional 3rdparty or not
+if (APPLE)
+  set (USE_GLX OFF CACHE BOOL "Are X11 OpenGL used on OSX or not")
 endif()
 
-if (WIN32)
-  SET(OS_WITH_BIT "win${COMPILER_BITNESS}")
-elseif(APPLE)
-  SET(OS_WITH_BIT "mac${COMPILER_BITNESS}")
-else()
-  SET(OS_WITH_BIT "lin${COMPILER_BITNESS}")
-endif()
+set (USE_FREEIMAGE OFF CACHE BOOL "Is freeimage used or not")
 
-add_definitions(-DCSFDB)
-if(WIN32)
-  add_definitions(/DWNT -wd4996)
-elseif(APPLE)
-  add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS)
-else()
-  add_definitions(-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DLIN)
+if (NOT DEFINED ANDROID)
+  set (USE_GL2PS OFF CACHE BOOL "Is gl2ps used or not")
+  set (USE_TBB OFF CACHE BOOL "Is tbb used or not")
+  set (USE_OPENCL OFF CACHE BOOL "Is OpenCL used or not")
 endif()
 
-# enable structured exceptions for MSVC
-string(REGEX MATCH "EHsc" ISFLAG "${CMAKE_CXX_FLAGS}")
-IF(ISFLAG)
-  STRING(REGEX REPLACE "EHsc" "EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-ELSEIF(WIN32)
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHa")
-ENDIF()
-
-# enable parallel compilation on MSVC 9 and above
-IF(WIN32)
-  IF(NOT DEFINED MSVC70 AND NOT DEFINED MSVC80)
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
-  ENDIF()
-ENDIF()
-
-# increase compiler warnings level (-W4 for MSVC, -Wall for GCC)
-IF(MSVC)
-  if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
-    string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+# macro: include patched file if it exists
+macro (OCCT_INCLUDE_CMAKE_FILE BEING_INCLUDED_FILE)
+  if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake")
+    include(${BUILD_PATCH_DIR}/${BEING_INCLUDED_FILE}.cmake)
   else()
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
+    include(${BEING_INCLUDED_FILE}.cmake)
   endif()
-elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
-endif()
-
-SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
-SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
-
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEB")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEB")
+endmacro()
 
-set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
-set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib)
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin)
+# include occt macros
+OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_macros")
 
-# RESOURCES
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/DrawResources" DESTINATION  "${INSTALL_DIR}/src" )
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/StdResource" DESTINATION  "${INSTALL_DIR}/src" )
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/SHMessage" DESTINATION  "${INSTALL_DIR}/src" )
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Textures" DESTINATION  "${INSTALL_DIR}/src" )
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/Shaders" DESTINATION  "${INSTALL_DIR}/src" )
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSMessage" DESTINATION  "${INSTALL_DIR}/src" )
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XSTEPResource" DESTINATION  "${INSTALL_DIR}/src" )
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/XmlOcafResource" DESTINATION  "${INSTALL_DIR}/src" )
-
-install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Lexi_Expr.dat" DESTINATION  "${INSTALL_DIR}/src/UnitsAPI" )
-install(FILES "${CMAKE_SOURCE_DIR}/src/UnitsAPI/Units.dat"     DESTINATION  "${INSTALL_DIR}/src/UnitsAPI" )
-install(FILES "${CMAKE_SOURCE_DIR}/src/TObj/TObj.msg" DESTINATION  "${INSTALL_DIR}/src/TObj" )
-
-IF("${BUILD_CONFIGURATION}" STREQUAL "Debug") 
-  SET(3RDPARTY_BUILD_SUFFIX "") # debug == release
-  SET(BUILD_SUFFIX "d")
-ELSE()
-  SET(3RDPARTY_BUILD_SUFFIX "") 
-  SET(BUILD_SUFFIX "")
-ENDIF()
-
-FUNCTION(SUBDIRECTORY_NAMES MAIN_DIRECTORY RESULT)
-  file(GLOB SUB_ITEMS "${MAIN_DIRECTORY}/*")
-
-  foreach(ITEM ${SUB_ITEMS})
-    if(IS_DIRECTORY "${ITEM}")
-      GET_FILENAME_COMPONENT(ITEM_NAME "${ITEM}" NAME)
-      LIST(APPEND LOCAL_RESULT "${ITEM_NAME}")
-    endif()
-  endforeach()
-  set (${RESULT} ${LOCAL_RESULT} PARENT_SCOPE)
-ENDFUNCTION()
-
-FUNCTION(FIND_PRODUCT_DIR ROOT_DIR PRODUCT_NAME RESULT)
-  string( TOLOWER "${PRODUCT_NAME}" lower_PRODUCT_NAME )
-
-  LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*${COMPILER}.*${COMPILER_BITNESS}")
-  LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER}.*${COMPILER_BITNESS}")
-  LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER_BITNESS}")
-  LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+")
-  LIST(APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}")
-
-  SUBDIRECTORY_NAMES( "${ROOT_DIR}" SUBDIR_NAME_LIST)
-
-  FOREACH( SEARCH_TEMPLATE ${SEARCH_TEMPLATES})
-    IF(LOCAL_RESULT)
-      BREAK()
-    ENDIF()
-
-    FOREACH(SUBDIR_NAME ${SUBDIR_NAME_LIST})
-      string( TOLOWER "${SUBDIR_NAME}" lower_SUBDIR_NAME )
-
-      STRING(REGEX MATCH "${SEARCH_TEMPLATE}" DUMMY_VAR "${lower_SUBDIR_NAME}")
-      IF(DUMMY_VAR)
-        LIST(APPEND LOCAL_RESULT ${SUBDIR_NAME})
-      ENDIF()
-    ENDFOREACH()
-  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)
-    SET(${RESULT} ${DUMMY} PARENT_SCOPE)
-  ENDIF()
-ENDFUNCTION()
-
-IF(WIN32)
-  SET(DLL_SO "dll")
-  SET(DLL_SO_FOLDER "bin")
-  SET(DLL_SO_PREFIX "")
-ELSEIF(APPLE)
-  SET(DLL_SO "dylib")
-  SET(DLL_SO_FOLDER "lib")
-  SET(DLL_SO_PREFIX "lib")
-ELSE()
-  SET(DLL_SO "so")
-  SET(DLL_SO_FOLDER "lib")
-  SET(DLL_SO_PREFIX "lib")
-ENDIF()
+# BUILD_POSTFIX variable is used by all toolkit cmakelists.txt projects
+OCCT_MAKE_BUILD_POSTFIX()
 
-SET(3RDPARTY_DIR ${CMAKE_SOURCE_DIR} CACHE PATH "Directory contains required 3rdparty products")
-SET(3RDPARTY_INCLUDE_DIRS "")
-SET(3RDPARTY_NOT_INCLUDED)
+# include the patched or original list of modules
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_modules")
 
-IF(APPLE)
-  SET(USE_GLX OFF CACHE BOOL "whether use X11 OpenGL on OSX or not")
-ENDIF()
+# include the list of being used toolkits. USED_TOOLKITS variable
+OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_toolkits")
 
-SET(USE_GL2PS OFF CACHE BOOL "whether use gl2ps product or not")
-SET(USE_FREEIMAGE OFF CACHE BOOL "whether use freeimage product or not")
-SET(USE_TBB OFF CACHE BOOL "whether use tbb product or not")
-SET(USE_OPENCL OFF CACHE BOOL "whether use OpenCL or not")
+# include the patched or original list of definitions and flags
+OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_defs_flags")
 
-SET(INSTALL_TESTS OFF CACHE BOOL "Is tests copy to install directory")
+OCCT_INCLUDE_CMAKE_FILE ("adm/templates/3rdparty_macro")
 
-MACRO (CHECK_AND_UNSET VARNAME)
-  IF(DEFINED ${VARNAME})
-    UNSET(${VARNAME} CACHE)
-  ENDIF()
-ENDMACRO()
-
-MACRO (CHECK_AND_UNSET_GROUP VARNAME)
-  CHECK_AND_UNSET ("${VARNAME}_DIR")
-  CHECK_AND_UNSET ("${VARNAME}_INCLUDE_DIR")
-  CHECK_AND_UNSET ("${VARNAME}_DLL")
-  CHECK_AND_UNSET ("${VARNAME}_LIBRARY")
-ENDMACRO()
-
-MACRO(THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME)
-  IF(NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_DIR)
-    SET(3RDPARTY_${PRODUCT_NAME}_DIR "" CACHE PATH "Directory contains ${PRODUCT_NAME} product")
-  ENDIF()
-
-  IF(3RDPARTY_DIR AND ("${3RDPARTY_${PRODUCT_NAME}_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
-    FIND_PRODUCT_DIR("${3RDPARTY_DIR}" ${PRODUCT_NAME} ${PRODUCT_NAME}_DIR_NAME)
-    IF("${${PRODUCT_NAME}_DIR_NAME}" STREQUAL "")
-      MESSAGE(STATUS "${PRODUCT_NAME} DON'T FIND")
-    ELSE()
-      SET(3RDPARTY_${PRODUCT_NAME}_DIR "${3RDPARTY_DIR}/${${PRODUCT_NAME}_DIR_NAME}" CACHE PATH "Directory contains ${PRODUCT_NAME} product" FORCE)
-    ENDIF()
-  ENDIF()
-
-  SET(INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "Is ${PRODUCT_NAME} lib copy to install directory")
-
-  IF(3RDPARTY_${PRODUCT_NAME}_DIR)
-    IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
-      SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
-      if ("${PRODUCT_NAME}" STREQUAL "FREETYPE")
-        FIND_PATH(3RDPARTY_FREETYPE_INCLUDE_DIR ${HEADER_NAME} PATHS "${3RDPARTY_FREETYPE_DIR}/include" "${3RDPARTY_FREETYPE_DIR}/include/freetype2" NO_DEFAULT_PATH)
-      else()
-        FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/include" NO_DEFAULT_PATH)
-      endif()
-    ENDIF()
-
-    IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
-      SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to library of the ${PRODUCT_NAME} product" FORCE)
-      FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME}  PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/lib" NO_DEFAULT_PATH)
-    ENDIF()
-
-    IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
-      SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Path to shared library of the ${PRODUCT_NAME} product" FORCE)
-      FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}"  PATHS "${3RDPARTY_${PRODUCT_NAME}_DIR}/${DLL_SO_FOLDER}" NO_DEFAULT_PATH)
-    ENDIF()
-
-    MARK_AS_ADVANCED(3RDPARTY_${PRODUCT_NAME}_DIR)
-  ELSE()
-
-  ENDIF()
-
-  # check default path (with additions) for header search
-  IF("${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND")
-    SET(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR "3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the ${PRODUCT_NAME} product" FORCE)
-    FIND_PATH(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR ${HEADER_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_HEADER})
-  ENDIF()
-
-  # check default path (with additions) for library search
-  IF("${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND")
-    SET(3RDPARTY_${PRODUCT_NAME}_LIBRARY "3RDPARTY_${PRODUCT_NAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "Directory contains library of the ${PRODUCT_NAME} product" FORCE)
-    FIND_LIBRARY(3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME} ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_LIB})
-  ENDIF()
-
-  # check default path (with additions) for DLL search
-  IF("${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "" OR "${3RDPARTY_${PRODUCT_NAME}_DLL}" STREQUAL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND")
-    SET(3RDPARTY_${PRODUCT_NAME}_DLL "3RDPARTY_${PRODUCT_NAME}_DLL-NOTFOUND" CACHE FILEPATH "Directory contains shared library of the ${PRODUCT_NAME} product" FORCE)
-    FIND_FILE(3RDPARTY_${PRODUCT_NAME}_DLL "${DLL_SO_PREFIX}${LIBRARY_NAME}.${DLL_SO}" ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_DLL})
-  ENDIF()
-
-  IF(3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
-    SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
-  ENDIF()
+set (3RDPARTY_DIR_LABEL "The directory containing required 3rdparty products")
+if (NOT DEFINED 3RDPARTY_DIR)
+  set (3RDPARTY_DIR "" CACHE PATH ${3RDPARTY_DIR_LABEL})
+endif()
 
-  IF(3RDPARTY_${PRODUCT_NAME}_LIBRARY)
-    GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" PATH)
-    SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_LIBRARY)
-  ENDIF()
+# search for 3rdparty dir
+if ("${3RDPARTY_DIR}" STREQUAL "")
+  if (DEFINED ENV{3RDPARTY_DIR})
+    set (3RDPARTY_DIR "$ENV{3RDPARTY_DIR}" CACHE PATH ${3RDPARTY_DIR_LABEL} 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_LABEL} FORCE)
+  endif()
+endif()
 
-  IF(3RDPARTY_${PRODUCT_NAME}_DLL)
-    #
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL)
-  ENDIF()
+# search for CSF_TclLibs variable in EXTERNLIB of each being used toolkit
+OCCT_IS_PRODUCT_REQUIRED(CSF_TclLibs USE_TCL)
 
-  IF(INSTALL_${PRODUCT_NAME})
-    INSTALL(FILES "${3RDPARTY_${PRODUCT_NAME}_DLL}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${DLL_SO_FOLDER}${BUILD_SUFFIX}")
-    SET(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "")
-  ELSE()
-    GET_FILENAME_COMPONENT(3RDPARTY_${PRODUCT_NAME}_DLL_DIR "${3RDPARTY_${PRODUCT_NAME}_DLL}" PATH)
-  ENDIF()
-ENDMACRO()
-
-# TCL
-INCLUDE(adm/templates/tcl.cmake)
-
-#install tcltk
-IF(INSTALL_TCL)
-  SET(3RDPARTY_TCL_DLL_DIR "")
-  SET(3RDPARTY_TCL_LIB_DIR "")
-  
-  GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR_INSIDE "${3RDPARTY_TCL_LIBRARY}" PATH)
-  GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR_INSIDE "${3RDPARTY_TCL_DLL}" PATH)
-
-  IF (IS_TCL_VERSION_FOUND)
-    SET (TCL_VERSION ${TCL_MAJOR_VERSION}${TCL_SEP}${TCL_MINOR_VERSION})
-    SET (TCL_FOLDER_VERSION ${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION})
-  ELSE()
-    SET (TCL_VERSION "")
-
-    #TODO SEARCH tclX.X & tkX.X subdirs
-    SET (TCL_FOLDER_VERSION "")
-  ENDIF()
-  
-  INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR_INSIDE}/${DLL_SO_PREFIX}tcl${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${DLL_SO_FOLDER}${BUILD_SUFFIX}")
-  INSTALL(FILES "${3RDPARTY_TCL_DLL_DIR_INSIDE}/${DLL_SO_PREFIX}tk${TCL_VERSION}.${DLL_SO}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${DLL_SO_FOLDER}${BUILD_SUFFIX}")
-  
-  IF (IS_TCL_VERSION_FOUND)
-    # tcl is required to install in lib folder (without ${BUILD_SUFFIX})
-    INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tcl8" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
-    INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tcl${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
-    INSTALL(DIRECTORY "${3RDPARTY_TCL_LIB_DIR_INSIDE}/tk${TCL_FOLDER_VERSION}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
-  ELSE()
-    MESSAGE(STATUS "\nWarning: tclX.X and tkX.X subdirs won't be copyied during the installation process.")
-    MESSAGE(STATUS "Try seeking tcl within another folder by changing 3RDPARTY_TCL_DIR variable.")
-  ENDIF()
-ELSE()
-  GET_FILENAME_COMPONENT(3RDPARTY_TCL_DLL_DIR "${3RDPARTY_TCL_DLL}" PATH)
-  GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIB_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
-ENDIF()
+if ("${USE_TCL}" STREQUAL ON)
+  message (STATUS "Info: tcl is used by OCCT")
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/tcl")
+else()
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_TCL_DIR")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_TCL_INCLUDE_DIR")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_TCL_LIBRARY")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_TCL_LIBRARY_DIR")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_TK_INCLUDE_DIR")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_TK_LIBRARY")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_TK_LIBRARY_DIR")
+endif()
 
 # GLX
-IF(USE_GLX)
-  ADD_DEFINITIONS(-DMACOSX_USE_GLX)
-
-  IF(NOT DEFINED 3RDPARTY_GLX_DIR)
-    SET(3RDPARTY_GLX_DIR "" CACHE PATH "Directory contains GLX product")
-  ENDIF()
-
-  IF(3RDPARTY_DIR AND ("${3RDPARTY_GLX_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
-    FIND_PRODUCT_DIR("${3RDPARTY_DIR}" GLX GLX_DIR_NAME)
-    IF("${GLX_DIR_NAME}" STREQUAL "")
-      MESSAGE(STATUS "GLX DON'T FIND")
-    ELSE()
-      SET(3RDPARTY_GLX_DIR "${3RDPARTY_DIR}/${GLX_DIR_NAME}" CACHE PATH "Directory contains GLX product" FORCE)
-    ENDIF()
-  ENDIF()
-
-  IF(3RDPARTY_GLX_DIR)
-    SET(3RDPARTY_GLX_INCLUDE_DIR "${3RDPARTY_GLX_DIR}/include" CACHE FILEPATH "Directory contains headers of the GLX product" FORCE)
-    SET(3RDPARTY_GLX_LIBRARY_DIR "${3RDPARTY_GLX_DIR}/lib"     CACHE FILEPATH "Directory contains library of the GLX product" FORCE)
-
-    SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_GLX_INCLUDE_DIR}")
-    SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_GLX_LIBRARY_DIR}")
+if (USE_GLX)
+  add_definitions (-DMACOSX_USE_GLX)
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/glx")
+endif()
 
-    MARK_AS_ADVANCED(3RDPARTY_GLX_DIR)
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_INCLUDE_DIR)
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_GLX_LIBRARY_DIR)
-  ENDIF()
-ENDIF()
+# search for CSF_FREETYPE variable in EXTERNLIB of each being used toolkit
+OCCT_IS_PRODUCT_REQUIRED(CSF_FREETYPE USE_FREETYPE)
 
-# FREETYPE
-THIRDPARTY_PRODUCT("FREETYPE" "ft2build.h" "freetype${3RDPARTY_BUILD_SUFFIX}")
+if ("${USE_FREETYPE}" STREQUAL ON)
+  message (STATUS "Info: freetype is used by OCCT")
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freetype")
+else()
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_DIR")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_freetype2")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_LIBRARY")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_FREETYPE_LIBRARY_DIR")
+endif()
 
 # FREEIMAGE
-IF(USE_FREEIMAGE)
-  ADD_DEFINITIONS(-DHAVE_FREEIMAGE)
-
-  THIRDPARTY_PRODUCT("FREEIMAGE" "FreeImage.h" "freeimage${3RDPARTY_BUILD_SUFFIX}")
-  IF(WIN32)
-    IF("${3RDPARTY_FREEIMAGE_DIR}" STREQUAL "")
-    ELSE()
-      SET (3RDPARTY_FREEIMAGEPLUS_DIR "${3RDPARTY_FREEIMAGE_DIR}")
-    ENDIF()
-
-    THIRDPARTY_PRODUCT("FREEIMAGEPLUS" "FreeImagePlus.h" "freeimageplus${3RDPARTY_BUILD_SUFFIX}")
-
-  ENDIF()
-ELSE()
-  CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
-  CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
-  CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
-  CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
-ENDIF()
+if (USE_FREEIMAGE)
+  add_definitions (-DHAVE_FREEIMAGE)
+  message (STATUS "Info: freeimage is used by OCCT")
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freeimage")
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/freeimageplus")
+else()
+  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGE")
+  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_FREEIMAGEPLUS")
+  OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGE")
+  OCCT_CHECK_AND_UNSET ("INSTALL_FREEIMAGEPLUS")
+endif()
 
 # GL2PS
-IF(USE_GL2PS)
-  ADD_DEFINITIONS(-DHAVE_GL2PS)
-  THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps${3RDPARTY_BUILD_SUFFIX}")
-ELSE()
-  CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
-  CHECK_AND_UNSET ("INSTALL_GL2PS")
-ENDIF()
+if (USE_GL2PS)
+  add_definitions (-DHAVE_GL2PS)
+  message (STATUS "Info: gl2ps is used by OCCT")
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/gl2ps")
+else()
+  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_GL2PS")
+  OCCT_CHECK_AND_UNSET ("INSTALL_GL2PS")
+endif()
 
 # OPENCL
-IF(USE_OPENCL)
-  ADD_DEFINITIONS(-DHAVE_OPENCL)
-
-  SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER $ENV{AMDAPPSDKROOT}/include
-                                                  $ENV{INTELOCLSDKROOT}/include
-                                                  $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc
-                                                  $ENV{ATISTREAMSDKROOT}/include)
-
-
-  IF(${COMPILER_BITNESS} STREQUAL 32)
-    SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86
-                                                 $ENV{INTELOCLSDKROOT}/lib/x86
-                                                 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32
-                                                 $ENV{ATISTREAMSDKROOT}/lib/x86)
-  ELSEIF(${COMPILER_BITNESS} STREQUAL 64)
-    SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86_64
-                                                 $ENV{INTELOCLSDKROOT}/lib/x64
-                                                 $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64
-                                                 $ENV{ATISTREAMSDKROOT}/lib/x86_64)
-  ENDIF()
+if (USE_OPENCL)
+  add_definitions (-DHAVE_OPENCL)
+  message (STATUS "Info: OpenCL is used by OCCT")
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/opencl")
+else()
+  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER")
+  OCCT_CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
+  OCCT_CHECK_AND_UNSET ("INSTALL_OPENCL")
+endif()
 
+# TBB
+if (USE_TBB)
+  ADD_DEFINITIONS(-DHAVE_TBB)
+  message (STATUS "Info: tbb is used by OCCT")
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/tbb")
+else()
+  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
+  OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TBBMALLOC")
+  OCCT_CHECK_AND_UNSET ("INSTALL_TBB")
+endif()
 
-  THIRDPARTY_PRODUCT("OPENCL" "CL/cl.h" "OpenCL${3RDPARTY_BUILD_SUFFIX}")
+string (REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
 
-  # if CL/cl.h isn't found (and 3RDPARTY_OPENCL_INCLUDE_DIR isn't defined)
-  # then try to find OpenCL/cl.h (all other variable won't be changed)
-  IF("${3RDPARTY_OPENCL_INCLUDE_DIR}" STREQUAL "" OR "${3RDPARTY_OPENCL_INCLUDE_DIR}" STREQUAL "3RDPARTY_OPENCL_INCLUDE_DIR-NOTFOUND")
-    THIRDPARTY_PRODUCT("OPENCL" "OpenCL/cl.h" "OpenCL${3RDPARTY_BUILD_SUFFIX}")
-  ENDIF()
-  
-ELSE()
-  CHECK_AND_UNSET_GROUP ("3RDPARTY_OPENCL")
-  CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER")
-  CHECK_AND_UNSET ("3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB")
-  CHECK_AND_UNSET ("INSTALL_OPENCL")
-ENDIF()
+# check all 3rdparty paths
+if (3RDPARTY_NOT_INCLUDED)
+  message (FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
+endif()
 
-# TBB
-IF (USE_TBB)
-  ADD_DEFINITIONS(-DHAVE_TBB)
+list (REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
+string (REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
+message (STATUS "The directories containing 3rdparty headers: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
+include_directories (${3RDPARTY_INCLUDE_DIRS})
 
-  INCLUDE(adm/templates/tbb.cmake)
+list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
+string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
+message (STATUS "The directories containing 3rdparty libraries: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
+link_directories (${3RDPARTY_LIBRARY_DIRS})
 
-  IF(INSTALL_TBB)
-    INSTALL(FILES "${3RDPARTY_TBB_DLL}" "${3RDPARTY_TBB_MALLOC_DLL}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/${DLL_SO_FOLDER}${BUILD_SUFFIX}")
+OCCT_MAKE_BUILD_POSTFIX()
 
-    SET(3RDPARTY_TBB_DLL_DIR "")
-    SET(3RDPARTY_TBB_MALLOC_DLL_DIR "")
-  ELSE()
-    GET_FILENAME_COMPONENT(3RDPARTY_TBB_DLL_DIR "${3RDPARTY_TBB_DLL}" PATH)
-    GET_FILENAME_COMPONENT(3RDPARTY_TBB_MALLOC_DLL_DIR "${3RDPARTY_TBB_MALLOC_DLL}" PATH)
-  ENDIF()
-ELSE()
-  CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB")
-  CHECK_AND_UNSET_GROUP ("3RDPARTY_TBB_MALLOC")
-  CHECK_AND_UNSET ("3RDPARTY_TBB_DIR_NAME")
-  CHECK_AND_UNSET ("INSTALL_TBB")
-ENDIF()
+# build directories
+set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib${BUILD_POSTFIX})
+set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/lib${BUILD_POSTFIX})
+set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out/bin${BUILD_POSTFIX})
 
-string( REGEX REPLACE ";" " " 3RDPARTY_NOT_INCLUDED "${3RDPARTY_NOT_INCLUDED}")
+if ("${INSTALL_DIR}" STREQUAL "")
+  message (FATAL_ERROR "INSTALL_DIR variable is empty. It's required to define installation directory")
+else()
+  # inc,data,tests DIRECTORY
+  install (DIRECTORY "${CMAKE_SOURCE_DIR}/inc"          DESTINATION  "${INSTALL_DIR}")
+  install (DIRECTORY "${CMAKE_SOURCE_DIR}/data"         DESTINATION  "${INSTALL_DIR}")
+  install (DIRECTORY "${CMAKE_SOURCE_DIR}/samples/tcl"  DESTINATION  "${INSTALL_DIR}/samples")
+  if (INSTALL_TESTS)
+    install (DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION  "${INSTALL_DIR}" )
+  endif()
 
-#CHECK ALL 3RDPARTY PATHS
-IF(3RDPARTY_NOT_INCLUDED)
-  MESSAGE(FATAL_ERROR "NOT FOUND: ${3RDPARTY_NOT_INCLUDED}" )
-ENDIF()
+  # install patch inc, data, tests folder
+  if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
+    if (EXISTS "${BUILD_PATCH_DIR}/inc")
+      install (DIRECTORY "${BUILD_PATCH_DIR}/inc" DESTINATION  "${INSTALL_DIR}" )
+    endif()
 
-list(REMOVE_DUPLICATES 3RDPARTY_INCLUDE_DIRS)
-string( REGEX REPLACE ";" "\n\t" 3RDPARTY_INCLUDE_DIRS_WITH_ENDS "${3RDPARTY_INCLUDE_DIRS}")
-MESSAGE(STATUS "3RDPARTY_INCLUDE_DIRS: ${3RDPARTY_INCLUDE_DIRS_WITH_ENDS}")
-include_directories( ${3RDPARTY_INCLUDE_DIRS} )
+    if (EXISTS "${BUILD_PATCH_DIR}/data")
+      install (DIRECTORY "${BUILD_PATCH_DIR}/data"  DESTINATION  "${INSTALL_DIR}" )
+    endif()
 
-list(REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
-string( REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
-MESSAGE(STATUS "3RDPARTY_LIBRARY_DIRS: ${3RDPARTY_LIBRARY_DIRS_WITH_ENDS}")
-link_directories( ${3RDPARTY_LIBRARY_DIRS} )
+    if (INSTALL_TESTS)
+      if (EXISTS "${BUILD_PATCH_DIR}/tests")
+        install (DIRECTORY "${BUILD_PATCH_DIR}/tests" DESTINATION  "${INSTALL_DIR}" )
+      endif()
+    endif()
+  endif()
 
-IF("${INSTALL_DIR}" STREQUAL "")
-  MESSAGE(FATAL_ERROR "INSTALL_DIR is empty")
-ELSE()
-  # inc,data,tests DIRECTORY
-  install(DIRECTORY "${CMAKE_SOURCE_DIR}/inc"          DESTINATION  "${INSTALL_DIR}")
-  install(DIRECTORY "${CMAKE_SOURCE_DIR}/data"         DESTINATION  "${INSTALL_DIR}")
-  install(DIRECTORY "${CMAKE_SOURCE_DIR}/samples/tcl"  DESTINATION  "${INSTALL_DIR}/samples")
-  IF(INSTALL_TESTS)
-    install(DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION  "${INSTALL_DIR}" )
-  ENDIF()
+  if (WIN32)
+    set (SCRIPT_EXT bat)
+  else()
+    set (SCRIPT_EXT sh)
+  endif()
 
-    # install patch inc, data, tests folder
-  IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "")
-    IF(EXISTS "${BUILD_PATCH_DIR}/inc")
-      install(DIRECTORY "${BUILD_PATCH_DIR}/inc" DESTINATION  "${INSTALL_DIR}" )
-    ENDIF()
-    
-    IF(EXISTS "${BUILD_PATCH_DIR}/data")
-      install(DIRECTORY "${BUILD_PATCH_DIR}/data"  DESTINATION  "${INSTALL_DIR}" )
-    ENDIF()
-    
-    IF(INSTALL_TESTS)
-      IF(EXISTS "${BUILD_PATCH_DIR}/tests")
-        install(DIRECTORY "${BUILD_PATCH_DIR}/tests" DESTINATION  "${INSTALL_DIR}" )
-      ENDIF()
-    ENDIF()
-  ENDIF()
-  
   # DRAW.BAT or DRAW.SH
   IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}")
-    install(FILES "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" PERMISSIONS  
+    install(FILES "${BUILD_PATCH_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" PERMISSIONS
             OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
   ELSE()
-    install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" PERMISSIONS  
+    install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/draw.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" PERMISSIONS
             OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE)
   ENDIF()
-  
-  
-  SET(CUSTOM_CUR "custom_${COMPILER}_${COMPILER_BITNESS}_${BUILD_SUFFIX}.${SCRIPT_EXT}")
-  
+
+  # set compiler short name
+  OCCT_MAKE_COMPILER_SHORT_NAME()
+
+  OCCT_MAKE_COMPILER_BITNESS()
+
+  SET(SUB_CUSTOM "custom_${COMPILER}_${COMPILER_BITNESS}_${BUILD_POSTFIX}.${SCRIPT_EXT}")
+
   if (WIN32)
-    SET (CUSTOM_ADD_CONTENT "\nif exist \"%~dp0${CUSTOM_CUR}\" (\n  call \"%~dp0${CUSTOM_CUR}\" %1 %2 %3 \n)")
+    SET (ADDITIONAL_CUSTOM_CONTENT "\nif exist \"%~dp0${SUB_CUSTOM}\" (\n  call \"%~dp0${SUB_CUSTOM}\" %1 %2 %3 \n)")
   else()
-    SET (CUSTOM_ADD_CONTENT "\nif [ -e \"\${aScriptPath}/${CUSTOM_CUR}\" ]; then\n  source \"\${aScriptPath}/${CUSTOM_CUR}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
+    SET (ADDITIONAL_CUSTOM_CONTENT "\nif [ -e \"\${aScriptPath}/${SUB_CUSTOM}\" ]; then\n  source \"\${aScriptPath}/${SUB_CUSTOM}\" \"\${COMPILER}\" \"\${WOKSTATION}\${ARCH}\" \"\${CASDEB}\" \nfi")
   endif()
-  
+
   # change custom.bat/sh
   if (EXISTS "${INSTALL_DIR}/custom.${SCRIPT_EXT}")
-    FILE(READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
+    file (READ "${INSTALL_DIR}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT)
 
-    SET (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${CUSTOM_ADD_CONTENT}")
+    set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}")
 
-    FILE(WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
+    file (WRITE "${INSTALL_DIR}/custom.${SCRIPT_EXT}" "${CUSTOM_CONTENT}")
   else()
-    IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/custom.${SCRIPT_EXT}.main")
-      configure_file("${BUILD_PATCH_DIR}/adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" @ONLY)
-    ELSE()
-      configure_file("${CMAKE_SOURCE_DIR}/adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" @ONLY)
-    ENDIF()
-
-    install(FILES "${OCCT_BINARY_DIR}/custom.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}")
+    OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}")
   endif()
 
   # write current custom.bat/sh
-  IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/custom.${SCRIPT_EXT}.in")
-    configure_file("${BUILD_PATCH_DIR}/adm/templates/custom.${SCRIPT_EXT}.in" ${CUSTOM_CUR} @ONLY)
-  ELSE()
-    configure_file("${CMAKE_SOURCE_DIR}/adm/templates/custom.${SCRIPT_EXT}.in" ${CUSTOM_CUR} @ONLY)
-  ENDIF()
+  OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.in" "${SUB_CUSTOM}" "${INSTALL_DIR}")
 
-  install(FILES "${OCCT_BINARY_DIR}/${CUSTOM_CUR}" DESTINATION  "${INSTALL_DIR}" )
-  
-  IF (BUILD_Samples)
-    IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/sample.bat")
-      install(FILES "${BUILD_PATCH_DIR}/adm/templates/sample.bat" DESTINATION  "${INSTALL_DIR}")
-    ELSE()
-      install(FILES "${CMAKE_SOURCE_DIR}/adm/templates/sample.bat" DESTINATION  "${INSTALL_DIR}")
-    ENDIF()
-  ENDIF()
+  if (BUILD_MFC_SAMPLES)
+    OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR}")
+  endif()
 
-  IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/templates/env.${SCRIPT_EXT}.in")
-    configure_file("${BUILD_PATCH_DIR}/adm/templates/env.${SCRIPT_EXT}.in" env.${SCRIPT_EXT} @ONLY)
-  ELSE()
-    configure_file("${CMAKE_SOURCE_DIR}/adm/templates/env.${SCRIPT_EXT}.in" env.${SCRIPT_EXT} @ONLY)
-  ENDIF()
-  install(FILES "${OCCT_BINARY_DIR}/env.${SCRIPT_EXT}" DESTINATION  "${INSTALL_DIR}" )
-ENDIF()
+  OCCT_CONFIGURE_AND_INSTALL ("adm/templates/env.${SCRIPT_EXT}.in" "env.${SCRIPT_EXT}" "${INSTALL_DIR}")
+endif()
+
+# RESOURCES
+OCCT_INSTALL_FILE_OR_DIR ("src/DrawResources"          "${INSTALL_DIR}/src")
+OCCT_INSTALL_FILE_OR_DIR ("src/StdResource"            "${INSTALL_DIR}/src")
+OCCT_INSTALL_FILE_OR_DIR ("src/SHMessage"              "${INSTALL_DIR}/src")
+OCCT_INSTALL_FILE_OR_DIR ("src/Textures"               "${INSTALL_DIR}/src")
+OCCT_INSTALL_FILE_OR_DIR ("src/Shaders"                "${INSTALL_DIR}/src")
+OCCT_INSTALL_FILE_OR_DIR ("src/XSMessage"              "${INSTALL_DIR}/src")
+OCCT_INSTALL_FILE_OR_DIR ("src/XSTEPResource"          "${INSTALL_DIR}/src")
+OCCT_INSTALL_FILE_OR_DIR ("src/XmlOcafResource"        "${INSTALL_DIR}/src")
+
+OCCT_INSTALL_FILE_OR_DIR ("src/UnitsAPI/Lexi_Expr.dat" "${INSTALL_DIR}/src/UnitsAPI")
+OCCT_INSTALL_FILE_OR_DIR ("src/UnitsAPI/Units.dat"     "${INSTALL_DIR}/src/UnitsAPI")
+OCCT_INSTALL_FILE_OR_DIR ("src/TObj/TObj.msg"          "${INSTALL_DIR}/src/TObj")
+
+
+#Toolkits uses variables: INSTALL_DIR, OS_WITH_BIT, COMPILER, BUILD_POSTFIX
+OCCT_MAKE_OS_WITH_BITNESS()
+
+# consider for patch existence
+set (IS_PATCH_CURRENT "NO")
+set (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
+if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
+  set (IS_PATCH_CURRENT "YES")
+  set (TK_ROOT_DIR ${BUILD_PATCH_DIR})
+endif()
 
 # include patched toolkit projects or original ones
-SET (UNSUBDIRS "")
-IF(NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/CMakeToolKitsDeps.txt")
-  include(${BUILD_PATCH_DIR}/adm/cmake/CMakeToolKitsDeps.txt)
-ELSE()
-  SET (IS_PATCH_CURRENT "NO")
-  SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
-  include(adm/cmake/CMakeToolKitsDeps.txt)
-ENDIF()
+set (UNSUBDIRS "")
+if (NOT "${BUILD_PATCH_DIR}" STREQUAL "" AND EXISTS "${BUILD_PATCH_DIR}/adm/cmake/occt_inc_toolkits.cmake")
+  set (TK_ROOT_DIR ${BUILD_PATCH_DIR})
+  include (${BUILD_PATCH_DIR}/adm/cmake/occt_inc_toolkits.cmake)
+else()
+  set (IS_PATCH_CURRENT "NO")
+  set (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
+  include (adm/cmake/occt_inc_toolkits.cmake)
+endif()
 
-# include some required original toolkit
-IF(NOT "${UNSUBDIRS}" STREQUAL "")
-  SET (IS_PATCH_CURRENT "NO")
-  SET (TK_ROOT_DIR ${CMAKE_SOURCE_DIR})
+# include some required original occt_inc_toolkits
+if (NOT "${UNSUBDIRS}" STREQUAL "")
+  set (IS_PATCH_CURRENT "NO")
   # add required subdirs
-  FOREACH(UNSUBDIR ${UNSUBDIRS})
-    MESSAGE(STATUS "${UNSUBDIR}")
-    ADD_SUBDIRECTORY (${TK_ROOT_DIR}/${UNSUBDIR})
-  ENDFOREACH()
-ENDIF()
+  foreach (UNSUBDIR ${UNSUBDIRS})
+    add_subdirectory (${CMAKE_SOURCE_DIR}/${UNSUBDIR})
+  endforeach()
+endif()
 
 # samples do not support patch usage
-IF (BUILD_Samples)
+IF (BUILD_MFC_SAMPLES)
   SET (OCCT_ROOT ${CMAKE_SOURCE_DIR})
 
   SET (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard)
   SET (COMMON_WINMAIN_FILE      ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp)
 
-  ADD_SUBDIRECTORY (samples/mfc/standard/mfcsample)
-  ADD_SUBDIRECTORY (samples/mfc/standard/01_Geometry)
-  ADD_SUBDIRECTORY (samples/mfc/standard/02_Modeling)
-  ADD_SUBDIRECTORY (samples/mfc/standard/03_Viewer2d)
-  ADD_SUBDIRECTORY (samples/mfc/standard/04_Viewer3d)
-  ADD_SUBDIRECTORY (samples/mfc/standard/05_ImportExport)
-  ADD_SUBDIRECTORY (samples/mfc/standard/06_Ocaf)
-  ADD_SUBDIRECTORY (samples/mfc/standard/07_Triangulation)
-  ADD_SUBDIRECTORY (samples/mfc/standard/08_HLR)
-  ADD_SUBDIRECTORY (samples/mfc/standard/09_Animation)
-  ADD_SUBDIRECTORY (samples/mfc/standard/10_Convert)
+  add_subdirectory(samples/mfc/standard/mfcsample)
+  add_subdirectory(samples/mfc/standard/01_Geometry)
+  add_subdirectory(samples/mfc/standard/02_Modeling)
+  add_subdirectory(samples/mfc/standard/03_Viewer2d)
+  add_subdirectory(samples/mfc/standard/04_Viewer3d)
+  add_subdirectory(samples/mfc/standard/05_ImportExport)
+  add_subdirectory(samples/mfc/standard/06_Ocaf)
+  add_subdirectory(samples/mfc/standard/07_Triangulation)
+  add_subdirectory(samples/mfc/standard/08_HLR)
+  add_subdirectory(samples/mfc/standard/09_Animation)
+  add_subdirectory(samples/mfc/standard/10_Convert)
 ENDIF()
diff --git a/adm/templates/3rdparty_macro.cmake b/adm/templates/3rdparty_macro.cmake
new file mode 100644 (file)
index 0000000..f19560c
--- /dev/null
@@ -0,0 +1,185 @@
+#
+
+# include occt macros. compiler_bitness, os_wiht_bit, compiler and build_postfix
+OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_macros")
+
+macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME LIBRARY_NAME_DEBUG)
+
+  OCCT_MAKE_BUILD_POSTFIX()
+
+  # 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()
+
+  if (NOT DEFINED INSTALL_${PRODUCT_NAME})
+    set (INSTALL_${PRODUCT_NAME} OFF CACHE BOOL "Is ${PRODUCT_NAME} required to be copied into install directory")
+  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})
+  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()
+
+  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)
+    endif()
+  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)
+
+    # first of all, search for debug version of a library if build type is debug
+    if (DEFINED IS_BUILD_DEBUG)
+      find_library (3RDPARTY_${PRODUCT_NAME}_LIBRARY ${LIBRARY_NAME_DEBUG}
+                                                     PATHS 
+                                                      "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}"
+                                                      "${3RDPARTY_${PRODUCT_NAME}_DIR}/lib"
+                                                      "${3RDPARTY_${PRODUCT_NAME}_DIR}/libd"
+                                                      ${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_DEBUG})
+    endif()
+
+    # if build type is release or debug version of library isn't found - search for release version of one
+    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 (DEFINED IS_BUILD_DEBUG)
+        message (STATUS "Warning: debug version of ${PRODUCT_NAME} library isn't found (${LIBRARY_NAME_DEBUG}) in ${3RDPARTY_${PRODUCT_NAME}_DIR}/lib(d). Search for release one")
+      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})
+    endif()
+  endif()
+  
+  if (NOT DEFINED 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR)
+    set (3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR "" CACHE FILEPATH "The directory containing ${PRODUCT_NAME} library" FORCE)
+  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)
+  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()
+    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)
+
+      if (DEFINED IS_BUILD_DEBUG)
+        find_library (3RDPARTY_${PRODUCT_NAME}_DLL "${LIBRARY_NAME_DEBUG}"
+                                                   PATHS
+                                                    "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}"
+                                                    "${3RDPARTY_${PRODUCT_NAME}_DIR}/bin"
+                                                    "${3RDPARTY_${PRODUCT_NAME}_DIR}/bind"
+                                                    ${3RDPARTY_${PRODUCT_NAME}_ADDITIONAL_PATH_FOR_DLL}
+                                                   NO_DEFAULT_PATH)
+        
+        # second search if previous one do not find anything
+        find_library (3RDPARTY_${PRODUCT_NAME}_DLL "${LIBRARY_NAME_DEBUG}")
+      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)
+
+        if (DEFINED IS_BUILD_DEBUG)
+          message (STATUS "Warning: debug version of ${PRODUCT_NAME} dll isn't found (${LIBRARY_NAME_DEBUG}) in ${3RDPARTY_${PRODUCT_NAME}_DIR}/bin(d). Search for release one")
+        endif()
+
+        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)
+        
+        # second search if previous one do not find anything
+        find_library (3RDPARTY_${PRODUCT_NAME}_DLL "${LIBRARY_NAME}")
+      endif()
+    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)
+    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)
+    endif()
+  endif()
+  
+  if (3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
+    list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR}")
+  else()
+    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_INCLUDE_DIR)
+  endif()
+
+  if (3RDPARTY_${PRODUCT_NAME}_LIBRARY AND EXISTS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}")
+    list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR}")
+  else()
+    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_LIBRARY_DIR)
+  endif()
+
+  if (WIN32)
+    if (NOT 3RDPARTY_${PRODUCT_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+      list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL_DIR)
+    endif()
+  endif()
+
+  if (INSTALL_${PRODUCT_NAME})
+    OCCT_MAKE_OS_WITH_BITNESS()
+    OCCT_MAKE_COMPILER_SHORT_NAME()
+    OCCT_MAKE_BUILD_POSTFIX()
+
+    if (WIN32)
+      install (FILES "${3RDPARTY_${PRODUCT_NAME}_DLL}"     DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BUILD_POSTFIX}")
+    else()
+      install (FILES "${3RDPARTY_${PRODUCT_NAME}_LIBRARY}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}")
+    endif()
+  endif()
+  
+  mark_as_advanced (3RDPARTY_${PRODUCT_NAME}_LIBRARY 3RDPARTY_${PRODUCT_NAME}_DLL)
+endmacro()
\ No newline at end of file
index b25681c..4685169 100644 (file)
@@ -2,7 +2,7 @@ echo off
 
 if "%VCVER%" == "@COMPILER@" (
   if "%ARCH%" == "@COMPILER_BITNESS@" (
-    if "%CASDEB%" == "@BUILD_SUFFIX@" (
+    if "%CASDEB%" == "@BUILD_POSTFIX@" (
       set "TCL_DIR=@3RDPARTY_TCL_DLL_DIR@"
       set "FREETYPE_DIR=@3RDPARTY_FREETYPE_DLL_DIR@"
       set "FREEIMAGE_DIR=@3RDPARTY_FREEIMAGE_DLL_DIR@"
index e1bb56d..95d1257 100644 (file)
@@ -8,5 +8,5 @@ if /I ["%3"]     == ["debug"] set "CASDEB=d"
 if /I ["%3"]     == ["d"]     set "CASDEB=d"
 
 rem include other custom.bat files with specific 3rdparty paths
-@CUSTOM_ADD_CONTENT@
+@ADDITIONAL_CUSTOM_CONTENT@
 
index 8a68095..156b242 100644 (file)
@@ -2,12 +2,12 @@
 
 if [ "$COMPILER" == "@COMPILER@" ]; then
   if [ "$ARCH" == "@COMPILER_BITNESS@" ]; then
-    if [ "$CASDEB" == "@BUILD_SUFFIX@" ]; then
-      export TCL_DIR="@3RDPARTY_TCL_DLL_DIR@"
-      export FREETYPE_DIR="@3RDPARTY_FREETYPE_DLL_DIR@"
-      export FREEIMAGE_DIR="@3RDPARTY_FREEIMAGE_DLL_DIR@"
-      export GL2PS_DIR="@3RDPARTY_GL2PS_DLL_DIR@"
-      export TBB_DIR="@3RDPARTY_TBB_DLL_DIR@"
+    if [ "$CASDEB" == "@BUILD_POSTFIX@" ]; then
+      export TCL_DIR="@3RDPARTY_TCL_LIBRARY_DIR@"
+      export FREETYPE_DIR="@3RDPARTY_FREETYPE_LIBRARY_DIR@"
+      export FREEIMAGE_DIR="@3RDPARTY_FREEIMAGE_LIBRARY_DIR@"
+      export GL2PS_DIR="@3RDPARTY_GL2PS_LIBRARY_DIR@"
+      export TBB_DIR="@3RDPARTY_TBB_LIBRARY_DIR@"
     fi
   fi
 fi
index 946ec06..7f8928a 100644 (file)
@@ -1,4 +1,4 @@
 #!/bin/bash
 
-@CUSTOM_ADD_CONTENT@
+@ADDITIONAL_CUSTOM_CONTENT@
 
index 72120b2..cc2a9eb 100644 (file)
@@ -5,7 +5,7 @@ set "SCRIPTROOT=%SCRIPTROOT:~0,-1%"
 
 set "VCVER=@COMPILER@"
 set "ARCH=@COMPILER_BITNESS@"
-set "CASDEB=@BUILD_SUFFIX@"
+set "CASDEB=@BUILD_POSTFIX@"
 
 if not ["%1"]    == [""]      set "VCVER=%1"
 if not ["%2"]    == [""]      set "ARCH=%2"
index 4915aca..b425cc3 100644 (file)
@@ -8,7 +8,7 @@ fi
 
 # Read script arguments
 shopt -s nocasematch
-export CASDEB="@BUILD_SUFFIX@";
+export CASDEB="@BUILD_POSTFIX@";
 if [[ "$1" == "debug" ]]; then export CASDEB="d"; fi
 if [[ "$1" == "d" ]]; then export CASDEB="d"; fi
 shopt -u nocasematch
diff --git a/adm/templates/freeimage.cmake b/adm/templates/freeimage.cmake
new file mode 100644 (file)
index 0000000..b1cbf34
--- /dev/null
@@ -0,0 +1,3 @@
+#freeimage
+
+THIRDPARTY_PRODUCT("FREEIMAGE" "FreeImage.h" "freeimage" "freeimaged")
\ No newline at end of file
diff --git a/adm/templates/freeimageplus.cmake b/adm/templates/freeimageplus.cmake
new file mode 100644 (file)
index 0000000..3afd905
--- /dev/null
@@ -0,0 +1,9 @@
+#freeimageplus
+
+if (WIN32)
+  if (3RDPARTY_FREEIMAGE_DIR AND NOT 3RDPARTY_FREEIMAGEPLUS_DIR)
+    set (3RDPARTY_FREEIMAGEPLUS_DIR "${3RDPARTY_FREEIMAGE_DIR}" CACHE PATH "The directory containing freeimageplus" FORCE)
+  endif()
+
+  THIRDPARTY_PRODUCT("FREEIMAGEPLUS" "FreeImagePlus.h" "freeimageplus" "freeimageplusd")
+endif()
\ No newline at end of file
diff --git a/adm/templates/freetype.cmake b/adm/templates/freetype.cmake
new file mode 100644 (file)
index 0000000..b787096
--- /dev/null
@@ -0,0 +1,233 @@
+# freetype
+
+if (NOT DEFINED INSTALL_FREETYPE)
+  set (INSTALL_FREETYPE OFF CACHE BOOL "Is freetype required to be copied into install directory")
+endif()
+
+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 and build_postfix
+OCCT_INCLUDE_CMAKE_FILE ("adm/templates/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)
+    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()
+endif()
+
+if (NOT DEFINED 3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build)
+  set (3RDPARTY_FREETYPE_INCLUDE_DIR_ft2build  "" CACHE FILEPATH "the path of ft2build.h")
+endif()
+
+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")
+endif()
+
+if (NOT DEFINED 3RDPARTY_FREETYPE_LIBRARY_DIR)
+  set (3RDPARTY_FREETYPE_LIBRARY_DIR           "" CACHE FILEPATH "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")
+  endif()
+endif()
+
+if (WIN32)
+  if (NOT DEFINED 3RDPARTY_FREETYPE_DLL_DIR)
+    set (3RDPARTY_FREETYPE_DLL_DIR               "" CACHE FILEPATH "The directory containing freetype shared library")
+  endif()
+endif()
+
+message (STATUS "Info: CMake default freetype search start...")
+find_package(Freetype)
+message (STATUS "Info: CMake default freetype search end")
+
+# 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)
+  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
+  message (STATUS "Info: CMake default search doesn't found FREETYPE_INCLUDE_DIR_freetype2")
+  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)
+  
+  if (NOT FREETYPE_INCLUDE_DIR_freetype2 OR NOT EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}")
+    message (STATUS "Info: FREETYPE_INCLUDE_DIR_freetype2 is NOT found by additional search")
+  else()
+    message (STATUS "Info: FREETYPE_INCLUDE_DIR_freetype2 is found by additional search")
+  endif()
+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()
+    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()
+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 (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()
+  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()
+  
+  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)
+  endif()
+
+  if (WIN32)
+    set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
+
+    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
+
+      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)
+    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)
+    endif()
+  endif()
+endif()
+
+
+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()
+
+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)
+  endif()
+endif()
+
+# include found paths to common variables
+if (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)
+endif()
+
+if (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)
+endif()
+
+if (3RDPARTY_FREETYPE_LIBRARY)
+  list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_FREETYPE_LIBRARY_DIR}")
+else()
+  list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_FREETYPE_LIBRARY_DIR)
+endif()
+
+if (WIN32)
+  if (NOT 3RDPARTY_FREETYPE_DLL OR NOT EXISTS "${3RDPARTY_FREETYPE_DLL}")
+    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_FREETYPE_DLL_DIR)
+  endif()
+endif()
+
+if (INSTALL_FREETYPE)
+
+  OCCT_MAKE_OS_WITH_BITNESS()
+  OCCT_MAKE_BUILD_POSTFIX()
+
+  if (WIN32)
+    install (FILES "${3RDPARTY_FREETYPE_DLL}"     DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BUILD_POSTFIX}")
+  else()
+    install (FILES "${3RDPARTY_FREETYPE_LIBRARY}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}")
+  endif()
+endif()
+
+# unset all redundant variables
+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
diff --git a/adm/templates/gl2ps.cmake b/adm/templates/gl2ps.cmake
new file mode 100644 (file)
index 0000000..d9d59ec
--- /dev/null
@@ -0,0 +1,3 @@
+#GL2PS
+
+THIRDPARTY_PRODUCT("GL2PS" "gl2ps.h" "gl2ps" "gl2psd")
\ No newline at end of file
diff --git a/adm/templates/glx.cmake b/adm/templates/glx.cmake
new file mode 100644 (file)
index 0000000..2965557
--- /dev/null
@@ -0,0 +1,3 @@
+# glx
+
+THIRDPARTY_PRODUCT("GLX" "GL/glx.h" "GL" "GLd")
\ No newline at end of file
diff --git a/adm/templates/occt_defs_flags.cmake b/adm/templates/occt_defs_flags.cmake
new file mode 100644 (file)
index 0000000..9dd5574
--- /dev/null
@@ -0,0 +1,68 @@
+
+if (MSVC)
+  add_definitions(/fp:precise)
+endif()
+
+# set compiler short name and choose SSE2 option for appropriate MSVC compilers
+# ONLY for 32-bit
+if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
+  if (MSVC80 OR MSVC90 OR MSVC10)
+    add_definitions(/arch:SSE2)
+  endif()
+endif()
+
+add_definitions (-DCSFDB)
+if (WIN32)
+  add_definitions (/DWNT -wd4996)
+elseif (APPLE)
+  add_definitions (-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H)
+else()
+  add_definitions (-fexceptions -fPIC -DOCC_CONVERT_SIGNALS -DHAVE_WOK_CONFIG_H -DHAVE_CONFIG_H -DLIN)
+endif()
+
+# enable structured exceptions for MSVC
+string (REGEX MATCH "EHsc" ISFLAG "${CMAKE_CXX_FLAGS}")
+if (ISFLAG)
+  string (REGEX REPLACE "EHsc" "EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+elseif (WIN32)
+  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHa")
+endif()
+
+# remove DEBUG flag if it exists
+string (REGEX MATCH "-DDEBUG" IS_DEBUG_CXX "${CMAKE_CXX_FLAGS_DEBUG}")
+if (IS_DEBUG_CXX)
+  message (STATUS "-DDEBUG has been removed from CMAKE_CXX_FLAGS_DEBUG")
+  string (REGEX REPLACE "-DDEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
+endif()
+
+string (REGEX MATCH "-DDEBUG" IS_DEBUG_C "${CMAKE_C_FLAGS_DEBUG}")
+if (IS_DEBUG_C)
+  message (STATUS "-DDEBUG has been removed from CMAKE_C_FLAGS_DEBUG")
+  string (REGEX REPLACE "-DDEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
+endif()
+
+# enable parallel compilation on MSVC 9 and above
+if (MSVC AND NOT MSVC70 AND NOT MSVC80)
+  set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP")
+endif()
+
+# generate a single response file which enlist all of the object files
+SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
+SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)
+
+# increase compiler warnings level (-W4 for MSVC, -Wall for GCC)
+if (MSVC)
+  if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
+    string (REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+  else()
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
+  endif()
+elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
+endif()
+
+set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNo_Exception")
+set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNo_Exception")
+
+set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEB")
+set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEB")
\ No newline at end of file
diff --git a/adm/templates/occt_macros.cmake b/adm/templates/occt_macros.cmake
new file mode 100644 (file)
index 0000000..2492316
--- /dev/null
@@ -0,0 +1,201 @@
+#
+
+macro (OCCT_CHECK_AND_UNSET VARNAME)
+  if (DEFINED ${VARNAME})
+    unset (${VARNAME} CACHE)
+  endif()
+endmacro()
+
+macro (OCCT_CHECK_AND_UNSET_GROUP VARNAME)
+  OCCT_CHECK_AND_UNSET ("${VARNAME}_DIR")
+
+  OCCT_CHECK_AND_UNSET ("${VARNAME}_INCLUDE_DIR")
+
+  OCCT_CHECK_AND_UNSET ("${VARNAME}_LIBRARY")
+  OCCT_CHECK_AND_UNSET ("${VARNAME}_LIBRARY_DIR")
+
+  OCCT_CHECK_AND_UNSET ("${VARNAME}_DLL")
+  OCCT_CHECK_AND_UNSET ("${VARNAME}_DLL_DIR")
+endmacro()
+
+# BUILD_POSTFIX, IS_BUILD_DEBUG variables
+macro (OCCT_MAKE_BUILD_POSTFIX)
+  if ("${BUILD_CONFIGURATION}" STREQUAL "Debug")
+    set (BUILD_POSTFIX "d")
+    set (IS_BUILD_DEBUG "")
+  else()
+    set (BUILD_POSTFIX "")
+    OCCT_CHECK_AND_UNSET (IS_BUILD_DEBUG)
+  endif()
+endmacro()
+
+# COMPILER_BITNESS variable
+macro (OCCT_MAKE_COMPILER_BITNESS)
+  math (EXPR COMPILER_BITNESS "32 + 32*(${CMAKE_SIZEOF_VOID_P}/8)")
+endmacro()
+
+# OS_WITH_BIT
+macro (OCCT_MAKE_OS_WITH_BITNESS)
+
+  OCCT_MAKE_COMPILER_BITNESS()
+
+  if (WIN32)
+    set (OS_WITH_BIT "win${COMPILER_BITNESS}")
+  elseif(APPLE)
+    set (OS_WITH_BIT "mac${COMPILER_BITNESS}")
+  else()
+    set (OS_WITH_BIT "lin${COMPILER_BITNESS}")
+  endif()
+endmacro()
+
+# COMPILER variable
+macro (OCCT_MAKE_COMPILER_SHORT_NAME)
+  if (MSVC)
+    if (MSVC70)
+      set (COMPILER vc7)
+    elseif (MSVC80)
+      set (COMPILER vc8)
+    elseif (MSVC90)
+      set (COMPILER vc9)
+    elseif (MSVC10)
+      set (COMPILER vc10)
+    elseif (MSVC11)
+      set (COMPILER vc11)
+    elseif (MSVC12)
+      set (COMPILER vc12)
+    endif()
+  elseif (DEFINED CMAKE_COMPILER_IS_GNUCC)
+    set (COMPILER gcc)
+  elseif (DEFINED CMAKE_COMPILER_IS_GNUCXX)
+    set (COMPILER gxx)
+  elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+    set (COMPILER clang)
+  elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
+    set (COMPILER icc)
+  else()
+    set (COMPILER ${CMAKE_GENERATOR})
+    string (REGEX REPLACE " " "" COMPILER ${COMPILER})
+  endif()
+endmacro()
+
+function (SUBDIRECTORY_NAMES MAIN_DIRECTORY RESULT)
+  file (GLOB SUB_ITEMS "${MAIN_DIRECTORY}/*")
+
+  foreach (ITEM ${SUB_ITEMS})
+    if (IS_DIRECTORY "${ITEM}")
+      get_filename_component (ITEM_NAME "${ITEM}" NAME)
+      list (APPEND LOCAL_RESULT "${ITEM_NAME}")
+    endif()
+  endforeach()
+  set (${RESULT} ${LOCAL_RESULT} PARENT_SCOPE)
+endfunction()
+
+function (FIND_PRODUCT_DIR ROOT_DIR PRODUCT_NAME RESULT)
+  OCCT_MAKE_COMPILER_SHORT_NAME()
+  OCCT_MAKE_COMPILER_BITNESS()
+
+  string (TOLOWER "${PRODUCT_NAME}" lower_PRODUCT_NAME)
+
+  list (APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*${COMPILER}.*${COMPILER_BITNESS}")
+  list (APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER}.*${COMPILER_BITNESS}")
+  list (APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+.*${COMPILER_BITNESS}")
+  list (APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}.*[0-9.]+")
+  list (APPEND SEARCH_TEMPLATES "${lower_PRODUCT_NAME}")
+
+  SUBDIRECTORY_NAMES ("${ROOT_DIR}" SUBDIR_NAME_LIST)
+
+  foreach (SEARCH_TEMPLATE ${SEARCH_TEMPLATES})
+    if (LOCAL_RESULT)
+      BREAK()
+    endif()
+
+    foreach (SUBDIR_NAME ${SUBDIR_NAME_LIST})
+      string (TOLOWER "${SUBDIR_NAME}" lower_SUBDIR_NAME)
+
+      string (REGEX MATCH "${SEARCH_TEMPLATE}" DUMMY_VAR "${lower_SUBDIR_NAME}")
+      if (DUMMY_VAR)
+        list (APPEND LOCAL_RESULT ${SUBDIR_NAME})
+      endif()
+    endforeach()
+  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)
+    set (${RESULT} ${DUMMY} PARENT_SCOPE)
+  endif()
+endfunction()
+
+macro (OCCT_INSTALL_FILE_OR_DIR BEING_INSTALLED_OBJECT DESTINATION_PATH)
+  if (BUILD_PATCH_DIR AND EXISTS "${BUILD_PATCH_DIR}/${BEING_INSTALLED_OBJECT}")
+    if (IS_DIRECTORY "${BUILD_PATCH_DIR}/${BEING_INSTALLED_OBJECT}")
+      # first of all, install original files
+      install (DIRECTORY "${CMAKE_SOURCE_DIR}/${BEING_INSTALLED_OBJECT}" DESTINATION  "${DESTINATION_PATH}")
+
+      # secondly, rewrite original files with patched ones
+      install (DIRECTORY "${BUILD_PATCH_DIR}/${BEING_INSTALLED_OBJECT}" DESTINATION  "${DESTINATION_PATH}")
+    else()
+      install (FILES     "${BUILD_PATCH_DIR}/${BEING_INSTALLED_OBJECT}" DESTINATION  "${DESTINATION_PATH}")
+    endif()
+  else()
+    if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/${BEING_INSTALLED_OBJECT}")
+      install (DIRECTORY "${CMAKE_SOURCE_DIR}/${BEING_INSTALLED_OBJECT}" DESTINATION  "${DESTINATION_PATH}")
+    else()
+      install (FILES     "${CMAKE_SOURCE_DIR}/${BEING_INSTALLED_OBJECT}" DESTINATION  "${DESTINATION_PATH}")
+    endif()
+  endif()
+endmacro()
+
+macro (OCCT_CONFIGURE_AND_INSTALL BEING_CONGIRUGED_FILE FINAL_NAME DESTINATION_PATH)
+  if (BUILD_PATCH_DIR AND EXISTS "${BUILD_PATCH_DIR}/${BEING_CONGIRUGED_FILE}")
+    configure_file("${BUILD_PATCH_DIR}/${BEING_CONGIRUGED_FILE}" "${FINAL_NAME}" @ONLY)
+  else()
+    configure_file("${CMAKE_SOURCE_DIR}/${BEING_CONGIRUGED_FILE}" "${FINAL_NAME}" @ONLY)
+  endif()
+
+  install(FILES "${OCCT_BINARY_DIR}/${FINAL_NAME}" DESTINATION  "${DESTINATION_PATH}")
+endmacro()
+
+function (OCCT_IS_PRODUCT_REQUIRED CSF_VAR_NAME USE_PRODUCT)
+  set (${USE_PRODUCT} OFF PARENT_SCOPE)
+  
+  if (NOT USED_TOOLKITS)
+    message(STATUS "Warning: the list of being used toolkits is empty")
+  else()
+    foreach (USED_TOOLKIT ${USED_TOOLKITS})
+      if (BUILD_PATCH_DIR AND EXISTS "${BUILD_PATCH_DIR}/src/${USED_TOOLKIT}/EXTERNLIB")
+        file (READ "${BUILD_PATCH_DIR}/src/${USED_TOOLKIT}/EXTERNLIB" FILE_CONTENT)
+      elseif (EXISTS "${CMAKE_SOURCE_DIR}/src/${USED_TOOLKIT}/EXTERNLIB")
+        file (READ "${CMAKE_SOURCE_DIR}/src/${USED_TOOLKIT}/EXTERNLIB" FILE_CONTENT)
+      endif()
+
+      string (REGEX MATCH "${CSF_VAR_NAME}" DOES_FILE_CONTAIN "${FILE_CONTENT}")
+
+      if (DOES_FILE_CONTAIN)
+        set (${USE_PRODUCT} ON PARENT_SCOPE)
+        break()
+      endif()
+    endforeach()
+  endif()
+endfunction()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/adm/templates/opencl.cmake b/adm/templates/opencl.cmake
new file mode 100644 (file)
index 0000000..59bcbcd
--- /dev/null
@@ -0,0 +1,27 @@
+#OpenCl
+
+SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_HEADER $ENV{AMDAPPSDKROOT}/include
+                                                  $ENV{INTELOCLSDKROOT}/include
+                                                  $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/inc
+                                                  $ENV{ATISTREAMSDKROOT}/include)
+
+
+IF(${COMPILER_BITNESS} STREQUAL 32)
+  SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86
+                                               $ENV{INTELOCLSDKROOT}/lib/x86
+                                               $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/Win32
+                                               $ENV{ATISTREAMSDKROOT}/lib/x86)
+ELSEIF(${COMPILER_BITNESS} STREQUAL 64)
+  SET (3RDPARTY_OPENCL_ADDITIONAL_PATH_FOR_LIB $ENV{AMDAPPSDKROOT}/lib/x86_64
+                                               $ENV{INTELOCLSDKROOT}/lib/x64
+                                               $ENV{NVSDKCOMPUTE_ROOT}/OpenCL/common/lib/x64
+                                               $ENV{ATISTREAMSDKROOT}/lib/x86_64)
+ENDIF()
+
+THIRDPARTY_PRODUCT("OPENCL" "CL/cl.h" "OpenCL" "OpenCLd")
+
+# if CL/cl.h isn't found (and 3RDPARTY_OPENCL_INCLUDE_DIR isn't defined)
+# then try to find OpenCL/cl.h (all other variable won't be changed)
+IF(NOT 3RDPARTY_OPENCL_INCLUDE_DIR OR NOT EXISTS "${3RDPARTY_OPENCL_INCLUDE_DIR}")
+  THIRDPARTY_PRODUCT("OPENCL" "OpenCL/cl.h" "OpenCL" "OpenCLd")
+ENDIF()
\ No newline at end of file
index cc77426..fa53392 100644 (file)
-# Find tbb includes and libraries
-  
-  IF(${COMPILER_BITNESS} STREQUAL 32)
-    SET (TBB_ARCH_NAME ia32)
-  ELSE()
-    SET (TBB_ARCH_NAME intel64)
-  ENDIF()
-  
-  IF(NOT DEFINED 3RDPARTY_TBB_DIR)
-    SET(3RDPARTY_TBB_DIR "" CACHE PATH "Directory contains tbb product")
-  ENDIF()
-  
-  SET(3RDPARTY_TBB_DIR_NAME "")
-  IF(3RDPARTY_DIR AND ("${3RDPARTY_TBB_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
-    FIND_PRODUCT_DIR("${3RDPARTY_DIR}" "TBB" 3RDPARTY_TBB_DIR_NAME)
-    IF("${3RDPARTY_TBB_DIR_NAME}" STREQUAL "")
-      MESSAGE(STATUS "TBB DON'T FIND")
-    ELSE()
-      SET(3RDPARTY_TBB_DIR "${3RDPARTY_DIR}/${3RDPARTY_TBB_DIR_NAME}" CACHE PATH "Directory contains tbb product" FORCE)
-    ENDIF()
-  ENDIF()
-  
-  SET(INSTALL_TBB OFF CACHE BOOL "Is tbb lib copy to install directory")
-
-  IF(3RDPARTY_TBB_DIR)
-    IF("${3RDPARTY_TBB_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED)
-      SET(3RDPARTY_TBB_INCLUDE_DIR "3RDPARTY_TBB_INCLUDE_DIR-NOTFOUND" CACHE PATH "Directory contains headers of the tbb product" FORCE)
-      FIND_PATH(3RDPARTY_TBB_INCLUDE_DIR tbb/tbb.h PATHS "${3RDPARTY_TBB_DIR}/include")
-    ENDIF()
-
-    SET(TBB_DEBUG_POSTFIX "")
-    if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
-      SET(TBB_DEBUG_POSTFIX "_debug")
-    ENDIF()
-    
-    IF("${3RDPARTY_TBB_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_TBB_LIBRARY}" STREQUAL "3RDPARTY_TBB_LIBRARY-NOTFOUND")
-      SET(3RDPARTY_TBB_LIBRARY "3RDPARTY_TBB_LIBRARY-NOTFOUND" CACHE PATH "Directory contains library of the tbb product" FORCE)
-      FIND_LIBRARY(3RDPARTY_TBB_LIBRARY tbb${TBB_DEBUG_POSTFIX} PATHS "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${COMPILER}" NO_DEFAULT_PATH)
-      
-      IF("${3RDPARTY_TBB_LIBRARY}" STREQUAL "3RDPARTY_TBB_LIBRARY-NOTFOUND")
-        FIND_LIBRARY(3RDPARTY_TBB_LIBRARY tbb${TBB_DEBUG_POSTFIX})
-      ENDIF()
-    ENDIF()
-
-    IF("${3RDPARTY_TBB_MALLOC_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_TBB_MALLOC_LIBRARY}" STREQUAL "3RDPARTY_TBB_MALLOC_LIBRARY-NOTFOUND")
-      SET(3RDPARTY_TBB_MALLOC_LIBRARY "3RDPARTY_TBB_MALLOC_LIBRARY-NOTFOUND" CACHE PATH "Directory contains library of the tbb malloc product" FORCE)
-      FIND_LIBRARY(3RDPARTY_TBB_MALLOC_LIBRARY tbbmalloc${TBB_DEBUG_POSTFIX} PATHS "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${COMPILER}" NO_DEFAULT_PATH)
-      
-      IF("${3RDPARTY_TBB_MALLOC_LIBRARY}" STREQUAL "3RDPARTY_TBB_MALLOC_LIBRARY-NOTFOUND")
-        FIND_LIBRARY(3RDPARTY_TBB_MALLOC_LIBRARY tbbmalloc${TBB_DEBUG_POSTFIX})
-      ENDIF()
-    ENDIF()
-    
-    
+# tbb
+
+OCCT_MAKE_BUILD_POSTFIX()
+
+if (NOT DEFINED INSTALL_TBB)
+  set (INSTALL_TBB OFF CACHE BOOL "Is tbb required to be copied into install directory")
+endif()
+
+# tbb directory
+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")
+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()
+
+# 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()
+
+# 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)
+  endif()
+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")
+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()
+endif()
+
+# tbb malloc shared library directory
+if (NOT DEFINED 3RDPARTY_TBBMALLOC_DLL_DIR)
+  set (3RDPARTY_TBBMALLOC_DLL_DIR "" CACHE FILEPATH "The directory containing tbb malloc shared library")
+endif()
+
+# include occt macros. compiler_bitness, os_wiht_bit, compiler and build_postfix
+OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_macros")
+
+# 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)
+  endif()
+endif()
+
+OCCT_MAKE_COMPILER_BITNESS()
+
+if (${COMPILER_BITNESS} STREQUAL 32)
+  set (TBB_ARCH_NAME ia32)
+else()
+  set (TBB_ARCH_NAME intel64)
+endif()
+
+# 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")
+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()
+
+OCCT_MAKE_COMPILER_SHORT_NAME()
+
+# TBB_COMPILER_FOLER
+#if (WIN32)
+  set (TBB_COMPILER_FOLER ${COMPILER})
+#else()
+#  set (TBB_COMPILER_FOLER ${COMPILER})
+#endif()
+
+OCCT_MAKE_BUILD_POSTFIX()
+
+# search for tbb and tbb malloc library in defined 3rdparty directory
+foreach (LIBRARY_NAME TBB TBBMALLOC)
+  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)
+    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)
+
+    # first of all, search for debug version of a library if build type is debug
+    if (DEFINED IS_BUILD_DEBUG)
+      find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${LIBRARY_NAME}_debug
+                                                     PATHS
+                                                      "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}"
+                                                      "${3RDPARTY_TBB_DIR}/libd/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}"
+                                                      "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}"
+                                                     NO_DEFAULT_PATH)
+
+      # second search if previous one do not find anything
+      find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${LIBRARY_NAME}_debug)
+    endif()
+
+    # if build type is release or debug version of library isn't found - search for release version of one
+    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 (DEFINED IS_BUILD_DEBUG)
+        message (STATUS "Warning: debug version of ${LIBRARY_NAME} library isn't found (${LIBRARY_NAME}_debug) in ${3RDPARTY_TBB_DIR}/lib(d). Search for release one")
+      endif()
+
+      find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${LIBRARY_NAME}
+                                                     PATHS
+                                                      "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}"
+                                                      "${3RDPARTY_TBB_DIR}/lib/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}"
+                                                     NO_DEFAULT_PATH)
+
+      # second search if previous one do not find anything
+      find_library (3RDPARTY_${LIBRARY_NAME}_LIBRARY ${LIBRARY_NAME})
+    endif()
+  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)
+    set (3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR "${3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR}" CACHE FILEPATH "The directory containing ${LIBRARY_NAME} library" FORCE)
+  endif()
+
+  # search for dll in defined 3rdparty directory (just for win case)
+  if (WIN32)
+    set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
     
-    IF("${3RDPARTY_TBB_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED)
-      SET(3RDPARTY_TBB_DLL "3RDPARTY_TBB_DLL-NOTFOUND" CACHE PATH "Directory contains shared library of the tbb product" FORCE)
-      FIND_FILE(3RDPARTY_TBB_DLL "${DLL_SO_PREFIX}tbb${TBB_DEBUG_POSTFIX}.${DLL_SO}" PATHS "${3RDPARTY_TBB_DIR}/${DLL_SO_FOLDER}/${TBB_ARCH_NAME}/${COMPILER}" NO_DEFAULT_PATH)
-      
-      IF("${3RDPARTY_TBB_DLL}" STREQUAL "3RDPARTY_TBB_DLL-NOTFOUND")
-        FIND_FILE(3RDPARTY_TBB_DLL "${DLL_SO_PREFIX}tbb${TBB_DEBUG_POSTFIX}.${DLL_SO}")
-      ENDIF()
-    ENDIF()
+    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)
+      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)
+
+      if (DEFINED IS_BUILD_DEBUG)
+        find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME}_debug
+                                       PATHS
+                                        "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}"
+                                        "${3RDPARTY_TBB_DIR}/bind/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}"
+                                        "${3RDPARTY_TBB_DIR}/bin/${TBB_ARCH_NAME}/${TBB_COMPILER_FOLER}"
+                                       NO_DEFAULT_PATH)
+
+        # second search if previous one do not find anything
+        find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME}_debug)
+      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)
+
+        if (DEFINED IS_BUILD_DEBUG)
+          message (STATUS "Warning: debug version of ${LIBRARY_NAME} dll isn't found (${LIBRARY_NAME}_debug) in ${3RDPARTY_TBB_DIR}/bin(d). Search for release one")
+        endif()
+
+        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)
+
+        # second search if previous one do not find anything
+        find_library (3RDPARTY_${LIBRARY_NAME}_DLL ${LIBRARY_NAME})
+      endif()
+    endif()
     
-    IF("${3RDPARTY_TBB_MALLOC_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED)
-      SET(3RDPARTY_TBB_MALLOC_DLL "3RDPARTY_TBB_MALLOC_DLL-NOTFOUND" CACHE PATH "Directory contains shared library of the tbb malloc product" FORCE)
-      FIND_FILE(3RDPARTY_TBB_MALLOC_DLL "${DLL_SO_PREFIX}tbbmalloc${TBB_DEBUG_POSTFIX}.${DLL_SO}" PATHS "${3RDPARTY_TBB_DIR}/${DLL_SO_FOLDER}/${TBB_ARCH_NAME}/${COMPILER}" NO_DEFAULT_PATH)
-      
-      IF("${3RDPARTY_TBB_MALLOC_DLL}" STREQUAL "3RDPARTY_TBB_MALLOC_DLL-NOTFOUND")
-        FIND_FILE(3RDPARTY_TBB_MALLOC_DLL "${DLL_SO_PREFIX}tbbmalloc${TBB_DEBUG_POSTFIX}.${DLL_SO}")
-      ENDIF()
-    ENDIF()
-
-    MARK_AS_ADVANCED(3RDPARTY_TBB_DIR_NAME)
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_DIR)
-  ENDIF()
-
-  IF(3RDPARTY_TBB_INCLUDE_DIR)
-    SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_TBB_INCLUDE_DIR}")
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_INCLUDE_DIR)
-  ENDIF()
-
-  IF(3RDPARTY_TBB_LIBRARY)
-    GET_FILENAME_COMPONENT(3RDPARTY_TBB_LIBRARY_DIR "${3RDPARTY_TBB_LIBRARY}" PATH)
-    SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_TBB_LIBRARY_DIR}")
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_LIBRARY)
-  ENDIF()
-  
-  IF(3RDPARTY_TBB_MALLOC_LIBRARY)
-    GET_FILENAME_COMPONENT(3RDPARTY_TBB_LIBRARY_DIR "${3RDPARTY_TBB_MALLOC_LIBRARY}" PATH)
-    SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_TBB_LIBRARY_DIR}")
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_MALLOC_LIBRARY)
-  ENDIF()
-  
-  IF(3RDPARTY_TBB_DLL)
-    #
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_DLL)
-  ENDIF()
-  
-  IF(3RDPARTY_TBB_MALLOC_DLL)
-    #
-  ELSE()
-    LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TBB_MALLOC_DLL)
-  ENDIF()
\ No newline at end of file
+    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)
+    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()
+
+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}")
+  else()
+    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBRARY_NAME}_LIBRARY_DIR)
+  endif()
+
+  if (WIN32)
+    if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}")
+      list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBRARY_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} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BUILD_POSTFIX}")
+  else()
+    install (FILES ${3RDPARTY_TBB_LIBRARY} ${3RDPARTY_TBBMALLOC_LIBRARY} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}")
+  endif()
+endif()
+
+mark_as_advanced (3RDPARTY_TBB_LIBRARY 3RDPARTY_TBBMALLOC_LIBRARY 3RDPARTY_TBB_DLL 3RDPARTY_TBBMALLOC_DLL)
index e93fd75..cda48d0 100644 (file)
-# - Find Tcl includes and libraries
+# tcl
 
-IF(WIN32)
-  SET(TCL_SEP "")
+if (NOT DEFINED INSTALL_TCL)
+  set (INSTALL_TCL OFF CACHE BOOL "Is tcl lib required to be copied into install directory")
+endif()
 
-  GET_FILENAME_COMPONENT(ActiveTcl_CurrentVersion 
-    "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl;CurrentVersion]" NAME)
+# tcl directory
+if (NOT DEFINED 3RDPARTY_TCL_DIR)
+  set (3RDPARTY_TCL_DIR "" CACHE PATH "The directory containing tcl")
+endif()
 
-ELSE()
-  SET(TCL_SEP ".")
-ENDIF()
+# tcl include directory
+if (NOT DEFINED 3RDPARTY_TCL_INCLUDE_DIR)
+  set (3RDPARTY_TCL_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of tcl")
+endif()
 
-IF(NOT DEFINED 3RDPARTY_TCL_DIR)
-  SET(3RDPARTY_TCL_DIR "" CACHE PATH "Directory contains TCL product")
-ENDIF()
+# tk include directory
+if (NOT DEFINED 3RDPARTY_TK_INCLUDE_DIR)
+  set (3RDPARTY_TK_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of tk")
+endif()
 
-IF(3RDPARTY_DIR AND ("${3RDPARTY_TCL_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED))
+# tcl library file (with absolute path)
+if (NOT DEFINED 3RDPARTY_TCL_LIBRARY OR NOT 3RDPARTY_TCL_LIBRARY_DIR)
+  set (3RDPARTY_TCL_LIBRARY "" CACHE FILEPATH "tcl library"  FORCE)
+endif()
+
+# tcl library directory
+if (NOT DEFINED 3RDPARTY_TCL_LIBRARY_DIR)
+  set (3RDPARTY_TCL_LIBRARY_DIR "" CACHE FILEPATH "The directory containing tcl library")
+endif()
+
+# tk library file (with absolute path)
+if (NOT DEFINED 3RDPARTY_TK_LIBRARY OR NOT 3RDPARTY_TK_LIBRARY_DIR)
+  set (3RDPARTY_TK_LIBRARY "" CACHE FILEPATH "tk library" FORCE)
+endif()
+
+# tk library directory
+if (NOT DEFINED 3RDPARTY_TK_LIBRARY_DIR)
+  set (3RDPARTY_TK_LIBRARY_DIR "" CACHE FILEPATH "The directory containing tk library")
+endif()
+
+# tcl shared library (with absolute path)
+if (WIN32)
+  if (NOT DEFINED 3RDPARTY_TCL_DLL OR NOT 3RDPARTY_TCL_DLL_DIR)
+    set (3RDPARTY_TCL_DLL "" CACHE FILEPATH "tcl shared library" FORCE)
+  endif()
+endif()
+
+# tcl shared library directory
+if (WIN32 AND NOT DEFINED 3RDPARTY_TCL_DLL_DIR)
+  set (3RDPARTY_TCL_DLL_DIR "" CACHE FILEPATH "The directory containing tcl shared library")
+endif()
+
+# tk shared library (with absolute path)
+if (WIN32)
+  if (NOT DEFINED 3RDPARTY_TK_DLL OR NOT 3RDPARTY_TK_DLL_DIR)
+    set (3RDPARTY_TK_DLL "" CACHE FILEPATH "tk shared library" FORCE)
+  endif()
+endif()
+
+# tk shared library directory
+if (WIN32 AND NOT DEFINED 3RDPARTY_TK_DLL_DIR)
+  set (3RDPARTY_TK_DLL_DIR "" CACHE FILEPATH "The directory containing tk shared library")
+endif()
+
+# search for tcl in user defined directory
+if (NOT 3RDPARTY_TCL_DIR AND 3RDPARTY_DIR)
   FIND_PRODUCT_DIR("${3RDPARTY_DIR}" tcl TCL_DIR_NAME)
-  IF("${TCL_DIR_NAME}" STREQUAL "")
-    MESSAGE(STATUS "\nInfo: tcl folder isn't found in ${3RDPARTY_DIR}. Start seeking in default folders")
-  ELSE()
-    SET(3RDPARTY_TCL_DIR "${3RDPARTY_DIR}/${TCL_DIR_NAME}" CACHE PATH "Directory contains TCL product" FORCE)
-  ENDIF()
-ENDIF()
-  
-SET(INSTALL_TCL OFF CACHE BOOL "Is TCL lib copy to install directory")
+  if (TCL_DIR_NAME)
+    set (3RDPARTY_TCL_DIR "${3RDPARTY_DIR}/${TCL_DIR_NAME}" CACHE PATH "The directory containing tcl" FORCE)
+  endif()
+endif()
 
-# include dir search
-IF("${3RDPARTY_TCL_INCLUDE_DIR}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_TCL_INCLUDE_DIR}" STREQUAL "3RDPARTY_TCL_INCLUDE_DIR-NOTFOUND")
-  SET(3RDPARTY_TCL_INCLUDE_DIR "3RDPARTY_TCL_INCLUDE_DIR-NOTFOUND" CACHE FILEPATH "Directory contains headers of the TCL product" FORCE)
-  
-  IF(NOT "${3RDPARTY_TCL_DIR}" STREQUAL "")
-    FIND_PATH(3RDPARTY_TCL_INCLUDE_DIR tcl.h PATHS "${3RDPARTY_TCL_DIR}/include" NO_DEFAULT_PATH)
-  ELSE()
-    SET(3RDPARTY_TCL_POSSIBLE_INCLUDE_DIRS /usr/include
-                                           /usr/local/include
-                                           /usr/include/tcl8${TCL_SEP}6
-                                           /usr/include/tcl8${TCL_SEP}5)
-    IF(WIN32)
-      SET(3RDPARTY_TCL_POSSIBLE_INCLUDE_DIRS ${3RDPARTY_TCL_POSSIBLE_INCLUDE_DIRS}
-          "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/include"
-          "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/include"
-          "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/include"
-          "$ENV{ProgramFiles}/Tcl/include"
-          #"$ENV{ProgramFiles\(x86\)}/Tcl/include"
-          "C:/Program Files/Tcl/include"
-          "C:/Tcl/include")
-    ENDIF(WIN32)
-
-    # check default path (with additions) for header search
-    FIND_PATH(3RDPARTY_TCL_INCLUDE_DIR tcl.h PATHS ${3RDPARTY_TCL_POSSIBLE_INCLUDE_DIRS})
+# define paths for default engine
+if (3RDPARTY_TCL_DIR AND EXISTS "${3RDPARTY_TCL_DIR}")
+  set (TCL_INCLUDE_PATH "${3RDPARTY_TCL_DIR}/include")
+endif()
+
+# check tcl/tk include dir, library dir and shared library dir
+macro (DIR_SUBDIR_FILE_FIT LIBNAME)
+  if (3RDPARTY_TCL_DIR AND EXISTS "${3RDPARTY_TCL_DIR}")
+    # tcl/tk include dir
+    if (3RDPARTY_${LIBNAME}_INCLUDE_DIR AND EXISTS "${3RDPARTY_${LIBNAME}_INCLUDE_DIR}")
+      string (REGEX MATCH "${3RDPARTY_TCL_DIR}" DOES_PATH_CONTAIN "${3RDPARTY_${LIBNAME}_INCLUDE_DIR}")
+      if (NOT DOES_PATH_CONTAIN)
+        set (3RDPARTY_${LIBNAME}_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of ${LIBNAME}" FORCE)
+      endif()
+    else()
+      set (3RDPARTY_${LIBNAME}_INCLUDE_DIR "" CACHE FILEPATH "The directory containing headers of ${LIBNAME}" FORCE)
+    endif()
     
-    #if find_path found something - set 3RDPARTY_TCL_DIR
-    IF(NOT "${3RDPARTY_TCL_INCLUDE_DIR}" STREQUAL "3RDPARTY_TCL_INCLUDE_DIR-NOTFOUND")
-      GET_FILENAME_COMPONENT (3RDPARTY_TCL_DIR "${3RDPARTY_TCL_INCLUDE_DIR}/../" ABSOLUTE)
-      SET(3RDPARTY_TCL_DIR ${3RDPARTY_TCL_DIR} CACHE FILEPATH "Directory contains TCL product" FORCE)
-    ENDIF()
-  ENDIF()
-ENDIF()
-
-#library dir search
-IF("${3RDPARTY_TCL_LIBRARY}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_TCL_LIBRARY}" STREQUAL "3RDPARTY_TCL_LIBRARY-NOTFOUND")
-  SET(3RDPARTY_TCL_LIBRARY "3RDPARTY_TCL_LIBRARY-NOTFOUND" CACHE FILEPATH "Path to library of the TCL product" FORCE)
+    # tcl/tk library dir
+    if (3RDPARTY_${LIBNAME}_LIBRARY_DIR AND EXISTS "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}")
+      
+      string (REGEX MATCH "${3RDPARTY_TCL_DIR}" DOES_PATH_CONTAIN "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}")
+      if (NOT DOES_PATH_CONTAIN)
+        set (3RDPARTY_${LIBNAME}_LIBRARY_DIR "" CACHE FILEPATH "The directory containing ${LIBNAME} library" FORCE)
+      endif()
+    else()
+      set (3RDPARTY_${LIBNAME}_LIBRARY_DIR "" CACHE FILEPATH "The directory containing ${LIBNAME} library" FORCE)
+    endif()
+
+    # tcl/tk shared library dir
+    if (WIN32)
+      if (3RDPARTY_${LIBNAME}_DLL_DIR AND EXISTS "${3RDPARTY_${LIBNAME}_DLL_DIR}")
+        string (REGEX MATCH "${3RDPARTY_TCL_DIR}" DOES_PATH_CONTAIN "${3RDPARTY_${LIBNAME}_DLL_DIR}")
+        if (NOT DOES_PATH_CONTAIN)
+          set (3RDPARTY_${LIBNAME}_DLL_DIR "" CACHE FILEPATH "The directory containing ${LIBNAME} shared library" FORCE)
+        endif()
+      else()
+        set (3RDPARTY_${LIBNAME}_DLL_DIR "" CACHE FILEPATH "The directory containing ${LIBNAME} shared library" FORCE)
+      endif()
+    endif()
+  endif()
+
+  # check tcl/tk library
+  if (3RDPARTY_${LIBNAME}_LIBRARY_DIR AND EXISTS "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}")
+    if (3RDPARTY_${LIBNAME}_LIBRARY AND EXISTS "${3RDPARTY_${LIBNAME}_LIBRARY}")
+      string (REGEX MATCH "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}" DOES_PATH_CONTAIN "${3RDPARTY_${LIBNAME}_LIBRARY}")
+
+      if (NOT DOES_PATH_CONTAIN)
+        set (3RDPARTY_${LIBNAME}_LIBRARY "" CACHE FILEPATH "${LIBNAME} library" FORCE)
+      endif()
+    else()
+      set (3RDPARTY_${LIBNAME}_LIBRARY "" CACHE FILEPATH "${LIBNAME} library" FORCE)
+    endif()
+  else()
+    set (3RDPARTY_${LIBNAME}_LIBRARY "" CACHE FILEPATH "${LIBNAME} library" FORCE)
+  endif()
+
+  # check tcl/tk shared library
+  if (WIN32)
+    if (3RDPARTY_${LIBNAME}_DLL_DIR AND EXISTS "${3RDPARTY_${LIBNAME}_DLL_DIR}")
+      if (3RDPARTY_${LIBNAME}_DLL AND EXISTS "${3RDPARTY_${LIBNAME}_DLL}")
+        string (REGEX MATCH "${3RDPARTY_${LIBNAME}_DLL_DIR}" DOES_PATH_CONTAIN "${3RDPARTY_${LIBNAME}_DLL}")
+
+        if (NOT DOES_PATH_CONTAIN)
+          set (3RDPARTY_${LIBNAME}_DLL "" CACHE FILEPATH "${LIBNAME} shared library" FORCE)
+        endif()
+      else()
+        set (3RDPARTY_${LIBNAME}_DLL "" CACHE FILEPATH "${LIBNAME} shared library" FORCE)
+      endif()
+    else()
+      set (3RDPARTY_${LIBNAME}_DLL "" CACHE FILEPATH "${LIBNAME} shared library" FORCE)
+    endif()
+  endif()
+endmacro()
+
+
+DIR_SUBDIR_FILE_FIT(TCL)
+DIR_SUBDIR_FILE_FIT(TK)
+
+
+# use default (CMake) TCL search
+find_package(TCL)
+
+foreach (LIBNAME TCL TK)
+  string (TOLOWER "${LIBNAME}" LIBNAME_L)
+
+  # tcl/tk include dir
+  if (NOT 3RDPARTY_${LIBNAME}_INCLUDE_DIR)
+    if (${LIBNAME}_INCLUDE_PATH AND EXISTS "${${LIBNAME}_INCLUDE_PATH}")
+      set (3RDPARTY_${LIBNAME}_INCLUDE_DIR "${${LIBNAME}_INCLUDE_PATH}" CACHE FILEPATH "The directory containing headers of ${LIBNAME}" FORCE)
+    endif()
+  endif()
+
+  # tcl/tk dir and library
+  if (NOT 3RDPARTY_${LIBNAME}_LIBRARY)
+    if (${LIBNAME}_LIBRARY AND EXISTS "${${LIBNAME}_LIBRARY}")
+      set (3RDPARTY_${LIBNAME}_LIBRARY "${${LIBNAME}_LIBRARY}" CACHE FILEPATH "${LIBNAME} library" FORCE)
+      
+      if (NOT 3RDPARTY_${LIBNAME}_LIBRARY_DIR)
+        get_filename_component (3RDPARTY_${LIBNAME}_LIBRARY_DIR "${3RDPARTY_${LIBNAME}_LIBRARY}" PATH)
+        set (3RDPARTY_${LIBNAME}_LIBRARY_DIR "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}" CACHE FILEPATH "The directory containing ${LIBNAME} library" FORCE)
+      endif()
+    endif()
+  endif()
+  
+
+  if (WIN32)
+    if (NOT 3RDPARTY_${LIBNAME}_DLL)
+        set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
+
+        set (DLL_FOLDER_FOR_SEARCH "")
+        if (3RDPARTY_${LIBNAME}_DLL_DIR)
+          set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_${LIBNAME}_DLL_DIR}")
+        elseif (3RDPARTY_TCL_DIR)
+          set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_TCL_DIR}/bin")
+        elseif (3RDPARTY_${LIBNAME}_LIBRARY_DIR)
+          get_filename_component (3RDPARTY_${LIBNAME}_LIBRARY_DIR_PARENT "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}" PATH)
+          set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_${LIBNAME}_LIBRARY_DIR_PARENT}/bin")
+        endif()
+        
+        set (3RDPARTY_${LIBNAME}_DLL "3RDPARTY_${LIBNAME}_DLL-NOTFOUND" CACHE FILEPATH "${LIBNAME} shared library" FORCE)
+        find_library (3RDPARTY_${LIBNAME}_DLL NAMES ${LIBNAME_L}86 ${LIBNAME_L}85
+                                              PATHS "${DLL_FOLDER_FOR_SEARCH}"
+                                              NO_DEFAULT_PATH)
+    endif()
+  endif()
+
+  DIR_SUBDIR_FILE_FIT(${LIBNAME})
   
-  IF(NOT "${3RDPARTY_TCL_DIR}" STREQUAL "")
-    FIND_LIBRARY(3RDPARTY_TCL_LIBRARY
-                 NAMES tcl8${TCL_SEP}6 tcl8${TCL_SEP}5 tcl
-                 PATHS "${3RDPARTY_TCL_DIR}/lib" NO_DEFAULT_PATH)
-  ELSE()
-    SET(3RDPARTY_TCL_POSSIBLE_LIBRARIES_DIRS /usr/lib /usr/local/lib)
+
+  # tcl/tk dir and library
+  if (NOT 3RDPARTY_${LIBNAME}_LIBRARY)
+    set (3RDPARTY_${LIBNAME}_LIBRARY "3RDPARTY_${LIBNAME}_LIBRARY-NOTFOUND" CACHE FILEPATH "${LIBNAME} library" FORCE)
+    find_library (3RDPARTY_${LIBNAME}_LIBRARY NAMES ${LIBNAME_L}8.6 ${LIBNAME_L}86 ${LIBNAME_L}8.5 ${LIBNAME_L}85
+                                              PATHS "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}"
+                                              NO_DEFAULT_PATH)
     
-    IF(WIN32)
-      SET(3RDPARTY_TCL_POSSIBLE_LIBRARIES_DIRS ${3RDPARTY_TCL_POSSIBLE_LIBRARIES_DIRS}
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/lib"
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/lib"
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib"
-        "$ENV{ProgramFiles}/Tcl/Lib"
-        "C:/Program Files/Tcl/lib" 
-        "C:/Tcl/lib" )
-    ENDIF()
+    # search in another place if previous search doesn't find anything
+    find_library (3RDPARTY_${LIBNAME}_LIBRARY NAMES ${LIBNAME_L}8.6 ${LIBNAME_L}86 ${LIBNAME_L}8.5 ${LIBNAME_L}85 
+                                              PATHS "${3RDPARTY_TCL_DIR}/lib"
+                                              NO_DEFAULT_PATH)    
     
-    # check default path (with additions) for library search
-    FIND_LIBRARY(3RDPARTY_TCL_LIBRARY
-                 NAMES tcl8${TCL_SEP}6 tcl8${TCL_SEP}5 tcl
-                 PATHS ${3RDPARTY_TCL_POSSIBLE_LIBRARIES_DIRS})
-  ENDIF()
-ENDIF()
-
-#search the version of found tcl library
-IF("${3RDPARTY_TCL_LIBRARY}" STREQUAL "" OR "${3RDPARTY_TCL_LIBRARY}" STREQUAL "3RDPARTY_TCL_LIBRARY-NOTFOUND")
-  SET (TCL_DLL_SO_NAMES ${DLL_SO_PREFIX}tcl8${TCL_SEP}6.${DLL_SO}
-                        ${DLL_SO_PREFIX}tcl8${TCL_SEP}5.${DLL_SO}
-                        ${DLL_SO_PREFIX}tcl.${DLL_SO})
-ELSE()
-  GET_FILENAME_COMPONENT(TCL_LIBRARY_NAME "${3RDPARTY_TCL_LIBRARY}" NAME)
-
-  STRING(REGEX REPLACE "^.*tcl([0-9])[^0-9]*[0-9].*$" "\\1" TCL_MAJOR_VERSION "${TCL_LIBRARY_NAME}")
-  STRING(REGEX REPLACE "^.*tcl[0-9][^0-9]*([0-9]).*$" "\\1" TCL_MINOR_VERSION "${TCL_LIBRARY_NAME}")
-
-  IF (NOT "${TCL_MAJOR_VERSION}" STREQUAL "${TCL_LIBRARY_NAME}")
-    SET (IS_TCL_VERSION_FOUND ON)
-  ELSE()
-    SET (IS_TCL_VERSION_FOUND OFF)
-  ENDIF()
-  
-  IF (IS_TCL_VERSION_FOUND)
-    SET (TCL_DLL_SO_NAMES "${DLL_SO_PREFIX}tcl${TCL_MAJOR_VERSION}${TCL_SEP}${TCL_MINOR_VERSION}.${DLL_SO}")
-  ELSE()
-    MESSAGE(STATUS "\nWarning: Tcl version isn't found. ${DLL_SO_PREFIX}tcl.${DLL_SO} is used")
-    SET (TCL_DLL_SO_NAMES "${DLL_SO_PREFIX}tcl.${DLL_SO}")
-  ENDIF()
-ENDIF()
-
-#dll_so search
-IF("${3RDPARTY_TCL_DLL}" STREQUAL "" OR CHANGES_ARE_NEEDED OR "${3RDPARTY_TCL_DLL}" STREQUAL "3RDPARTY_TCL_DLL-NOTFOUND")
-  SET(3RDPARTY_TCL_DLL "3RDPARTY_TCL_DLL-NOTFOUND" CACHE FILEPATH "Path to shared library of the TCL product" FORCE)
-  
-  IF(NOT "${3RDPARTY_TCL_DIR}" STREQUAL "")
-    FIND_FILE(3RDPARTY_TCL_DLL 
-              NAMES ${TCL_DLL_SO_NAMES}
-              PATHS "${3RDPARTY_TCL_DIR}/${DLL_SO_FOLDER}" NO_DEFAULT_PATH)
-  ELSE() 
-    SET(3RDPARTY_TCL_POSSIBLE_SO_DIRS /usr/lib /usr/local/lib)
+
+    if (NOT 3RDPARTY_${LIBNAME}_LIBRARY OR NOT EXISTS "${3RDPARTY_${LIBNAME}_LIBRARY}")
+      set (3RDPARTY_${LIBNAME}_LIBRARY "" CACHE FILEPATH "${LIBNAME} library" FORCE)
+    endif()
     
-    IF(WIN32)
-      SET(3RDPARTY_TCL_POSSIBLE_SO_DIRS ${3RDPARTY_TCL_POSSIBLE_SO_DIRS}
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ActiveState\\ActiveTcl\\${ActiveTcl_CurrentVersion}]/bin"
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.6;Root]/bin"
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/bin"
-        "$ENV{ProgramFiles}/Tcl/Bin"
-        "C:/Program Files/Tcl/bin" 
-        "C:/Tcl/b" )
-    ENDIF()
+    if (NOT 3RDPARTY_${LIBNAME}_LIBRARY_DIR AND 3RDPARTY_${LIBNAME}_LIBRARY)
+      get_filename_component (3RDPARTY_${LIBNAME}_LIBRARY_DIR "${3RDPARTY_${LIBNAME}_LIBRARY}" PATH)
+      set (3RDPARTY_${LIBNAME}_LIBRARY_DIR "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}" CACHE FILEPATH "The directory containing ${LIBNAME} library" FORCE)
+    endif()
+  endif()
+
+  set (3RDPARTY_${LIBNAME}_LIBRARY_VERSION "")
+  if (3RDPARTY_${LIBNAME}_LIBRARY AND EXISTS "${3RDPARTY_${LIBNAME}_LIBRARY}")
+    get_filename_component (${LIBNAME}_LIBRARY_NAME "${3RDPARTY_${LIBNAME}_LIBRARY}" NAME)
+    string(REGEX REPLACE "^.*${LIBNAME_L}([0-9]\\.*[0-9]).*$" "\\1" ${LIBNAME}_LIBRARY_VERSION "${${LIBNAME}_LIBRARY_NAME}")
     
-    # check default path (with additions) for dll_so search
-    FIND_FILE(3RDPARTY_TCL_DLL 
-              NAMES ${TCL_DLL_SO_NAMES}
-              PATHS ${3RDPARTY_TCL_POSSIBLE_SO_DIRS})
-  ENDIF()
-ENDIF()
+    if (NOT "${${LIBNAME}_LIBRARY_VERSION}" STREQUAL "${${LIBNAME}_LIBRARY_NAME}")
+      set (3RDPARTY_${LIBNAME}_LIBRARY_VERSION "${${LIBNAME}_LIBRARY_VERSION}")
+    else() # if the version isn't found - seek other library with 8.6 or 8.5 version in the same dir
+      message (STATUS "Info: ${LIBNAME} version isn't found")
+    endif()
+  endif()
   
-IF(NOT "${3RDPARTY_TCL_DIR}" STREQUAL "")
-  MARK_AS_ADVANCED(3RDPARTY_TCL_DIR)
-ENDIF()
-
-# #includes found paths to common variables
-IF(3RDPARTY_TCL_INCLUDE_DIR)
-  SET(3RDPARTY_INCLUDE_DIRS "${3RDPARTY_INCLUDE_DIRS};${3RDPARTY_TCL_INCLUDE_DIR}")
-ELSE()
-  LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TCL_INCLUDE_DIR)
-ENDIF()
-
-IF(3RDPARTY_TCL_LIBRARY)
-  GET_FILENAME_COMPONENT(3RDPARTY_TCL_LIBRARY_DIR "${3RDPARTY_TCL_LIBRARY}" PATH)
-SET(3RDPARTY_LIBRARY_DIRS "${3RDPARTY_LIBRARY_DIRS};${3RDPARTY_TCL_LIBRARY_DIR}")
-ELSE()
-  LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TCL_LIBRARY)
-ENDIF()
+
+  set (3RDPARTY_${LIBNAME}_LIBRARY_VERSION_WITH_DOT "")
+  if (3RDPARTY_${LIBNAME}_LIBRARY_VERSION)
+    string (REGEX REPLACE "^.*([0-9])[^0-9]*[0-9].*$" "\\1" 3RDPARTY_${LIBNAME}_MAJOR_VERSION "${3RDPARTY_${LIBNAME}_LIBRARY_VERSION}")
+    string (REGEX REPLACE "^.*[0-9][^0-9]*([0-9]).*$" "\\1" 3RDPARTY_${LIBNAME}_MINOR_VERSION "${3RDPARTY_${LIBNAME}_LIBRARY_VERSION}")
+    set (3RDPARTY_${LIBNAME}_LIBRARY_VERSION_WITH_DOT "${3RDPARTY_${LIBNAME}_MAJOR_VERSION}.${3RDPARTY_${LIBNAME}_MINOR_VERSION}")
+  endif()
+
+  if (WIN32)
+    if (NOT 3RDPARTY_${LIBNAME}_DLL)
+        set (CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
+
+        set (DLL_FOLDER_FOR_SEARCH "")
+        if (3RDPARTY_${LIBNAME}_DLL_DIR)
+          set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_${LIBNAME}_DLL_DIR}")
+        elseif (3RDPARTY_TCL_DIR)
+          set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_TCL_DIR}/bin")
+        else()
+          get_filename_component (3RDPARTY_${LIBNAME}_LIBRARY_DIR_PARENT "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}" PATH)
+          set (DLL_FOLDER_FOR_SEARCH "${3RDPARTY_${LIBNAME}_LIBRARY_DIR_PARENT}/bin")
+        endif()
+        
+        set (3RDPARTY_${LIBNAME}_DLL "3RDPARTY_${LIBNAME}_DLL-NOTFOUND" CACHE FILEPATH "${LIBNAME} shared library" FORCE)
+        find_library (3RDPARTY_${LIBNAME}_DLL NAMES ${LIBNAME_L}${3RDPARTY_${LIBNAME}_LIBRARY_VERSION}
+                                              PATHS "${DLL_FOLDER_FOR_SEARCH}"
+                                              NO_DEFAULT_PATH)
+        
+        if (NOT 3RDPARTY_${LIBNAME}_DLL OR NOT EXISTS "${3RDPARTY_${LIBNAME}_DLL}")
+          set (3RDPARTY_${LIBNAME}_DLL "" CACHE FILEPATH "${LIBNAME} shared library" FORCE)
+        endif()
+      
+        if (NOT 3RDPARTY_${LIBNAME}_DLL_DIR AND 3RDPARTY_${LIBNAME}_DLL)
+          get_filename_component (3RDPARTY_${LIBNAME}_DLL_DIR "${3RDPARTY_${LIBNAME}_DLL}" PATH)
+          set (3RDPARTY_${LIBNAME}_DLL_DIR "${3RDPARTY_${LIBNAME}_DLL_DIR}" CACHE FILEPATH "The directory containing ${LIBNAME} shared library" FORCE)
+        endif()
+    endif()
+  endif()
   
-IF(3RDPARTY_TCL_DLL)
-ELSE()
-  LIST(APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_TCL_DLL)
-ENDIF()
\ No newline at end of file
+  # include found paths to common variables
+  if (3RDPARTY_${LIBNAME}_INCLUDE_DIR AND EXISTS "${3RDPARTY_${LIBNAME}_INCLUDE_DIR}")
+    list (APPEND 3RDPARTY_INCLUDE_DIRS "${3RDPARTY_${LIBNAME}_INCLUDE_DIR}")
+  else()
+    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBNAME}_INCLUDE_DIR)
+  endif()
+
+  if (3RDPARTY_${LIBNAME}_LIBRARY AND EXISTS "${3RDPARTY_${LIBNAME}_LIBRARY}")
+    list (APPEND 3RDPARTY_LIBRARY_DIRS "${3RDPARTY_${LIBNAME}_LIBRARY_DIR}")
+  else()
+    list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBNAME}_LIBRARY_DIR})
+  endif()
+
+  if (WIN32)
+    if (NOT 3RDPARTY_${LIBNAME}_DLL OR NOT EXISTS "${3RDPARTY_${LIBNAME}_DLL}")
+      list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBNAME}_DLL_DIR)
+    endif()
+  endif()
+endforeach()
+
+# install tcltk
+if (INSTALL_TCL)
+  # include occt macros. compiler_bitness, os_wiht_bit, compiler and build_postfix
+  OCCT_INCLUDE_CMAKE_FILE ("adm/templates/occt_macros")
+
+  OCCT_MAKE_OS_WITH_BITNESS()
+  OCCT_MAKE_COMPILER_SHORT_NAME()
+  OCCT_MAKE_BUILD_POSTFIX()
+
+  if (WIN32)
+    install (FILES ${3RDPARTY_TCL_DLL} ${3RDPARTY_TK_DLL} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BUILD_POSTFIX}")
+  else()
+    install (FILES ${3RDPARTY_TCL_LIBRARY} ${3RDPARTY_TK_LIBRARY} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}")
+  endif()
+
+  if (TCL_TCLSH_VERSION)
+    # tcl is required to install in lib folder (without ${BUILD_POSTFIX})
+    install (DIRECTORY "${3RDPARTY_TCL_LIBRARY_DIR}/tcl8"                    DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
+    install (DIRECTORY "${3RDPARTY_TCL_LIBRARY_DIR}/tcl${3RDPARTY_TCL_LIBRARY_VERSION_WITH_DOT}" DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
+    install (DIRECTORY "${3RDPARTY_TCL_LIBRARY_DIR}/tk${3RDPARTY_TK_LIBRARY_VERSION_WITH_DOT}"  DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib")
+  else()
+    message (STATUS "\nWarning: tclX.X and tkX.X subdirs won't be copyied during the installation process.")
+    message (STATUS "Try seeking tcl within another folder by changing 3RDPARTY_TCL_DIR variable.")
+  endif()
+endif()
+
+mark_as_advanced (3RDPARTY_TCL_LIBRARY 3RDPARTY_TK_LIBRARY 3RDPARTY_TCL_DLL 3RDPARTY_TK_DLL)
+
+# unset all redundant variables
+#TCL
+OCCT_CHECK_AND_UNSET (TCL_LIBRARY)
+OCCT_CHECK_AND_UNSET (TCL_INCLUDE_PATH)
+OCCT_CHECK_AND_UNSET (TCL_TCLSH)
+#TK
+OCCT_CHECK_AND_UNSET (TK_LIBRARY)
+OCCT_CHECK_AND_UNSET (TK_INCLUDE_PATH)
+OCCT_CHECK_AND_UNSET (TK_WISH)
index e3ab1cb..6f8c394 100644 (file)
@@ -50,6 +50,7 @@ dev_guides/building/3rdparty/3rdparty_osx.md
 dev_guides/building/wok/wok.md
 dev_guides/building/automake.md
 dev_guides/building/cmake/cmake.md
+dev_guides/building/android/android.md
 dev_guides/building/code_blocks.md
 dev_guides/building/msvc.md
 dev_guides/building/xcode.md
diff --git a/dox/dev_guides/building/android/android.md b/dox/dev_guides/building/android/android.md
new file mode 100644 (file)
index 0000000..8f21cb6
--- /dev/null
@@ -0,0 +1,71 @@
+Building with CMake and ADT for Android {#occt_dev_guides__building_android}
+===================
+
+@tableofcontents
+
+This file describes the steps to build OCCT libraries from a complete source package
+with following tools:
+  - Generation of eclipse project files
+    - CMake v3.0+ http://www.cmake.org/cmake/resources/software.html
+    - Cross-compilation toolchain for CMake https://github.com/taka-no-me/android-cmake
+    - Android NDK rev.10+ https://developer.android.com/tools/sdk/ndk/index.html
+    - Make: MinGW v4.82+ for Windows, GNU Make vXX for Linux. http://sourceforge.net/projects/mingw/files/
+  - Building eclipse project files of OCCT
+    - Android Developer Tools (ADT) v22+ https://developer.android.com/sdk/index.html
+
+## Generation of eclipse project files
+Run GUI tool provided by CMake: cmake-gui
+
+### Tools configuration
+   - Specify the root folder of OCCT (<i>$CASROOT</i>, which contains *CMakelists.txt* file) by clicking **Browse Source**.
+  - Specify the location (build folder) for Cmake generated project files by clicking **Browse Build**.
+
+@figure{/dev_guides/building/android/images/android_image001.png}
+
+Click **Configure** button. It opens the window with a drop-down list of generators supported by CMake project. - 
+
+Select "Eclipse CDT4 - MinGW MakeFiles" item from the list
+  - Choose "Specify toolchain file for cross-compiling"
+  - Click "Next"
+@figure{/dev_guides/building/android/images/android_image002.png}
+  - Specify the Toolchain file at next dialog by android.toolchain.cmake is contained by cross-compilation toolchain for CMake
+  - Click "Finish"
+@figure{/dev_guides/building/android/images/android_image003.png}
+
+Add cache entry ANDROID_NDK - path (entry type is PATH) to the NDK folder ("Add Entry" button)
+@figure{/dev_guides/building/android/images/android_image004.png}
+
+if there is message "CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool."  
+Define CMAKE_MAKE_PROGRAM variable with the file path to mingw32-make executable. 
+@figure{/dev_guides/building/android/images/android_image005.png}
+
+### OCCT Configuration
+
+How to configure OCCT, see "OCCT Configuration" section of @ref occt_dev_guides__building_cmake "Building with CMake"
+taking into account the specific configuration variables for android:
+  - ANDROID_ABI = armeabi-v7a
+  - ANDROID_NATIVE_API_LEVEL = 15
+  - ANDROID_NDK_LAYOUT is equal to BUILD_CONFIGURATION variable 
+  - CMAKE_ECLIPSE_VERSION is equal to installed eclipse version (e.g., 4.2)
+
+Configure parallel building:
+  - CMAKE_ECLIPSE_MAKE_ARGUMENTS = -jN where N = your numbers of CPU cores (threads)
+
+@figure{/dev_guides/building/android/images/android_image006.png}
+
+### Generation of eclipse projects files
+
+Click **Generate** button and wait until the generation process is finished. 
+Then the eclipse project files will appear in the build folder (e.g. <i> D:/android-build-eclipse-api-15 </i>).
+
+## Building eclipse project files of OCCT
+
+  - Open eclipse (downloaded ADT bundle contains it)
+  @figure{/dev_guides/building/android/images/android_image007.png}
+  - Import "Existing project into Workspace"
+  @figure{/dev_guides/building/android/images/android_image008.png}
+  @figure{/dev_guides/building/android/images/android_image009.png}
+  - Build ALL
+  @figure{/dev_guides/building/android/images/android_image010.png}
+  
+When the building process has finished, libraries are located in \<build folder\>/out (e.g. <i> D:/android-build-eclipse-api-15/out </i>).
\ No newline at end of file
diff --git a/dox/dev_guides/building/android/images/android_image001.png b/dox/dev_guides/building/android/images/android_image001.png
new file mode 100644 (file)
index 0000000..55d5183
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image001.png differ
diff --git a/dox/dev_guides/building/android/images/android_image002.png b/dox/dev_guides/building/android/images/android_image002.png
new file mode 100644 (file)
index 0000000..c731f9f
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image002.png differ
diff --git a/dox/dev_guides/building/android/images/android_image003.png b/dox/dev_guides/building/android/images/android_image003.png
new file mode 100644 (file)
index 0000000..782b2d8
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image003.png differ
diff --git a/dox/dev_guides/building/android/images/android_image004.png b/dox/dev_guides/building/android/images/android_image004.png
new file mode 100644 (file)
index 0000000..005ac50
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image004.png differ
diff --git a/dox/dev_guides/building/android/images/android_image005.png b/dox/dev_guides/building/android/images/android_image005.png
new file mode 100644 (file)
index 0000000..d18843c
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image005.png differ
diff --git a/dox/dev_guides/building/android/images/android_image006.png b/dox/dev_guides/building/android/images/android_image006.png
new file mode 100644 (file)
index 0000000..efedc15
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image006.png differ
diff --git a/dox/dev_guides/building/android/images/android_image007.png b/dox/dev_guides/building/android/images/android_image007.png
new file mode 100644 (file)
index 0000000..410e8dc
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image007.png differ
diff --git a/dox/dev_guides/building/android/images/android_image008.png b/dox/dev_guides/building/android/images/android_image008.png
new file mode 100644 (file)
index 0000000..40446e4
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image008.png differ
diff --git a/dox/dev_guides/building/android/images/android_image009.png b/dox/dev_guides/building/android/images/android_image009.png
new file mode 100644 (file)
index 0000000..5c3fa6c
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image009.png differ
diff --git a/dox/dev_guides/building/android/images/android_image010.png b/dox/dev_guides/building/android/images/android_image010.png
new file mode 100644 (file)
index 0000000..c56621a
Binary files /dev/null and b/dox/dev_guides/building/android/images/android_image010.png differ
index 373d278..49d8326 100644 (file)
@@ -24,6 +24,7 @@ you need to:
 3. Build using your preferred build tool.
    - \subpage occt_dev_guides__building_automake "Building on Linux with Autotools"
    - \subpage occt_dev_guides__building_cmake "Building with CMake (cross-platform)"
+   - \subpage occt_dev_guides__building_android "Building with CMake and ADT for Android (cross-platform)"
    - \subpage occt_dev_guides__building_code_blocks "Building on Mac OS X with Code::Blocks"
    - \subpage occt_dev_guides__building_msvc "Building on Windows with MS Visual Studio"
    - \subpage occt_dev_guides__building_xcode "Building on Mac OS X with Xcode"
index 1b31508..ae63555 100644 (file)
@@ -5,7 +5,7 @@ Building with CMake {#occt_dev_guides__building_cmake}
 
 This file describes the steps to build OCCT libraries from a complete source package
 with **CMake**. CMake is free software that can create GNU Makefiles, KDevelop, 
-XCode, and Visual Studio project files. **CMake** version 2.6 or above is 
+XCode, Eclipse and Visual Studio project files. **CMake** version 3.0 or above is 
 required.
 
 If you build OCCT from bare sources (as in Git repository) or make some 
@@ -32,7 +32,7 @@ It is recommended to separate build and install directories from OCCT source dir
 
 Run CMake indicating the path to OCCT sources <i>($CASROOT)</i> and selected build directory.
 
-It is recommended to use GUI tools provided by CMake: *cmake-gui* on Windows and Mac, *ccmake* or *cmake-gui* on Linux.
+It is recommended to use GUI tools provided by CMake: *cmake-gui* on Windows, Mac and Linux (*ccmake* also can be used on Linux).
 
 ### Windows:
 
@@ -100,69 +100,65 @@ library.
 
 If you have 3rd-party libraries in a non-default location 
 (e.g., on Windows, binaries downloaded from http://www.opencascade.org/getocc/download/3rdparty/") 
-specify *3RDPARTY_DIR* variable that points to the folders of 3rd-party libraries (some or all). 
+*3RDPARTY_DIR* variable should be specified with the path to the folders where required 3rd-party libraries will be sought
 
-At the next configuration step the 3rd-party libraries will be searched for in *3RDPARTY_DIR* directory, and stored in *3RDPARTY_\<LIBRARY\>_DIR* variables.
+The results of search for 3rd-party directories will be stored in *3RDPARTY_\<LIBRARY\>_DIR* variables. If *3RDPARTY_DIR* directory is defined, required libraries are sought in *3RDPARTY_DIR* location.
 
-The procedure expects to find binary and header files of each 3rd-party library in its own sub-directory, separated by sub-directories *bin*, *lib*, and *include*.
+The procedure expects to find binary and header files of each 3rd-party library in its own sub-directory: *bin*, *lib* and *include*.
 
 Press **Configure** (**c** key for ccmake).
 
-The result of the 3rdparty product search will be recorded in the corresponding variables:
+The result of the search are recorded in the corresponding variables:
 
-* *3RDPARTY_\<PRODUCT\>_DIR* - path to the product directory (with directory name) (e.g. <i>D:/3rdparty/Tcl-8.5.12.0-32</i>)
-* *3RDPARTY_\<PRODUCT\>_LIBRARY* - path to .lib libraries (with the library name) (e.g. <i>D:/3rdparty/Tcl-8.5.12.0-32/lib/tcl85.lib</i>). 
-  In non-windows case, this variable is the same as *3RDPARTY_\<PRODUCT\>_DLL*.
-* *3RDPARTY_\<PRODUCT\>_INCLUDE* - path to the include directory that contains the required header file (with "include" name) (e.g., <i>D:/3rdparty/Tcl-8.5.12.0-32/include including tcl.h</i>)
-* *3RDPARTY_\<PRODUCT\>_DLL* - path to  <i>.dll/.so/.dylib</i> library  (with the library name) (e.g., <i>D:/3rdparty/Tcl-8.5.12.0-32/bin/tcl85.dll</i>)
+* *3RDPARTY_\<PRODUCT\>_DIR* - path to the 3rdparty directory (with directory name) (e.g. <i>D:/3rdparty/tcltk-86-32</i>)
+* *3RDPARTY_\<PRODUCT\>_LIBRARY_DIR* - path to directory containing a library (e.g. <i>D:/3rdparty/tcltk-86-32/lib</i>). 
+* *3RDPARTY_\<PRODUCT\>_INCLUDE_DIR* - path to the directory containing a header file (e.g., <i>D:/3rdparty/tcltk-86-32/include</i>)
+* *3RDPARTY_\<PRODUCT\>_DLL_DIR* - path to the directory containing a shared library (e.g., <i>D:/3rdparty/tcltk-86-32/bin</i>) This variable is able just in windows case
+
+
+Note: a libraries and include directories should be the children of product directory if the last one is defined.
 
 The search process is as follows:
 
 1. Common path: *3RDPARTY_DIR*
 2. Path to a particular 3rd-party library: *3RDPARTY_\<PRODUCT\>_DIR*
 3. Paths to headers and binaries:
-   1. *3RDPARTY_\<PRODUCT\>_INCLUDE*
-   2. *3RDPARTY_\<PRODUCT\>_LIBRARY*
-   3. *3RDPARTY_\<PRODUCT\>_DLL*
+   1. *3RDPARTY_\<PRODUCT\>_INCLUDE_DIR*
+   2. *3RDPARTY_\<PRODUCT\>_LIBRARY_DIR*
+   3. *3RDPARTY_\<PRODUCT\>_DLL_DIR*
 
 If a variable of any level is not defined (empty or <i> \<variable name\>-NOTFOUND </i>) 
 and the upper level variable is defined, the content of the non-defined variable 
-will be searched for at the next configuration step. If search process in level 3 
-does not find the required files, it searches in default places also.
-
-**Note**: the names of searched libraries and header files are hard-coded.
-Freetype search process tries to find *ft2build.h* file in *3RDPARTY_FREETYPE INCLUDE* directory 
-and after that adds *3RDPARTY_FREETYPE_INCLUDE /freetype2* path to common includes if it exists. 
+will be sought at the next configuration step. If search process at level 3 does not find the required files, it seeks in default places.
 
 Important: If *BUILD_CONFIGURATION* variable is changed, at the next configuration 
 *3RDPARTY_ variables* will be replaced by the search process result, except for the *3RDPARTY_DIR* variable.
 
-*Note* : CMake will produce an error after the configuration step until all required variables are defined correctly.
+**Note** : CMake will produce an error after the configuration step until all required variables are defined correctly.
 If the search result (include path, or library path, or dll path) does not meet your expectations, 
-you can  change *3RDPARTY_\<PRODUCT\>_DIR variable*, clear (if they are not empty) 
-*3RDPARTY_\<PRODUCT\>_DLL, 3RDPARTY_\<PRODUCT\>_INCLUDE_DIR* and 3RDPARTY_\<PRODUCT\>_LIBRARY variables 
+you can  change *3RDPARTY_\<PRODUCT\>_*_DIR variable*, clear (if they are not empty) 
+*3RDPARTY_\<PRODUCT\>_DLL_DIR, 3RDPARTY_\<PRODUCT\>_INCLUDE_DIR* and 3RDPARTY_\<PRODUCT\>_LIBRARY_DIR variables 
 (or clear one of them) and run the configuration process again. 
 
 At this time the search will be performed in the newly identified directory 
-and the result will be recorded to empty variables (non-empty variables will not be replaced).
+and the result will be recorded to corresponding variables (replace old value if it is necessary).
 
 For example, (Linux case) *3RDPARTY_FREETYPE_DIR* variable 
 
-    /PRODUCTS/maintenance/Mandriva2010/freetype-2.3.7
+    /PRODUCTS/maintenance/Mandriva2010/freetype-2.4.10
 
 can be changed to 
 
-    /PRODUCTS/maintenance/Mandriva2010/freetype-2.4.10
-
-and the related variables *3RDPARTY_FREETYPE_DLL, 3RDPARTY_FREETYPE_INCLUDE_DIR* and  *3RDPARTY_FREETYPE_LIBRARY* will be cleared.
+    /PRODUCTS/maintenance/Mandriva2010/freetype-2.5.3
 
-@figure{/dev_guides/building/cmake/images/cmake_image005.png}
+During the configuration process and the related variables (*3RDPARTY_FREETYPE_DLL_DIR*, *3RDPARTY_FREETYPE_INCLUDE_DIR* and *3RDPARTY_FREETYPE_LIBRARY_DIR*) will be filled with new found values
 
-During the configuration process the cleaned variables will be filled with new found values.
+**Note**: The names of searched libraries and header files are hard-coded. If there is the need to change their names,
+change appropriate cmake variables (edit CMakeCache.txt file or edit in cmake-gui in advance mode) without reconfiguration: *3RDPARTY_\<PRODUCT\>_INCLUDE* for include, *3RDPARTY_\<PRODUCT\>_LIB* for library and *3RDPARTY_\<PRODUCT\>_DLL* for shared library.
 
 ###The variables with INSTALL_ prefix:
 
-Define in *INSTALL_DIR* variable the path, where the built OCCT files (libraries, executables and headers) will be placed.
+Define *INSTALL_DIR* variable as the path will be contain the built OCCT files (libraries, executables and headers)
 If <i>INSTALL_\<PRODUCT\></i> variable is checked, 3rd-party products will be copied to the install directory.
 
 At the end of the configuration process "configuring done" message will be shown and the generation process can be started.
@@ -178,9 +174,7 @@ Then the project files will appear in the build folder (e.g. <i> d:/occt/build/w
 
 ### Linux
 
-When the configuration is complete, start the generation process by pressing **g**.
-
-@figure{/dev_guides/building/cmake/images/cmake_image006.png}
+Click **Generate** button (if you use cmake-gui) or press **g** (for ccmake) to start the generation process.
 
 ### Mac OS X
 
@@ -189,11 +183,14 @@ Then the project files will appear in the build folder (e.g. <i> /Developer/occt
 
 ## OCCT Building
 
-The install folder contains *bin, inc, lib* and *res* folders and a script to run *DRAWEXE* (*draw.bat* or *draw.sh*).
-* **bin** contains executables, DLL (Windows) style shared libraries and pdb-files in OCCT debug version.
-* **lib** contains the import parts of DLL libraries.
-* **inc** contains header files.
-* **res** contains all required source files for OCCT.
+The install folder contains the scripts to run *DRAWEXE* (*draw.bat* or *draw.sh*) and samples (if its were built; (see below **MFC samples**)); the directory structure is follow:
+* **data**    - data files for OCCT (brep, iges, stp)
+* **inc**     - header files
+* **samples** - tcl sample files
+* **src**     - all required source files for OCCT
+* **tests**   - OCCT test suite
+* **win32/vc10/bind**> - example relative directory tree of binary files (3rdparty and occt) (the abstract one is <system with bitness>/<compiler>/bin<build type>)
+* **win32/vc9/lib**>   - example relative directory tree of libraries (3rdparty and occt) (the abstract one is <system with bitness>/<compiler>/lib<build type>)
 
 ### Windows (Visual studio)
 
diff --git a/dox/dev_guides/building/cmake/images/cmake_image006.png b/dox/dev_guides/building/cmake/images/cmake_image006.png
deleted file mode 100644 (file)
index 0d7ec18..0000000
Binary files a/dox/dev_guides/building/cmake/images/cmake_image006.png and /dev/null differ
index 899aca2..a7a36ce 100644 (file)
@@ -218,9 +218,9 @@ then run **wgendoc** command with required arguments, for instance:
 @section OCCT_OVW_SECTION_5 Requirements
 
 Open CASCADE Technology is designed to be highly portable and is known to 
-work on wide range of platforms (UNIX, Linux, Windows, Mac OS X). 
+work on wide range of platforms (UNIX, Linux, Windows, Mac OS X, Android). 
 Current version is officially certified on Windows (IA-32 and x86-64), 
-Linux (x86-64) and MAC OS X (x86-64) platforms. 
+Linux (x86-64), MAC OS X (x86-64) and Android (4.0.4 armv7) platforms. 
 
 The tables below describe the recommended hardware and software configurations
 for which OCCT is certified to work.
@@ -235,7 +235,7 @@ for which OCCT is certified to work.
 | Graphic library | OpenGL 1.1+ (OpenGL 2.1+ is recommended)|
 | C++      | GNU gcc 4.0.  - 4.7.3. |
 | TCL (for testing tools)    | Tcltk 8.5 or 8.6 http://www.tcl.tk/software/tcltk/download.html |
-| Qt (for demonstration tools) | Qt 4.6.2 http://qt.nokia.com/downloads |
+| Qt (for demonstration tools) | Qt 4.6.2 http://qt-project.org/downloads |
 | Freetype (for text rendering) | freetype-2.4.11 http://sourceforge.net/projects/freetype/files/ |
 | FreeImage (optional, for support of common 2D graphic formats) | FreeImage 3.15.4 http://sourceforge.net/projects/freeimage/files |
 | gl2ps (optional, for export contents of OCCT viewer to vector graphic files) | gl2ps-1.3.8  http://geuz.org/gl2ps/ |
@@ -254,7 +254,7 @@ for which OCCT is certified to work.
 | Graphic library | OpenGL 1.1+ (OpenGL 2.1+ is recommended)|
 | C++ | Microsoft Visual Studio: 2005 SP1, 2008 SP1\*, 2010 SP1, 2012 Update 3, 2013 <br>Intel C++ Composer XE 2013 SP1 |
 | TCL (for testing tools) | Tcl/Tk 8.5 or 8.6 http://www.tcl/tk/software/tcltk/download.html |
-| Qt (for demonstration tools) | Qt 4.6.2 http://qt.nokia.com/downloads |
+| Qt (for demonstration tools) | Qt 4.6.2 http://qt-project.org/downloads |
 | Freetype (OCCT Text rendering) | freetype-2.4.11 http://sourceforge.net/projects/freetype/files/ |
 | FreeImage (Support of common graphic formats) | FreeImage 3.15.4 http://sourceforge.net/projects/freeimage/files |
 | gl2ps (Export contents of OCCT viewer to vector graphic file) | gl2ps-1.3.8  http://geuz.org/gl2ps/ |
@@ -274,13 +274,20 @@ for which OCCT is certified to work.
 | Graphic library | OpenGL 1.1+ (OpenGL 2.1+ is recommended)|
 | C++      | XCode 3.2 or newer (4.x is recommended) |
 | TCL (for testing tools)    | Tcltk 8.5 or 8.6 http://www.tcl.tk/software/tcltk/download.html |
-| Qt (for demonstration tools) | Qt 4.6.2 http://qt.nokia.com/downloads |
+| Qt (for demonstration tools) | Qt 4.6.2 http://qt-project.org/downloads |
 | Freetype (OCCT Text rendering) | freetype-2.4.11 http://sourceforge.net/projects/freetype/files/ |
 | FreeImage (Support of common graphic formats) | FreeImage 3.15.4 http://sourceforge.net/projects/freeimage/files |
 | gl2ps (Export contents of OCCT viewer to vector graphic file) | gl2ps-1.3.8  http://geuz.org/gl2ps/ |
 | Intel TBB (optional, for multithreaded algorithms) | TBB 3.x or 4.x http://www.threadingbuildingblocks.org/ |
 | OpenCL (optional, for ray tracing visualization) | Native OpenCL 1.2.8 | 
 
+@subsection OCCT_OVW_SECTION_5_4 Android
+
+| Operating System  | Android 4.0.4+  |
+| ----- | ----- |
+| Minimum memory    | 512 MB, 1 GB recommended |
+| Freetype (for text rendering) | freetype-2.4.11 http://sourceforge.net/projects/freetype/files/ |
+
 @subsection overview_req_graphics Graphic cards
 
 For 3d viewer, graphic card or software implementation supporting OpenGL 1.1 
index 0bce76c..c54601a 100644 (file)
@@ -10,5 +10,14 @@ if exist "%~dp0env.bat" (
   call "%~dp0env.bat"
 )
 
-tclsh.exe %~dp0adm/start.tcl  %*
+set "TCL_EXEC=tclsh.exe"
+
+for %%X in (%TCL_EXEC%) do (set TCL_FOUND=%%~$PATH:X)
+
+if defined TCL_FOUND (
+  %TCL_EXEC% %~dp0adm/start.tcl  %*
+) else (
+  echo "Error. %TCL_EXEC% is not found. Please update PATH variable"
+)
+
 SET "PATH=%OLD_PATH%"
index 2e948ea..fbe3267 100644 (file)
@@ -71,9 +71,9 @@ add_executable (Geometry WIN32 ${Geometry_SOURCE_FILES}
 
 set_property(TARGET Geometry PROPERTY FOLDER Samples)
 
-install (TARGETS Geometry RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                          ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                          LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS Geometry RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                          ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                          LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${Geometry_SRC_DIR}
index 10cbb64..7685dd5 100644 (file)
@@ -39,9 +39,9 @@ add_executable ( Modeling WIN32 ${Modeling_SOURCE_FILES}
 
 set_property (TARGET Modeling PROPERTY FOLDER Samples)
 
-install (TARGETS Modeling RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                          ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                          LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS Modeling RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                          ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                          LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${MFC_STANDARD_SAMPLES_DIR}/02_Modeling
index c271e83..bf1b3bb 100644 (file)
@@ -35,9 +35,9 @@ add_executable (Viewer2d WIN32 ${Viewer2d_SOURCE_FILES}
 
 set_property (TARGET Viewer2d PROPERTY FOLDER Samples)
 
-install (TARGETS Viewer2d RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                          ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                          LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS Viewer2d RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                          ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                          LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${MFC_STANDARD_SAMPLES_DIR}/03_Viewer2d
index 42e4df4..4424a15 100644 (file)
@@ -63,9 +63,9 @@ add_executable (Viewer3d WIN32 ${Viewer3d_SOURCE_FILES}
 
 set_property (TARGET Viewer3d PROPERTY FOLDER Samples)
 
-install (TARGETS Viewer3d RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                          ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                          LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS Viewer3d RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                          ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                          LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${Viewer3d_SRC_DIR}
index 7e9e8ac..5c47d36 100644 (file)
@@ -39,9 +39,9 @@ add_executable (ImportExport WIN32 ${ImportExport_SOURCE_FILES}
 
 set_property (TARGET ImportExport PROPERTY FOLDER Samples)
 
-install (TARGETS ImportExport RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                              ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                              LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS ImportExport RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                              ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                              LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${MFC_STANDARD_SAMPLES_DIR}/05_ImportExport
index c19a8c8..4d70782 100644 (file)
@@ -55,9 +55,9 @@ add_executable (Ocaf WIN32 ${Ocaf_SOURCE_FILES}
 
 set_property (TARGET Ocaf PROPERTY FOLDER Samples)
 
-install (TARGETS Ocaf RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                      ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                      LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS Ocaf RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                      ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                      LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${MFC_STANDARD_SAMPLES_DIR}/06_Ocaf
index e332e64..b85e1cb 100644 (file)
@@ -41,9 +41,9 @@ add_executable (Triangulation WIN32 ${Triangulation_SOURCE_FILES}
 
 set_property (TARGET Triangulation PROPERTY FOLDER Samples)
 
-install (TARGETS Triangulation RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                               ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                               LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS Triangulation RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                               ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                               LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${MFC_STANDARD_SAMPLES_DIR}/07_Triangulation
index b92752e..ed8853f 100644 (file)
@@ -63,9 +63,9 @@ add_executable (HLR WIN32 ${HLR_SOURCE_FILES}
 
 set_property (TARGET HLR PROPERTY FOLDER Samples)
 
-install (TARGETS HLR RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                     ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                     LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS HLR RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                     ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                     LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${HLR_RESOURCE_DIR}
index fdf25ec..82e6d14 100644 (file)
@@ -46,9 +46,9 @@ add_executable (Animation WIN32 ${Animation_SOURCE_FILES}
 
 set_property (TARGET Animation PROPERTY FOLDER Samples)
 
-install (TARGETS Animation RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                           ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                           LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS Animation RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                           ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                           LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${Animation_RESOURCE_DIR}
index 0d20f80..8e6de1e 100644 (file)
@@ -63,9 +63,9 @@ add_executable (Convert WIN32 ${Convert_SOURCE_FILES}
 
 set_property (TARGET Convert PROPERTY FOLDER Samples)
 
-install (TARGETS Convert RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                         ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                         LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS Convert RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                         ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                         LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories (${OCCT_ROOT}/inc
                      ${Convert_SRC_DIR}
index 5d1ed1c..c982b55 100644 (file)
@@ -140,9 +140,9 @@ add_library ( mfcsample SHARED ${mfcsample_SOURCE_FILES}
 
 set_property (TARGET mfcsample PROPERTY FOLDER Samples)
 
-install (TARGETS mfcsample RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_SUFFIX}"
-                           ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}"
-                           LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_SUFFIX}")
+install (TARGETS mfcsample RUNTIME DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/bin${BUILD_POSTFIX}"
+                           ARCHIVE DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}"
+                           LIBRARY DESTINATION "${INSTALL_DIR}/win${COMPILER_BITNESS}/${COMPILER}/lib${BUILD_POSTFIX}")
 
 include_directories( ${OCCT_ROOT}/inc
                      ${MFC_STANDARD_COMMON_SAMPLES_DIR}