]> OCCT Git - occt-wok.git/commitdiff
0024888: Refactoring of OCCT CMake meta-project
authoribs <ibs@opencascade.com>
Wed, 7 May 2014 11:36:50 +0000 (15:36 +0400)
committeribs <ibs@opencascade.com>
Tue, 16 Sep 2014 09:43:52 +0000 (13:43 +0400)
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
src/WOKTclLib/osutils.tcl
src/WOKTclLib/templates/template.cmake_dinf [deleted file]
src/WOKTclLib/templates/template.cmake_inc_toolkits [new file with mode: 0644]
src/WOKTclLib/templates/template.cmake_toolkits [new file with mode: 0644]

index dcfad359def7c4a659d503c2a751910de19dcabc..fcea405d119c37490985126e71ce08baf57835dc 100755 (executable)
@@ -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.
index 778656fa94e638cbf8dcea51c5d69b277472eae5..33d4ffe33df4a56e6f855448e0339148755e31a3 100755 (executable)
@@ -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_dinf b/src/WOKTclLib/templates/template.cmake_dinf
deleted file mode 100644 (file)
index 45aeb27..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-# dynamic content of OCCT
-
-__TOOLKIT_DEPS__
-
-__MODULE_DEPS__
-
-list( APPEND USED_TOOLKITS ${BUILD_TOOLKITS})
-
-foreach( TOOLKIT ${USED_TOOLKITS} )
- set(TurnONthe${TOOLKIT} ON)
- foreach( TK ${${TOOLKIT}_DEPS})
-   set(TurnONthe${TK} ON)
- endforeach()
-endforeach()
-
-__INCLUDE_TOOLKITS__
\ No newline at end of file
diff --git a/src/WOKTclLib/templates/template.cmake_inc_toolkits b/src/WOKTclLib/templates/template.cmake_inc_toolkits
new file mode 100644 (file)
index 0000000..470a216
--- /dev/null
@@ -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_toolkits b/src/WOKTclLib/templates/template.cmake_toolkits
new file mode 100644 (file)
index 0000000..d984fd8
--- /dev/null
@@ -0,0 +1,14 @@
+# being used toolkits
+
+__TOOLKIT_DEPS__
+
+__MODULE_DEPS__
+
+list( APPEND USED_TOOLKITS ${BUILD_TOOLKITS})
+
+foreach( TOOLKIT ${USED_TOOLKITS} )
+ set(TurnONthe${TOOLKIT} ON)
+ foreach( TK ${${TOOLKIT}_DEPS})
+   set(TurnONthe${TK} ON)
+ endforeach()
+endforeach()
\ No newline at end of file