From cb75bb4da5befbaf9e96858170e3ad6c6f1469c4 Mon Sep 17 00:00:00 2001 From: ibs Date: Wed, 7 May 2014 15:36:50 +0400 Subject: [PATCH] 0024888: Refactoring of OCCT CMake meta-project tcl hard-coded version was removed cmake required information about occt was divided onto two files: occt_toolkits.cmake occt_inc_toolkits.cmake debug paths were corrected ADD_SUBDIRECTORY preferred to SUBDIRS --- src/WOKTclLib/OS.tcl | 59 +++++++++++-------- src/WOKTclLib/osutils.tcl | 39 +++++++----- .../templates/template.cmake_inc_toolkits | 6 ++ ...ate.cmake_dinf => template.cmake_toolkits} | 7 +-- 4 files changed, 64 insertions(+), 47 deletions(-) create mode 100644 src/WOKTclLib/templates/template.cmake_inc_toolkits rename src/WOKTclLib/templates/{template.cmake_dinf => template.cmake_toolkits} (78%) diff --git a/src/WOKTclLib/OS.tcl b/src/WOKTclLib/OS.tcl index dcfad35..fcea405 100755 --- a/src/WOKTclLib/OS.tcl +++ b/src/WOKTclLib/OS.tcl @@ -2980,19 +2980,21 @@ proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} } proc OS:MKCMK { theOutDir {theModules {}} {theAllSolution ""} } { puts stderr "Generating CMake meta project" - set anSubPath "adm/cmake" - set anModulesFileName "CMakeModules.txt" - set anToolKitDepsFileName "CMakeToolKitsDeps.txt" + set aSubPath "adm/cmake" + set aModulesFileName "occt_modules.cmake" + set aBeingIncludedToolkits "occt_inc_toolkits.cmake" + set aBeingUsedToolkits "occt_toolkits.cmake" - set anModulesTmpl [osutils:readtemplate cmake_modules "Modules of OCCT"] - set anDepsTmpl [osutils:readtemplate cmake_dinf "toolkits and includes of OCCT"] + set aModulesTmpl [osutils:readtemplate cmake_modules "OCCT modules"] + set aToolkitsTmpl [osutils:readtemplate cmake_toolkits "toolkit dependencies"] + set anIncToolkitsTmpl [osutils:readtemplate cmake_inc_toolkits "toolkits including"] # modules of occt set aBuff [list] foreach aModule $theModules { lappend aBuff "SET(BUILD_${aModule} ON CACHE BOOL \"include ${aModule}\" )" } - regsub -all -- {__MODULE_LIST__} $anModulesTmpl [join $aBuff "\n"] anModulesTmpl + regsub -all -- {__MODULE_LIST__} $aModulesTmpl [join $aBuff "\n"] aModulesTmpl # dynamic content of occt set aBuff [list] @@ -3006,7 +3008,7 @@ proc OS:MKCMK { theOutDir {theModules {}} {theAllSolution ""} } { lappend aBuff "set(${anExecutable}_DEPS \"${aDepToolkits}\")" } } - regsub -all -- {__TOOLKIT_DEPS__} $anDepsTmpl [join $aBuff "\n"] anDepsTmpl + regsub -all -- {__TOOLKIT_DEPS__} $aToolkitsTmpl [join $aBuff "\n"] aToolkitsTmpl set aBuff [list] foreach aModule $theModules { @@ -3026,57 +3028,62 @@ proc OS:MKCMK { theOutDir {theModules {}} {theAllSolution ""} } { } lappend aBuff "endif()" } - regsub -all -- {__MODULE_DEPS__} $anDepsTmpl [join $aBuff "\n"] anDepsTmpl + regsub -all -- {__MODULE_DEPS__} $aToolkitsTmpl [join $aBuff "\n"] aToolkitsTmpl set aBuff [list] foreach aModule $theModules { foreach aToolKit [${aModule}:toolkits] { #create directory - if {![file exists "$theOutDir/$anSubPath/$aToolKit"]} { - file mkdir "$theOutDir/$anSubPath/$aToolKit" + if {![file exists "$theOutDir/$aSubPath/$aToolKit"]} { + file mkdir "$theOutDir/$aSubPath/$aToolKit" } #add directory to main cmake metafile - lappend aBuff "IF(EXISTS \"\$\{TK_ROOT_DIR\}/$anSubPath/${aToolKit}\")" - lappend aBuff " subdirs(\$\{TK_ROOT_DIR\}/$anSubPath/${aToolKit})" + lappend aBuff "IF(EXISTS \"\$\{TK_ROOT_DIR\}/$aSubPath/${aToolKit}\")" + lappend aBuff " add_subdirectory(\$\{TK_ROOT_DIR\}/$aSubPath/${aToolKit})" lappend aBuff "ELSE()" - lappend aBuff " LIST(APPEND UNSUBDIRS \"$anSubPath/${aToolKit}\")" + lappend aBuff " LIST(APPEND UNSUBDIRS \"$aSubPath/${aToolKit}\")" lappend aBuff "ENDIF()" # create cmake metafile into target subdir - osutils:cmktk $theOutDir/$anSubPath $aToolKit false ${aModule} + osutils:cmktk $theOutDir/$aSubPath $aToolKit false ${aModule} } foreach anExecutable [OS:executable ${aModule}] { #create directory - if {![file exists "$theOutDir/$anSubPath/$anExecutable"]} { - file mkdir "$theOutDir/$anSubPath/$anExecutable" + if {![file exists "$theOutDir/$aSubPath/$anExecutable"]} { + file mkdir "$theOutDir/$aSubPath/$anExecutable" } #add directory to main cmake metafile - lappend aBuff "IF(EXISTS \"\$\{TK_ROOT_DIR\}/$anSubPath/${anExecutable}\")" - lappend aBuff " subdirs(\$\{TK_ROOT_DIR\}/$anSubPath/${anExecutable})" + lappend aBuff "IF(EXISTS \"\$\{TK_ROOT_DIR\}/$aSubPath/${anExecutable}\")" + lappend aBuff " add_subdirectory(\$\{TK_ROOT_DIR\}/$aSubPath/${anExecutable})" lappend aBuff "ELSE()" - lappend aBuff " LIST(APPEND UNSUBDIRS \"$anSubPath/${anExecutable}\")" + lappend aBuff " LIST(APPEND UNSUBDIRS \"$aSubPath/${anExecutable}\")" lappend aBuff "ENDIF()\n" # create cmake metafile into target subdir - osutils:cmktk $theOutDir/$anSubPath $anExecutable true ${aModule} + osutils:cmktk $theOutDir/$aSubPath $anExecutable true ${aModule} } } - regsub -all -- {__INCLUDE_TOOLKITS__} $anDepsTmpl [join $aBuff "\n"] anDepsTmpl + regsub -all -- {__INCLUDE_TOOLKITS__} $anIncToolkitsTmpl [join $aBuff "\n"] anIncToolkitsTmpl #generate cmake files - set aFile [open [set fdsw [file join "$theOutDir/$anSubPath" $anModulesFileName]] w] + set aFile [open [set fdsw [file join "$theOutDir/$aSubPath" $aModulesFileName]] w] fconfigure $aFile -translation crlf - puts $aFile $anModulesTmpl + puts $aFile $aModulesTmpl + close $aFile + + set aFile [open [set fdsw [file join "$theOutDir/$aSubPath" $aBeingUsedToolkits]] w] + fconfigure $aFile -translation crlf + puts $aFile $aToolkitsTmpl close $aFile - set aFile [open [set fdsw [file join "$theOutDir/$anSubPath" $anToolKitDepsFileName]] w] + set aFile [open [set fdsw [file join "$theOutDir/$aSubPath" $aBeingIncludedToolkits]] w] fconfigure $aFile -translation crlf - puts $aFile $anDepsTmpl + puts $aFile $anIncToolkitsTmpl close $aFile - puts "The Cmake meta-files are stored in the [file normalize $theOutDir/$anSubPath] directories" + puts "The Cmake meta-files are stored in the [file normalize $theOutDir/$aSubPath] directories" } # Generates Code Blocks workspace. diff --git a/src/WOKTclLib/osutils.tcl b/src/WOKTclLib/osutils.tcl index 778656f..33d4ffe 100755 --- a/src/WOKTclLib/osutils.tcl +++ b/src/WOKTclLib/osutils.tcl @@ -1852,7 +1852,7 @@ proc osutils:vtkCsf {{theLibSuffix ""}} { return [join $aLibArray " "] } -proc osutils:csfList { theOS theCsfMap } { +proc osutils:csfList { theOS theCsfMap theTarget} { upvar $theCsfMap aCsfMap unset theCsfMap @@ -1871,9 +1871,11 @@ proc osutils:csfList { theOS theCsfMap } { set aCsfMap(CSF_OpenGlLibs) "opengl32.lib glu32.lib" # -- 3rd-parties precompiled libraries - # Note: Tcl library name depends on version and is chosen by #pragma -# set aCsfMap(CSF_TclLibs) "tcl86.lib" -# set aCsfMap(CSF_TclTkLibs) "tk86.lib" + if { "$theTarget" == "cmake" } { + set aCsfMap(CSF_TclLibs) "tcl\${3RDPARTY_TCL_LIBRARY_VERSION}.lib" + set aCsfMap(CSF_TclTkLibs) "tk\${3RDPARTY_TCL_LIBRARY_VERSION}.lib" + } + set aCsfMap(CSF_QT) "QtCore4.lib QtGui4.lib" #-- VTK @@ -1882,8 +1884,13 @@ proc osutils:csfList { theOS theCsfMap } { } else { #-- Tcl/Tk configuration - set aCsfMap(CSF_TclLibs) "tcl8.6" - set aCsfMap(CSF_TclTkLibs) "X11 tk8.6" + if { "$theTarget" == "cmake" } { + set aCsfMap(CSF_TclLibs) "tcl\${3RDPARTY_TCL_LIBRARY_VERSION}" + set aCsfMap(CSF_TclTkLibs) "X11 tk\${3RDPARTY_TK_LIBRARY_VERSION}" + } else { + set aCsfMap(CSF_TclLibs) "tcl8.6" + set aCsfMap(CSF_TclTkLibs) "X11 tk8.6" + } if { "$theOS" == "lin" } { set aCsfMap(CSF_ThreadLibs) "pthread rt" @@ -1928,10 +1935,10 @@ proc osutils:csfList { theOS theCsfMap } { } } -proc osutils:usedOsLibs { theToolKit theOS } { +proc osutils:usedOsLibs { theToolKit theOS {theTarget ""}} { set aUsedLibs [list] - osutils:csfList $theOS anOsCsfList + osutils:csfList $theOS anOsCsfList $theTarget foreach element [osutils:tk:hascsf [woklocate -p ${theToolKit}:source:EXTERNLIB [wokcd]]] { # test if variable is not setted - continue @@ -2006,8 +2013,8 @@ proc osutils:cmktk { theOutDir theToolKit {theIsExec false} theModule} { set anOutFileName "CMakeLists.txt" set anCommonUsedToolKits [osutils:commonUsedTK $theToolKit] - set anUsedWntLibs [osutils:usedOsLibs $theToolKit "wnt"] - set anUsedUnixLibs [osutils:usedOsLibs $theToolKit "lin"] + set anUsedWntLibs [osutils:usedOsLibs $theToolKit "wnt" cmake] + set anUsedUnixLibs [osutils:usedOsLibs $theToolKit "lin" cmake] set anUsedMacLibs [osutils:usedOsLibs $theToolKit "mac"] set anUnits [list] @@ -2306,20 +2313,20 @@ proc osutils:cmktk { theOutDir theToolKit {theIsExec false} theModule} { lappend aFileBuff "" lappend aFileBuff " set_property(TARGET ${theToolKit} PROPERTY FOLDER ${theModule})" lappend aFileBuff "" - lappend aFileBuff " install( TARGETS ${theToolKit} DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/bin\$\{BUILD_SUFFIX\}\" )" + lappend aFileBuff " install( TARGETS ${theToolKit} DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/bin\$\{BUILD_POSTFIX\}\" )" } else { lappend aFileBuff " add_library( ${theToolKit} SHARED \$\{${theToolKit}_USED_SRCFILES\} )" lappend aFileBuff "" lappend aFileBuff " set_property(TARGET ${theToolKit} PROPERTY FOLDER ${theModule})" lappend aFileBuff "" lappend aFileBuff " install( TARGETS ${theToolKit} - RUNTIME DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/bin\$\{BUILD_SUFFIX\}\" - ARCHIVE DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/lib\$\{BUILD_SUFFIX\}\" - LIBRARY DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/lib\$\{BUILD_SUFFIX\}\")" + RUNTIME DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/bin\$\{BUILD_POSTFIX\}\" + ARCHIVE DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/lib\$\{BUILD_POSTFIX\}\" + LIBRARY DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/lib\$\{BUILD_POSTFIX\}\")" lappend aFileBuff "" lappend aFileBuff " if (MSVC)" - lappend aFileBuff " install( FILES \$\{CMAKE_BINARY_DIR\}/out/bin/Debug/${theToolKit}.pdb CONFIGURATIONS Debug - DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/bin\$\{BUILD_SUFFIX\}\")" + lappend aFileBuff " install( FILES \$\{CMAKE_BINARY_DIR\}/out/bind/Debug/${theToolKit}.pdb CONFIGURATIONS Debug + DESTINATION \"\$\{INSTALL_DIR\}/\$\{OS_WITH_BIT\}/\$\{COMPILER\}/bin\$\{BUILD_POSTFIX\}\")" lappend aFileBuff " endif()" lappend aFileBuff "" } diff --git a/src/WOKTclLib/templates/template.cmake_inc_toolkits b/src/WOKTclLib/templates/template.cmake_inc_toolkits new file mode 100644 index 0000000..470a216 --- /dev/null +++ b/src/WOKTclLib/templates/template.cmake_inc_toolkits @@ -0,0 +1,6 @@ +# include all being used toolkits + +# USED_TOOLKITS variable +OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkits) + +__INCLUDE_TOOLKITS__ \ No newline at end of file diff --git a/src/WOKTclLib/templates/template.cmake_dinf b/src/WOKTclLib/templates/template.cmake_toolkits similarity index 78% rename from src/WOKTclLib/templates/template.cmake_dinf rename to src/WOKTclLib/templates/template.cmake_toolkits index 45aeb27..d984fd8 100644 --- a/src/WOKTclLib/templates/template.cmake_dinf +++ b/src/WOKTclLib/templates/template.cmake_toolkits @@ -1,5 +1,4 @@ - -# dynamic content of OCCT +# being used toolkits __TOOLKIT_DEPS__ @@ -12,6 +11,4 @@ foreach( TOOLKIT ${USED_TOOLKITS} ) foreach( TK ${${TOOLKIT}_DEPS}) set(TurnONthe${TK} ON) endforeach() -endforeach() - -__INCLUDE_TOOLKITS__ \ No newline at end of file +endforeach() \ No newline at end of file -- 2.39.5