0031471: Confuguration, genproj - unable to build OCC Products
[occt.git] / adm / genproj.tcl
index ef2f7e3..961c42e 100644 (file)
@@ -26,7 +26,7 @@ set path [file normalize .]
 set THE_CASROOT ""
 set fBranch ""
 if { [info exists ::env(CASROOT)] } {
-  set THE_CASROOT "$::env(CASROOT)"
+  set THE_CASROOT [file normalize "$::env(CASROOT)"]
 }
 
 proc _get_options { platform type branch } {
@@ -68,12 +68,12 @@ proc _get_type { name } {
   return ""
 }
 
-proc _get_used_files { pk {inc true} {src true} } {
+proc _get_used_files { pk theSrcDir {inc true} {src true} } {
   global path
   set type [_get_type $pk]
   set lret {}
-  set pk_path  "$path/src/$pk"
-  set FILES_path "$path/src/$pk/FILES"
+  set pk_path  "$path/$theSrcDir/$pk"
+  set FILES_path "$path/$theSrcDir/$pk/FILES"
   set FILES {}
   if {[file exists $FILES_path]} {
     set fd [open $FILES_path rb]
@@ -100,12 +100,12 @@ proc _get_used_files { pk {inc true} {src true} } {
   return $lret
 }
 
-# return location of the path within src directory
-proc osutils:findSrcSubPath {theSubPath} {
-  if {[file exists "$::path/src/$theSubPath"]} {
-    return "$::path/src/$theSubPath"
+# return location of the path within source directory
+proc osutils:findSrcSubPath {theSrcDir theSubPath} {
+  if {[file exists "$::path/$theSrcDir/$theSubPath"]} {
+    return "$::path/$theSrcDir/$theSubPath"
   }
-  return "$::THE_CASROOT/src/$theSubPath"
+  return "$::THE_CASROOT/$theSrcDir/$theSubPath"
 }
 
 # Auxiliary tool comparing content of two files line-by-line.
@@ -156,11 +156,11 @@ proc osutils:writeTextFile { theFile theContent {theEol lf} } {
 }
 
 # Function re-generating header files for specified text resource
-proc genResources { theResource } {
+proc genResources { theSrcDir theResource } {
   global path
 
   set aResFileList {}
-  set aResourceAbsPath [file normalize "${path}/src/${theResource}"]
+  set aResourceAbsPath [file normalize "${path}/$theSrcDir/${theResource}"]
   set aResourceDirectory ""
   set isResDirectory false
 
@@ -193,13 +193,13 @@ proc genResources { theResource } {
 
     # generate
     set aContent {}
-    lappend aContent "// This file has been automatically generated from resource file src/${aResourceDirectory}/${aResFileIter}"
+    lappend aContent "// This file has been automatically generated from resource file $theSrcDir/${aResourceDirectory}/${aResFileIter}"
        lappend aContent ""
 
     # generate necessary structures
     set aLineList {}
-    if {[file exists "${path}/src/${aResourceDirectory}/${aResFileIter}"]} {
-      set anInputFile [open "${path}/src/${aResourceDirectory}/${aResFileIter}" rb]
+    if {[file exists "${path}/$theSrcDir/${aResourceDirectory}/${aResFileIter}"]} {
+      set anInputFile [open "${path}/$theSrcDir/${aResourceDirectory}/${aResFileIter}" rb]
       fconfigure $anInputFile -translation crlf
       set aLineList [split [read $anInputFile] "\n"]
       close $anInputFile
@@ -226,9 +226,9 @@ proc genResources { theResource } {
     }
 
     # Save generated content to header file
-    set aHeaderFilePath "${path}/src/${aResourceDirectory}/${aHeaderFileName}"
+    set aHeaderFilePath "${path}/$theSrcDir/${aResourceDirectory}/${aHeaderFileName}"
     if { [osutils:writeTextFile $aHeaderFilePath $aContent] == true } {
-      puts "Generating header file from resource file: ${path}/src/${aResourceDirectory}/${aResFileIter}"
+      puts "Generating header file from resource file: ${path}/$theSrcDir/${aResourceDirectory}/${aResFileIter}"
     } else {
          #puts "Header file from resource ${path}/src/${aResourceDirectory}/${aResFileIter} is up-to-date"
     }
@@ -236,7 +236,7 @@ proc genResources { theResource } {
 }
 
 # Function re-generating header files for all text resources
-proc genAllResources {} {
+proc genAllResources { theSrcDir } {
   global path
   set aCasRoot [file normalize $path]
   if {![file exists "$aCasRoot/adm/RESOURCES"]} {
@@ -250,21 +250,21 @@ proc genAllResources {} {
   set anAdmResources [lsearch -inline -all -not -exact $anAdmResources ""]
 
   foreach line $anAdmResources {
-    genResources "${line}"
+    genResources $theSrcDir "${line}"
   }
 }
 
 # Wrapper-function to generate VS project files
-proc genproj {theIDE args} {
-  set aSupportedIDEs { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc14-uwp" "cbp" "xcd"}
-  set aSupportedPlatforms { "wnt" "lin" "mac" "ios" "qnx" }
+proc genproj {theFormat args} {
+  set aSupportedFormats { "vc7" "vc8" "vc9" "vc10" "vc11" "vc12" "vc14" "vc141" "vc142" "vclang" "cbp" "xcd" "pro"}
+  set aSupportedPlatforms { "wnt" "uwp" "lin" "mac" "ios" "qnx" }
   set isHelpRequire false
 
-  # check IDE argument
-  if { $theIDE == "-h" || $theIDE == "-help" || $theIDE == "--help" } {
+  # check format argument
+  if { $theFormat == "-h" || $theFormat == "-help" || $theFormat == "--help" } {
     set isHelpRequire true
-  } elseif { [lsearch -exact $aSupportedIDEs $theIDE] < 0 } {
-    puts "Error: genproj: unrecognized IDE \"$theIDE\""
+  } elseif { [lsearch -exact $aSupportedFormats $theFormat] < 0 } {
+    puts "Error: genproj: unrecognized project format \"$theFormat\""
     set isHelpRequire true
   }
 
@@ -272,9 +272,9 @@ proc genproj {theIDE args} {
   set aCmpl "gcc"
 
   # Determine default platform: wnt for vc*, mac for xcd, current for cbp
-  if { [regexp "^vc" $theIDE] } {
+  if { [regexp "^vc" $theFormat] } {
     set aPlatform "wnt"
-  } elseif { $theIDE == "xcd" || $::tcl_platform(os) == "Darwin" } {
+  } elseif { $theFormat == "xcd" || $::tcl_platform(os) == "Darwin" } {
     set aPlatform "mac"
   } elseif { $::tcl_platform(platform) == "windows" } {
     set aPlatform "wnt"
@@ -284,8 +284,12 @@ proc genproj {theIDE args} {
 
   # Check optional arguments
   set aLibType "dynamic"
-  foreach arg $args {
-    if { $arg == "-h" || $arg == "-help" || $arg == "--help" } {
+  set aSolution "OCCT"
+  for {set anArgIter 0} {$anArgIter < [llength args]} {incr anArgIter} {
+    set arg [lindex $args $anArgIter]
+    if { $arg == "" } {
+      continue
+    } elseif { $arg == "-h" || $arg == "-help" || $arg == "--help" } {
       set isHelpRequire true
     } elseif { [lsearch -exact $aSupportedPlatforms $arg] >= 0 } {
       set aPlatform $arg
@@ -295,6 +299,9 @@ proc genproj {theIDE args} {
     } elseif { $arg == "-dynamic" } {
       set aLibType "dynamic"
       puts "Dynamic build has been selected"
+    } elseif { $arg == "-solution" } {
+      incr anArgIter
+      set aSolution [lindex $args $anArgIter]
     } else {
       puts "Error: genproj: unrecognized option \"$arg\""
       set isHelpRequire true
@@ -302,21 +309,25 @@ proc genproj {theIDE args} {
   }
 
   if {  $isHelpRequire == true } {
-    puts "usage: genproj IDE \[Platform\] \[-static\] \[-h|-help|--help\]
+    puts "usage: genproj Format \[Platform\] \[-static\] \[-h|-help|--help\]
 
-    IDE must be one of:
+    Format must be one of:
       vc8      -  Visual Studio 2005
       vc9      -  Visual Studio 2008
       vc10     -  Visual Studio 2010
       vc11     -  Visual Studio 2012
       vc12     -  Visual Studio 2013
       vc14     -  Visual Studio 2015
-      vc14-uwp -  Visual Studio 2015 for Universal Windows Platform project
+      vc141    -  Visual Studio 2017
+      vc142    -  Visual Studio 2019
+      vclang   -  Visual Studio with ClangCL toolset
       cbp      -  CodeBlocks
       xcd      -  XCode
+      pro      -  Qt Creator
 
-    Platform (optional, only for CodeBlocks and XCode):
-      wnt   -  Windows
+    Platform (optional):
+      wnt   -  Windows Desktop
+      uwp   -  Universal Windows Platform
       lin   -  Linux
       mac   -  OS X
       ios   -  iOS
@@ -332,24 +343,41 @@ proc genproj {theIDE args} {
     return
   }
 
-  puts "Preparing to generate $theIDE projects for $aPlatform platform..."
+  puts "Preparing to generate $theFormat projects for $aPlatform platform..."
 
-  # path to where to generate projects, hardcoded from current dir
+  # base path to where to generate projects, hardcoded from current dir
   set anAdmPath [file normalize "${::path}/adm"]
 
-  OS:MKPRC "$anAdmPath" "$theIDE" "$aLibType" "$aPlatform" "$aCmpl"
+  OS:MKPRC "$anAdmPath" "$theFormat" "$aLibType" "$aPlatform" "$aCmpl" "$aSolution"
+
+  genprojbat "$theFormat" "$aPlatform" "$aSolution"
+  genAllResources "src"
+}
+
+# copy file providing warning if the target file exists and has 
+# different date or size; if it is newer than source, save it as .bak
+proc copy_with_warning {from to} {
+  if { [file exists "$to"] &&
+      ([file size   "$to"] != [file size  "$from"] ||
+       [file mtime  "$to"] != [file mtime "$from"]) } {
+    puts "Warning: file $to is updated (copied from $from)!"
+    if { [file mtime $to] > [file mtime $from] } {
+      puts "Info: old content of file $to is saved in ${to}.bak"
+      file copy -force -- "$to" "${to}.bak"
+    }
+  }
 
-  genprojbat "$theIDE" $aPlatform
-  genAllResources
+  file copy -force -- "$from" "$to"
 }
 
-proc genprojbat {theIDE thePlatform} {
+# Generate auxiliary scripts for launching IDE.
+proc genprojbat {theFormat thePlatform theSolution} {
   set aTargetPlatformExt sh
-  if { $thePlatform == "wnt" } {
+  if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
     set aTargetPlatformExt bat
   }
 
-  if {"$theIDE" != "cmake"} {
+  if {"$theFormat" != "cmake"} {
     # copy env.bat/sh only if not yet present
     if { ! [file exists "$::path/env.${aTargetPlatformExt}"] } {
       set anEnvTmplFile [open "$::THE_CASROOT/adm/templates/env.${aTargetPlatformExt}" "r"]
@@ -368,23 +396,43 @@ proc genprojbat {theIDE thePlatform} {
       close $anEnvFile
     }
 
-    file copy -force -- "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
+    copy_with_warning "$::THE_CASROOT/adm/templates/draw.${aTargetPlatformExt}" "$::path/draw.${aTargetPlatformExt}"
+
+    if { "$::BUILD_Inspector" == "true" } {
+      copy_with_warning "$::THE_CASROOT/adm/templates/inspector.${aTargetPlatformExt}" "$::path/inspector.${aTargetPlatformExt}"
+    }
   }
 
-  if {[regexp {(vc)[0-9]*$} $theIDE] == 1 || [regexp {(vc)[0-9]*-uwp$} $theIDE] == 1} {
-    file copy -force -- "$::THE_CASROOT/adm/templates/msvc.bat" "$::path/msvc.bat"
+  set aSolShList ""
+  if { [regexp {^vc} $theFormat] } {
+    set aSolShList "msvc.bat"
   } else {
-    switch -exact -- "$theIDE" {
-      "cbp"   {
-        file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.sh"  "$::path/codeblocks.sh"
-        file copy -force -- "$::THE_CASROOT/adm/templates/codeblocks.bat" "$::path/codeblocks.bat"
+    switch -exact -- "$theFormat" {
+      "cbp" {
+        set aSolShList { "codeblocks.sh" "codeblocks.bat" }
         # Code::Blocks 16.01 does not create directory for import libs, help him
-        file mkdir "$::path/$thePlatform/cbp/lib"
-        file mkdir "$::path/$thePlatform/cbp/libd"
+        set aPlatformAndCompiler "${thePlatform}/gcc"
+        if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
+          set aPlatformAndCompiler "${thePlatform}/clang"
+        }
+        file mkdir "$::path/${aPlatformAndCompiler}/lib"
+        file mkdir "$::path/${aPlatformAndCompiler}/libd"
       }
-      "xcd"   { file copy -force -- "$::THE_CASROOT/adm/templates/xcode.sh"      "$::path/xcode.sh" }
+      "xcd" { set aSolShList "xcode.sh" }
     }
   }
+
+  foreach aSolSh $aSolShList {
+    set anShFile [open "$::THE_CASROOT/adm/templates/${aSolSh}" "r"]
+    set anShTmpl [read $anShFile]
+    close $anShFile
+
+    regsub -all -- {__SOLUTION__} $anShTmpl "$theSolution" anShTmpl
+
+    set anShFile [open "$::path/${aSolSh}" "w"]
+    puts $anShFile $anShTmpl
+    close $anShFile
+  }
 }
 
 ###### MSVC #############################################################33
@@ -399,13 +447,14 @@ proc removeAllOccurrencesOf { theObject theList } {
 set aTKNullKey "TKNull"
 set THE_GUIDS_LIST($aTKNullKey) "{00000000-0000-0000-0000-000000000000}"
 
-# Entry function to generate project files and solutions for IDE
+# Entry function to generate project files
 # @param theOutDir   Root directory for project files
-# @param theIDE      IDE code name (vc10 for Visual Studio 2010, cbp for Code::Blocks, xcd for XCode)
+# @param theFormat   Project format name (vc.. for Visual Studio projects, cbp for Code::Blocks, xcd for XCode)
 # @param theLibType  Library type - dynamic or static
 # @param thePlatform Optional target platform for cross-compiling, e.g. ios for iOS
 # @param theCmpl     Compiler option (msvc or gcc)
-proc OS:MKPRC { theOutDir theIDE theLibType thePlatform theCmpl } {
+# @param theSolution Solution name
+proc OS:MKPRC { theOutDir theFormat theLibType thePlatform theCmpl theSolution } {
   global path
   set anOutRoot $theOutDir
   if { $anOutRoot == "" } {
@@ -414,14 +463,19 @@ proc OS:MKPRC { theOutDir theIDE theLibType thePlatform theCmpl } {
 
   # Create output directory
   set aWokStation "$thePlatform"
-  if { [lsearch -exact {vc7 vc8 vc9 vc10 vc11 vc12 vc14 vc14-uwp} $theIDE] != -1 } {
+  if { [regexp {^vc} $theFormat] } {
     set aWokStation "msvc"
   }
-
-  set anOutDir "${anOutRoot}/${aWokStation}/${theIDE}"
+  set aSuffix ""
+  set isUWP 0
+  if { $thePlatform == "uwp" } {
+    set aSuffix "-uwp"
+    set isUWP 1
+  }
+  set anOutDir "${anOutRoot}/${aWokStation}/${theFormat}${aSuffix}"
 
   # read map of already generated GUIDs
-  set aGuidsFilePath [file join $anOutDir "wok_${theIDE}_guids.txt"]
+  set aGuidsFilePath [file join $anOutDir "wok_${theFormat}_guids.txt"]
   if [file exists "$aGuidsFilePath"] {
     set aFileIn [open "$aGuidsFilePath" r]
     set aFileDataRaw [read $aFileIn]
@@ -436,29 +490,23 @@ proc OS:MKPRC { theOutDir theIDE theLibType thePlatform theCmpl } {
   }
 
   # make list of modules and platforms
-  set aModules [OS:init]
+  set aModules [OS:init OS Modules]
+  if { [llength $aModules] == 0 } {
+    set aModules [OS:init VAS Products]
+  }
   if { "$thePlatform" == "ios" } {
     set goaway [list Draw]
     set aModules [osutils:juststation $goaway $aModules]
   }
 
   # Draw module is turned off due to it is not supported on UWP
-  if { [regexp {(vc)[0-9]*-uwp$} $theIDE] == 1 } {
+  if { $isUWP } {
     set aDrawIndex [lsearch -exact ${aModules} "Draw"]
     if { ${aDrawIndex} != -1 } {
       set aModules [lreplace ${aModules} ${aDrawIndex} ${aDrawIndex}]
     }
   }
 
-  # generate one solution for all projects if complete OS or VAS is processed
-  set anAllSolution "OCCT"
-
-  wokUtils:FILES:mkdir $anOutDir
-  if { ![file exists $anOutDir] } {
-    puts stderr "Error: Could not create output directory \"$anOutDir\""
-    return
-  }
-
   # create the out dir if it does not exist
   if (![file isdirectory $path/inc]) {
     puts "$path/inc folder does not exists and will be created"
@@ -467,10 +515,39 @@ proc OS:MKPRC { theOutDir theIDE theLibType thePlatform theCmpl } {
 
   # collect all required header files
   puts "Collecting required header files into $path/inc ..."
-  osutils:collectinc $aModules $path/inc
+  osutils:collectinc $aModules "src" $path/inc
+
+  # make list of Inspector tools
+  set aTools {}
+  if { "$::BUILD_Inspector" == "true" } {
+    set aTools [OS:init OS Tools]
+    if { [llength $aTools] == 0 } {
+      set aTools [OS:init VAS Tools]
+    }
+
+    # create the out dir if it does not exist
+    if (![file isdirectory $path/inc/inspector]) {
+     puts "$path/inc/inspector folder does not exists and will be created"
+     wokUtils:FILES:mkdir $path/inc/inspector
+    }
+
+    # collect all required header files
+    puts "Collecting required tools header files into $path/inc/inspector ..."
+    osutils:collectinc $aTools "tools" $path/inc/inspector
+  }
+
+  if { "$theFormat" == "pro" } {
+    return
+  }
+
+  wokUtils:FILES:mkdir $anOutDir
+  if { ![file exists $anOutDir] } {
+    puts stderr "Error: Could not create output directory \"$anOutDir\""
+    return
+  }
 
-  # Generating project files for the selected IDE
-  switch -exact -- "$theIDE" {
+  # Generating project files for the selected format
+  switch -exact -- "$theFormat" {
     "vc7"   -
     "vc8"   -
     "vc9"   -
@@ -478,11 +555,13 @@ proc OS:MKPRC { theOutDir theIDE theLibType thePlatform theCmpl } {
     "vc11"  -
     "vc12"  -
     "vc14"  -
-    "vc14-uwp" { OS:MKVC  $anOutDir $aModules $anAllSolution $theIDE }
-    "cbp"      { OS:MKCBP $anOutDir $aModules $anAllSolution $thePlatform $theCmpl }
+    "vc141" -
+    "vc142" -
+    "vclang"   { OS:MKVC  $anOutDir $aModules $aTools $theSolution $theFormat $isUWP}
+    "cbp"      { OS:MKCBP $anOutDir $aModules $theSolution $thePlatform $theCmpl }
     "xcd"      {
       set ::THE_GUIDS_LIST($::aTKNullKey) "000000000000000000000000"
-      OS:MKXCD $anOutDir $aModules $anAllSolution $theLibType $thePlatform
+      OS:MKXCD $anOutDir $aModules $theSolution $theLibType $thePlatform
     }
   }
 
@@ -497,54 +576,50 @@ proc OS:MKPRC { theOutDir theIDE theLibType thePlatform theCmpl } {
 }
 
 # Function to generate Visual Studio solution and project files
-proc OS:MKVC { theOutDir {theModules {}} {theAllSolution ""} {theVcVer "vc8"} } {
+proc OS:MKVC { theOutDir theModules theTools theAllSolution theVcVer isUWP } {
 
   puts stderr "Generating VS project files for $theVcVer"
 
   # generate projects for toolkits and separate solution for each module
   foreach aModule $theModules {
-    OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST
-    OS:vcproj     $theVcVer $aModule          $theOutDir ::THE_GUIDS_LIST
+    OS:vcsolution $theVcVer $aModule $aModule $theOutDir ::THE_GUIDS_LIST "src" "" ""
+    OS:vcproj     $theVcVer $isUWP   $aModule $theOutDir ::THE_GUIDS_LIST "src"    ""
+  }
+
+  # generate projects for toolkits and separate solution for each tool
+  foreach aTool $theTools {
+    OS:vcsolution $theVcVer $aTool $aTool $theOutDir ::THE_GUIDS_LIST "tools" "" "src"
+    OS:vcproj     $theVcVer $isUWP $aTool $theOutDir ::THE_GUIDS_LIST "tools"    "src"
   }
 
   # generate single solution "OCCT" containing projects from all modules
   if { "$theAllSolution" != "" } {
-    OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST
+    OS:vcsolution $theVcVer $theAllSolution $theModules $theOutDir ::THE_GUIDS_LIST "src" $theTools "tools"
   }
 
   puts "The Visual Studio solution and project files are stored in the $theOutDir directory"
 }
 
-proc OS:init {{os {}}} {
+proc OS:init {theVas theNameOfDefFile {os {}}} {
   set askplat $os
   set aModules {}
   if { "$os" == "" } {
     set os $::tcl_platform(os)
   }
 
-  if [file exists "$::path/src/VAS/Products.tcl"] {
-    source "$::path/src/VAS/Products.tcl"
-    foreach aModuleIter [VAS:Products] {
-      set aFileTcl "$::path/src/VAS/${aModuleIter}.tcl"
-      if [file exists $aFileTcl] {
-        source $aFileTcl
-        lappend aModules $aModuleIter
-      } else {
-        puts stderr "Definition file for module $aModuleIter is not found in unit VAS"
-      }
-    }
+  if { ![file exists "$::path/src/${theVas}/${theNameOfDefFile}.tcl"]} {
     return $aModules
   }
 
   # Load list of OCCT modules and their definitions
-  source "$::path/src/OS/Modules.tcl"
-  foreach aModuleIter [OS:Modules] {
-    set aFileTcl "$::path/src/OS/${aModuleIter}.tcl"
+  source "$::path/src/${theVas}/${theNameOfDefFile}.tcl"
+  foreach aModuleIter [${theVas}:${theNameOfDefFile}] {
+    set aFileTcl "$::path/src/${theVas}/${aModuleIter}.tcl"
     if [file exists $aFileTcl] {
       source $aFileTcl
       lappend aModules $aModuleIter
     } else {
-      puts stderr "Definition file for module $aModuleIter is not found in unit OS"
+      puts stderr "Definition file for $aModuleIter is not found in unit ${theVas}"
     }
   }
 
@@ -663,10 +738,10 @@ proc OS:executable { module } {
 }
 
 # Topological sort of toolkits in tklm
-proc osutils:tk:sort { tklm } {
+proc osutils:tk:sort { tklm theSrcDir theSourceDirOther } {
   set tkby2 {}
   foreach tkloc $tklm {
-    set lprg [wokUtils:LIST:Purge [osutils:tk:close $tkloc]]
+    set lprg [wokUtils:LIST:Purge [osutils:tk:close $tkloc $theSrcDir $theSourceDirOther]]
     foreach tkx  $lprg {
       if { [lsearch $tklm $tkx] != -1 } {
         lappend tkby2 [list $tkx $tkloc]
@@ -687,26 +762,26 @@ proc osutils:tk:sort { tklm } {
 #  close dependencies of ltk. (full wok pathes of toolkits)
 # The CURRENT WOK LOCATION MUST contains ALL TOOLKITS required.
 # (locate not performed.)
-proc osutils:tk:close { ltk } {
+proc osutils:tk:close { ltk theSrcDir theSourceDirOther } {
   set result {}
   set recurse {}
   foreach dir $ltk {
-    set ids [LibToLink $dir]
+    set ids [LibToLink $dir $theSrcDir $theSourceDirOther]
 #    puts "osutils:tk:close($ltk) ids='$ids'"
     set eated [osutils:tk:eatpk $ids]
     set result [concat $result $eated]
-    set ids [LibToLink $dir]
+    set ids [LibToLink $dir $theSrcDir $theSourceDirOther]
     set result [concat $result $ids]
 
     foreach file $eated {
-      set kds [osutils:findSrcSubPath "$file/EXTERNLIB"]
+      set kds [osutils:findSrcSubPath $theSrcDir "$file/EXTERNLIB"]
       if { [osutils:tk:eatpk $kds] !=  {} } {
         lappend recurse $file
       }
     }
   }
   if { $recurse != {} } {
-    set result [concat $result [osutils:tk:close $recurse]]
+    set result [concat $result [osutils:tk:close $recurse $theSrcDir $theSourceDirOther]]
   }
   return $result
 }
@@ -723,16 +798,19 @@ proc osutils:tk:eatpk { EXTERNLIB  } {
 }
 # Define libraries to link using only EXTERNLIB file
 
-proc LibToLink {theTKit} {
+proc LibToLink {theTKit theSrcDir theSourceDirOther} {
   regexp {^.*:([^:]+)$} $theTKit dummy theTKit
   set type [_get_type $theTKit]
   if {$type != "t" && $type != "x"} {
     return
   }
   set aToolkits {}
-  set anExtLibList [osutils:tk:eatpk [osutils:findSrcSubPath "$theTKit/EXTERNLIB"]]
+  set anExtLibList [osutils:tk:eatpk [osutils:findSrcSubPath $theSrcDir "$theTKit/EXTERNLIB"]]
   foreach anExtLib $anExtLibList {
-    set aFullPath [LocateRecur $anExtLib]
+    set aFullPath [LocateRecur $anExtLib $theSrcDir]
+    if { "$aFullPath" == "" && "$theSourceDirOther" != "" } {
+      set aFullPath [LocateRecur $anExtLib $theSourceDirOther]
+    }
     if { "$aFullPath" != "" && [_get_type $anExtLib] == "t" } {
       lappend aToolkits $anExtLib
     }
@@ -741,16 +819,16 @@ proc LibToLink {theTKit} {
 }
 # Search unit recursively
 
-proc LocateRecur {theName} {
-  set theNamePath [osutils:findSrcSubPath "$theName"]
+proc LocateRecur {theName theSrcDir} {
+  set theNamePath [osutils:findSrcSubPath $theSrcDir "$theName"]
   if {[file isdirectory $theNamePath]} {
     return $theNamePath
   }
   return ""
 }
 
-proc OS:genGUID { {theIDE "vc"} } {
-  if { "$theIDE" == "vc" } {
+proc OS:genGUID { {theFormat "vc"} } {
+  if { "$theFormat" == "vc" } {
     set p1 "[format %07X [expr { int(rand() * 268435456) }]][format %X [expr { int(rand() * 16) }]]"
     set p2 "[format %04X [expr { int(rand() * 6536) }]]"
     set p3 "[format %04X [expr { int(rand() * 6536) }]]"
@@ -769,7 +847,7 @@ proc OS:genGUID { {theIDE "vc"} } {
 }
 
 # collect all include file that required for theModules in theOutDir
-proc osutils:collectinc {theModules theIncPath} {
+proc osutils:collectinc {theModules theSrcDir theIncPath} {
   global path
   set aCasRoot [file normalize $path]
   set anIncPath [file normalize $theIncPath]
@@ -784,14 +862,14 @@ proc osutils:collectinc {theModules theIncPath} {
     foreach aToolKit [${aModule}:toolkits] {
       lappend anUsedToolKits $aToolKit
 
-      foreach aDependency [LibToLink $aToolKit] {
+      foreach aDependency [LibToLink $aToolKit $theSrcDir ""] {
         lappend anUsedToolKits $aDependency
       }
     }
     foreach anExecutable [OS:executable ${aModule}] {
       lappend anUsedToolKits $anExecutable
 
-      foreach aDependency [LibToLink $anExecutable] {
+      foreach aDependency [LibToLink $anExecutable $theSrcDir ""] {
         lappend anUsedToolKits $aDependency
       }
     }
@@ -800,7 +878,7 @@ proc osutils:collectinc {theModules theIncPath} {
 
   set anUnits {}
   foreach anUsedToolKit $anUsedToolKits {
-    set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit]]
+    set anUnits [concat $anUnits [osutils:tk:units $anUsedToolKit $theSrcDir] ]
   }
   set anUnits [lsort -unique $anUnits]
 
@@ -825,14 +903,14 @@ proc osutils:collectinc {theModules theIncPath} {
     }
     set aHeaderTmpl [wokUtils:FILES:FileToString $::THE_CASROOT/adm/templates/header.in]
 
-    # relative anIncPath in connection with aCasRoot/src
-    set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/src"]
+    # relative anIncPath in connection with aCasRoot/$theSrcDir
+    set aFromBuildIncToSrcPath [relativePath "$anIncPath" "$aCasRoot/$theSrcDir"]
 
     # create and copy short-cut header files
     foreach anUnit $anUnits {
-      osutils:checksrcfiles ${anUnit}
+      osutils:checksrcfiles ${anUnit} $theSrcDir
 
-      set aHFiles [_get_used_files ${anUnit} true false]
+      set aHFiles [_get_used_files ${anUnit} $theSrcDir true false]
       foreach aHeaderFile ${aHFiles} {
         set aHeaderFileName [lindex ${aHeaderFile} 1]
         lappend allHeaderFiles "${aHeaderFileName}"
@@ -867,15 +945,15 @@ proc osutils:collectinc {theModules theIncPath} {
   } else {
     set nbcopied 0
     foreach anUnit $anUnits {
-      osutils:checksrcfiles ${anUnit}
+      osutils:checksrcfiles ${anUnit} $theSrcDir
 
-      set aHFiles [_get_used_files ${anUnit} true false]
+      set aHFiles [_get_used_files ${anUnit} $theSrcDir true false]
       foreach aHeaderFile ${aHFiles} {
         set aHeaderFileName [lindex ${aHeaderFile} 1]
         lappend allHeaderFiles "${aHeaderFileName}"
 
         # copy file only if target does not exist or is older than original
-        set torig [file mtime $aCasRoot/src/$anUnit/$aHeaderFileName]
+        set torig [file mtime $aCasRoot/$theSrcDir/$anUnit/$aHeaderFileName]
         set tcopy 0
         if { [file isfile $anIncPath/$aHeaderFileName] } {
           set tcopy [file mtime $anIncPath/$aHeaderFileName]
@@ -886,12 +964,12 @@ proc osutils:collectinc {theModules theIncPath} {
             if { $tcopy != 0 } {
               file delete -force "$theIncPath/$aHeaderFileName"
             }
-            file link -hard  $anIncPath/$aHeaderFileName $aCasRoot/src/$anUnit/$aHeaderFileName
+            file link -hard  $anIncPath/$aHeaderFileName $aCasRoot/$theSrcDir/$anUnit/$aHeaderFileName
           } else {
-            file copy -force $aCasRoot/src/$anUnit/$aHeaderFileName $anIncPath/$aHeaderFileName
+            file copy -force $aCasRoot/$theSrcDir/$anUnit/$aHeaderFileName $anIncPath/$aHeaderFileName
           }
         } elseif { $tcopy != $torig } {
-          puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aCasRoot/src/$anUnit/$aHeaderFileName, not changed!"
+          puts "Warning: file $anIncPath/$aHeaderFileName is newer than $aCasRoot/$theSrcDir/$anUnit/$aHeaderFileName, not changed!"
         }
       }
     }
@@ -902,7 +980,7 @@ proc osutils:collectinc {theModules theIncPath} {
   set anIncFiles [glob -tails -nocomplain -dir ${anIncPath} "*"]
   foreach anIncFile ${anIncFiles} {
     if { [lsearch -exact ${allHeaderFiles} ${anIncFile}] == -1 } {
-      puts "Warning: file ${anIncPath}/${anIncFile} is not presented in the sources and will be removed from ${theIncPath}!"
+      puts "Warning: file ${anIncPath}/${anIncFile} is not present in the sources and will be removed from ${theIncPath}"
       file delete -force "${theIncPath}/${anIncFile}"
     }
   }
@@ -931,9 +1009,10 @@ proc osutils:vcsolution:header { vcversion } {
       "# Visual Studio 2012\n"
   } elseif { "$vcversion" == "vc12" } {
     append var \
-      "Microsoft Visual Studio Solution File, Format Version 13.00\n" \
+      "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
       "# Visual Studio 2013\n"
-  } elseif { "$vcversion" == "vc14"  || "$vcversion" == "vc14-uwp"} {
+  } elseif { "$vcversion" == "vc14" || "$vcversion" == "vc141" || 
+             "$vcversion" == "vc142" || "$vcversion" == "vclang" } {
     append var \
       "Microsoft Visual Studio Solution File, Format Version 12.00\n" \
       "# Visual Studio 14\n"
@@ -1019,44 +1098,16 @@ proc osutils:vcsolution:config:end { vcversion } {
 # generate Visual Studio solution file
 # if module is empty, generates one solution for all known modules
 
-proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
+proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap theSrcDir theModulesOther theSourceDirOther } {
   global path
   upvar $theGuidsMap aGuidsMap
 
   # collect list of projects to be created
   set aProjects {}
   set aDependencies {}
-  foreach aModule $theModules {
-    # toolkits
-    foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
-      lappend aProjects $aToolKit
-      lappend aProjectsInModule($aModule) $aToolKit
-      lappend aDependencies [LibToLink $aToolKit]
-    }
-    # executables, assume one project per cxx file...
-    foreach aUnit [OS:executable ${aModule}] {
-      set aUnitLoc $aUnit
-      set src_files [_get_used_files $aUnit false]
-      set aSrcFiles {}
-      foreach s $src_files {
-        regexp {source ([^\s]+)} $s dummy name
-        lappend aSrcFiles $name
-      }
-      foreach aSrcFile $aSrcFiles {
-        set aFileExtension [file extension $aSrcFile]
-        if { $aFileExtension == ".cxx" } {
-          set aPrjName [file rootname $aSrcFile]
-          lappend aProjects $aPrjName
-          lappend aProjectsInModule($aModule) $aPrjName
-          if {[file isdirectory $path/src/$aUnitLoc]} {
-            lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
-          } else {
-            lappend aDependencies {}
-          }
-        }
-      }
-    }
-  }
+
+  osutils:convertModules $theModules $theSrcDir $theSourceDirOther aProjects aProjectsInModule aDependencies
+  osutils:convertModules $theModulesOther $theSourceDirOther $theSrcDir aProjects aProjectsInModule aDependencies
 
 # generate GUIDs for projects (unless already known)
   foreach aProject $aProjects {
@@ -1083,6 +1134,15 @@ proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
     }
   }
 
+  if { "$theVcVer" != "vc7" && [llength "$theModulesOther"] > 1 } {
+    set aModule "Tools"
+    if { ! [info exists aGuidsMap(_$aModule)] } {
+      set aGuidsMap(_$aModule) [OS:genGUID]
+    }
+    set aGuid $aGuidsMap(_$aModule)
+    append aFileBuff "Project(\"${VC_GROUP_GUID}\") = \"$aModule\", \"$aModule\", \"$aGuid\"\nEndProject\n"
+  }
+
   # extension of project files
   set aProjExt [osutils:vcproj:ext $theVcVer]
 
@@ -1127,6 +1187,13 @@ proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
         append aFileBuff "             $aGuidsMap($aProject) = $aGuidsMap(_$aModule)\n"
       }
     }
+    set aToolsName "Tools"
+    foreach aModule $theModulesOther {
+      if { ! [info exists aProjectsInModule($aModule)] } { continue }
+      foreach aProject $aProjectsInModule($aModule) {
+        append aFileBuff "             $aGuidsMap($aProject) = $aGuidsMap(_$aToolsName)\n"
+      }
+    }
     append aFileBuff " EndGlobalSection\n"
   }
 
@@ -1140,38 +1207,96 @@ proc OS:vcsolution { theVcVer theSolName theModules theOutDir theGuidsMap } {
   close $aFile
   return [file join $theOutDir ${theSolName}.sln]
 }
+
+# Generate auxiliary containers with information about modules.
+# @param theModules List of modules       
+# @param theSrcDir Directory of module toolkits
+# @param theSourceDirOther Directory with other additional sources to find out toolkits in dependencies
+# @param theProjects list of all found projects/toolkits
+# @param theProjectsInModule map of module into toolkits/projects
+# @param theDependencies list of the project dependencies. To find the project dependencies, get it by the index in project container
+proc osutils:convertModules { theModules theSrcDir theSourceDirOther theProjects theProjectsInModule theDependencies } {
+  global path
+  upvar $theProjectsInModule aProjectsInModule
+  upvar $theProjects aProjects
+  upvar $theDependencies aDependencies
+
+  foreach aModule $theModules {
+    # toolkits
+    foreach aToolKit [osutils:tk:sort [${aModule}:toolkits] $theSrcDir $theSourceDirOther] {
+      lappend aProjects $aToolKit
+      lappend aProjectsInModule($aModule) $aToolKit
+      lappend aDependencies [LibToLink $aToolKit $theSrcDir $theSourceDirOther]
+    }
+    # executables, assume one project per cxx file...
+    foreach aUnit [OS:executable ${aModule}] {
+      set aUnitLoc $aUnit
+      set src_files [_get_used_files $aUnit $theSrcDir false]
+      set aSrcFiles {}
+      foreach s $src_files {
+        regexp {source ([^\s]+)} $s dummy name
+        lappend aSrcFiles $name
+      }
+      foreach aSrcFile $aSrcFiles {
+        set aFileExtension [file extension $aSrcFile]
+        if { $aFileExtension == ".cxx" } {
+          set aPrjName [file rootname $aSrcFile]
+          lappend aProjects $aPrjName
+          lappend aProjectsInModule($aModule) $aPrjName
+          if {[file isdirectory $path/$theSrcDir/$aUnitLoc]} {
+            lappend aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile] $theSrcDir $theSourceDirOther]
+          } else {
+            lappend aDependencies {}
+          }
+        }
+      }
+    }
+  }
+}
 # Generate Visual Studio projects for specified version
 
-proc OS:vcproj { theVcVer theModules theOutDir theGuidsMap } {
+proc OS:vcproj { theVcVer isUWP theModules theOutDir theGuidsMap theSrcDir theSourceDirOther } {
   upvar $theGuidsMap aGuidsMap
 
   set aProjectFiles {}
 
   foreach aModule $theModules {
     foreach aToolKit [${aModule}:toolkits] {
-      lappend aProjectFiles [osutils:vcproj  $theVcVer $theOutDir $aToolKit     aGuidsMap]
+      lappend aProjectFiles [osutils:vcproj  $theVcVer $isUWP $theOutDir $aToolKit     aGuidsMap $theSrcDir $theSourceDirOther]
     }
     foreach anExecutable [OS:executable ${aModule}] {
-      lappend aProjectFiles [osutils:vcprojx $theVcVer $theOutDir $anExecutable aGuidsMap]
+      lappend aProjectFiles [osutils:vcprojx $theVcVer $isUWP $theOutDir $anExecutable aGuidsMap $theSrcDir $theSourceDirOther]
     }
   }
   return $aProjectFiles
 }
 # generate template name and load it for given version of Visual Studio and platform
 
-proc osutils:vcproj:readtemplate {theVcVer isexec} {
+proc osutils:vcproj:readtemplate {theVcVer isUWP isExec} {
   set anExt $theVcVer
   if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
     set anExt vc10
   }
 
+  # determine versions of runtime and toolset
+  set aVCRTVer $theVcVer 
+  set aToolset "v[string range $theVcVer 2 3]0"
+  if { $theVcVer == "vc141" } {
+    set aVCRTVer "vc14"
+    set aToolset "v141"
+  } elseif { $theVcVer == "vc142" } {
+    set aVCRTVer "vc14"
+    set aToolset "v142"
+  } elseif { $theVcVer == "vclang" } {
+    set aVCRTVer "vc14"
+    set aToolset "ClangCL"
+  }
+
   set what "$theVcVer"
-  set aVerExt [string range $theVcVer 2 end]
-  set aVerExt "v${aVerExt}0"
   set aCmpl32 ""
   set aCmpl64 ""
   set aCharSet "Unicode"
-  if { $isexec } {
+  if { $isExec } {
     set anExt "${anExt}x"
     set what "$what executable"
   }
@@ -1181,8 +1306,7 @@ proc osutils:vcproj:readtemplate {theVcVer isexec} {
   }
   set aTmpl [osutils:readtemplate $anExt "MS VC++ project ($what)"]
 
-  if { $theVcVer == "vc14-uwp" } {
-    set aVerExt "v140"
+  if { $isUWP } {
     set UwpWinRt "<CompileAsWinRT>false</CompileAsWinRT>"
     foreach bitness {32 64} {
       set indent ""
@@ -1209,8 +1333,8 @@ proc osutils:vcproj:readtemplate {theVcVer isexec} {
     set aReleaseLnk "\n      <OptimizeReferences>true</OptimizeReferences>\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>"
   }
 
-  regsub -all -- {__VCVER__}     $aTmpl $theVcVer aTmpl
-  regsub -all -- {__VCVEREXT__}  $aTmpl $aVerExt  aTmpl
+  regsub -all -- {__VCVER__}     $aTmpl $aVCRTVer aTmpl
+  regsub -all -- {__VCVEREXT__}  $aTmpl $aToolset aTmpl
   regsub -all -- {__VCCHARSET__} $aTmpl $aCharSet aTmpl
   regsub -all -- {__VCReleasePDB__} $aTmpl $aDebugInfo aTmpl
   regsub -all -- "${format_template}__VCLNKREL__" $aTmpl "${aReleaseLnk}" aTmpl
@@ -1236,15 +1360,24 @@ proc wokUtils:FILES:FileToString { fin } {
 
 # List extensions of compilable files in OCCT
 proc osutils:compilable {thePlatform} {
-  if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
-    return [list .c .cxx .cpp .mm]
-  }
+  if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .c .cxx .cpp .mm] }
   return [list .c .cxx .cpp]
 }
 
-proc osutils:commonUsedTK { theToolKit } {
+# List extensions of header file in OCCT
+proc osutils:fileExtensionsHeaders {thePlatform} {
+  if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } { return [list .h .hxx .hpp .lxx .pxx .gxx ] }
+  return [list .h .hxx .hpp .lxx .pxx .gxx .mm ]
+}
+
+# List extensions of Qt resource file in OCCT
+proc osutils:fileExtensionsResources {thePlatform} {
+  return [list .qrc ]
+}
+
+proc osutils:commonUsedTK { theToolKit theSrcDir theSourceDirOther} {
   set anUsedToolKits [list]
-  set aDepToolkits [LibToLink $theToolKit]
+  set aDepToolkits [LibToLink $theToolKit $theSrcDir $theSourceDirOther]
   foreach tkx $aDepToolkits {
     if {[_get_type $tkx] == "t"} {
       lappend anUsedToolKits "${tkx}"
@@ -1269,7 +1402,7 @@ proc osutils:tk:csfInExternlib { EXTERNLIB } {
 # @param theOS         - target OS
 # @param theCsfLibsMap - libraries  map
 # @param theCsfFrmsMap - frameworks map, OS X specific
-proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
+proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap theRelease} {
   upvar $theCsfLibsMap aLibsMap
   upvar $theCsfFrmsMap aFrmsMap
 
@@ -1285,13 +1418,12 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
     } else {
       set aLibsMap(CSF_FreeImagePlus) "freeimage"
     }
+  } elseif { "$theOS" == "wnt" } {
+    set aLibsMap(CSF_FreeImagePlus) "windowscodecs"
   }
   if { "$::HAVE_FFMPEG" == "true" } {
     set aLibsMap(CSF_FFmpeg) "avcodec avformat swscale avutil"
   }
-  if { "$::HAVE_GL2PS" == "true" } {
-    set aLibsMap(CSF_GL2PS) "gl2ps"
-  }
   if { "$::HAVE_TBB" == "true" } {
     set aLibsMap(CSF_TBB) "tbb tbbmalloc"
   }
@@ -1303,11 +1435,16 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
     }
   }
   if { "$::HAVE_ZLIB" == "true" } {
-    set aLibsMap(CSF_ZLIB) "zlib"
+    set aLibsMap(CSF_ZLIB) "z"
   }
   if { "$::HAVE_LIBLZMA" == "true" } {
     set aLibsMap(CSF_LIBLZMA) "liblzma"
   }
+  if { "$::HAVE_E57" == "true" && "$theOS" != "wnt" } {
+    # exclude wnt, as there are different pragma lib depending on debug/release
+    set aLibsMap(CSF_E57)    "E57RefImpl"
+    set aLibsMap(CSF_xerces) "xerces-c"
+  }
 
   if { "$theOS" == "wnt" } {
     #  WinAPI libraries
@@ -1315,9 +1452,11 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
     set aLibsMap(CSF_advapi32)     "advapi32"
     set aLibsMap(CSF_gdi32)        "gdi32"
     set aLibsMap(CSF_user32)       "user32 comdlg32"
+    set aLibsMap(CSF_shell32)      "shell32"
     set aLibsMap(CSF_opengl32)     "opengl32"
     set aLibsMap(CSF_wsock32)      "wsock32"
     set aLibsMap(CSF_netapi32)     "netapi32"
+    set aLibsMap(CSF_winmm)        "winmm"
     set aLibsMap(CSF_OpenGlLibs)   "opengl32"
     if { "$::HAVE_GLES2" == "true" } {
       set aLibsMap(CSF_OpenGlLibs) "libEGL libGLESv2"
@@ -1328,22 +1467,40 @@ proc osutils:csfList { theOS theCsfLibsMap theCsfFrmsMap } {
     # the naming is different on Windows
     set aLibsMap(CSF_TclLibs)      "tcl86"
     set aLibsMap(CSF_TclTkLibs)    "tk86"
-
-    set aLibsMap(CSF_QT)           "QtCore4 QtGui4"
+    if { "$theRelease" == "true" } {
+      set aLibsMap(CSF_QT)         "Qt5Gui Qt5Widgets Qt5Xml Qt5Core"
+    } else {
+      set aLibsMap(CSF_QT)         "Qt5Guid Qt5Widgetsd Qt5Xmld Qt5Cored"
+    }
 
     # tbb headers define different pragma lib depending on debug/release
     set aLibsMap(CSF_TBB) ""
+
+    if { "$::HAVE_ZLIB" == "true" } {
+      set aLibsMap(CSF_ZLIB) "zlib"
+    }
   } else {
-    if { "$theOS" == "mac" } {
+    set aLibsMap(CSF_dl)           "dl"
+    if { "$theOS" == "mac" || "$theOS" == "ios" } {
       set aLibsMap(CSF_objc)       "objc"
-      set aFrmsMap(CSF_Appkit)     "Appkit"
+      if { "$theOS" == "ios" } {
+        set aFrmsMap(CSF_Appkit)     "UIKit"
+        set aFrmsMap(CSF_OpenGlLibs) "OpenGLES"
+      } else {
+        set aFrmsMap(CSF_Appkit)     "AppKit"
+        set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
+      }
       set aFrmsMap(CSF_IOKit)      "IOKit"
-      set aFrmsMap(CSF_OpenGlLibs) "OpenGL"
       set aFrmsMap(CSF_TclLibs)    "Tcl"
       set aLibsMap(CSF_TclLibs)    ""
       set aFrmsMap(CSF_TclTkLibs)  "Tk"
       set aLibsMap(CSF_TclTkLibs)  ""
+      set aLibsMap(CSF_QT)         "QtCore QtGui"
+    } elseif { "$theOS" == "android" } {
+      set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
+      set aLibsMap(CSF_androidlog) "log"
     } else {
+      set aLibsMap(CSF_fontconfig) "fontconfig"
       if { "$theOS" == "qnx" } {
         # CSF_ThreadLibs - pthread API is part of libc on QNX
         set aLibsMap(CSF_OpenGlLibs) "EGL GLESv2"
@@ -1393,16 +1550,16 @@ proc osutils:vtkCsf {{theOS ""}} {
 
 # @param theLibsList   - dependencies (libraries  list)
 # @param theFrameworks - dependencies (frameworks list, OS X specific)
-proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
+proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks theSrcDir { theRelease true } } {
   global path
   upvar $theLibsList   aLibsList
   upvar $theFrameworks aFrameworks
   set aLibsList   [list]
   set aFrameworks [list]
 
-  osutils:csfList $theOS aLibsMap aFrmsMap
+  osutils:csfList $theOS aLibsMap aFrmsMap $theRelease
 
-  foreach aCsfElem [osutils:tk:csfInExternlib "$path/src/${theToolKit}/EXTERNLIB"] {
+  foreach aCsfElem [osutils:tk:csfInExternlib "$path/$theSrcDir/${theToolKit}/EXTERNLIB"] {
     if [info exists aLibsMap($aCsfElem)] {
       foreach aLib [split "$aLibsMap($aCsfElem)"] {
         if { [lsearch $aLibsList $aLib] == "-1" } {
@@ -1421,12 +1578,12 @@ proc osutils:usedOsLibs { theToolKit theOS theLibsList theFrameworks } {
 }
 
 # Returns liste of UD in a toolkit. tkloc is a full path wok.
-proc osutils:tk:units { tkloc } {
+proc osutils:tk:units { tkloc theSrcDir } {
   global path
   set l {}
-  set PACKAGES "$path/src/$tkloc/PACKAGES"
+  set PACKAGES "$path/$theSrcDir/$tkloc/PACKAGES"
   foreach u [wokUtils:FILES:FileToList $PACKAGES] {
-    if {[file isdirectory "$path/src/$u"]} {
+    if {[file isdirectory "$path/$theSrcDir/$u"]} {
       lappend l $u
     }
   }
@@ -1437,8 +1594,7 @@ proc osutils:tk:units { tkloc } {
 }
 
 proc osutils:justwnt { listloc } {
-  # ImageUtility is required for support for old (<6.5.4) versions of OCCT
-  set goaway [list Xdps Xw  ImageUtility WOKUnix]
+  set goaway [list Xw]
   return [osutils:juststation $goaway $listloc]
 }
 
@@ -1528,31 +1684,28 @@ proc wokUtils:FILES:wtail { f n } {
 }
 
 # Generate entry for one source file in Visual Studio 10 project file
-proc osutils:vcxproj:file { vcversion file params } {
-  append text "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
-  if { $params != "" } {
-    append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">[string trim ${params}]  %(AdditionalOptions)</AdditionalOptions>\n"
-  }
-
-  if { $params != "" } {
-    append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">[string trim ${params}]  %(AdditionalOptions)</AdditionalOptions>\n"
-  }
-
-  if { $params != "" } {
-    append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">[string trim ${params}]  %(AdditionalOptions)</AdditionalOptions>\n"
-  }
-
-  if { $params != "" } {
-    append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">[string trim ${params}]  %(AdditionalOptions)</AdditionalOptions>\n"
+proc osutils:vcxproj:cxxfile { theFile theParams theSrcFileLevel } {
+  if { $theParams == "" } {
+    return "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile $theSrcFileLevel]]\" />\n"
   }
 
+  set aParams [string trim ${theParams}]
+  append text "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\">\n"
+  append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
+  append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|Win32\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
+  append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Debug|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
+  append text "      <AdditionalOptions Condition=\"\'\$(Configuration)|\$(Platform)\'==\'Release|x64\'\">${aParams} %(AdditionalOptions)</AdditionalOptions>\n"
   append text "    </ClCompile>\n"
   return $text
 }
 
+# Generate entry for one header file in Visual Studio 10 project file
+proc osutils:vcxproj:hxxfile { theFile } { return "    <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $theFile 3]]\" />\n" }
+
 # Generate Visual Studio 2010 project filters file
-proc osutils:vcxproj:filters { dir proj theFilesMap } {
-  upvar $theFilesMap aFilesMap
+proc osutils:vcxproj:filters { dir proj theCxxFilesMap theHxxFilesMap } {
+  upvar $theCxxFilesMap aCxxFilesMap
+  upvar $theHxxFilesMap aHxxFilesMap
 
   # header
   append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
@@ -1563,17 +1716,25 @@ proc osutils:vcxproj:filters { dir proj theFilesMap } {
   append text "    <Filter Include=\"Source files\">\n"
   append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
   append text "    </Filter>\n"
-  foreach unit $aFilesMap(units) {
+  append text "    <Filter Include=\"Header files\">\n"
+  append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
+  append text "    </Filter>\n"
+  foreach unit $aCxxFilesMap(units) {
     append text "    <Filter Include=\"Source files\\${unit}\">\n"
     append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
     append text "    </Filter>\n"
   }
+  foreach unit $aHxxFilesMap(units) {
+    append text "    <Filter Include=\"Header files\\${unit}\">\n"
+    append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
+    append text "    </Filter>\n"
+  }
   append text "  </ItemGroup>\n"
 
-  # list of files
+  # list of cxx files
   append text "  <ItemGroup>\n"
-  foreach unit $aFilesMap(units) {
-    foreach file $aFilesMap($unit) {
+  foreach unit $aCxxFilesMap(units) {
+    foreach file $aCxxFilesMap($unit) {
       append text "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
       append text "      <Filter>Source files\\${unit}</Filter>\n"
       append text "    </ClCompile>\n"
@@ -1581,51 +1742,19 @@ proc osutils:vcxproj:filters { dir proj theFilesMap } {
   }
   append text "  </ItemGroup>\n"
 
-  # end
-  append text "</Project>"
-
-  # write file
-  set fp [open [set fvcproj [file join $dir ${proj}.vcxproj.filters]] w]
-  fconfigure $fp -translation crlf
-  puts $fp $text
-  close $fp
-
-  return ${proj}.vcxproj.filters
-}
-
-# Generate Visual Studio 2011 project filters file
-proc osutils:vcx1proj:filters { dir proj theFilesMap } {
-  upvar $theFilesMap aFilesMap
-
-  # header
-  append text "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
-  append text "<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n"
-
-  # list of "filters" (units)
+  # list of hxx files
   append text "  <ItemGroup>\n"
-  append text "    <Filter Include=\"Source files\">\n"
-  append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
-  append text "    </Filter>\n"
-  foreach unit $aFilesMap(units) {
-    append text "    <Filter Include=\"Source files\\${unit}\">\n"
-    append text "      <UniqueIdentifier>[OS:genGUID]</UniqueIdentifier>\n"
-    append text "    </Filter>\n"
-  }
-  append text "  </ItemGroup>\n"
-
-  # list of files
-  append text "  <ItemGroup>\n"
-  foreach unit $aFilesMap(units) {
-    foreach file $aFilesMap($unit) {
-      append text "    <ClCompile Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
-      append text "      <Filter>Source files\\${unit}</Filter>\n"
-      append text "    </ClCompile>\n"
+  foreach unit $aHxxFilesMap(units) {
+    foreach file $aHxxFilesMap($unit) {
+      append text "    <ClInclude Include=\"..\\..\\..\\[wokUtils:EASY:bs1 [wokUtils:FILES:wtail $file 3]]\">\n"
+      append text "      <Filter>Header files\\${unit}</Filter>\n"
+      append text "    </ClInclude>\n"
     }
   }
   append text "  </ItemGroup>\n"
 
   append text "  <ItemGroup>\n"
-  append text "    <ResourceCompile Include=\"${proj}.rc\" />"
+  append text "    <ResourceCompile Include=\"${proj}.rc\" />\n"
   append text "  </ItemGroup>\n"
 
   # end
@@ -1654,8 +1783,16 @@ proc osutils:readtemplate:rc {theOutDir theToolKit} {
 }
 
 # Generate Visual Studio project file for ToolKit
-proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
-  if { $theProjTmpl == {} } {set theProjTmpl [osutils:vcproj:readtemplate $theVcVer 0]}
+proc osutils:vcproj { theVcVer isUWP theOutDir theToolKit theGuidsMap theSrcDir theSourceDirOther } {
+  global path
+
+  set aHasQtDep "false"
+  foreach aCsfElem [osutils:tk:csfInExternlib "$path/$theSrcDir/${theToolKit}/EXTERNLIB"] {
+    if { "$aCsfElem" == "CSF_QT" } {
+      set aHasQtDep "true"
+    }
+  }
+  set theProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 0]
 
   set l_compilable [osutils:compilable wnt]
   regsub -all -- {__TKNAM__} $theProjTmpl $theToolKit theProjTmpl
@@ -1666,40 +1803,34 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
   }
   regsub -all -- {__PROJECT_GUID__} $theProjTmpl $aGuidsMap($theToolKit) theProjTmpl
 
-  set theProjTmpl [osutils:uwp:proj ${theVcVer} ${theProjTmpl}]
+  set theProjTmpl [osutils:uwp:proj $isUWP ${theProjTmpl}]
 
   set aUsedLibs [list]
 
-  if { "$theVcVer" == "vc14-uwp" } {
+  if { $isUWP } {
     lappend aUsedLibs "WindowsApp.lib"
   }
 
-  foreach tkx [osutils:commonUsedTK  $theToolKit] {
+  foreach tkx [osutils:commonUsedTK  $theToolKit $theSrcDir $theSourceDirOther] {
     lappend aUsedLibs "${tkx}.lib"
   }
 
-  osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
-  foreach aLibIter $aLibs {
-    lappend aUsedLibs "${aLibIter}.lib"
-  }
+  set anOsReleaseLibs {}
+  set anOsDebugLibs {}
+  osutils:usedOsLibs $theToolKit "wnt" anOsReleaseLibs aFrameworks $theSrcDir true
+  osutils:usedOsLibs $theToolKit "wnt" anOsDebugLibs aFrameworks $theSrcDir false
 
   # correct names of referred third-party libraries that are named with suffix
   # depending on VC version
-  regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
-
-  # and put this list to project file
-  #puts "$theToolKit requires  $aUsedLibs"
-  if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
-    set aUsedLibs [join $aUsedLibs {;}]
-  }
-  regsub -all -- {__TKDEP__} $theProjTmpl $aUsedLibs theProjTmpl
+  regsub -all -- {__TKDEP__} $theProjTmpl [osutils:depLibraries $aUsedLibs $anOsReleaseLibs $theVcVer] theProjTmpl
+  regsub -all -- {__TKDEP_DEBUG__} $theProjTmpl [osutils:depLibraries $aUsedLibs $anOsDebugLibs $theVcVer] theProjTmpl
 
   set anIncPaths "..\\..\\..\\inc"
-  set aTKDefines ""
+#  set aTKDefines ""
   set aFilesSection ""
-  set aVcFilesX(units) ""
-  set listloc [osutils:tk:units $theToolKit]
-  set resultloc [osutils:justwnt $listloc]
+  set aVcFilesCxx(units) ""
+  set aVcFilesHxx(units) ""
+  set listloc [osutils:tk:units $theToolKit $theSrcDir]
   if [array exists written] { unset written }
   #puts "\t1 [wokparam -v %CMPLRS_CXX_Options [w_info -f]] father"
   #puts "\t2 [wokparam -v %CMPLRS_CXX_Options] branch"
@@ -1708,10 +1839,25 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
   set fxloparamfcxx [lindex [osutils:intersect3 [_get_options wnt cmplrs_cxx f] [_get_options wnt cmplrs_cxx b]] 2]
   set fxloparamfc   [lindex [osutils:intersect3 [_get_options wnt cmplrs_c f] [_get_options wnt cmplrs_c b]] 2]
   set fxloparam ""
-  foreach fxlo $resultloc {
+  foreach fxlo $listloc {
     set xlo $fxlo
-    set aSrcFiles [osutils:tk:files $xlo wnt]
-       set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
+    set aSrcFiles [osutils:tk:cxxfiles $xlo wnt $theSrcDir]
+    set aHxxFiles [osutils:tk:hxxfiles $xlo wnt $theSrcDir]
+
+    # prepare Qt moc files, appears only in Inspector - directory tools
+    set aGeneratedFiles {}
+    if { "$aHasQtDep" == "true" } {
+      set aMocResFiles [osutils:tk:mocfiles $aHxxFiles $theOutDir]
+      set aGeneratedFiles [osutils:tk:execfiles $aMocResFiles $theOutDir moc${::SYS_EXE_SUFFIX} moc cpp]
+
+      set aQrcResFiles [osutils:tk:qrcfiles $xlo wnt $theSrcDir]
+      set aQrcFiles [osutils:tk:execfiles $aQrcResFiles $theOutDir rcc${::SYS_EXE_SUFFIX} rcc cpp]
+      foreach resFile $aQrcFiles {
+        lappend aGeneratedFiles $resFile
+      }
+    }
+
+    set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx $fxlo]
     if {$fxlo_cmplrs_options_cxx == ""} {
       set fxlo_cmplrs_options_cxx [_get_options wnt cmplrs_cxx b]
     }
@@ -1739,12 +1885,32 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
       foreach aSrcFile [lsort $aSrcFiles] {
         if { ![info exists written([file tail $aSrcFile])] } {
           set written([file tail $aSrcFile]) 1
-          append aFilesSection [osutils:vcxproj:file $theVcVer $aSrcFile $needparam]
+          append aFilesSection [osutils:vcxproj:cxxfile $aSrcFile $needparam 3]
         } else {
           puts "Warning : in vcproj more than one occurences for [file tail $aSrcFile]"
         }
-        if { ! [info exists aVcFilesX($xlo)] } { lappend aVcFilesX(units) $xlo }
-        lappend aVcFilesX($xlo) $aSrcFile
+        if { ! [info exists aVcFilesCxx($xlo)] } { lappend aVcFilesCxx(units) $xlo }
+        lappend aVcFilesCxx($xlo) $aSrcFile
+      }
+      foreach aHxxFile [lsort $aHxxFiles] {
+        if { ![info exists written([file tail $aHxxFile])] } {
+          set written([file tail $aHxxFile]) 1
+          append aFilesSection [osutils:vcxproj:hxxfile $aHxxFile]
+        } else {
+          puts "Warning : in vcproj more than one occurences for [file tail $aHxxFile]"
+        }
+        if { ! [info exists aVcFilesHxx($xlo)] } { lappend aVcFilesHxx(units) $xlo }
+        lappend aVcFilesHxx($xlo) $aHxxFile
+      }
+      foreach aGenFile [lsort $aGeneratedFiles] {
+        if { ![info exists written([file tail $aGenFile])] } {
+          set written([file tail $aGenFile]) 1
+          append aFilesSection [osutils:vcxproj:cxxfile $aGenFile $needparam 5]
+        } else {
+          puts "Warning : in vcproj more than one occurences for [file tail $aGenFile]"
+        }
+        if { ! [info exists aVcFilesCxx($xlo)] } { lappend aVcFilesCxx(units) $xlo }
+        lappend aVcFilesCxx($xlo) $aGenFile
       }
     } else {
       append aFilesSection "\t\t\t<Filter\n"
@@ -1760,15 +1926,9 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
       }
       append aFilesSection "\t\t\t</Filter>\n"
     }
-
-    # macros
-    append aTKDefines ";__${xlo}_DLL"
-    # common includes
-#    append anIncPaths ";..\\..\\..\\src\\${xlo}"
   }
 
   regsub -all -- {__TKINC__}  $theProjTmpl $anIncPaths theProjTmpl
-  regsub -all -- {__TKDEFS__} $theProjTmpl $aTKDefines theProjTmpl
   regsub -all -- {__FILES__}  $theProjTmpl $aFilesSection theProjTmpl
 
   # write file
@@ -1778,12 +1938,8 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
   close $aFile
 
   # write filters file for vc10+
-  if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" || "$theVcVer" == "vc9" } {
-    # nothing
-  } elseif { "$theVcVer" == "vc10" } {
-    lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesX]
-  } else {
-    lappend aVcFiles [osutils:vcx1proj:filters $theOutDir $theToolKit aVcFilesX]
+  if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
+    lappend aVcFiles [osutils:vcxproj:filters $theOutDir $theToolKit aVcFilesCxx aVcFilesHxx]
   }
 
   # write resource file
@@ -1792,14 +1948,40 @@ proc osutils:vcproj { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
   return $aVcFiles
 }
 
+# Appends OS libraries into the list of used libraries.
+# Corrects list of referred third-party libraries that are named with suffix
+# depending on VC version
+# Unites list of used libraries into a variable with separator for VStudio older than vc9
+# @param theUsedLibs List of libraries, to be changed
+# @param theOsLibs List of Os library names, before using an extension should be added
+# @param theVcVer version of VStudio
+
+proc osutils:depLibraries { theUsedLibs theOsLibs theVcVer } {
+  foreach aLibIter $theOsLibs {
+    lappend theUsedLibs "${aLibIter}.${::SYS_LIB_SUFFIX}"
+  }
+
+  # correct names of referred third-party libraries that are named with suffix
+  # depending on VC version
+  set aVCRTVer [string range $theVcVer 0 3]
+  regsub -all -- {vc[0-9]+} $theUsedLibs $aVCRTVer theUsedLibs
+
+  # and put this list to project file
+  if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
+    set theUsedLibs [join $theUsedLibs {;}]
+  }
+
+  return $theUsedLibs
+}
+
 # for a unit returns a map containing all its file in the current
 # workbench
 # local = 1 only local files
-proc osutils:tk:loadunit { loc map } {
+proc osutils:tk:loadunit { loc map theSrcDir} {
   #puts $loc
   upvar $map TLOC
   catch { unset TLOC }
-  set lfiles [_get_used_files $loc]
+  set lfiles [_get_used_files $loc $theSrcDir]
   foreach f $lfiles {
     #puts "\t$f"
     set t [lindex $f 0]
@@ -1815,16 +1997,14 @@ proc osutils:tk:loadunit { loc map } {
   return
 }
 
-# Returns the list of all compilable files name in a toolkit, or devunit of any type
-# Tfiles lists for each unit the type of file that can be compiled.
-proc osutils:tk:files { tkloc thePlatform } {
+# Returns the list of all files name in a toolkit within specified list of file extensions.
+proc osutils:tk:files { tkloc theExtensions theSrcDir } {
   set Tfiles(source,nocdlpack)     {source pubinclude}
   set Tfiles(source,toolkit)       {}
   set Tfiles(source,executable)    {source pubinclude}
-  set listloc [concat [osutils:tk:units $tkloc] $tkloc]
+  set listloc [concat [osutils:tk:units $tkloc $theSrcDir] $tkloc ]
   #puts " listloc = $listloc"
 
-  set l_comp [osutils:compilable $thePlatform]
   set resultloc $listloc
   set lret {}
   foreach loc $resultloc {
@@ -1834,9 +2014,10 @@ proc osutils:tk:files { tkloc thePlatform } {
          "t" { set utyp "toolkit" }
          "n" { set utyp "nocdlpack" }
          "x" { set utyp "executable" }
+         default { error "Error: Cannot determine type of unit $loc, check adm/UDLIST!" }
     }
     if [array exists map] { unset map }
-    osutils:tk:loadunit $loc map
+    osutils:tk:loadunit $loc map $theSrcDir
     #puts " loc = $loc === > [array names map]"
     set LType $Tfiles(source,${utyp})
     foreach typ [array names map] {
@@ -1848,7 +2029,7 @@ proc osutils:tk:files { tkloc thePlatform } {
       #puts $type
       foreach f $map($type) {
         #puts $f
-        if { [lsearch $l_comp [file extension $f]] != -1 } {
+        if { [lsearch $theExtensions [file extension $f]] != -1 } {
           lappend lret $f
         }
       }
@@ -1857,15 +2038,55 @@ proc osutils:tk:files { tkloc thePlatform } {
   return $lret
 }
 
+# Returns the list of all compilable files name in a toolkit.
+proc osutils:tk:cxxfiles { tkloc thePlatform theSrcDir } { return [osutils:tk:files $tkloc [osutils:compilable $thePlatform] $theSrcDir] }
+
+# Returns the list of all header files name in a toolkit.
+proc osutils:tk:hxxfiles { tkloc thePlatform theSrcDir } { return [osutils:tk:files $tkloc [osutils:fileExtensionsHeaders $thePlatform] $theSrcDir] }
+
+# Returns the list of all resource (qrc) files name in a toolkit.
+proc osutils:tk:qrcfiles { tkloc thePlatform theSourceDir } { return [osutils:tk:files $tkloc [osutils:fileExtensionsResources $thePlatform] $theSourceDir] }
+
+# Returns the list of all header files name in a toolkit.
+proc osutils:tk:mocfiles { HxxFiles theOutDir } {
+  set lret {}
+  foreach file $HxxFiles {
+    # processing only files where Q_OBJECT exists
+    set fd [open "$file" rb]
+    set FILES [split [read $fd] "\n"]
+    close $fd
+
+    set isQObject [expr [regexp "Q_OBJECT" $FILES]]
+    if { ! $isQObject } {
+      continue;
+    }
+    lappend lret $file
+  }
+  return $lret
+}
+
+# Returns the list of all header files name in a toolkit.
+proc osutils:tk:execfiles { theFiles theOutDir theCommand thePrefix theExtension} {
+  set lret {}
+  set anOutDir $theOutDir/$thePrefix
+  file mkdir $anOutDir
+
+  foreach file $theFiles {
+    set aResourceName [file tail $file]
+    set anOutFile $anOutDir/${thePrefix}_[file rootname $aResourceName].$theExtension
+
+    exec $theCommand $file -o $anOutFile
+    lappend lret $anOutFile
+  }
+  return $lret
+}
+
 # Generate Visual Studio project file for executable
-proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {} } } {
+proc osutils:vcprojx { theVcVer isUWP theOutDir theToolKit theGuidsMap theSrcDir theSourceDirOther } {
   set aVcFiles {}
-  foreach f [osutils:tk:files $theToolKit wnt] {
-    if { $theProjTmpl == {} } {
-      set aProjTmpl [osutils:vcproj:readtemplate $theVcVer 1]
-    } else {
-      set aProjTmpl $theProjTmpl
-    }
+  foreach f [osutils:tk:cxxfiles $theToolKit wnt $theSrcDir] {
+    set aProjTmpl [osutils:vcproj:readtemplate $theVcVer $isUWP 1]
+
     set aProjName [file rootname [file tail $f]]
     set l_compilable [osutils:compilable wnt]
     regsub -all -- {__XQTNAM__} $aProjTmpl $aProjName aProjTmpl
@@ -1877,35 +2098,30 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
     regsub -all -- {__PROJECT_GUID__} $aProjTmpl $aGuidsMap($aProjName) aProjTmpl
 
     set aUsedLibs [list]
-    foreach tkx [osutils:commonUsedTK  $theToolKit] {
+    foreach tkx [osutils:commonUsedTK  $theToolKit $theSrcDir $theSourceDirOther] {
       lappend aUsedLibs "${tkx}.lib"
     }
 
-    osutils:usedOsLibs $theToolKit "wnt" aLibs aFrameworks
-    foreach aLibIter $aLibs {
-      lappend aUsedLibs "${aLibIter}.lib"
-    }
+    set anOsReleaseLibs {}
+    set anOsDebugLibs {}
+    osutils:usedOsLibs $theToolKit "wnt" anOsReleaseLibs aFrameworks $theSrcDir true
+    osutils:usedOsLibs $theToolKit "wnt" anOsDebugLibs aFrameworks $theSrcDir false
 
-    # correct names of referred third-party libraries that are named with suffix
-    # depending on VC version
-    regsub -all -- {vc[0-9]+} $aUsedLibs $theVcVer aUsedLibs
-
-#    puts "$aProjName requires  $aUsedLibs"
-    if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
-      set aUsedLibs [join $aUsedLibs {;}]
-    }
-    regsub -all -- {__TKDEP__} $aProjTmpl $aUsedLibs aProjTmpl
+    set aVCRTVer [string range $theVcVer 0 3]
+    regsub -all -- {__TKDEP__} $aProjTmpl [osutils:depLibraries $aUsedLibs $anOsReleaseLibs $theVcVer] aProjTmpl
+    regsub -all -- {__TKDEP_DEBUG__} $aProjTmpl [osutils:depLibraries $aUsedLibs $anOsDebugLibs $theVcVer] aProjTmpl
 
     set aFilesSection ""
-    set aVcFilesX(units) ""
+    set aVcFilesCxx(units) ""
+       set aVcFilesHxx(units) ""
 
     if { ![info exists written([file tail $f])] } {
       set written([file tail $f]) 1
 
       if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
-        append aFilesSection [osutils:vcxproj:file $theVcVer $f ""]
-        if { ! [info exists aVcFilesX($theToolKit)] } { lappend aVcFilesX(units) $theToolKit }
-        lappend aVcFilesX($theToolKit) $f
+        append aFilesSection [osutils:vcxproj:cxxfile $f "" 3]
+        if { ! [info exists aVcFilesCxx($theToolKit)] } { lappend aVcFilesCxx(units) $theToolKit }
+        lappend aVcFilesCxx($theToolKit) $f
       } else {
         append aFilesSection "\t\t\t<Filter\n"
         append aFilesSection "\t\t\t\tName=\"$theToolKit\"\n"
@@ -1914,13 +2130,11 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
         append aFilesSection "\t\t\t</Filter>"
       }
     } else {
-      puts "Warning : in vcproj there are than one occurences for [file tail $f]"
+      puts "Warning : in vcproj there are more than one occurences for [file tail $f]"
     }
     #puts "$aProjTmpl $aFilesSection"
-    set aTKDefines ";__${theToolKit}_DLL"
     set anIncPaths "..\\..\\..\\inc"
     regsub -all -- {__TKINC__}  $aProjTmpl $anIncPaths    aProjTmpl
-    regsub -all -- {__TKDEFS__} $aProjTmpl $aTKDefines    aProjTmpl
     regsub -all -- {__FILES__}  $aProjTmpl $aFilesSection aProjTmpl
     regsub -all -- {__CONF__}   $aProjTmpl Application    aProjTmpl
 
@@ -1936,9 +2150,12 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
 
     # write filters file for vc10
     if { "$theVcVer" != "vc7" && "$theVcVer" != "vc8" && "$theVcVer" != "vc9" } {
-      lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesX]
+      lappend aVcFiles [osutils:vcxproj:filters $theOutDir $aProjName aVcFilesCxx aVcFilesHxx]
     }
 
+    # write resource file
+    lappend aVcFiles [osutils:readtemplate:rc $theOutDir $aProjName]
+
     set aCommonSettingsFileTmpl ""
     if { "$theVcVer" == "vc7" || "$theVcVer" == "vc8" } {
       # nothing
@@ -1948,7 +2165,7 @@ proc osutils:vcprojx { theVcVer theOutDir theToolKit theGuidsMap {theProjTmpl {}
       set aCommonSettingsFileTmpl [wokUtils:FILES:FileToString "$::THE_CASROOT/adm/templates/vcxproj.user.vc10x"]
     }
     if { "$aCommonSettingsFileTmpl" != "" } {
-      regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $theVcVer aCommonSettingsFileTmpl
+      regsub -all -- {__VCVER__} $aCommonSettingsFileTmpl $aVCRTVer aCommonSettingsFileTmpl
 
       set aFile [open [set aVcFilePath "$aCommonSettingsFile"] w]
       fconfigure $aFile -translation crlf
@@ -2100,20 +2317,20 @@ proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
   set aTKSrcFiles   [list]
 
   # collect list of referred libraries to link with
-  osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
-  set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
+  osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks "src"
+  set aDepToolkits [wokUtils:LIST:Purge [osutils:tk:close $theToolKit "src" ""]]
   foreach tkx $aDepToolkits {
     lappend aUsedLibs "${tkx}"
   }
 
   lappend anIncPaths "../../../inc"
-  set listloc [osutils:tk:units $theToolKit]
+  set listloc [osutils:tk:units $theToolKit "src"]
 
   if { [llength $listloc] == 0 } {
     set listloc $theToolKit
   }
 
-  if { $thePlatform == "wnt" } {
+  if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
     set resultloc [osutils:justwnt  $listloc]
   } else {
     set resultloc [osutils:justunix $listloc]
@@ -2121,7 +2338,7 @@ proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
   if [array exists written] { unset written }
   foreach fxlo $resultloc {
     set xlo       $fxlo
-    set aSrcFiles [osutils:tk:files $xlo $thePlatform]
+    set aSrcFiles [osutils:tk:cxxfiles $xlo $thePlatform "src"]
     foreach aSrcFile [lsort $aSrcFiles] {
       if { ![info exists written([file tail $aSrcFile])] } {
         set written([file tail $aSrcFile]) 1
@@ -2132,9 +2349,9 @@ proc osutils:cbptk { theCmpl theOutDir theToolKit thePlatform} {
     }
 
     # macros for correct DLL exports
-    if { $thePlatform == "wnt" } {
-      lappend aTKDefines "__${xlo}_DLL"
-    }
+#    if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
+#      lappend aTKDefines "__${xlo}_DLL"
+#    }
   }
 
   return [osutils:cbp $theCmpl $theOutDir $theToolKit $thePlatform $aTKSrcFiles $aUsedLibs $aFrameworks $anIncPaths $aTKDefines]
@@ -2153,8 +2370,8 @@ proc OS:cworkspace { theSolName theModules theOutDir } {
   # collect list of projects to be created
   foreach aModule $theModules {
     # toolkits
-    foreach aToolKit [osutils:tk:sort [${aModule}:toolkits]] {
-      set aDependencies [LibToLink $aToolKit]
+    foreach aToolKit [osutils:tk:sort [${aModule}:toolkits] "src" ""] {
+      set aDependencies [LibToLink $aToolKit "src" ""]
       if { [llength $aDependencies] == 0 } {
         puts $aFile "\t\t<Project filename=\"${aToolKit}.cbp\" />"
       } else {
@@ -2169,7 +2386,7 @@ proc OS:cworkspace { theSolName theModules theOutDir } {
     # executables, assume one project per cxx file...
     foreach aUnit [OS:executable ${aModule}] {
       set aUnitLoc $aUnit
-      set src_files [_get_used_files $aUnit false]
+      set src_files [_get_used_files $aUnit "src" false]
       set aSrcFiles {}
       foreach s $src_files { 
         regexp {source ([^\s]+)} $s dummy name
@@ -2181,7 +2398,7 @@ proc OS:cworkspace { theSolName theModules theOutDir } {
           set aPrjName [file rootname $aSrcFile]
           set aDependencies [list]
           if {[file isdirectory $path/src/$aUnitLoc]} {
-            set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile]]
+            set aDependencies [LibToLinkX $aUnitLoc [file rootname $aSrcFile] "src" ""]
           }
           set anActiveState ""
           if { $isActiveSet == 0 } {
@@ -2215,7 +2432,7 @@ proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
   set aWokArch    "$::env(ARCH)"
 
   set aCbpFiles {}
-  foreach aSrcFile [osutils:tk:files $theToolKit $thePlatform] {
+  foreach aSrcFile [osutils:tk:cxxfiles $theToolKit $thePlatform "src"] {
     # collect list of referred libraries to link with
     set aUsedLibs     [list]
     set aFrameworks   [list]
@@ -2224,9 +2441,9 @@ proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
     set aTKSrcFiles   [list]
     set aProjName [file rootname [file tail $aSrcFile]]
 
-    osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks
+    osutils:usedOsLibs $theToolKit $thePlatform aUsedLibs aFrameworks "src"
 
-    set aDepToolkits [LibToLinkX $theToolKit $aProjName]
+    set aDepToolkits [LibToLinkX $theToolKit $aProjName "src" ""]
     foreach tkx $aDepToolkits {
       if {[_get_type $tkx] == "t"} {
         lappend aUsedLibs "${tkx}"
@@ -2251,9 +2468,9 @@ proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
     }
 
     # macros for correct DLL exports
-    if { $thePlatform == "wnt" } {
-      lappend aTKDefines "__${theToolKit}_DLL"
-    }
+#    if { $thePlatform == "wnt" || $thePlatform == "uwp" } {
+#      lappend aTKDefines "__${theToolKit}_DLL"
+#    }
 
     # common include paths
     lappend anIncPaths "../../../inc"
@@ -2275,7 +2492,6 @@ proc osutils:cbpx { theCmpl theOutDir theToolKit thePlatform } {
 # @param theDefines    - compiler macro definitions
 # @param theIsExe      - flag to indicate executable / library target
 proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibsList theFrameworks theIncPaths theDefines {theIsExe "false"} } {
-  set aWokStation $thePlatform
   set aWokArch    "$::env(ARCH)"
 
   set aCmplCbp "gcc"
@@ -2284,7 +2500,11 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
   set aCmplFlagsDebug   [list]
   set toPassArgsByFile 0
   set aLibPrefix "lib"
-  if { "$aWokStation" == "wnt" || "$aWokStation" == "qnx" } {
+  set aPlatformAndCompiler "${thePlatform}/gcc"
+  if { "$thePlatform" == "mac" || "$thePlatform" == "ios" } {
+    set aPlatformAndCompiler "${thePlatform}/clang"
+  }
+  if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" || "$thePlatform" == "qnx" } {
     set toPassArgsByFile 1
   }
   if { "$theCmpl" == "msvc" } {
@@ -2299,12 +2519,12 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
     lappend aCmplFlags    "-D_CRT_SECURE_NO_WARNINGS"
     lappend aCmplFlags    "-D_CRT_NONSTDC_NO_DEPRECATE"
   } elseif { "$theCmpl" == "gcc" } {
-    if { "$aWokStation" != "qnx" } {
+    if { "$thePlatform" != "qnx" } {
       set aCmplFlags      "-mmmx -msse -msse2 -mfpmath=sse"
     }
     set aCmplFlagsRelease "-O2"
     set aCmplFlagsDebug   "-O0 -g"
-    if { "$aWokStation" == "wnt" } {
+    if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
       lappend aCmplFlags "-std=gnu++0x"
       lappend aCmplFlags "-D_WIN32_WINNT=0x0501"
     } else {
@@ -2318,7 +2538,7 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
   lappend aCmplFlagsRelease "-DNDEBUG"
   lappend aCmplFlagsRelease "-DNo_Exception"
   lappend aCmplFlagsDebug   "-D_DEBUG"
-  if { "$aWokStation" == "qnx" } {
+  if { "$thePlatform" == "qnx" } {
     lappend aCmplFlags "-D_QNX_SOURCE"
   }
 
@@ -2340,20 +2560,20 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
   # Release target configuration
   puts $aFile "\t\t\t<Target title=\"Release\">"
   if { "$theIsExe" == "true" } {
-    puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
+    puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bin/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
     puts $aFile "\t\t\t\t<Option type=\"1\" />"
   } else {
-    if { "$aWokStation" == "wnt" } {
-      puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bin/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aWokStation}/cbp/lib/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
+    if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
+      puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bin/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aPlatformAndCompiler}/lib/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
     } else {
-      puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
+      puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/lib/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
     }
     puts $aFile "\t\t\t\t<Option type=\"3\" />"
   }
-  puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/obj\" />"
+  puts $aFile "\t\t\t\t<Option object_output=\"../../../${aPlatformAndCompiler}/obj\" />"
   puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
   puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
-  if { "$aWokStation" == "wnt" } {
+  if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
     puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
   } else {
     puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
@@ -2373,15 +2593,15 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
   if { $toPassArgsByFile == 1 } {
     puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkFileName\" />"
   }
-  puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/lib\" />"
-  if { "$aWokStation" == "mac" } {
+  puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aPlatformAndCompiler}/lib\" />"
+  if { "$thePlatform" == "mac" } {
     if { [ lsearch $theLibsList X11 ] >= 0} {
       puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
     }
   }
   puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch})\" />"
-  if { "$aWokStation" == "lin" } {
-    puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aWokStation}/cbp/lib\" />"
+  if { "$thePlatform" == "lin" } {
+    puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aPlatformAndCompiler}/lib\" />"
   }
   puts $aFile "\t\t\t\t</Linker>"
 
@@ -2390,20 +2610,20 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
   # Debug target configuration
   puts $aFile "\t\t\t<Target title=\"Debug\">"
   if { "$theIsExe" == "true" } {
-    puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
+    puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bind/${theProjName}\" prefix_auto=\"0\" extension_auto=\"0\" />"
     puts $aFile "\t\t\t\t<Option type=\"1\" />"
   } else {
-    if { "$aWokStation" == "wnt" } {
-      puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/bind/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aWokStation}/cbp/libd/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
+    if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
+      puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/bind/${aLibPrefix}${theProjName}\" imp_lib=\"../../../${aPlatformAndCompiler}/libd/\$(TARGET_OUTPUT_BASENAME)\" prefix_auto=\"1\" extension_auto=\"1\" />"
     } else {
-      puts $aFile "\t\t\t\t<Option output=\"../../../${aWokStation}/cbp/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
+      puts $aFile "\t\t\t\t<Option output=\"../../../${aPlatformAndCompiler}/libd/lib${theProjName}.so\" prefix_auto=\"0\" extension_auto=\"0\" />"
     }
     puts $aFile "\t\t\t\t<Option type=\"3\" />"
   }
-  puts $aFile "\t\t\t\t<Option object_output=\"../../../${aWokStation}/cbp/objd\" />"
+  puts $aFile "\t\t\t\t<Option object_output=\"../../../${aPlatformAndCompiler}/objd\" />"
   puts $aFile "\t\t\t\t<Option compiler=\"$aCmplCbp\" />"
   puts $aFile "\t\t\t\t<Option createDefFile=\"0\" />"
-  if { "$aWokStation" == "wnt" } {
+  if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
     puts $aFile "\t\t\t\t<Option createStaticLib=\"1\" />"
   } else {
     puts $aFile "\t\t\t\t<Option createStaticLib=\"0\" />"
@@ -2423,15 +2643,15 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
   if { $toPassArgsByFile == 1 } {
     puts $aFile "\t\t\t\t\t<Add option=\"\@$aLnkDebFileName\" />"
   }
-  puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aWokStation}/cbp/libd\" />"
-  if { "$aWokStation" == "mac" } {
+  puts $aFile "\t\t\t\t\t<Add directory=\"../../../${aPlatformAndCompiler}/libd\" />"
+  if { "$thePlatform" == "mac" } {
     if { [ lsearch $theLibsList X11 ] >= 0} {
       puts $aFile "\t\t\t\t\t<Add directory=\"/usr/X11/lib\" />"
     }
   }
   puts $aFile "\t\t\t\t\t<Add option=\"\$(CSF_OPT_LNK${aWokArch}D)\" />"
-  if { "$aWokStation" == "lin" } {
-    puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aWokStation}/cbp/libd\" />"
+  if { "$thePlatform" == "lin" } {
+    puts $aFile "\t\t\t\t\t<Add option=\"-Wl,-rpath-link=../../../${aPlatformAndCompiler}/libd\" />"
   }
   puts $aFile "\t\t\t\t</Linker>"
 
@@ -2452,7 +2672,7 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
 
   # COMMON linker options
   puts $aFile "\t\t<Linker>"
-  if { "$aWokStation" == "wnt" && "$theCmpl" == "gcc" } {
+  if { "$thePlatform" == "wnt" && "$theCmpl" == "gcc" } {
     puts $aFile "\t\t\t<Add option=\"-Wl,--export-all-symbols\" />"
   }
   foreach aFrameworkName $theFrameworks {
@@ -2498,8 +2718,8 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
       puts $aFile "\t\t\t<Option link=\"0\" />"
       puts $aFile "\t\t</Unit>"
 
-      set aFileObj  [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/obj/src/"]  $aSrcFile]]
-      set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/$aWokStation/cbp/objd/src/"] $aSrcFile]]
+      set aFileObj  [string map {.cxx .o} [string map [list "/src/" "/${aPlatformAndCompiler}/obj/src/"]  $aSrcFile]]
+      set aFileObjd [string map {.cxx .o} [string map [list "/src/" "/${aPlatformAndCompiler}/objd/src/"] $aSrcFile]]
       puts -nonewline $aFileLnkObj  "$aFileObj "
       puts -nonewline $aFileLnkObjd "$aFileObjd "
     } else {
@@ -2508,7 +2728,7 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
     }
   }
 
-  if { "$aWokStation" == "wnt" } {
+  if { "$thePlatform" == "wnt" || "$thePlatform" == "uwp" } {
     close $aFileLnkObj
     close $aFileLnkObjd
   }
@@ -2521,8 +2741,8 @@ proc osutils:cbp { theCmpl theOutDir theProjName thePlatform theSrcFiles theLibs
 }
 
 # Define libraries to link using only EXTERNLIB file
-proc LibToLinkX {thePackage theDummyName} {
-  set aToolKits [LibToLink $thePackage]
+proc LibToLinkX {thePackage theDummyName theSrcDir theSourceDirOther} {
+  set aToolKits [LibToLink $thePackage $theSrcDir $theSourceDirOther]
   return $aToolKits
 }
 
@@ -2548,7 +2768,7 @@ proc OS:xcworkspace:toolkits { theModule } {
   set aBuff ""
 
   # Adding toolkits for module in workspace.
-  foreach aToolKit [osutils:tk:sort [${theModule}:toolkits]] {
+  foreach aToolKit [osutils:tk:sort [${theModule}:toolkits] "src" ""] {
     append aBuff "         <FileRef\n"
     append aBuff "            location = \"group:${aToolKit}.xcodeproj\">\n"
     append aBuff "         </FileRef>\n"
@@ -2557,7 +2777,7 @@ proc OS:xcworkspace:toolkits { theModule } {
   # Adding executables for module, assume one project per cxx file...
   foreach aUnit [OS:executable ${theModule}] {
     set aUnitLoc $aUnit
-    set src_files [_get_used_files $aUnit false]
+    set src_files [_get_used_files $aUnit "src" false]
     set aSrcFiles {}
     foreach s $src_files {
       regexp {source ([^\s]+)} $s dummy name
@@ -2644,20 +2864,20 @@ proc OS:xcodeproj { theModules theOutDir theGuidsMap theLibType thePlatform} {
 }
 
 # Generates dependencies section for Xcode project files.
-proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids theIsStatic} {
+proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection theDepsGuids theDepsRefGuids thePlatform theIsStatic} {
   upvar $theGuidsMap         aGuidsMap
   upvar $theFileRefSection   aFileRefSection
   upvar $theDepsGuids        aDepsGuids
   upvar $theDepsRefGuids     aDepsRefGuids
 
   set aBuildFileSection ""
-  set aUsedLibs         [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]]
-  set aDepToolkits      [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit]] $theToolKit]
+  set aUsedLibs         [wokUtils:LIST:Purge [osutils:tk:close $theToolKit "src" ""]]
+  set aDepToolkits      [lappend [wokUtils:LIST:Purge [osutils:tk:close $theToolKit "src" ""]] $theToolKit]
 
   if { "$theTargetType" == "executable" } {
-    set aFile [osutils:tk:files $theToolKit mac]
+    set aFile [osutils:tk:cxxfiles $theToolKit mac "src"]
     set aProjName [file rootname [file tail $aFile]]
-    set aDepToolkits [LibToLinkX $theToolKit $aProjName]
+    set aDepToolkits [LibToLinkX $theToolKit $aProjName "src" ""]
   }
 
   set aLibExt "dylib"
@@ -2668,7 +2888,7 @@ proc osutils:xcdtk:deps {theToolKit theTargetType theGuidsMap theFileRefSection
     }
   }
 
-  osutils:usedOsLibs $theToolKit "mac" aLibs aFrameworks
+  osutils:usedOsLibs $theToolKit $thePlatform aLibs aFrameworks "src"
   set aUsedLibs [concat $aUsedLibs $aLibs]
   set aUsedLibs [concat $aUsedLibs $aFrameworks]
   foreach tkx $aUsedLibs {
@@ -2704,7 +2924,7 @@ proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGro
   upvar $theGuidsMap          aGuidsMap
   upvar $theIncPaths          anIncPaths
 
-  set listloc [osutils:tk:units $theToolKit]
+  set listloc [osutils:tk:units $theToolKit "src"]
   set resultloc [osutils:justunix $listloc]
   set aBuildFileSection ""
   set aPackages [lsort -nocase $resultloc]
@@ -2721,7 +2941,7 @@ proc osutils:xcdtk:sources {theToolKit theTargetType theSrcFileRefSection theGro
       set aGuidsMap($aPackage) [OS:genGUID "xcd"]
     }
 
-    set aSrcFiles [osutils:tk:files $xlo mac]
+    set aSrcFiles [osutils:tk:cxxfiles $xlo mac "src"]
     foreach aSrcFile [lsort $aSrcFiles] {
       set aFileExt "sourcecode.cpp.cpp"
 
@@ -2883,7 +3103,7 @@ proc osutils:xcdtk { theOutDir theToolKit theGuidsMap theIsStatic thePlatform {t
   }
 
   puts $aPbxprojFile [osutils:xcdtk:sources $theToolKit $theTargetType aSrcFileRefSection aGroupSection aPackagesGuids aSrcFileGuids aGuidsMap anIncPaths]
-  puts $aPbxprojFile [osutils:xcdtk:deps    $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $theIsStatic]
+  puts $aPbxprojFile [osutils:xcdtk:deps    $theToolKit $theTargetType aGuidsMap aDepsFileRefSection aDepsGuids aDepsRefGuids $thePlatform $theIsStatic]
   # End PBXBuildFile section
 
   # Begin PBXFileReference section
@@ -3326,7 +3546,7 @@ proc osutils:sdk { theSdkMajorVer {isQuietMode false} {theSdkDirectories {}} } {
 }
 
 # Generate global properties to Visual Studio project file for UWP solution
-proc osutils:uwp:proj { theVcVer theProjTmpl } {
+proc osutils:uwp:proj { isUWP theProjTmpl } {
 
   set uwp_properties ""
   set uwp_generate_metadata ""
@@ -3334,7 +3554,7 @@ proc osutils:uwp:proj { theVcVer theProjTmpl } {
 
   set format_template ""
 
-  if { ${theVcVer} == "vc14-uwp" } {
+  if { $isUWP } {
     set sdk_versions [osutils:sdk 10]
     set sdk_max_ver [lindex ${sdk_versions} end]
 
@@ -3360,7 +3580,7 @@ proc osutils:uwp:proj { theVcVer theProjTmpl } {
 }
 
 # Report all files found in package directory but not listed in FILES
-proc osutils:checksrcfiles { theUnit } {
+proc osutils:checksrcfiles { theUnit theSrcDir} {
   global path
   set aCasRoot [file normalize ${path}]
 
@@ -3369,7 +3589,7 @@ proc osutils:checksrcfiles { theUnit } {
     return
   }
 
-  set anUnitAbsPath [file normalize "${aCasRoot}/src/${theUnit}"]
+  set anUnitAbsPath [file normalize "${aCasRoot}/$theSrcDir/${theUnit}"]
 
   if {[file exists "${anUnitAbsPath}/FILES"]} {
     set aFilesFile [open "${anUnitAbsPath}/FILES" rb]
@@ -3384,6 +3604,9 @@ proc osutils:checksrcfiles { theUnit } {
       if { "${aFile}" == "FILES" } {
         continue
       }
+      if { "${aFile}" == "icons" } {
+        continue
+      }
       if { [lsearch -exact ${aFilesFileList} ${aFile}] == -1 } {
         puts "Warning: file ${anUnitAbsPath}/${aFile} is not listed in ${anUnitAbsPath}/FILES!"
       }