From 94829f849287e1f819bf28daae32db85963d22ac Mon Sep 17 00:00:00 2001 From: ibs Date: Thu, 2 Jul 2015 16:55:21 +0300 Subject: [PATCH] 0026388: Setting debugging environment of the Visual Studio solution of OCCT generated by CMake 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 /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 /inc folder --- CMakeLists.txt | 91 +++++++++++++-------------- adm/cmake/3rdparty_macro.cmake | 4 +- adm/cmake/BuildToolkit.cmake | 2 - adm/cmake/freetype.cmake | 4 +- adm/cmake/occt_macros.cmake | 32 ++++++++++ adm/cmake/tbb.cmake | 4 +- adm/cmake/tcl.cmake | 22 ++++--- adm/cmake/vtk.cmake | 12 ++-- adm/templates/DRAWEXE.vcxproj.user.in | 9 +++ adm/templates/header.in | 1 + 10 files changed, 115 insertions(+), 66 deletions(-) create mode 100644 adm/templates/DRAWEXE.vcxproj.user.in create mode 100644 adm/templates/header.in diff --git a/CMakeLists.txt b/CMakeLists.txt index daf12528cc..7fd204cf78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 /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 /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}" ) + OCCT_INSTALL_FILE_OR_DIR ("data" "${INSTALL_DIR}") + OCCT_INSTALL_FILE_OR_DIR ("samples/tcl" "${INSTALL_DIR}/samples") + + if (INSTALL_SAMPLES) + OCCT_INSTALL_FILE_OR_DIR ("samples" "${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() - - if (EXISTS "${BUILD_PATCH_DIR}/data") - install (DIRECTORY "${BUILD_PATCH_DIR}/data" DESTINATION "${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() diff --git a/adm/cmake/3rdparty_macro.cmake b/adm/cmake/3rdparty_macro.cmake index bd97520eea..3130b59bca 100644 --- a/adm/cmake/3rdparty_macro.cmake +++ b/adm/cmake/3rdparty_macro.cmake @@ -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() diff --git a/adm/cmake/BuildToolkit.cmake b/adm/cmake/BuildToolkit.cmake index eb85d473a7..26cb58a960 100644 --- a/adm/cmake/BuildToolkit.cmake +++ b/adm/cmake/BuildToolkit.cmake @@ -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 diff --git a/adm/cmake/freetype.cmake b/adm/cmake/freetype.cmake index 4d98077616..19d6424198 100644 --- a/adm/cmake/freetype.cmake +++ b/adm/cmake/freetype.cmake @@ -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() diff --git a/adm/cmake/occt_macros.cmake b/adm/cmake/occt_macros.cmake index a8e94c5bda..84b4527730 100644 --- a/adm/cmake/occt_macros.cmake +++ b/adm/cmake/occt_macros.cmake @@ -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}") diff --git a/adm/cmake/tbb.cmake b/adm/cmake/tbb.cmake index 67bb90e537..01bc044dda 100644 --- a/adm/cmake/tbb.cmake +++ b/adm/cmake/tbb.cmake @@ -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() diff --git a/adm/cmake/tcl.cmake b/adm/cmake/tcl.cmake index 9fe2a41c10..5eb747b750 100644 --- a/adm/cmake/tcl.cmake +++ b/adm/cmake/tcl.cmake @@ -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) diff --git a/adm/cmake/vtk.cmake b/adm/cmake/vtk.cmake index e0f8674c19..ea4cb27bf7 100644 --- a/adm/cmake/vtk.cmake +++ b/adm/cmake/vtk.cmake @@ -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 index 0000000000..be63c38f49 --- /dev/null +++ b/adm/templates/DRAWEXE.vcxproj.user.in @@ -0,0 +1,9 @@ + + + + CASROOT=@CMAKE_SOURCE_DIR@ +PATH=@3RDPARTY_DLL_DIRS_FOR_PATH@;%PATH% + + WindowsLocalDebugger + + \ No newline at end of file diff --git a/adm/templates/header.in b/adm/templates/header.in new file mode 100644 index 0000000000..f32e82fd4d --- /dev/null +++ b/adm/templates/header.in @@ -0,0 +1 @@ +#include "@OCCT_HEADER_FILE@"