0026388: Setting debugging environment of the Visual Studio solution of OCCT generate...
authoribs <ibs@opencascade.com>
Thu, 2 Jul 2015 13:55:21 +0000 (16:55 +0300)
committerabv <abv@opencascade.com>
Sun, 12 Jul 2015 10:57:22 +0000 (13:57 +0300)
0. debugging environment added to DRAWEXE vcxproj
1. OCCT header files copied to inc directory of an installation folder. (the grouping of header files removed)
1. collect reference files of all OCCT header files in <binary dir>/inc during cmake configuration process
2. tcl installation procedure installs all dlls found in tcl bin folder (for win. this approach takes into account installing of zlib library that may be located in tcl bin folder)
4. each a OCCT project include just 3rdparty paths and <cmake binary dir>/inc folder

CMakeLists.txt
adm/cmake/3rdparty_macro.cmake
adm/cmake/BuildToolkit.cmake
adm/cmake/freetype.cmake
adm/cmake/occt_macros.cmake
adm/cmake/tbb.cmake
adm/cmake/tcl.cmake
adm/cmake/vtk.cmake
adm/templates/DRAWEXE.vcxproj.user.in [new file with mode: 0644]
adm/templates/header.in [new file with mode: 0644]

index daf1252..7fd204c 100644 (file)
@@ -57,11 +57,8 @@ if (${BUILD_BISON_FLEX_FILES})
   endforeach()
 endif()
 
-# group include files in folder install
-set (INSTALL_GROUP_INC ON CACHE BOOL "In include files grouped in install folder")
-
 # copy samples to install directory
-set (INSTALL_SAMPLES OFF CACHE BOOL "Copy samples to install directory")
+set (INSTALL_SAMPLES OFF CACHE BOOL "Copy OCCT samples to install directory")
 
 set (CMAKE_BUILD_TYPE ${BUILD_CONFIGURATION} CACHE INTERNAL "Build type of OCCT" FORCE )
 
@@ -260,6 +257,9 @@ if (3RDPARTY_INCLUDE_DIRS)
   include_directories (${3RDPARTY_INCLUDE_DIRS})
 endif()
 
+# include <cmake binary folder>/inc
+include_directories (${CMAKE_BINARY_DIR}/inc)
+
 if (3RDPARTY_LIBRARY_DIRS)
   list (REMOVE_DUPLICATES 3RDPARTY_LIBRARY_DIRS)
   string (REGEX REPLACE ";" "\n\t" 3RDPARTY_LIBRARY_DIRS_WITH_ENDS "${3RDPARTY_LIBRARY_DIRS}")
@@ -286,52 +286,30 @@ if (WIN32)
   set ("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${TAIL_OF_OUTPUT_VARNAME}" "${OUTPUT_BINARY_DIR}")
 endif()
 
+message (STATUS "\nInfo: Collecting all OCCT header files into ${CMAKE_BINARY_DIR}/inc ...")
+
+# (!) patch is not taken into account COLLECT_AND_INSTALL_OCCT_HEADER_FILES
+# collect all the headers to <binary dir>/inc folder
+COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/adm/templates/header.in" "${CMAKE_BINARY_DIR}" "${USED_TOOLKITS}")
+# apply patched header files
+#if (NOT "${BUILD_PATCH_DIR}" STREQUAL "")
+#  COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${BUILD_PATCH_DIR}" "${CMAKE_SOURCE_DIR}/adm/templates/header.in" "${CMAKE_BINARY_DIR}")
+#endif()
+
 if ("${INSTALL_DIR}" STREQUAL "")
   message (FATAL_ERROR "INSTALL_DIR variable is empty. It's required to define installation directory")
 else()
 
