From 1fa1615244319b1e0ede0aba9b86f0dc1d3672a9 Mon Sep 17 00:00:00 2001 From: nds Date: Sun, 18 Mar 2018 15:34:17 +0300 Subject: [PATCH] 0029571: Samples: build qt samples together with OCCT Extending CMake procedure by 'BUILD_MODULE_QtSamples' variable to switch on qt samples build. Implementation required: - union of occt_toolkit_tool.cmake and occt_toolkit.cmake files; - correction of qt samples sources by adding path to Qt 'plugins' folder. It helps to avoid definition of additional variable (QT_QPA_PLATFORM_PLUGIN_PATH) when staring sample.bat for qt samples; - executable processing is extended in cmake procedure by providing 'EXECUTABLE_PROJECT' variable. Now we need not specify custom processing for DRAWEXE in occt_toolkit.cmake --- CMakeLists.txt | 91 ++++-- adm/SAMPLES | 2 + adm/SAMPLES_RESOURCES | 2 + adm/cmake/occt_macros.cmake | 28 +- adm/cmake/occt_toolkit.cmake | 149 ++++++--- adm/cmake/occt_toolkit_prepare_sample.cmake | 18 ++ adm/cmake/occt_toolkit_prepare_tool.cmake | 13 + adm/cmake/occt_toolkit_tool.cmake | 302 ------------------ adm/cmake/qt_macro.cmake | 71 +++- adm/cmake/vardescr.cmake | 5 + adm/templates/sample.bat | 4 + samples/qt/AndroidQt/AndroidQt.pro | 21 +- samples/qt/AndroidQt/AndroidQt.qrc | 8 - samples/qt/AndroidQt/CMakeLists.txt | 9 + samples/qt/AndroidQt/EXTERNLIB | 17 + samples/qt/AndroidQt/FILES | 2 + samples/qt/AndroidQt/PACKAGES | 1 + samples/qt/AndroidQt/ReadMe.md | 58 +++- samples/qt/AndroidQt/res/qml/main.qml | 2 +- samples/qt/AndroidQt/{ => src}/AndroidQt.cxx | 0 samples/qt/AndroidQt/{ => src}/AndroidQt.h | 0 samples/qt/AndroidQt/src/AndroidQt.qrc | 8 + .../{ => src}/AndroidQt_TouchParameters.cxx | 0 .../{ => src}/AndroidQt_TouchParameters.h | 0 .../AndroidQt_UserInteractionParameters.h | 0 .../AndroidQt/{ => src}/AndroidQt_Window.cxx | 0 .../qt/AndroidQt/{ => src}/AndroidQt_Window.h | 0 samples/qt/AndroidQt/src/FILES | 9 + samples/qt/AndroidQt/{ => src}/Main.cxx | 2 +- samples/qt/Common/src/ApplicationCommon.cxx | 7 +- samples/qt/Common/src/DocumentCommon.cxx | 5 +- samples/qt/Common/src/FILES | 17 + samples/qt/Common/src/MDIWindow.cxx | 1 - samples/qt/FuncDemo/CMakeLists.txt | 5 + samples/qt/FuncDemo/EXTERNLIB | 14 + samples/qt/FuncDemo/FILES | 2 + samples/qt/FuncDemo/FuncDemo.pro | 2 + samples/qt/FuncDemo/PACKAGES | 1 + samples/qt/FuncDemo/env.bat | 3 +- samples/qt/FuncDemo/src/FILES | 28 ++ samples/qt/FuncDemo/src/FuncDemo.qrc | 7 + samples/qt/FuncDemo/src/main.cpp | 7 + samples/qt/IESample/CMakeLists.txt | 11 + samples/qt/IESample/EXTERNLIB | 29 ++ samples/qt/IESample/FILES | 2 + samples/qt/IESample/PACKAGES | 3 + samples/qt/IESample/env.bat | 1 - samples/qt/IESample/src/FILES | 1 + samples/qt/IESample/src/Main.cxx | 9 +- samples/qt/Interface/src/Application.cxx | 8 +- samples/qt/Interface/src/FILES | 6 + samples/qt/Tutorial/CMakeLists.txt | 11 + samples/qt/Tutorial/EXTERNLIB | 29 ++ samples/qt/Tutorial/FILES | 2 + samples/qt/Tutorial/PACKAGES | 2 + samples/qt/Tutorial/env.bat | 1 - samples/qt/Tutorial/src/ApplicationTut.cxx | 7 +- samples/qt/Tutorial/src/FILES | 8 + samples/qt/Tutorial/src/Main.cxx | 7 + samples/tools/TInspectorEXE/CMakeLists.txt | 8 +- samples/tools/TInspectorEXE/FILES | 7 +- samples/tools/TInspectorEXE/PACKAGES | 1 + samples/tools/TInspectorEXE/TInspectorEXE.qrc | 6 - samples/tools/TInspectorEXE/src/FILES | 6 + .../TInspectorEXE/{ => src}/TInspectorEXE.cxx | 14 +- .../tools/TInspectorEXE/src/TInspectorEXE.qrc | 6 + .../TInspectorEXE_OpenFileDialog.cxx | 6 +- .../TInspectorEXE_OpenFileDialog.hxx | 0 .../TInspectorEXE_OpenFileViewModel.cxx | 0 .../TInspectorEXE_OpenFileViewModel.hxx | 0 .../adm/cmake/occt_toolkit_standalone.cmake | 2 +- src/DRAWEXE/CMakeLists.txt | 2 + tools/DFBrowserPane/DFBrowserPane.hxx | 2 +- tools/TInspector/TInspector_Communicator.cxx | 7 +- tools/TKDFBrowser/CMakeLists.txt | 4 +- tools/TKShapeView/CMakeLists.txt | 4 +- tools/TKTInspector/CMakeLists.txt | 4 +- tools/TKTInspectorAPI/CMakeLists.txt | 4 +- tools/TKToolsDraw/CMakeLists.txt | 4 +- tools/TKTreeModel/CMakeLists.txt | 4 +- tools/TKVInspector/CMakeLists.txt | 4 +- tools/TKView/CMakeLists.txt | 4 +- 82 files changed, 672 insertions(+), 485 deletions(-) create mode 100644 adm/SAMPLES create mode 100644 adm/SAMPLES_RESOURCES create mode 100644 adm/cmake/occt_toolkit_prepare_sample.cmake create mode 100644 adm/cmake/occt_toolkit_prepare_tool.cmake delete mode 100644 adm/cmake/occt_toolkit_tool.cmake delete mode 100644 samples/qt/AndroidQt/AndroidQt.qrc create mode 100644 samples/qt/AndroidQt/CMakeLists.txt create mode 100644 samples/qt/AndroidQt/EXTERNLIB create mode 100644 samples/qt/AndroidQt/FILES create mode 100644 samples/qt/AndroidQt/PACKAGES rename samples/qt/AndroidQt/{ => src}/AndroidQt.cxx (100%) rename samples/qt/AndroidQt/{ => src}/AndroidQt.h (100%) create mode 100644 samples/qt/AndroidQt/src/AndroidQt.qrc rename samples/qt/AndroidQt/{ => src}/AndroidQt_TouchParameters.cxx (100%) rename samples/qt/AndroidQt/{ => src}/AndroidQt_TouchParameters.h (100%) rename samples/qt/AndroidQt/{ => src}/AndroidQt_UserInteractionParameters.h (100%) rename samples/qt/AndroidQt/{ => src}/AndroidQt_Window.cxx (100%) rename samples/qt/AndroidQt/{ => src}/AndroidQt_Window.h (100%) create mode 100644 samples/qt/AndroidQt/src/FILES rename samples/qt/AndroidQt/{ => src}/Main.cxx (93%) create mode 100644 samples/qt/Common/src/FILES create mode 100644 samples/qt/FuncDemo/CMakeLists.txt create mode 100644 samples/qt/FuncDemo/EXTERNLIB create mode 100644 samples/qt/FuncDemo/FILES create mode 100644 samples/qt/FuncDemo/PACKAGES create mode 100644 samples/qt/FuncDemo/src/FILES create mode 100644 samples/qt/FuncDemo/src/FuncDemo.qrc create mode 100644 samples/qt/IESample/CMakeLists.txt create mode 100644 samples/qt/IESample/EXTERNLIB create mode 100644 samples/qt/IESample/FILES create mode 100644 samples/qt/IESample/PACKAGES create mode 100644 samples/qt/IESample/src/FILES create mode 100644 samples/qt/Interface/src/FILES create mode 100644 samples/qt/Tutorial/CMakeLists.txt create mode 100644 samples/qt/Tutorial/EXTERNLIB create mode 100644 samples/qt/Tutorial/FILES create mode 100644 samples/qt/Tutorial/PACKAGES create mode 100644 samples/qt/Tutorial/src/FILES create mode 100644 samples/tools/TInspectorEXE/PACKAGES delete mode 100644 samples/tools/TInspectorEXE/TInspectorEXE.qrc create mode 100644 samples/tools/TInspectorEXE/src/FILES rename samples/tools/TInspectorEXE/{ => src}/TInspectorEXE.cxx (93%) create mode 100644 samples/tools/TInspectorEXE/src/TInspectorEXE.qrc rename samples/tools/TInspectorEXE/{ => src}/TInspectorEXE_OpenFileDialog.cxx (98%) rename samples/tools/TInspectorEXE/{ => src}/TInspectorEXE_OpenFileDialog.hxx (100%) rename samples/tools/TInspectorEXE/{ => src}/TInspectorEXE_OpenFileViewModel.cxx (100%) rename samples/tools/TInspectorEXE/{ => src}/TInspectorEXE_OpenFileViewModel.hxx (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dbe95ff2c..beee192894 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -346,6 +346,7 @@ separate_arguments (BUILD_ADDITIONAL_TOOLKITS) if (MSVC) set (BUILD_MODULE_MfcSamples OFF CACHE BOOL "${BUILD_MODULE_MfcSamples_DESCR}") endif() +set (BUILD_MODULE_QtSamples OFF CACHE BOOL "${BUILD_MODULE_QtSamples_DESCR}") set (BUILD_Inspector OFF CACHE BOOL "${BUILD_Inspector_DESCR}") @@ -381,7 +382,7 @@ endif() # include the patched or original list of modules # list _TOOLKITS is created foreach module and contains its toolkits # list will contain all modules -OCCT_MODULES_AND_TOOLKITS (OCCT_MODULES) +OCCT_MODULES_AND_TOOLKITS (MODULES "TOOLKITS" OCCT_MODULES) foreach (OCCT_MODULE ${OCCT_MODULES}) BUILD_MODULE (${OCCT_MODULE}) @@ -775,30 +776,31 @@ else() set (SCRIPT_EXT sh) endif() -# OCCT tools -# include the patched or original list of tools -# list _TOOLKITS is created foreach tool and contains its toolkits -# list will contain all tools -if (NOT BUILD_Inspector) - OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_QT") - OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TQTMALLOC") - OCCT_CHECK_AND_UNSET ("INSTALL_QT") -else() - OCCT_TOOLS_AND_TOOLKITS (OCCT_TOOLS) - foreach (OCCT_TOOL ${OCCT_TOOLS}) - list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS}) - endforeach() - - # collect all the headers to /inc folder - string(TIMESTAMP CURRENT_TIME "%H:%M:%S") - message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/tools/inc ...") - COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "${INSTALL_DIR_INCLUDE}/inspector") - - +if (BUILD_Inspector OR BUILD_MODULE_QtSamples) # check qt 3rdparty path add_definitions (-DHAVE_QT) OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/qt") message (STATUS "Info: Qt is used by OCCT") +else() + OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_QT") + OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_TQTMALLOC") + OCCT_CHECK_AND_UNSET ("INSTALL_QT") +endif() + +# OCCT tools +# include the patched or original list of tools +# list _TOOLKITS is created foreach tool and contains its toolkits +# list will contain all tools +if (BUILD_Inspector) + OCCT_MODULES_AND_TOOLKITS (TOOLS "TOOL_TOOLKITS" OCCT_TOOLS) + foreach (OCCT_TOOL ${OCCT_TOOLS}) + list (APPEND BUILD_TOOL_TOOLKITS ${${OCCT_TOOL}_TOOL_TOOLKITS}) + endforeach() + + # collect all the headers to /inc/inspector folder + string(TIMESTAMP CURRENT_TIME "%H:%M:%S") + message (STATUS "\nInfo: \(${CURRENT_TIME}\) Start collecting all OCCT tool header files into ${CMAKE_BINARY_DIR}/inc/inspector ...") + COLLECT_AND_INSTALL_OCCT_HEADER_FILES ("${CMAKE_BINARY_DIR}" "${BUILD_TOOL_TOOLKITS}" "${CMAKE_SOURCE_DIR}/tools" "${INSTALL_DIR_INCLUDE}/inspector") endif() # OCCT samples @@ -896,7 +898,7 @@ OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${S # write current custom.bat/sh (for build directory) OCCT_CONFIGURE ("adm/templates/custom.build.${SCRIPT_EXT}.in" "${SUB_CUSTOM_NAME}") -if (BUILD_MODULE_MfcSamples) +if (BUILD_MODULE_MfcSamples OR BUILD_MODULE_QtSamples) OCCT_INSTALL_FILE_OR_DIR ("adm/templates/sample.bat" "${INSTALL_DIR_SCRIPT}") OCCT_COPY_FILE_OR_DIR ("adm/templates/sample.bat" "${CMAKE_BINARY_DIR}") endif() @@ -924,6 +926,15 @@ foreach(RESOURCE ${RESOURCES}) endif() endforeach() +if (BUILD_MODULE_QtSamples) + FILE_TO_LIST ("adm/SAMPLES_RESOURCES" SAMPLES_RESOURCES) + foreach(RESOURCE ${SAMPLES_RESOURCES}) + OCCT_INSTALL_FILE_OR_DIR ("samples/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/samples") + #message("Copy Sample resources: samples/${RESOURCE} into ${INSTALL_DIR_RESOURCE}/samples") + endforeach() +endif() + + # patch installed DrawDefault file if BUILD_SHARED_LIBRARY_NAME_POSTFIX is changed if (NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "") OCCT_UPDATE_DRAW_DEFAULT_FILE() @@ -968,9 +979,11 @@ endif() message (STATUS "Info: \(${CURRENT_TIME}\) OCCT toolkits processed") # samples do not support patch usage -if (BUILD_MODULE_MfcSamples) +if (BUILD_MODULE_MfcSamples OR BUILD_MODULE_QtSamples) set (OCCT_ROOT ${CMAKE_SOURCE_DIR}) +endif() +if (BUILD_MODULE_MfcSamples) set (MFC_STANDARD_SAMPLES_DIR ${OCCT_ROOT}/samples/mfc/standard) set (COMMON_WINMAIN_FILE ${MFC_STANDARD_SAMPLES_DIR}/Common/Winmain.cpp) @@ -989,6 +1002,33 @@ if (BUILD_MODULE_MfcSamples) message (STATUS "Info: \(${CURRENT_TIME}\) MFC Sample projects added") endif() +OCCT_MODULES_AND_TOOLKITS (SAMPLES "SAMPLES_TOOLKITS" OCCT_SAMPLES) + +if (BUILD_MODULE_QtSamples) + if (NOT Qt5_FOUND OR NOT USE_GLES2) + list (REMOVE_ITEM qt_SAMPLES_TOOLKITS AndroidQt) + message (STATUS "Info: AndroidQt sample excluded due to Qt5 or GLES2 usage are disabled") + endif() + + if (NOT BUILD_Inspector) + list (REMOVE_ITEM tools_SAMPLES_TOOLKITS TInspectorEXE) + message (STATUS "Info: TInspectorEXE sample excluded due to BUILD_Inspector is disabled") + endif() + + foreach (OCCT_SAMPLE ${OCCT_SAMPLES}) + list (APPEND BUILD_SAMPLE_TOOLKITS ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS}) + + # collect all the headers to /inc/samples folder + string(TIMESTAMP CURRENT_TIME "%H:%M:%S") + message (STATUS "Info: \(${CURRENT_TIME}\) ${OCCT_SAMPLE} Sample projects added") + + # include patched toolkit projects or original ones + foreach (BUILD_SAMPLE_TOOLKIT ${${OCCT_SAMPLE}_SAMPLES_TOOLKITS}) + OCCT_ADD_SUBDIRECTORY ("samples/${OCCT_SAMPLE}/${BUILD_SAMPLE_TOOLKIT}") + endforeach() + endforeach() +endif() + if (BUILD_MODULE_UwpSample) add_subdirectory(samples/xaml) endif() @@ -1003,11 +1043,6 @@ if (BUILD_TOOL_TOOLKITS) PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_WRITE WORLD_EXECUTE) endif() - set (BUILD_SAMPLE_TOOLKITS TInspectorEXE) - foreach (BUILD_SAMPLE_TOOL_TOOLKIT ${BUILD_SAMPLE_TOOLKITS}) - OCCT_ADD_SUBDIRECTORY ("samples/tools/${BUILD_SAMPLE_TOOL_TOOLKIT}") - endforeach() - # patch TInspectorEXE OCCT_CONFIGURE ("adm/templates/TInspectorEXE.vcxproj.user.in" "${CMAKE_BINARY_DIR}/samples/tools/TInspectorEXE/TInspectorEXE.vcxproj.user") endif() diff --git a/adm/SAMPLES b/adm/SAMPLES new file mode 100644 index 0000000000..d9f7257e5c --- /dev/null +++ b/adm/SAMPLES @@ -0,0 +1,2 @@ +qt AndroidQt FuncDemo IESample Tutorial +tools TInspectorEXE \ No newline at end of file diff --git a/adm/SAMPLES_RESOURCES b/adm/SAMPLES_RESOURCES new file mode 100644 index 0000000000..a353f3f6e6 --- /dev/null +++ b/adm/SAMPLES_RESOURCES @@ -0,0 +1,2 @@ +qt/Common/res/ +qt/Tutorial/res/ \ No newline at end of file diff --git a/adm/cmake/occt_macros.cmake b/adm/cmake/occt_macros.cmake index faea1709d0..1ba4f798bc 100644 --- a/adm/cmake/occt_macros.cmake +++ b/adm/cmake/occt_macros.cmake @@ -502,11 +502,11 @@ function (OCCT_TOOLKIT_FULL_DEP TOOLKIT_NAME TOOLKIT_FULL_DEPS) set (${TOOLKIT_FULL_DEPS} ${LOCAL_TOOLKIT_FULL_DEPS} PARENT_SCOPE) endfunction() -# Function to get list of modules and toolkits from file adm/MODULES. +# Function to get list of modules/toolkits/samples from file adm/${FILE_NAME}. # Creates list <$MODULE_LIST> to store list of MODULES and -# _TOOLKITS foreach module to store its toolkits. -function (OCCT_MODULES_AND_TOOLKITS MODULE_LIST) - FILE_TO_LIST ("adm/MODULES" FILE_CONTENT) +# _TOOLKITS foreach module to store its toolkits, where "TOOLKITS" is defined by TOOLKITS_NAME_SUFFIX. +function (OCCT_MODULES_AND_TOOLKITS FILE_NAME TOOLKITS_NAME_SUFFIX MODULE_LIST) + FILE_TO_LIST ("adm/${FILE_NAME}" FILE_CONTENT) foreach (CONTENT_LINE ${FILE_CONTENT}) string (REPLACE " " ";" CONTENT_LINE ${CONTENT_LINE}) @@ -514,30 +514,12 @@ function (OCCT_MODULES_AND_TOOLKITS MODULE_LIST) list (REMOVE_AT CONTENT_LINE 0) list (APPEND ${MODULE_LIST} ${MODULE_NAME}) # (!) REMOVE THE LINE BELOW (implicit variables) - set (${MODULE_NAME}_TOOLKITS ${CONTENT_LINE} PARENT_SCOPE) + set (${MODULE_NAME}_${TOOLKITS_NAME_SUFFIX} ${CONTENT_LINE} PARENT_SCOPE) endforeach() set (${MODULE_LIST} ${${MODULE_LIST}} PARENT_SCOPE) endfunction() -# Function to get list of tools and toolkits from file adm/TOOLS. -# Creates list <$TOOL_LIST> to store list of TOOLS and -# _TOOLKITS foreach tool to store its toolkits. -function (OCCT_TOOLS_AND_TOOLKITS TOOL_LIST) - FILE_TO_LIST ("adm/TOOLS" FILE_CONTENT) - - foreach (CONTENT_LINE ${FILE_CONTENT}) - string (REPLACE " " ";" CONTENT_LINE ${CONTENT_LINE}) - list (GET CONTENT_LINE 0 TOOL_NAME) - list (REMOVE_AT CONTENT_LINE 0) - list (APPEND ${TOOL_LIST} ${TOOL_NAME}) - # (!) REMOVE THE LINE BELOW (implicit variables) - set (${TOOL_NAME}_TOOL_TOOLKITS ${CONTENT_LINE} PARENT_SCOPE) - endforeach() - - set (${TOOL_LIST} ${${TOOL_LIST}} PARENT_SCOPE) -endfunction() - # Returns OCC version string from file Standard_Version.hxx (if available) function (OCC_VERSION OCC_VERSION_MAJOR OCC_VERSION_MINOR OCC_VERSION_MAINTENANCE OCC_VERSION_DEVELOPMENT OCC_VERSION_STRING_EXT) diff --git a/adm/cmake/occt_toolkit.cmake b/adm/cmake/occt_toolkit.cmake index 45107551c7..689ed40a21 100644 --- a/adm/cmake/occt_toolkit.cmake +++ b/adm/cmake/occt_toolkit.cmake @@ -1,12 +1,40 @@ # script for each OCCT toolkit -# parce PACKAGES file -if ("${PROJECT_NAME}" STREQUAL DRAWEXE) - set (USED_PACKAGES DRAWEXE) -else() - FILE_TO_LIST ("src/${PROJECT_NAME}/PACKAGES" USED_PACKAGES) +# filling some variables by default values(src) or using custom(tools, samples) +set (RELATIVE_SOURCES_DIR "${RELATIVE_DIR}") +if ("${RELATIVE_SOURCES_DIR}" STREQUAL "") + #if it is not defined, use default directory + set (RELATIVE_SOURCES_DIR "src") endif() +set (OCC_MODULES_LIST "${MODULES_LIST}") +if ("${OCC_MODULES_LIST}" STREQUAL "") + set (OCC_MODULES_LIST ${OCCT_MODULES}) +endif() + +set (OCC_TARGET_FOLDER "${TARGET_FOLDER}") +if ("${OCC_TARGET_FOLDER}" STREQUAL "") + set (OCC_TARGET_FOLDER "Modules") +endif() + +set (OCCT_TOOLKITS_NAME_SUFFIX "${TOOLKITS_NAME_SUFFIX}") +if ("${OCCT_TOOLKITS_NAME_SUFFIX}" STREQUAL "") + set (OCCT_TOOLKITS_NAME_SUFFIX "TOOLKITS") +endif() + +# parce PACKAGES file +FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/PACKAGES" USED_PACKAGES) +if ("${USED_PACKAGES}" STREQUAL "") + set (USED_PACKAGES ${PROJECT_NAME}) +endif() + +if (USE_QT) + # Qt dependencies + OCCT_INCLUDE_CMAKE_FILE (adm/cmake/qt_macro) + FIND_QT_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES) + include_directories("${PROJECT_INCLUDES}") +endif(USE_QT) + set (PRECOMPILED_DEFS) if (NOT BUILD_SHARED_LIBS) @@ -17,16 +45,26 @@ if (NOT BUILD_SHARED_LIBS) endif() # Get all used packages from toolkit +UNSET(RESOURCE_FILES) foreach (OCCT_PACKAGE ${USED_PACKAGES}) - + + #remove part after "/" in the OCCT_PACKAGE variable if exists + string (FIND "${OCCT_PACKAGE}" "/" _index) + if (_index GREATER -1) + math (EXPR _index "${_index}") + string (SUBSTRING "${OCCT_PACKAGE}" 0 ${_index} OCCT_PACKAGE_NAME) + else() + set (OCCT_PACKAGE_NAME "${OCCT_PACKAGE}") + endif() + # TKService contains platform-dependent packages: Xw and WNT if ((WIN32 AND "${OCCT_PACKAGE}" STREQUAL "Xw") OR (NOT WIN32 AND "${OCCT_PACKAGE}" STREQUAL "WNT")) # do nothing else() -# if (WIN32) -# list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE}_DLL") -# endif() + if (WIN32) + list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE_NAME}_DLL") + endif() set (SOURCE_FILES) set (HEADER_FILES) @@ -35,11 +73,11 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES}) if (${BUILD_YACCLEX}) # flex files - OCCT_ORIGIN_AND_PATCHED_FILES ("src/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX) + OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX) list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN) # bison files - OCCT_ORIGIN_AND_PATCHED_FILES ("src/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON) + OCCT_ORIGIN_AND_PATCHED_FILES ("${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON) list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN) if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0) @@ -61,8 +99,8 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES}) if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL}) set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c) set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c) - BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}") - FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}") + BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}") + FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}") ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME}) list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE}) @@ -72,23 +110,23 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES}) endif() # header files - if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES") - file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h") - file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx") - file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx") + if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES") + file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h") + file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx") + file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx") - file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c") + file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c") if(APPLE) - file (STRINGS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm") + file (STRINGS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm") endif() else() - file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h") - file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx") - file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx") + file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h") + file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx") + file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx") - file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c") + file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c") if(APPLE) - file (STRINGS "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm") + file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm") endif() endif() @@ -99,26 +137,36 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES}) endif() foreach(HEADER_FILE ${HEADER_FILES}) - if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${HEADER_FILE}") - message (STATUS "Info: consider patched file: ${BUILD_PATCH}/src/${OCCT_PACKAGE}/${HEADER_FILE}") - list (APPEND USED_INCFILES "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${HEADER_FILE}") - SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${HEADER_FILE}") + if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}") + message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}") + list (APPEND USED_INCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}") + SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}") else() - list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}") - SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${HEADER_FILE}") + list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}") + SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}") endif() endforeach() foreach(SOURCE_FILE ${SOURCE_FILES}) - if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${SOURCE_FILE}") - message (STATUS "Info: consider patched file: ${BUILD_PATCH}/src/${OCCT_PACKAGE}/${SOURCE_FILE}") - list (APPEND USED_SRCFILES "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${SOURCE_FILE}") - SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/src/${OCCT_PACKAGE}/${SOURCE_FILE}") + if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}") + message (STATUS "Info: consider patched file: ${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}") + list (APPEND USED_SRCFILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}") + SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${BUILD_PATCH}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}") else() - list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}") - SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/src/${OCCT_PACKAGE}/${SOURCE_FILE}") + list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}") + SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE_NAME}" FILES "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}") endif() endforeach() + + if (USE_QT) + FIND_AND_INSTALL_QT_RESOURCES (${OCCT_PACKAGE} RESOURCE_FILES) + #message("Qt Resource files are: ${QT_RESOURCE_FILES} in ${OCCT_PACKAGE}") + endif(USE_QT) + + #message("Resource files are: ${RESOURCE_FILES} in ${OCCT_PACKAGE}") + foreach(RESOURCE_FILE ${RESOURCE_FILES}) + SOURCE_GROUP ("Resource Files\\${OCCT_PACKAGE_NAME}" FILES "${RESOURCE_FILE}") + endforeach() endif() endforeach() string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}") @@ -135,8 +183,9 @@ if (MSVC) endif() set (CURRENT_MODULE) -foreach (OCCT_MODULE ${OCCT_MODULES}) - list (FIND ${OCCT_MODULE}_TOOLKITS ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT) +foreach (OCCT_MODULE ${OCC_MODULES_LIST}) + list (FIND ${OCCT_MODULE}_${OCCT_TOOLKITS_NAME_SUFFIX} ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT) + if (NOT ${CURRENT_PROJECT_IS_BUILT} EQUAL -1) set (CURRENT_MODULE ${OCCT_MODULE}) endif() @@ -146,13 +195,18 @@ if (WIN32) OCCT_INSERT_CODE_FOR_TARGET () endif() -if ("${PROJECT_NAME}" STREQUAL "DRAWEXE") - add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE}) +if (USE_QT) + FIND_AND_WRAP_MOC_FILES("${USED_INCFILES}" "${PROJECT_NAME}_MOC_FILES") + #message("MOC files: ${${PROJECT_NAME}_MOC_FILES}") +endif (USE_QT) + +if (EXECUTABLE_PROJECT) + add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES}) install (TARGETS ${PROJECT_NAME} DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}") else() - add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE}) + add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RESOURCE_FILES} ${${PROJECT_NAME}_MOC_FILES}) if (MSVC) install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb @@ -181,7 +235,7 @@ else() endif() if (CURRENT_MODULE) - set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "Modules/${CURRENT_MODULE}") + set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "${OCC_TARGET_FOLDER}/${CURRENT_MODULE}") set_target_properties (${PROJECT_NAME} PROPERTIES MODULE "${CURRENT_MODULE}") if (APPLE) if (NOT "${INSTALL_NAME_DIR}" STREQUAL "") @@ -207,7 +261,7 @@ set (USED_TOOLKITS_BY_CURRENT_PROJECT) set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT) # parce EXTERNLIB file -FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS) +FILE_TO_LIST ("${RELATIVE_SOURCES_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS) foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM}) if (NOT COMMENT_FOUND) @@ -303,6 +357,15 @@ if (BUILD_SHARED_LIBS) target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT}) endif() +if (USE_QT) + foreach (PROJECT_LIBRARY_DEBUG ${PROJECT_LIBRARIES_DEBUG}) + target_link_libraries (${PROJECT_NAME} debug ${PROJECT_LIBRARY_DEBUG}) + endforeach() + foreach (PROJECT_LIBRARY_RELEASE ${PROJECT_LIBRARIES_RELEASE}) + target_link_libraries (${PROJECT_NAME} optimized ${PROJECT_LIBRARY_RELEASE}) + endforeach() +endif() + # suppress deprecation warnings inside OCCT itself for old gcc versions with unavailable Standard_DISABLE_DEPRECATION_WARNINGS if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6.0) diff --git a/adm/cmake/occt_toolkit_prepare_sample.cmake b/adm/cmake/occt_toolkit_prepare_sample.cmake new file mode 100644 index 0000000000..ecc5ba0683 --- /dev/null +++ b/adm/cmake/occt_toolkit_prepare_sample.cmake @@ -0,0 +1,18 @@ +if ("${TARGET_FOLDER}" STREQUAL "") + set (EXECUTABLE_PROJECT ON) + set (USE_QT ON) + + set (RELATIVE_DIR "samples/qt") + set (MODULES_LIST ${OCCT_SAMPLES}) + set (TARGET_FOLDER "Samples") + set (TOOLKITS_NAME_SUFFIX "SAMPLES_TOOLKITS") + + include_directories("${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/${RELATIVE_DIR}") +else() + unset (USE_QT) + unset (RELATIVE_DIR) + unset (EXECUTABLE_PROJECT) + unset (MODULES_LIST) + unset (TARGET_FOLDER) + unset (TOOLKITS_NAME_SUFFIX) +endif("${TARGET_FOLDER}" STREQUAL "") diff --git a/adm/cmake/occt_toolkit_prepare_tool.cmake b/adm/cmake/occt_toolkit_prepare_tool.cmake new file mode 100644 index 0000000000..eed173ae63 --- /dev/null +++ b/adm/cmake/occt_toolkit_prepare_tool.cmake @@ -0,0 +1,13 @@ +if ("${TARGET_FOLDER}" STREQUAL "") + set (USE_QT ON) + set (RELATIVE_DIR "tools") + set (MODULES_LIST ${OCCT_TOOLS}) + set (TARGET_FOLDER "Tools") + set (TOOLKITS_NAME_SUFFIX "TOOL_TOOLKITS") +else() + unset (USE_QT) + unset (RELATIVE_DIR) + unset (MODULES_LIST) + unset (TARGET_FOLDER) + unset (TOOLKITS_NAME_SUFFIX) +endif("${TARGET_FOLDER}" STREQUAL "") diff --git a/adm/cmake/occt_toolkit_tool.cmake b/adm/cmake/occt_toolkit_tool.cmake deleted file mode 100644 index d934de6d54..0000000000 --- a/adm/cmake/occt_toolkit_tool.cmake +++ /dev/null @@ -1,302 +0,0 @@ -# script for each OCCT tool toolkit - -# Qt dependencies -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/qt_macro) - -FIND_QT_PACKAGE(PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT_INCLUDES) -include_directories("${PROJECT_INCLUDES}" - "${CMAKE_BINARY_DIR}/${INSTALL_DIR_INCLUDE}/tools") - -FILE_TO_LIST ("tools/${PROJECT_NAME}/PACKAGES" USED_PACKAGES) -# parce PACKAGES file - -if ("${PROJECT_NAME}" STREQUAL TInspectorEXE) - set (USED_PACKAGES ${PROJECT_NAME}) - set (PACKAGE_PREFIX_DIR "samples/tools") - include_directories("${PROJECT_INCLUDES}" - "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${PROJECT_NAME}") -else() - FILE_TO_LIST ("tools/${PROJECT_NAME}/PACKAGES" USED_PACKAGES) - set (PACKAGE_PREFIX_DIR "tools") -endif() - - -SET (RCC_FILES) -foreach (OCCT_PACKAGE ${USED_PACKAGES}) - #message("Dir is ${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${OCCT_PACKAGE}.qrc") - FIND_AND_WRAP_RESOURCE_FILE("${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${OCCT_PACKAGE}.qrc" RCC_FILES) -endforeach() -#message("RCC_FILES for ${PROJECT_NAME} are ${RCC_FILES}") - -set (PRECOMPILED_DEFS) - -if (NOT BUILD_SHARED_LIBS) - list (APPEND PRECOMPILED_DEFS "-DOCCT_NO_PLUGINS") - if (WIN32) - list (APPEND PRECOMPILED_DEFS "-DOCCT_STATIC_BUILD") - endif() -endif() - -# Get all used packages from toolkit -foreach (OCCT_PACKAGE ${USED_PACKAGES}) - - ADD_DEFINITIONS(-D${OCCT_PACKAGE}_EXPORTS) - - # TKService contains platform-dependent packages: Xw and WNT - if ((WIN32 AND "${OCCT_PACKAGE}" STREQUAL "Xw") OR (NOT WIN32 AND "${OCCT_PACKAGE}" STREQUAL "WNT")) - # do nothing - else() - -# if (WIN32) -# list (APPEND PRECOMPILED_DEFS "-D__${OCCT_PACKAGE}_DLL") -# endif() - - set (SOURCE_FILES) - set (HEADER_FILES) - - # Generate Flex and Bison files - if (${BUILD_YACCLEX}) - - # flex files - OCCT_ORIGIN_AND_PATCHED_FILES ("tools/${OCCT_PACKAGE}" "*[.]lex" SOURCE_FILES_FLEX) - list (LENGTH SOURCE_FILES_FLEX SOURCE_FILES_FLEX_LEN) - - # bison files - OCCT_ORIGIN_AND_PATCHED_FILES ("tools/${OCCT_PACKAGE}" "*[.]yacc" SOURCE_FILES_BISON) - list (LENGTH SOURCE_FILES_BISON SOURCE_FILES_BISON_LEN) - - if (${SOURCE_FILES_FLEX_LEN} EQUAL ${SOURCE_FILES_BISON_LEN} AND NOT ${SOURCE_FILES_FLEX_LEN} EQUAL 0) - - list (SORT SOURCE_FILES_FLEX) - list (SORT SOURCE_FILES_BISON) - - math (EXPR SOURCE_FILES_FLEX_LEN "${SOURCE_FILES_FLEX_LEN} - 1") - foreach (FLEX_FILE_INDEX RANGE ${SOURCE_FILES_FLEX_LEN}) - - list (GET SOURCE_FILES_FLEX ${FLEX_FILE_INDEX} CURRENT_FLEX_FILE) - get_filename_component (CURRENT_FLEX_FILE_NAME ${CURRENT_FLEX_FILE} NAME_WE) - - list (GET SOURCE_FILES_BISON ${FLEX_FILE_INDEX} CURRENT_BISON_FILE) - get_filename_component (CURRENT_BISON_FILE_NAME ${CURRENT_BISON_FILE} NAME_WE) - - string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL) - - if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL}) - set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c) - set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c) - BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/tools/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME}") - FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/tools/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME}") - ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME}) - - list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE}) - endif() - endforeach() - endif() - endif() - - # header files - if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES") - file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h") - file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx") - file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx") - - file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c") - if(APPLE) - file (STRINGS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm") - endif() - else() - file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_M REGEX ".+[.]h") - file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_LXX REGEX ".+[.]lxx") - file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" HEADER_FILES_GXX REGEX ".+[.]gxx") - - file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_C REGEX ".+[.]c") - if(APPLE) - file (STRINGS "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/FILES" SOURCE_FILES_M REGEX ".+[.]mm") - endif() - endif() - - - - list (APPEND HEADER_FILES ${HEADER_FILES_M} ${HEADER_FILES_LXX} ${SOURCE_FILES_GXX}) - list (APPEND SOURCE_FILES ${SOURCE_FILES_C}) - if(APPLE) - list (APPEND SOURCE_FILES ${SOURCE_FILES_M}) - endif() - - foreach(HEADER_FILE ${HEADER_FILES}) - if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}") - message (STATUS "Info: consider patched file: ${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}") - list (APPEND USED_INCFILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}") - SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${HEADER_FILE}") - else() - list (APPEND USED_INCFILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}") - SOURCE_GROUP ("Header Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${HEADER_FILE}") - endif() - endforeach() - - - foreach(SOURCE_FILE ${SOURCE_FILES}) - if (BUILD_PATCH AND EXISTS "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}") - message (STATUS "Info: consider patched file: ${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}") - list (APPEND USED_SRCFILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}") - SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${BUILD_PATCH}/tools/${OCCT_PACKAGE}/${SOURCE_FILE}") - else() - list (APPEND USED_SRCFILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}") - SOURCE_GROUP ("Source Files\\${OCCT_PACKAGE}" FILES "${CMAKE_SOURCE_DIR}/${PACKAGE_PREFIX_DIR}/${OCCT_PACKAGE}/${SOURCE_FILE}") - endif() - endforeach() - endif() -endforeach() -string (REGEX REPLACE ";" " " PRECOMPILED_DEFS "${PRECOMPILED_DEFS}") - -set (USED_RCFILE "") -if (MSVC) - set (USED_RCFILE "${CMAKE_BINARY_DIR}/resources/${PROJECT_NAME}.rc") - - if (APPLY_OCCT_PATCH_DIR AND EXISTS "${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in") - configure_file("${APPLY_OCCT_PATCH_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY) - else() - configure_file("${CMAKE_SOURCE_DIR}/adm/templates/occt_toolkit.rc.in" "${USED_RCFILE}" @ONLY) - endif() -endif() - -set (CURRENT_MODULE) -foreach (OCCT_MODULE ${OCCT_TOOLS}) - list (FIND ${OCCT_MODULE}_TOOL_TOOLKITS ${PROJECT_NAME} CURRENT_PROJECT_IS_BUILT) - if (NOT ${CURRENT_PROJECT_IS_BUILT} EQUAL -1) - set (CURRENT_MODULE ${OCCT_MODULE}) - endif() -endforeach() - -if (WIN32) - OCCT_INSERT_CODE_FOR_TARGET () -endif() - -FIND_AND_WRAP_MOC_FILES("${USED_INCFILES}" "${PROJECT_NAME}_MOC_FILES") -#message("MOC files: ${${PROJECT_NAME}_MOC_FILES}") - -if ("${PROJECT_NAME}" STREQUAL TInspectorEXE) - add_executable (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RCC_FILES} ${${PROJECT_NAME}_MOC_FILES}) - - install (TARGETS ${PROJECT_NAME} - DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}") -else() - add_library (${PROJECT_NAME} ${USED_SRCFILES} ${USED_INCFILES} ${USED_RCFILE} ${RCC_FILES} ${${PROJECT_NAME}_MOC_FILES}) - - if (MSVC) - install (FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.pdb - CONFIGURATIONS Debug RelWithDebInfo - DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}") - endif() - - if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "") - set (CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT ${CMAKE_SHARED_LIBRARY_SUFFIX}) - set (CMAKE_SHARED_LIBRARY_SUFFIX "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}") - endif() - - install (TARGETS ${PROJECT_NAME} - EXPORT OpenCASCADE${CURRENT_MODULE}Targets - RUNTIME DESTINATION "${INSTALL_DIR_BIN}\${OCCT_INSTALL_BIN_LETTER}" - ARCHIVE DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}" - LIBRARY DESTINATION "${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}") - - - if (NOT WIN32) - if (BUILD_SHARED_LIBS AND NOT "${BUILD_SHARED_LIBRARY_NAME_POSTFIX}" STREQUAL "") - set (LINK_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX_DEFAULT}/tools") - set (LIBRARY_NAME "${INSTALL_DIR}/${INSTALL_DIR_LIB}\${OCCT_INSTALL_BIN_LETTER}/lib${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}/tools") - OCCT_CREATE_SYMLINK_TO_FILE (${LIBRARY_NAME} ${LINK_NAME}) - endif() - endif() -endif() - -if (CURRENT_MODULE) - set_target_properties (${PROJECT_NAME} PROPERTIES FOLDER "Tools/${CURRENT_MODULE}") - set_target_properties (${PROJECT_NAME} PROPERTIES MODULE "${CURRENT_MODULE}") - if (APPLE) - if (NOT "${INSTALL_NAME_DIR}" STREQUAL "") - set_target_properties (${PROJECT_NAME} PROPERTIES BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "${INSTALL_NAME_DIR}") - endif() - endif() -endif() - -get_property (OCC_VERSION_MAJOR GLOBAL PROPERTY OCC_VERSION_MAJOR) -get_property (OCC_VERSION_MINOR GLOBAL PROPERTY OCC_VERSION_MINOR) -get_property (OCC_VERSION_MAINTENANCE GLOBAL PROPERTY OCC_VERSION_MAINTENANCE) - -if (ANDROID) - # do not append version to the filename - set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}") -else() - set_target_properties (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${PRECOMPILED_DEFS}" - SOVERSION "${OCC_VERSION_MAJOR}" - VERSION "${OCC_VERSION_MAJOR}.${OCC_VERSION_MINOR}.${OCC_VERSION_MAINTENANCE}") -endif() - -set (USED_TOOLKITS_BY_CURRENT_PROJECT) -set (USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT) - -# parce EXTERNLIB file -FILE_TO_LIST ("${PACKAGE_PREFIX_DIR}/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS) -foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS}) - string (REGEX MATCH "^ *#" COMMENT_FOUND ${USED_ITEM}) - if (NOT COMMENT_FOUND) - string (REGEX MATCH "^TK" TK_FOUND ${USED_ITEM}) - string (REGEX MATCH "^vtk" VTK_FOUND ${USED_ITEM}) - - if (NOT "${TK_FOUND}" STREQUAL "" OR NOT "${VTK_FOUND}" STREQUAL "") - list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM}) - if (NOT "${VTK_FOUND}" STREQUAL "" AND BUILD_SHARED_LIBS AND INSTALL_VTK AND COMMAND OCCT_INSTALL_VTK) - OCCT_INSTALL_VTK(${USED_ITEM}) - endif() - else() - string (REGEX MATCH "^CSF_" CSF_FOUND ${USED_ITEM}) - if ("${CSF_FOUND}" STREQUAL "") - message (STATUS "Info: ${USED_ITEM} from ${PROJECT_NAME} skipped due to it is empty") - else() # get CSF_ value - set (CURRENT_CSF ${${USED_ITEM}}) - if (NOT "x${CURRENT_CSF}" STREQUAL "x") - # prepare a list from a string with whitespaces - separate_arguments (CURRENT_CSF) - list (APPEND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT ${CURRENT_CSF}) - endif() - endif() - endif() - endif() -endforeach() - -if (APPLE) - list (FIND USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT X11 IS_X11_FOUND) - if (NOT ${IS_X11_FOUND} EQUAL -1) - find_package (X11 COMPONENTS X11 Xext Xmu Xi) - if (NOT X11_FOUND) - message (STATUS "Warning: X11 is not found. It's required to install The XQuartz project: http://www.xquartz.org") - endif() - endif() -endif() - -# Update list of used VTK libraries if OpenGL2 Rendering BackEnd is used. -# Add VTK_OPENGL2_BACKEND definition. -if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2") - add_definitions(-DVTK_OPENGL2_BACKEND) - foreach (VTK_EXCLUDE_LIBRARY vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL) - list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "${VTK_EXCLUDE_LIBRARY}" IS_VTK_OPENGL_FOUND) - if (NOT ${IS_VTK_OPENGL_FOUND} EQUAL -1) - list (REMOVE_ITEM USED_TOOLKITS_BY_CURRENT_PROJECT ${VTK_EXCLUDE_LIBRARY}) - if (${VTK_EXCLUDE_LIBRARY} STREQUAL vtkRenderingOpenGL) - list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT vtkRenderingOpenGL2) - endif() - endif() - endforeach() -endif() - -if (BUILD_SHARED_LIBS) - target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT}) -endif() - -# Set Qt dependencies -target_link_libraries(${PROJECT_NAME} "${PROJECT_LIBRARIES}") - -target_link_libraries(${PROJECT_NAME} debug "${PROJECT_LIBRARIES_DEBUG}") -target_link_libraries(${PROJECT_NAME} optimized "${PROJECT_LIBRARIES_RELEASE}") - diff --git a/adm/cmake/qt_macro.cmake b/adm/cmake/qt_macro.cmake index 5cdbe9cf26..c535772c2e 100644 --- a/adm/cmake/qt_macro.cmake +++ b/adm/cmake/qt_macro.cmake @@ -12,13 +12,21 @@ macro (FIND_QT_PACKAGE PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT # Now we can apply standard CMake finder for Qt5. We do this mostly # to have qt5_wrap_cpp() function available - find_package(Qt5 QUIET COMPONENTS Widgets PATHS ${3RDPARTY_QT_DIR} NO_DEFAULT_PATH) + find_package(Qt5 QUIET COMPONENTS Widgets Quick PATHS ${3RDPARTY_QT_DIR} NO_DEFAULT_PATH) if (${Qt5_FOUND}) #message (STATUS "Qt5 cmake configuration") - set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}") - set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}") - set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}") + set(PROJECT_INCLUDES "${Qt5Widgets_INCLUDE_DIRS}" "${Qt5Quick_INCLUDE_DIRS}") + set(PROJECT_LIBRARIES_DEBUG "${Qt5Widgets_LIBRARIES}" "${Qt5Quick_LIBRARIES}") + set(PROJECT_LIBRARIES_RELEASE "${Qt5Widgets_LIBRARIES}" "${Qt5Quick_LIBRARIES}") + + # processing *.ts files to generate *.qm + find_package(Qt5LinguistTools) + get_target_property(QT_LRELEASE_EXECUTABLE Qt5::lrelease LOCATION) + mark_as_advanced(QT_LRELEASE_EXECUTABLE) + + GET_FILENAME_COMPONENT(QT_BINARY_DIR ${QT_LRELEASE_EXECUTABLE} DIRECTORY) + MARK_AS_ADVANCED(QT_BINARY_DIR) else() # Now we can apply standard CMake finder for Qt. We do this mostly # to have qt4_wrap_cpp() function available @@ -33,6 +41,7 @@ macro (FIND_QT_PACKAGE PROJECT_LIBRARIES_DEBUG PROJECT_LIBRARIES_RELEASE PROJECT set(PROJECT_LIBRARIES_DEBUG "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so") set(PROJECT_LIBRARIES_RELEASE "${3RDPARTY_QT_DIR}/lib/libQtCore.so;${3RDPARTY_QT_DIR}/lib/libQtGui.so") endif(WIN32) + find_program(QT_LRELEASE_EXECUTABLE lrelease) endif() endmacro() @@ -69,3 +78,57 @@ macro (FIND_AND_WRAP_RESOURCE_FILE RESOURCE_FILE_NAME RCC_FILES) endif() endif() endmacro() + +macro (FIND_AND_INSTALL_TS_FILE RESOURCE_FILE_NAME TARGET_FOLDER QM_FILES) + if(EXISTS "${RESOURCE_FILE_NAME}") + GET_FILENAME_COMPONENT(_name ${RESOURCE_FILE_NAME} NAME_WE) + SET(_output ${CMAKE_CURRENT_BINARY_DIR}/${_name}.qm) + SET(_cmd_${_name} ${QT_LRELEASE_EXECUTABLE} ${RESOURCE_FILE_NAME} -qm ${_output}) + + set(TARGET_NAME ${_name}_resources) + + if (NOT TARGET "${TARGET_NAME}") + add_custom_target(${TARGET_NAME} ALL COMMAND ${_cmd_${_name}} DEPENDS ${RESOURCE_FILE_NAME}) + set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "${TARGET_FOLDER}") + + list (APPEND ${QM_FILES} "${_output}") + endif() + endif() +endmacro() + +macro (FIND_AND_INSTALL_QT_RESOURCES OCCT_PACKAGE RESOURCE_FILES) + file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" TS_FILES REGEX ".+[.]ts") + file (STRINGS "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/FILES" QRC_FILES REGEX ".+[.]qrc") + + string (FIND "${OCCT_PACKAGE}" "/" _index) + if (_index GREATER -1) + math (EXPR _index "${_index}") + string (SUBSTRING "${OCCT_PACKAGE}" 0 ${_index} OCCT_PACKAGE_NAME) + else() + set (OCCT_PACKAGE_NAME "${OCCT_PACKAGE}") + endif(_index GREATER -1) + + #message("QRC files are: ${QRC_FILES} in ${OCCT_PACKAGE}") + foreach (QRC_FILE ${QRC_FILES}) + set (QRC_FILE_RELATIVE "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${QRC_FILE}") + if (EXISTS ${QRC_FILE_RELATIVE}) + FIND_AND_WRAP_RESOURCE_FILE(${QRC_FILE_RELATIVE} RCC_FILES) + list (APPEND ${RESOURCE_FILES} "${RCC_FILES}") + endif() + endforeach() + + #message("TS files are: ${TS_FILES} in ${OCCT_PACKAGE}") + foreach (TS_FILE ${TS_FILES}) + set (TS_FILE_RELATIVE "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${TS_FILE}") + FIND_AND_INSTALL_TS_FILE(${TS_FILE_RELATIVE} "${TARGET_FOLDER}/${CURRENT_MODULE}" QM_FILES) + if (EXISTS ${TS_FILE_RELATIVE}) + list (APPEND ${RESOURCE_FILES} "${TS_FILE_RELATIVE}") + endif() + endforeach() + + foreach (QM_FILE ${QM_FILES}) + INSTALL(FILES ${QM_FILE} DESTINATION "${INSTALL_DIR_RESOURCE}/samples") + #message("install *.qm files (${QM_FILE}) to: ${INSTALL_DIR_RESOURCE}/samples") + endforeach (QM_FILE ${QM_FILES}) +endmacro() + diff --git a/adm/cmake/vardescr.cmake b/adm/cmake/vardescr.cmake index c2327622a5..f5c7d2b375 100644 --- a/adm/cmake/vardescr.cmake +++ b/adm/cmake/vardescr.cmake @@ -122,6 +122,11 @@ set (BUILD_MODULE_MfcSamples_DESCR These samples show some possibilities of using OCCT and they can be executed with script samples.bat from the installation directory (INSTALL_DIR)") +set (BUILD_MODULE_QtSamples_DESCR +"Indicates whether OCCT Qt samples should be built together with OCCT. +These samples show some possibilities of using OCCT and they can be executed +with script samples.bat from the installation directory (INSTALL_DIR)") + set (BUILD_Inspector_DESCR "Indicates whether OCCT inspector should be built together with OCCT. This inspector provides functionality to interactively inspect low-level content diff --git a/adm/templates/sample.bat b/adm/templates/sample.bat index 89b0fdbb9d..023346648d 100644 --- a/adm/templates/sample.bat +++ b/adm/templates/sample.bat @@ -16,6 +16,10 @@ if ["%1"] == [""] ( echo HLR echo Animation echo Convert + echo AndroidQt + echo FuncDemo + echo IESample + echo Tutorial PAUSE exit /B ) diff --git a/samples/qt/AndroidQt/AndroidQt.pro b/samples/qt/AndroidQt/AndroidQt.pro index 7ddc34b91d..0b1527fc51 100644 --- a/samples/qt/AndroidQt/AndroidQt.pro +++ b/samples/qt/AndroidQt/AndroidQt.pro @@ -2,12 +2,12 @@ TEMPLATE = app QT += qml quick widgets -SOURCES += Main.cxx \ - AndroidQt.cxx \ - AndroidQt_Window.cxx \ - AndroidQt_TouchParameters.cxx +SOURCES += src/Main.cxx \ + src/AndroidQt.cxx \ + src/AndroidQt_Window.cxx \ + src/AndroidQt_TouchParameters.cxx -RESOURCES += AndroidQt.qrc +RESOURCES += ./src/AndroidQt.qrc # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = @@ -19,10 +19,13 @@ include(OCCT.pri) include(Deployment.pri) HEADERS += \ - AndroidQt.h \ - AndroidQt_Window.h \ - AndroidQt_TouchParameters.h \ - AndroidQt_UserInteractionParameters.h + src/AndroidQt.h \ + src/AndroidQt_Window.h \ + src/AndroidQt_TouchParameters.h \ + src/AndroidQt_UserInteractionParameters.h + +INCLUDEPATH += $$_PRO_FILE_PWD_/src +DEPENDPATH += $$_PRO_FILE_PWD_/src OTHER_FILES += \ android/src/org/qtproject/example/AndroidQt/AndroidQt.java \ diff --git a/samples/qt/AndroidQt/AndroidQt.qrc b/samples/qt/AndroidQt/AndroidQt.qrc deleted file mode 100644 index bcead84dcb..0000000000 --- a/samples/qt/AndroidQt/AndroidQt.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - res/qml/main.qml - - - res/icons/ic_action_collection.png - - diff --git a/samples/qt/AndroidQt/CMakeLists.txt b/samples/qt/AndroidQt/CMakeLists.txt new file mode 100644 index 0000000000..126582e8e2 --- /dev/null +++ b/samples/qt/AndroidQt/CMakeLists.txt @@ -0,0 +1,9 @@ +project(AndroidQt) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) + +ADD_DEFINITIONS(-DNO_Common_EXPORTS) + + diff --git a/samples/qt/AndroidQt/EXTERNLIB b/samples/qt/AndroidQt/EXTERNLIB new file mode 100644 index 0000000000..fb5edc8d1d --- /dev/null +++ b/samples/qt/AndroidQt/EXTERNLIB @@ -0,0 +1,17 @@ +TKernel +TKMath +TKG2d +TKG3d +TKGeomBase +TKBRep +TKGeomAlgo +TKTopAlgo +TKShHealing +TKService +TKMesh +TKHLR +TKV3d +TKOpenGl +CSF_FreeImagePlus +CSF_FREETYPE +CSF_OpenGlLibs diff --git a/samples/qt/AndroidQt/FILES b/samples/qt/AndroidQt/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/samples/qt/AndroidQt/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/samples/qt/AndroidQt/PACKAGES b/samples/qt/AndroidQt/PACKAGES new file mode 100644 index 0000000000..089247b96e --- /dev/null +++ b/samples/qt/AndroidQt/PACKAGES @@ -0,0 +1 @@ +AndroidQt/src diff --git a/samples/qt/AndroidQt/ReadMe.md b/samples/qt/AndroidQt/ReadMe.md index 080f5cbfb3..d39dafbc42 100644 --- a/samples/qt/AndroidQt/ReadMe.md +++ b/samples/qt/AndroidQt/ReadMe.md @@ -13,8 +13,17 @@ Requirements for building sample: * Android SDK from 2014.07.02 or newer * Android NDK r9d or newer * Apache Ant 1.9.4 or higher - -Configure project for building sample: +* OCCT compiled under Android platform and placed in directories: + * occt\libs\armeabi-v7a\*.so and occt\inc\*.hxx (libraries and include files of OCCT install) + * android\assets\opencascade\shared\Shaders\* (Shaders folder of OCCT install: \share\opencascade\resources\Shaders) + * 3rdparty\include\freetype2\*, 3rdparty\include\FreeImage.h and 3rdparty\libs\armeabi-v7a\libFreeImage.so and 3rdparty\libs\armeabi-v7a\libfreetype.so + +It is also possible to to correct OCCT.pri file an get resources from another tree of directories. + +When AndroidQt will be started, it may be helpful to have some default data files(BRep) on Device for opening in AndroidQt. +Copy these files into "android\assets\opencascade\shared" and it will be installed to device during compilation procedure. + +Having prepared all these products, configure AndroidQt project for building sample: In QtCreator, open AndroidQt.pro project-file: ~~~~ @@ -28,27 +37,52 @@ Tools->Options->Android * In JDK location specify path to Java Development Kit * In Android SDK location specify path to Android SDK * In Android NDK location specify path to Android NDK +(During this location definition, warning is possible and OK: + "Qt version for architecture mips is missing. To add the Qt version, select Options > Build & Run > Qt Versins.") * In Ant executable specify path to ant.bat file located in Apache Ant bin directory -Make sure that "Android for armeabi-v7a" kit has been detected +Make sure that "Android for armeabi-v7a" kit has been detected (present in the list). ~~~~ Tools->Options->Build & Run ~~~~ -The paths to OCCT and 3rdparty libraries are specified in "OCCT.pri" file: - -the paths to the headers: +also or it can be checked or corrected in: ~~~~ -INCLUDEPATH += /occt/inc /3rdparty/include -DEPENDPATH += /occt/inc /3rdparty/include +Projects->Android for armeabi-v7a option should be checked +~~~~ + +Switch On device, connect it to PC and define it in Qt Creator: +~~~~ +Projects->Manage Kits...->Devices->Device: Run on Android +~~~~ +Check that "Current state" is "Ready to use" on this page. + +~~~~ +Projects->Build Settings->General: Shadow build is switched OFF ~~~~ -the libraries location: +Start configuration: + ~~~~ -LIBS += -L/occt/libs/armeabi-v7a +Call Build -> Run qmake +~~~~ +Check content of "Compile Output" view. + +In order to perform qmake correctly, for example if you have the following error: +~~~~ +Running steps for project AndroidQt... +Could not start process "\android_armv7\bin\qmake.exe" \samples\qt\AndroidQt\AndroidQt.pro -r -spec android-g++ "CONFIG+=debug" "CONFIG+=declarative_debug" "CONFIG+=qml_debug" +Error while building/deploying project AndroidQt (kit: Android for armeabi-v7a (GCC 4.9, Qt 5.3.2)) +When executing step "qmake" ~~~~ -OCCT resources (Shaders, SHMessage, StdResource, TObj, UnitsAPI and XSMessage folder) should be copied to androidqt_dir/android/assets/opencascade/shared/ directory. Current sample requires at least Shaders folder. +~~~~ +Projects->Build Settings->General: switch OFF Shadow build +Build->Build Project "Android Qt" +Build->Run +~~~~ + +Dialog to "Select Android Device" is shown. Select Compatible Device, Ok. +In case of any error, see log in "Application Output" view. -Select build configuration: Debug or Release and click Build->Build Project "AndroidQt" or (Ctrl + B). After successful build the application can be deployed to device or emulator. diff --git a/samples/qt/AndroidQt/res/qml/main.qml b/samples/qt/AndroidQt/res/qml/main.qml index c80be25fcc..2566fb29cd 100644 --- a/samples/qt/AndroidQt/res/qml/main.qml +++ b/samples/qt/AndroidQt/res/qml/main.qml @@ -62,7 +62,7 @@ Window { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - source: "qrc:///icons/res/icons/ic_action_collection.png" + source: "qrc:/ic_action_collection.png" } MouseArea { diff --git a/samples/qt/AndroidQt/AndroidQt.cxx b/samples/qt/AndroidQt/src/AndroidQt.cxx similarity index 100% rename from samples/qt/AndroidQt/AndroidQt.cxx rename to samples/qt/AndroidQt/src/AndroidQt.cxx diff --git a/samples/qt/AndroidQt/AndroidQt.h b/samples/qt/AndroidQt/src/AndroidQt.h similarity index 100% rename from samples/qt/AndroidQt/AndroidQt.h rename to samples/qt/AndroidQt/src/AndroidQt.h diff --git a/samples/qt/AndroidQt/src/AndroidQt.qrc b/samples/qt/AndroidQt/src/AndroidQt.qrc new file mode 100644 index 0000000000..fbc4b4a719 --- /dev/null +++ b/samples/qt/AndroidQt/src/AndroidQt.qrc @@ -0,0 +1,8 @@ + + + ../res/qml/main.qml + + + ../res/icons/ic_action_collection.png + + diff --git a/samples/qt/AndroidQt/AndroidQt_TouchParameters.cxx b/samples/qt/AndroidQt/src/AndroidQt_TouchParameters.cxx similarity index 100% rename from samples/qt/AndroidQt/AndroidQt_TouchParameters.cxx rename to samples/qt/AndroidQt/src/AndroidQt_TouchParameters.cxx diff --git a/samples/qt/AndroidQt/AndroidQt_TouchParameters.h b/samples/qt/AndroidQt/src/AndroidQt_TouchParameters.h similarity index 100% rename from samples/qt/AndroidQt/AndroidQt_TouchParameters.h rename to samples/qt/AndroidQt/src/AndroidQt_TouchParameters.h diff --git a/samples/qt/AndroidQt/AndroidQt_UserInteractionParameters.h b/samples/qt/AndroidQt/src/AndroidQt_UserInteractionParameters.h similarity index 100% rename from samples/qt/AndroidQt/AndroidQt_UserInteractionParameters.h rename to samples/qt/AndroidQt/src/AndroidQt_UserInteractionParameters.h diff --git a/samples/qt/AndroidQt/AndroidQt_Window.cxx b/samples/qt/AndroidQt/src/AndroidQt_Window.cxx similarity index 100% rename from samples/qt/AndroidQt/AndroidQt_Window.cxx rename to samples/qt/AndroidQt/src/AndroidQt_Window.cxx diff --git a/samples/qt/AndroidQt/AndroidQt_Window.h b/samples/qt/AndroidQt/src/AndroidQt_Window.h similarity index 100% rename from samples/qt/AndroidQt/AndroidQt_Window.h rename to samples/qt/AndroidQt/src/AndroidQt_Window.h diff --git a/samples/qt/AndroidQt/src/FILES b/samples/qt/AndroidQt/src/FILES new file mode 100644 index 0000000000..0bb880c9b3 --- /dev/null +++ b/samples/qt/AndroidQt/src/FILES @@ -0,0 +1,9 @@ +AndroidQt.cxx +AndroidQt.h +AndroidQt.qrc +AndroidQt_TouchParameters.cxx +AndroidQt_TouchParameters.h +AndroidQt_UserInteractionParameters.h +AndroidQt_Window.cxx +AndroidQt_Window.h +Main.cxx diff --git a/samples/qt/AndroidQt/Main.cxx b/samples/qt/AndroidQt/src/Main.cxx similarity index 93% rename from samples/qt/AndroidQt/Main.cxx rename to samples/qt/AndroidQt/src/Main.cxx index 48102a5902..dca2797359 100644 --- a/samples/qt/AndroidQt/Main.cxx +++ b/samples/qt/AndroidQt/src/Main.cxx @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) qmlRegisterType("AndroidQt", 1, 0, "AndroidQt"); QQmlApplicationEngine engine; - engine.load (QUrl (QStringLiteral ("qrc:///res/qml/main.qml"))); + engine.load (QUrl (QStringLiteral ("qrc:/main.qml"))); return app.exec(); } diff --git a/samples/qt/Common/src/ApplicationCommon.cxx b/samples/qt/Common/src/ApplicationCommon.cxx index ee65f377ce..a3e94903ab 100755 --- a/samples/qt/Common/src/ApplicationCommon.cxx +++ b/samples/qt/Common/src/ApplicationCommon.cxx @@ -15,6 +15,7 @@ #include #include +#include #include @@ -583,8 +584,10 @@ void ApplicationCommonWindow::onSetMaterial( int theMaterial ) QString ApplicationCommonWindow::getResourceDir() { static QString aResourceDir = - QString::fromUtf8 (qgetenv ("CSF_ResourcesDefaults").constData()); - + QString (OSD_Environment ("CSF_ResourcesDefaults").Value().ToCString()); + if (aResourceDir.isEmpty()) + aResourceDir = QString (OSD_Environment ("CSF_OCCTResourcePath").Value().ToCString()) + "/samples"; + return aResourceDir; } diff --git a/samples/qt/Common/src/DocumentCommon.cxx b/samples/qt/Common/src/DocumentCommon.cxx index 19aaac6b3f..f19194ec2d 100755 --- a/samples/qt/Common/src/DocumentCommon.cxx +++ b/samples/qt/Common/src/DocumentCommon.cxx @@ -13,6 +13,9 @@ #include #include #include +#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) +#include +#endif #include // ======================================================================= @@ -32,7 +35,7 @@ Handle(V3d_Viewer) DocumentCommon::Viewer (const Standard_ExtString , { Handle(Aspect_DisplayConnection) aDisplayConnection; #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) - aDisplayConnection = new Aspect_DisplayConnection (qgetenv ("DISPLAY").constData()); + aDisplayConnection = new Aspect_DisplayConnection (OSD_Environment ("DISPLAY").Value()); #endif aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection); } diff --git a/samples/qt/Common/src/FILES b/samples/qt/Common/src/FILES new file mode 100644 index 0000000000..12ba2818f3 --- /dev/null +++ b/samples/qt/Common/src/FILES @@ -0,0 +1,17 @@ +ApplicationCommon.cxx +ApplicationCommon.h +Common-icon.ts +Common-string.ts +CommonSample.h +DocumentCommon.cxx +DocumentCommon.h +Material.cxx +Material.h +MDIWindow.cxx +MDIWindow.h +OcctWindow.cxx +OcctWindow.h +Transparency.cxx +Transparency.h +View.cxx +View.h diff --git a/samples/qt/Common/src/MDIWindow.cxx b/samples/qt/Common/src/MDIWindow.cxx index e1315ce6ee..f09bce4064 100755 --- a/samples/qt/Common/src/MDIWindow.cxx +++ b/samples/qt/Common/src/MDIWindow.cxx @@ -105,7 +105,6 @@ void MDIWindow::onWindowActivated () void MDIWindow::dump() { - QString datadir = (QString(qgetenv ("CSF_OCCTDataPath").constData()) + "/images"); QString filter = "Images Files (*.bmp *.ppm *.png *.jpg *.tiff *.tga *.gif *.exr)"; QFileDialog fd ( 0 ); fd.setModal( true ); diff --git a/samples/qt/FuncDemo/CMakeLists.txt b/samples/qt/FuncDemo/CMakeLists.txt new file mode 100644 index 0000000000..92dc1e6281 --- /dev/null +++ b/samples/qt/FuncDemo/CMakeLists.txt @@ -0,0 +1,5 @@ +project(FuncDemo) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) diff --git a/samples/qt/FuncDemo/EXTERNLIB b/samples/qt/FuncDemo/EXTERNLIB new file mode 100644 index 0000000000..7ced3fdd54 --- /dev/null +++ b/samples/qt/FuncDemo/EXTERNLIB @@ -0,0 +1,14 @@ +TKBO +TKBRep +TKCAF +TKCDF +TKG2d +TKG3d +TKGeomAlgo +TKGeomBase +TKernel +TKLCAF +TKMath +TKMesh +TKPrim +TKTopAlgo diff --git a/samples/qt/FuncDemo/FILES b/samples/qt/FuncDemo/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/samples/qt/FuncDemo/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/samples/qt/FuncDemo/FuncDemo.pro b/samples/qt/FuncDemo/FuncDemo.pro index 67df58079a..d462720bd4 100644 --- a/samples/qt/FuncDemo/FuncDemo.pro +++ b/samples/qt/FuncDemo/FuncDemo.pro @@ -14,6 +14,8 @@ OCCT_DEFINES = $$(CSF_DEFINES) DEFINES = $$split(OCCT_DEFINES, ;) +RESOURCES += ./src/FuncDemo.qrc + unix { UNAME = $$system(uname -s) LIBLIST = $$(LD_LIBRARY_PATH) diff --git a/samples/qt/FuncDemo/PACKAGES b/samples/qt/FuncDemo/PACKAGES new file mode 100644 index 0000000000..6417933607 --- /dev/null +++ b/samples/qt/FuncDemo/PACKAGES @@ -0,0 +1 @@ +FuncDemo/src \ No newline at end of file diff --git a/samples/qt/FuncDemo/env.bat b/samples/qt/FuncDemo/env.bat index d0450d73cd..78c73fc58a 100644 --- a/samples/qt/FuncDemo/env.bat +++ b/samples/qt/FuncDemo/env.bat @@ -4,5 +4,4 @@ call "%~dp0..\..\..\env.bat" %1 %2 %3 call "custom.bat" %1 %2 %3 -set "PATH=%QTDIR%/bin;%PATH%" -set "QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms" \ No newline at end of file +set "PATH=%QTDIR%/bin;%PATH%" \ No newline at end of file diff --git a/samples/qt/FuncDemo/src/FILES b/samples/qt/FuncDemo/src/FILES new file mode 100644 index 0000000000..07ace65e6e --- /dev/null +++ b/samples/qt/FuncDemo/src/FILES @@ -0,0 +1,28 @@ +BaseDriver.cpp +BaseDriver.h +CircleDriver.cpp +CircleDriver.h +ConeDriver.cpp +ConeDriver.h +CylinderDriver.cpp +CylinderDriver.h +edge.cpp +edge.h +FILES +FThread.cpp +FThread.h +graphwidget.cpp +graphwidget.h +main.cpp +mainwindow.cpp +mainwindow.h +node.cpp +node.h +PointDriver.cpp +PointDriver.h +PrismDriver.cpp +PrismDriver.h +ShapeSaverDriver.cpp +ShapeSaverDriver.h +SimpleDriver.cpp +SimpleDriver.h diff --git a/samples/qt/FuncDemo/src/FuncDemo.qrc b/samples/qt/FuncDemo/src/FuncDemo.qrc new file mode 100644 index 0000000000..57e284ec48 --- /dev/null +++ b/samples/qt/FuncDemo/src/FuncDemo.qrc @@ -0,0 +1,7 @@ + + + ../images/new.png + ../images/open.png + ../images/save.png + + diff --git a/samples/qt/FuncDemo/src/main.cpp b/samples/qt/FuncDemo/src/main.cpp index 7ddfdf73f3..4f35cca9ea 100644 --- a/samples/qt/FuncDemo/src/main.cpp +++ b/samples/qt/FuncDemo/src/main.cpp @@ -41,8 +41,15 @@ #include #include "mainwindow.h" +#include + int main(int argc, char *argv[]) { +#if QT_VERSION > 0x050000 + TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value(); + if (!aPlugindsDirName.IsEmpty()) + QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins"); +#endif QApplication app(argc, argv); MainWindow mainWin; mainWin.show(); diff --git a/samples/qt/IESample/CMakeLists.txt b/samples/qt/IESample/CMakeLists.txt new file mode 100644 index 0000000000..d29fa8bae0 --- /dev/null +++ b/samples/qt/IESample/CMakeLists.txt @@ -0,0 +1,11 @@ +project(IESample) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) +include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/Interface/src") +include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/Common/src") +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) + +ADD_DEFINITIONS(-DNO_COMMONSAMPLE_EXPORTS -DNO_IESAMPLE_EXPORTS) + + diff --git a/samples/qt/IESample/EXTERNLIB b/samples/qt/IESample/EXTERNLIB new file mode 100644 index 0000000000..71631a4b6f --- /dev/null +++ b/samples/qt/IESample/EXTERNLIB @@ -0,0 +1,29 @@ +TKBRep +TKBool +TKBO +TKCDF +TKFillet +TKG2d +TKG3d +TKGeomAlgo +TKGeomBase +TKHLR +TKIGES +TKernel +TKMath +TKMesh +TKOffset +TKOpenGl +TKPrim +TKShHealing +TKService +TKSTEP +TKSTEP209 +TKSTEPAttr +TKSTEPBase +TKSTL +TKTopAlgo +TKV3d +TKVRML +TKXSBase + diff --git a/samples/qt/IESample/FILES b/samples/qt/IESample/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/samples/qt/IESample/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/samples/qt/IESample/PACKAGES b/samples/qt/IESample/PACKAGES new file mode 100644 index 0000000000..aa9aa1a3ca --- /dev/null +++ b/samples/qt/IESample/PACKAGES @@ -0,0 +1,3 @@ +IESample/src +Common/src +Interface/src \ No newline at end of file diff --git a/samples/qt/IESample/env.bat b/samples/qt/IESample/env.bat index 90a5c2cebd..3b7e3e4eb7 100755 --- a/samples/qt/IESample/env.bat +++ b/samples/qt/IESample/env.bat @@ -9,4 +9,3 @@ set "CSF_ResourcesDefaults=%RES_DIR%" set "CSF_IEResourcesDefaults=%RES_DIR%" set "PATH=%QTDIR%/bin;%PATH%" -set "QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms" \ No newline at end of file diff --git a/samples/qt/IESample/src/FILES b/samples/qt/IESample/src/FILES new file mode 100644 index 0000000000..f9dea79a18 --- /dev/null +++ b/samples/qt/IESample/src/FILES @@ -0,0 +1 @@ +Main.cxx \ No newline at end of file diff --git a/samples/qt/IESample/src/Main.cxx b/samples/qt/IESample/src/Main.cxx index 7baef2703f..87b7924d97 100755 --- a/samples/qt/IESample/src/Main.cxx +++ b/samples/qt/IESample/src/Main.cxx @@ -1,15 +1,20 @@ #include "Application.h" +#include + #include #include #include #include - int main ( int argc, char* argv[] ) { - +#if QT_VERSION > 0x050000 + TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value(); + if (!aPlugindsDirName.IsEmpty()) + QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins"); +#endif QApplication a( argc, argv ); QString resDir = ApplicationCommonWindow::getResourceDir(); diff --git a/samples/qt/Interface/src/Application.cxx b/samples/qt/Interface/src/Application.cxx index b14e7d4bc8..ec3cdca222 100755 --- a/samples/qt/Interface/src/Application.cxx +++ b/samples/qt/Interface/src/Application.cxx @@ -6,6 +6,8 @@ #include #include +#include + ApplicationWindow::ApplicationWindow() : ApplicationCommonWindow( ), myImportPopup( 0 ), @@ -210,8 +212,10 @@ void ApplicationWindow::onSelectionChanged() QString ApplicationWindow::getIEResourceDir() { static QString aResourceDir = - QString::fromUtf8 (qgetenv ("CSF_IEResourcesDefaults").constData()); - + QString (OSD_Environment ("CSF_IEResourcesDefaults").Value().ToCString()); + if (aResourceDir.isEmpty()) + aResourceDir = QString (OSD_Environment ("CSF_OCCTResourcePath").Value().ToCString()) + "/samples"; + return aResourceDir; } diff --git a/samples/qt/Interface/src/FILES b/samples/qt/Interface/src/FILES new file mode 100644 index 0000000000..c338ab41f5 --- /dev/null +++ b/samples/qt/Interface/src/FILES @@ -0,0 +1,6 @@ +Application.cxx +Application.h +IESample.h +Interface-string.ts +Translate.cxx +Translate.h diff --git a/samples/qt/Tutorial/CMakeLists.txt b/samples/qt/Tutorial/CMakeLists.txt new file mode 100644 index 0000000000..c5b08c52ec --- /dev/null +++ b/samples/qt/Tutorial/CMakeLists.txt @@ -0,0 +1,11 @@ +project(Tutorial) + +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) +include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/Interface/src") +include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/Common/src") +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) + +ADD_DEFINITIONS(-DNO_COMMONSAMPLE_EXPORTS -DNO_IESAMPLE_EXPORTS) + + diff --git a/samples/qt/Tutorial/EXTERNLIB b/samples/qt/Tutorial/EXTERNLIB new file mode 100644 index 0000000000..8beff5afee --- /dev/null +++ b/samples/qt/Tutorial/EXTERNLIB @@ -0,0 +1,29 @@ +TKBRep +TKBool +TKBO +TKCDF +TKFillet +TKG2d +TKG3d +TKGeomAlgo +TKGeomBase +TKernel +TKHLR +TKIGES +TKMath +TKMesh +TKOffset +TKOpenGl +TKPrim +TKService +TKShHealing +TKSTEP +TKSTEP209 +TKSTEPAttr +TKSTEPBase +TKSTL +TKTopAlgo +TKV3d +TKVRML +TKXSBase + diff --git a/samples/qt/Tutorial/FILES b/samples/qt/Tutorial/FILES new file mode 100644 index 0000000000..ca4f0e567b --- /dev/null +++ b/samples/qt/Tutorial/FILES @@ -0,0 +1,2 @@ +EXTERNLIB +PACKAGES diff --git a/samples/qt/Tutorial/PACKAGES b/samples/qt/Tutorial/PACKAGES new file mode 100644 index 0000000000..bd31a4fb0b --- /dev/null +++ b/samples/qt/Tutorial/PACKAGES @@ -0,0 +1,2 @@ +Tutorial/src +Common/src \ No newline at end of file diff --git a/samples/qt/Tutorial/env.bat b/samples/qt/Tutorial/env.bat index 781e09ef67..56b7eeb0c8 100755 --- a/samples/qt/Tutorial/env.bat +++ b/samples/qt/Tutorial/env.bat @@ -9,4 +9,3 @@ set "CSF_ResourcesDefaults=%RES_DIR%" set "CSF_TutorialResourcesDefaults=%RES_DIR%" set "PATH=%QTDIR%/bin;%PATH%" -set "QT_QPA_PLATFORM_PLUGIN_PATH=%QTDIR%\plugins\platforms" \ No newline at end of file diff --git a/samples/qt/Tutorial/src/ApplicationTut.cxx b/samples/qt/Tutorial/src/ApplicationTut.cxx index 6a6baa5aa4..5be0008f5c 100755 --- a/samples/qt/Tutorial/src/ApplicationTut.cxx +++ b/samples/qt/Tutorial/src/ApplicationTut.cxx @@ -1,6 +1,8 @@ #include "ApplicationTut.h" #include "DocumentTut.h" +#include + #include #include #include @@ -59,7 +61,8 @@ void ApplicationTut::onMakeBottleAction() QString ApplicationTut::getTutResourceDir() { - static QString resDir (qgetenv ("CSF_TutorialResourcesDefaults").constData()); + static QString resDir (OSD_Environment ("CSF_TutorialResourcesDefaults").Value().ToCString()); + if (resDir.isEmpty()) + resDir = QString (OSD_Environment ("CSF_OCCTResourcePath").Value().ToCString()) + "/samples"; return resDir; } - diff --git a/samples/qt/Tutorial/src/FILES b/samples/qt/Tutorial/src/FILES new file mode 100644 index 0000000000..54bd00b648 --- /dev/null +++ b/samples/qt/Tutorial/src/FILES @@ -0,0 +1,8 @@ +ApplicationTut.cxx +ApplicationTut.h +DocumentTut.cxx +DocumentTut.h +Main.cxx +MakeBottle.cxx +Tutorial-icon.ts +Tutorial-string.ts diff --git a/samples/qt/Tutorial/src/Main.cxx b/samples/qt/Tutorial/src/Main.cxx index 1d4cfe4685..1603de271d 100755 --- a/samples/qt/Tutorial/src/Main.cxx +++ b/samples/qt/Tutorial/src/Main.cxx @@ -1,10 +1,17 @@ #include "ApplicationTut.h" +#include + #include #include int main ( int argc, char* argv[] ) { +#if QT_VERSION > 0x050000 + TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value(); + if (!aPlugindsDirName.IsEmpty()) + QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins"); +#endif QApplication a( argc, argv ); QString resDir = ApplicationCommonWindow::getResourceDir(); diff --git a/samples/tools/TInspectorEXE/CMakeLists.txt b/samples/tools/TInspectorEXE/CMakeLists.txt index 070c323411..f7eb48ea40 100644 --- a/samples/tools/TInspectorEXE/CMakeLists.txt +++ b/samples/tools/TInspectorEXE/CMakeLists.txt @@ -1,5 +1,7 @@ project(TInspectorEXE) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) - -set_property (TARGET ${PROJECT_NAME} PROPERTY FOLDER Samples) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) +set (RELATIVE_DIR "samples/tools") +include_directories("${CMAKE_SOURCE_DIR}/${RELATIVE_DIR}/TInspectorEXE/src") +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_sample) diff --git a/samples/tools/TInspectorEXE/FILES b/samples/tools/TInspectorEXE/FILES index b1a28198cd..ca4f0e567b 100644 --- a/samples/tools/TInspectorEXE/FILES +++ b/samples/tools/TInspectorEXE/FILES @@ -1,5 +1,2 @@ -TInspectorEXE.cxx -TInspectorEXE_OpenFileDialog.cxx -TInspectorEXE_OpenFileDialog.hxx -TInspectorEXE_OpenFileViewModel.cxx -TInspectorEXE_OpenFileViewModel.hxx +EXTERNLIB +PACKAGES diff --git a/samples/tools/TInspectorEXE/PACKAGES b/samples/tools/TInspectorEXE/PACKAGES new file mode 100644 index 0000000000..51a97991c3 --- /dev/null +++ b/samples/tools/TInspectorEXE/PACKAGES @@ -0,0 +1 @@ +TInspectorEXE/src diff --git a/samples/tools/TInspectorEXE/TInspectorEXE.qrc b/samples/tools/TInspectorEXE/TInspectorEXE.qrc deleted file mode 100644 index 331296a3d7..0000000000 --- a/samples/tools/TInspectorEXE/TInspectorEXE.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - icons/folder_open.png - icons/folder_import.png - - diff --git a/samples/tools/TInspectorEXE/src/FILES b/samples/tools/TInspectorEXE/src/FILES new file mode 100644 index 0000000000..b48157613c --- /dev/null +++ b/samples/tools/TInspectorEXE/src/FILES @@ -0,0 +1,6 @@ +TInspectorEXE.cxx +TInspectorEXE_OpenFileDialog.cxx +TInspectorEXE_OpenFileDialog.hxx +TInspectorEXE_OpenFileViewModel.cxx +TInspectorEXE_OpenFileViewModel.hxx +TInspectorEXE.qrc \ No newline at end of file diff --git a/samples/tools/TInspectorEXE/TInspectorEXE.cxx b/samples/tools/TInspectorEXE/src/TInspectorEXE.cxx similarity index 93% rename from samples/tools/TInspectorEXE/TInspectorEXE.cxx rename to samples/tools/TInspectorEXE/src/TInspectorEXE.cxx index 7523a95f9e..012e95f3fe 100644 --- a/samples/tools/TInspectorEXE/TInspectorEXE.cxx +++ b/samples/tools/TInspectorEXE/src/TInspectorEXE.cxx @@ -74,15 +74,11 @@ void setPluginSampleDirectory (const TCollection_AsciiString& theName, TInspecto // ======================================================================= int main (int argc, char** argv) { - OSD_Environment anEnvironment ("QTDIR"); - TCollection_AsciiString aPlugindsDirName = anEnvironment.Value(); - if (aPlugindsDirName.IsEmpty()) - { - std::cout << "QTDIR is not defined" << std::endl; - return 0; - } - aPlugindsDirName += "/plugins"; - QApplication::addLibraryPath (aPlugindsDirName.ToCString()); +#if QT_VERSION > 0x050000 + TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value(); + if (!aPlugindsDirName.IsEmpty()) + QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins"); +#endif QApplication anApp (argc, argv); std::set aPlugins; diff --git a/samples/tools/TInspectorEXE/src/TInspectorEXE.qrc b/samples/tools/TInspectorEXE/src/TInspectorEXE.qrc new file mode 100644 index 0000000000..b3a84f67dc --- /dev/null +++ b/samples/tools/TInspectorEXE/src/TInspectorEXE.qrc @@ -0,0 +1,6 @@ + + + ../icons/folder_open.png + ../icons/folder_import.png + + diff --git a/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx b/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.cxx similarity index 98% rename from samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx rename to samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.cxx index 4607755c2b..1b4dd51f12 100644 --- a/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.cxx +++ b/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.cxx @@ -56,7 +56,7 @@ QPushButton* TInspectorEXE_OpenButton::StartButton() if (!myStartButton) { myStartButton = new QPushButton(); - myStartButton->setIcon (QIcon (":/icons/folder_open.png")); + myStartButton->setIcon (QIcon (":folder_open.png")); connect (myStartButton, SIGNAL (clicked()), this, SLOT (onStartButtonClicked())); } return myStartButton; @@ -138,11 +138,11 @@ TInspectorEXE_OpenFileDialog::TInspectorEXE_OpenFileDialog (QWidget* theParent, aSelectFileLay->addWidget (mySelectedName, 1, 0); QToolButton* aSelectFileBtn = new QToolButton (aSelectFileBox); - aSelectFileBtn->setIcon (QIcon (":/icons/folder_open.png")); + aSelectFileBtn->setIcon (QIcon (":folder_open.png")); aSelectFileLay->addWidget (aSelectFileBtn, 1, 1); myFolderApplyOpen = new QToolButton (aSelectFileBox); - myFolderApplyOpen->setIcon (QIcon (":/icons/folder_import.png")); + myFolderApplyOpen->setIcon (QIcon (":folder_import.png")); myFolderApplyOpen->setIconSize (QSize (ICON_SIZE, ICON_SIZE)); myFolderApplyOpen->setEnabled (false); aSelectFileLay->addWidget (myFolderApplyOpen, 0, 2, 2, 1); diff --git a/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx b/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.hxx similarity index 100% rename from samples/tools/TInspectorEXE/TInspectorEXE_OpenFileDialog.hxx rename to samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileDialog.hxx diff --git a/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx b/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileViewModel.cxx similarity index 100% rename from samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.cxx rename to samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileViewModel.cxx diff --git a/samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx b/samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileViewModel.hxx similarity index 100% rename from samples/tools/TInspectorEXE/TInspectorEXE_OpenFileViewModel.hxx rename to samples/tools/TInspectorEXE/src/TInspectorEXE_OpenFileViewModel.hxx diff --git a/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake b/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake index 2eafae1a02..223c362ca1 100644 --- a/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake +++ b/samples/tools/TStandalone/adm/cmake/occt_toolkit_standalone.cmake @@ -47,7 +47,7 @@ include_directories( add_definitions(-D__WIN32__) add_definitions(-DWNT) -add_definitions(-D${PROJECT_NAME}_EXPORTS) +add_definitions(-D__${PROJECT_NAME}_DLL) # parce EXTERNLIB file FILE_TO_LIST ("src/${PROJECT_NAME}/EXTERNLIB" USED_EXTERNLIB_AND_TOOLKITS) diff --git a/src/DRAWEXE/CMakeLists.txt b/src/DRAWEXE/CMakeLists.txt index 11673ed63a..bdf6279949 100644 --- a/src/DRAWEXE/CMakeLists.txt +++ b/src/DRAWEXE/CMakeLists.txt @@ -1,3 +1,5 @@ project(DRAWEXE) +set (EXECUTABLE_PROJECT ON) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +unset (EXECUTABLE_PROJECT) diff --git a/tools/DFBrowserPane/DFBrowserPane.hxx b/tools/DFBrowserPane/DFBrowserPane.hxx index 6deb03a75e..be7be47031 100644 --- a/tools/DFBrowserPane/DFBrowserPane.hxx +++ b/tools/DFBrowserPane/DFBrowserPane.hxx @@ -16,7 +16,7 @@ #ifndef DFBROWSERPANE_H #define DFBROWSERPANE_H -#ifdef DFBrowserPane_EXPORTS +#ifdef __DFBrowserPane_DLL #ifdef _WIN32 #define DFBROWSERPANE_EXPORT __declspec(dllexport) #else diff --git a/tools/TInspector/TInspector_Communicator.cxx b/tools/TInspector/TInspector_Communicator.cxx index 72771c13f0..025163e350 100644 --- a/tools/TInspector/TInspector_Communicator.cxx +++ b/tools/TInspector/TInspector_Communicator.cxx @@ -37,10 +37,9 @@ TInspector_Communicator::TInspector_Communicator() static int argc = 1; static char* argv[] = { (char*)"", 0 }; #if QT_VERSION > 0x050000 - OSD_Environment anEnvironment ("QTDIR"); - TCollection_AsciiString aPlugindsDirName = anEnvironment.Value(); - aPlugindsDirName += "/plugins"; - QApplication::addLibraryPath (aPlugindsDirName.ToCString()); + TCollection_AsciiString aPlugindsDirName = OSD_Environment ("QTDIR").Value(); + if (!aPlugindsDirName.IsEmpty()) + QApplication::addLibraryPath (QString (aPlugindsDirName.ToCString()) + "/plugins"); #endif new QApplication (argc, argv); } diff --git a/tools/TKDFBrowser/CMakeLists.txt b/tools/TKDFBrowser/CMakeLists.txt index 10902483db..29b45e9843 100644 --- a/tools/TKDFBrowser/CMakeLists.txt +++ b/tools/TKDFBrowser/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKDFBrowser) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKShapeView/CMakeLists.txt b/tools/TKShapeView/CMakeLists.txt index d57cc9fa2d..928a72f1e8 100644 --- a/tools/TKShapeView/CMakeLists.txt +++ b/tools/TKShapeView/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKShapeView) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) \ No newline at end of file +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKTInspector/CMakeLists.txt b/tools/TKTInspector/CMakeLists.txt index 3ed8dce1ff..0a05b7ca15 100644 --- a/tools/TKTInspector/CMakeLists.txt +++ b/tools/TKTInspector/CMakeLists.txt @@ -2,6 +2,8 @@ project(TKTInspector) set (INSTALL_API ON) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) unset (INSTALL_API) diff --git a/tools/TKTInspectorAPI/CMakeLists.txt b/tools/TKTInspectorAPI/CMakeLists.txt index a6afae44b2..d2f21e0f9b 100644 --- a/tools/TKTInspectorAPI/CMakeLists.txt +++ b/tools/TKTInspectorAPI/CMakeLists.txt @@ -2,7 +2,9 @@ project(TKTInspectorAPI) SET (TOOL_API_LIBRARY ON) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) UNSET (TOOL_API_LIBRARY) diff --git a/tools/TKToolsDraw/CMakeLists.txt b/tools/TKToolsDraw/CMakeLists.txt index 1812573e8f..f57982cf05 100644 --- a/tools/TKToolsDraw/CMakeLists.txt +++ b/tools/TKToolsDraw/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKToolsDraw) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKTreeModel/CMakeLists.txt b/tools/TKTreeModel/CMakeLists.txt index 6247c374a7..99fc025494 100644 --- a/tools/TKTreeModel/CMakeLists.txt +++ b/tools/TKTreeModel/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKTreeModel) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKVInspector/CMakeLists.txt b/tools/TKVInspector/CMakeLists.txt index dfdb809cb4..1a6de1456a 100644 --- a/tools/TKVInspector/CMakeLists.txt +++ b/tools/TKVInspector/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKVInspector) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) \ No newline at end of file +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) diff --git a/tools/TKView/CMakeLists.txt b/tools/TKView/CMakeLists.txt index 705ccd4047..ed33343886 100644 --- a/tools/TKView/CMakeLists.txt +++ b/tools/TKView/CMakeLists.txt @@ -1,3 +1,5 @@ project(TKView) -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit_prepare_tool)