-  # inc,data,tests DIRECTORY
-  file (GLOB DIRS RELATIVE ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/*)
-  foreach(CDIR ${DIRS})
-    file(GLOB HFiles "${CMAKE_SOURCE_DIR}/src/${CDIR}/*.[hgl]xx" "${CMAKE_SOURCE_DIR}/src/${CDIR}/*.h")
-    set (GROUP_CDIR "")
-    if (INSTALL_GROUP_INC)
-      set (GROUP_CDIR ${CDIR})
-    endif()
-    install(FILES ${HFiles} DESTINATION "${INSTALL_DIR}/inc/${GROUP_CDIR}")
-  endforeach(CDIR)
-
-  install (DIRECTORY "${CMAKE_SOURCE_DIR}/data"         DESTINATION  "${INSTALL_DIR}")
-  install (DIRECTORY "${CMAKE_SOURCE_DIR}/samples/tcl"  DESTINATION  "${INSTALL_DIR}/samples")
-  if (TESTS_INSTALL)
-    install (DIRECTORY "${CMAKE_SOURCE_DIR}/tests" DESTINATION  "${INSTALL_DIR}" )
-  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}" )
-    else()
-      file (GLOB DIRS RELATIVE ${BUILD_PATCH_DIR}/src ${BUILD_PATCH_DIR}/src/*)
-      foreach(CDIR ${DIRS})
-        file(GLOB HFiles "${BUILD_PATCH_DIR}/src/${CDIR}/*.[hgl]xx" "${BUILD_PATCH_DIR}/src/${CDIR}/*.h")
-        if (INSTALL_GROUP_INC)
-          install(FILES ${HFiles} DESTINATION "${INSTALL_DIR}/inc/${CDIR}")
-        else()
-          install(FILES ${HFiles} DESTINATION "${INSTALL_DIR}/inc")
-        endif()
-      endforeach(CDIR)
-    endif()
+  OCCT_INSTALL_FILE_OR_DIR ("data" "${INSTALL_DIR}")
+  OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR}/samples")
 
-    if (EXISTS "${BUILD_PATCH_DIR}/data")
-      install (DIRECTORY "${BUILD_PATCH_DIR}/data"  DESTINATION  "${INSTALL_DIR}" )
-    endif()
+  if (INSTALL_SAMPLES)
+    OCCT_INSTALL_FILE_OR_DIR ("samples" "${INSTALL_DIR}")
+  endif()
 
-    if (TESTS_INSTALL)
-      if (EXISTS "${BUILD_PATCH_DIR}/tests")
-        install (DIRECTORY "${BUILD_PATCH_DIR}/tests" DESTINATION "${INSTALL_DIR}" )
-      endif()
-    endif()
+  if (TESTS_INSTALL)
+    OCCT_INSTALL_FILE_OR_DIR ("tests" "${INSTALL_DIR}")
   endif()
 
   if (WIN32)
@@ -359,7 +337,6 @@ else()
     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
@@ -392,7 +369,6 @@ else()
     OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "${INSTALL_DIR}")
   endif()
 
-
   # write current custom.bat/sh
   OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.in" "${SUB_CUSTOM}" "${INSTALL_DIR}")
 
@@ -429,6 +405,27 @@ foreach (USED_TOOLKIT ${USED_TOOLKITS})
   endif()
 endforeach()
 
+# patch DRAWEXE
+if (MSVC AND 3RDPARTY_DLL_DIRS)
+  list (FIND USED_TOOLKITS DRAWEXE DRAWEXE_INDEX)
+  if (${DRAWEXE_INDEX} GREATER -1)
+    list (REMOVE_DUPLICATES 3RDPARTY_DLL_DIRS)
+    set (3RDPARTY_DLL_DIRS_FOR_PATH "")
+
+    foreach (3RDPARTY_DLL_DIR ${3RDPARTY_DLL_DIRS})
+      set (3RDPARTY_DLL_DIRS_FOR_PATH "${3RDPARTY_DLL_DIRS_FOR_PATH};${3RDPARTY_DLL_DIR}")
+    endforeach()
+
+    OCCT_MAKE_COMPILER_BITNESS()
+    set (X_COMPILER_BITNESS "x64")
+    if ("${COMPILER_BITNESS}" STREQUAL "32")
+      set (X_COMPILER_BITNESS "Win32")
+    endif()
+
+    configure_file (${CMAKE_SOURCE_DIR}/adm/templates/DRAWEXE.vcxproj.user.in ${CMAKE_BINARY_DIR}/src/DRAWEXE/DRAWEXE.vcxproj.user @ONLY)
+  endif()
+endif()
+
 # samples do not support patch usage
 if (BUILD_MFC_SAMPLES)
   set (OCCT_ROOT ${CMAKE_SOURCE_DIR})
@@ -448,7 +445,3 @@ if (BUILD_MFC_SAMPLES)
   add_subdirectory(samples/mfc/standard/09_Animation)
   add_subdirectory(samples/mfc/standard/10_Convert)
 endif()
-
-if (INSTALL_SAMPLES)
-  OCCT_INSTALL_FILE_OR_DIR ("samples" "${INSTALL_DIR}")
-endif()
index bd97520..3130b59 100644 (file)
@@ -164,7 +164,9 @@ macro (THIRDPARTY_PRODUCT PRODUCT_NAME HEADER_NAME LIBRARY_NAME LIBRARY_NAME_DEB
   endif()
 
   if (WIN32)
-    if (NOT 3RDPARTY_${PRODUCT_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+    if (3RDPARTY_${PRODUCT_NAME}_DLL OR EXISTS "${3RDPARTY_${PRODUCT_NAME}_DLL}")
+      list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${PRODUCT_NAME}_DLL_DIR}")
+    else()
       list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${PRODUCT_NAME}_DLL_DIR)
     endif()
   endif()
index eb85d47..26cb58a 100644 (file)
@@ -60,7 +60,6 @@ foreach (CDIR ${COMPILER_DIRECTORIES})
   endforeach()
 endforeach()
 
-list (APPEND COMPILER_DIRECTORIES "${OCCT_SOURCE_DIR}/src")
 list (FIND USED_TOOLKITS ${PROJECT_NAME} isFOUND)
 
 OCCT_MAKE_BUILD_POSTFIX()
@@ -91,6 +90,5 @@ if ("${USED_TOOLKITS}" STREQUAL "" OR NOT ${isFOUND} EQUAL -1)
 
   set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER "Modules/${CURRENT_MODULE}")
   set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}")
-  include_directories (${COMPILER_DIRECTORIES})
   target_link_libraries (${PROJECT_NAME} ${USED_LIBS})
 endif()
\ No newline at end of file
index 4d98077..19d6424 100644 (file)
@@ -199,7 +199,9 @@ else()
 endif()
 
 if (WIN32)
-  if (NOT 3RDPARTY_FREETYPE_DLL OR NOT EXISTS "${3RDPARTY_FREETYPE_DLL}")
+  if (3RDPARTY_FREETYPE_DLL OR EXISTS "${3RDPARTY_FREETYPE_DLL}")
+    list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_FREETYPE_DLL_DIR}")
+  else()
     list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_FREETYPE_DLL_DIR)
   endif()
 endif()
index a8e94c5..84b4527 100644 (file)
@@ -158,6 +158,38 @@ macro (OCCT_CONFIGURE_AND_INSTALL BEING_CONGIRUGED_FILE FINAL_NAME DESTINATION_P
   install(FILES "${OCCT_BINARY_DIR}/${FINAL_NAME}" DESTINATION  "${DESTINATION_PATH}")
 endmacro()
 
+macro (COLLECT_AND_INSTALL_OCCT_HEADER_FILES ROOT_OCCT_DIR TEMPLATE_HEADER_PATH ROOT_TARGET_OCCT_DIR OCCT_USED_TOOLKITS)
+  set (OCCT_SOURCE_DIRS)
+
+  foreach (OCCT_USED_TOOLKIT ${OCCT_USED_TOOLKITS})
+    # append parent folder
+    list (APPEND OCCT_SOURCE_DIRS ${OCCT_USED_TOOLKIT})
+
+    # append all required package folders
+    set (OCCT_USED_TOOLKIT_DEPS)
+    if (EXISTS "${ROOT_OCCT_DIR}/src/${OCCT_USED_TOOLKIT}/PACKAGES")
+      file (STRINGS "${ROOT_OCCT_DIR}/src/${OCCT_USED_TOOLKIT}/PACKAGES" OCCT_USED_TOOLKIT_DEPS)
+    endif()
+
+    foreach (OCCT_USED_TOOLKIT_DEP ${OCCT_USED_TOOLKIT_DEPS})
+      list (APPEND OCCT_SOURCE_DIRS ${OCCT_USED_TOOLKIT_DEP})
+    endforeach()
+  endforeach()
+
+  foreach (OCCT_SOURCE_DIR ${OCCT_SOURCE_DIRS})
+    # get all header files from each src folder 
+    file (GLOB OCCT_HEADER_FILES "${ROOT_OCCT_DIR}/src/${OCCT_SOURCE_DIR}/*.[hgl]xx" "${ROOT_OCCT_DIR}/src/${OCCT_SOURCE_DIR}/*.h")
+
+    install (FILES ${OCCT_HEADER_FILES} DESTINATION "${INSTALL_DIR}/inc")
+
+    # create new file including found header
+    foreach (OCCT_HEADER_FILE ${OCCT_HEADER_FILES})
+      get_filename_component (HEADER_FILE_NAME ${OCCT_HEADER_FILE} NAME)
+      configure_file ("${TEMPLATE_HEADER_PATH}" "${ROOT_TARGET_OCCT_DIR}/inc/${HEADER_FILE_NAME}" @ONLY)
+    endforeach()
+  endforeach()
+endmacro()
+
 macro (OCCT_COPY_FILE_OR_DIR BEING_COPIED_OBJECT DESTINATION_PATH)
   # first of all, copy original files
   file (COPY "${CMAKE_SOURCE_DIR}/${BEING_COPIED_OBJECT}" DESTINATION  "${DESTINATION_PATH}")
index 67bb90e..01bc044 100644 (file)
@@ -233,7 +233,9 @@ foreach (LIBRARY_NAME TBB TBBMALLOC)
   endif()
 
   if (WIN32)
-    if (NOT 3RDPARTY_${LIBRARY_NAME}_DLL OR NOT EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}")
+    if (3RDPARTY_${LIBRARY_NAME}_DLL OR EXISTS "${3RDPARTY_${LIBRARY_NAME}_DLL}")
+      list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${LIBRARY_NAME}_DLL_DIR}")
+    else()
       list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBRARY_NAME}_DLL_DIR)
     endif()
   endif()
index 9fe2a41..5eb747b 100644 (file)
@@ -236,7 +236,6 @@ foreach (LIBNAME TCL TK)
     endif()
   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}")
@@ -288,7 +287,9 @@ foreach (LIBNAME TCL TK)
   endif()
 
   if (WIN32)
-    if (NOT 3RDPARTY_${LIBNAME}_DLL OR NOT EXISTS "${3RDPARTY_${LIBNAME}_DLL}")
+    if (3RDPARTY_${LIBNAME}_DLL OR EXISTS "${3RDPARTY_${LIBNAME}_DLL}")
+      list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_${LIBNAME}_DLL_DIR}")
+    else()
       list (APPEND 3RDPARTY_NOT_INCLUDED 3RDPARTY_${LIBNAME}_DLL_DIR)
     endif()
   endif()
@@ -304,13 +305,18 @@ if (INSTALL_TCL)
   OCCT_MAKE_BUILD_POSTFIX()
 
   if (WIN32)
-    install (FILES ${3RDPARTY_TCL_DLL} ${3RDPARTY_TK_DLL} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BUILD_POSTFIX}")
-       install (FILES ${3RDPARTY_TCL_DLL_DIR}/zlib1.dll DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BUILD_POSTFIX}")
+    # tcl 8.6 requires zlib. install all dlls from tcl bin folder that may contain zlib also
+
+    # collect and install all dlls from tcl/tk dll dirs
+    file (GLOB TCL_DLLS "${3RDPARTY_TCL_DLL_DIR}/*.dll")
+    file (GLOB TK_DLLS  "${3RDPARTY_TK_DLL_DIR}/*.dll")
+    install (FILES ${TCL_DLLS} ${TK_DLLS} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/bin${BUILD_POSTFIX}")
   else()
-       get_filename_component(ABS_PATH ${3RDPARTY_TCL_LIBRARY} REALPATH)
-    install (FILES ${ABS_PATH} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}")
-       get_filename_component(ABS_PATH ${3RDPARTY_TK_LIBRARY} REALPATH)
-       install (FILES ${ABS_PATH} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}")
+    get_filename_component(3RDPARTY_TCL_LIBRARY_REALPATH ${3RDPARTY_TCL_LIBRARY} REALPATH)
+    install (FILES ${3RDPARTY_TCL_LIBRARY_REALPATH} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}")
+
+    get_filename_component(3RDPARTY_TK_LIBRARY_REALPATH ${3RDPARTY_TK_LIBRARY} REALPATH)
+    install (FILES ${3RDPARTY_TK_LIBRARY_REALPATH} DESTINATION "${INSTALL_DIR}/${OS_WITH_BIT}/${COMPILER}/lib${BUILD_POSTFIX}")
   endif()
 
   if (TCL_TCLSH_VERSION)
index e0f8674..ea4cb27 100644 (file)
@@ -113,12 +113,16 @@ if (WIN32)
     if(EXISTS "${3RDPARTY_VTK_DIR}/bin${BUILD_POSTFIX}")
       set (3RDPARTY_VTK_DLL_DIR "${3RDPARTY_VTK_DIR}/bin${BUILD_POSTFIX}" CACHE FILEPATH "The directory containing dll of VTK" FORCE)
     else()
-         if (NOT "${BUILD_POSTFIX}" STREQUAL "" AND EXISTS "${3RDPARTY_VTK_DIR}/bin")
-           set (3RDPARTY_VTK_DLL_DIR "${3RDPARTY_VTK_DIR}/bin" CACHE FILEPATH "The directory containing dll of VTK" FORCE)
+      if (NOT "${BUILD_POSTFIX}" STREQUAL "" AND EXISTS "${3RDPARTY_VTK_DIR}/bin")
+       set (3RDPARTY_VTK_DLL_DIR "${3RDPARTY_VTK_DIR}/bin" CACHE FILEPATH "The directory containing dll of VTK" FORCE)
       endif()
-       endif()
+    endif()
   endif()
-endif()
+
+  if (3RDPARTY_VTK_DLL_DIR OR EXISTS "${3RDPARTY_VTK_DLL_DIR}")
+    list (APPEND 3RDPARTY_DLL_DIRS "${3RDPARTY_VTK_DLL_DIR}")
+  endif()
+endif() 
 
 OCCT_CHECK_AND_UNSET(VTK_DIR)
 
diff --git a/adm/templates/DRAWEXE.vcxproj.user.in b/adm/templates/DRAWEXE.vcxproj.user.in
new file mode 100644 (file)
index 0000000..be63c38
--- /dev/null
@@ -0,0 +1,9 @@
+\feff<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='@BUILD_CONFIGURATION@|@X_COMPILER_BITNESS@'">
+ <LocalDebuggerEnvironment>CASROOT=@CMAKE_SOURCE_DIR@
+PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;%PATH%
+ </LocalDebuggerEnvironment>
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/adm/templates/header.in b/adm/templates/header.in
new file mode 100644 (file)
index 0000000..f32e82f
--- /dev/null
@@ -0,0 +1 @@
+#include "@OCCT_HEADER_FILE@"