[cmake-developers] [CMake 0016074]: Setting link_directories in toolchain file is only used for compiler tests, and inhibits effect of repeating the command

2016-04-21 Thread Mantis Bug Tracker

The following issue has been SUBMITTED. 
== 
https://cmake.org/Bug/view.php?id=16074 
== 
Reported By:Antonio
Assigned To:
== 
Project:CMake
Issue ID:   16074
Category:   (No Category)
Reproducibility:have not tried
Severity:   minor
Priority:   normal
Status: new
== 
Date Submitted: 2016-04-21 09:58 EDT
Last Modified:  2016-04-21 09:58 EDT
== 
Summary:Setting link_directories in toolchain file is only
used for compiler tests, and inhibits effect of repeating the command
Description: 
In the attached example,
TOOLCHAIN FILE:
link_directories("D:/abcd")

CMAKELISTS.TXT:
project(dummyProject)
cmake_minimum_required(VERSION 3.4)
link_directories("D:/abcd")
link_directories("D:/efgh")
add_library(dummyTarget SHARED dummy.cpp)

At linking stage, only the "-LD:/efgh" will be there:
cmd.exe /C "cd . &&  -shared -o libdummyTarget.dll
-Wl,--out-implib,libdummyTarget.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
CMakeFiles/dummyTarget.dir/dummy.cpp.obj -LD:/efgh -lkernel32 -luser32 -lgdi32
-lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."

Note: In the CMakeOutput.log file is possible to see that -LD:/abcd is used in
the preliminary compiler tests.

Use case:
I am dealing with a toolchain where the std library is in a specific location,
and to pass the preliminary cmake compiler tests I must set the std library
location with a link_directories command. Since it is toolchain specific, it
makes sense to set in the toolchain file. I can pass the compiler tests if I
call `link_directories` in the toolchain file.

The only workaround I could find so far was to directly set the flag (still in
the toolchain file):

# SET(CMAKE_EXE_LINKER_FLAGS "-LD:/abcd")
# SET(CMAKE_SHARED_LINKER_FLAGS "-LD:/abcd")
# SET(CMAKE_MODULE_LINKER_FLAGS "-LD:/abcd")

Steps to Reproduce: 
1) Take the project in attachment
2) Configure with the attached toolchain, for example using ninja generator
3a) With ninja, run ninja -v to see the command line
3b) With make, run make.exe VERBOSE=1 to see the command line
== 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2016-04-21 09:58 AntonioNew Issue
2016-04-21 09:58 AntonioFile Added: CMakeBugProject.zip 
  
==

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


[cmake-developers] [CMake 0016073]: InstallRequiredSystemLibraries needs updating for MSVS2015

2016-04-21 Thread Mantis Bug Tracker

The following issue has been SUBMITTED. 
== 
https://cmake.org/Bug/view.php?id=16073 
== 
Reported By:Lewoco
Assigned To:
== 
Project:CMake
Issue ID:   16073
Category:   Modules
Reproducibility:always
Severity:   minor
Priority:   normal
Status: new
== 
Date Submitted: 2016-04-21 03:38 EDT
Last Modified:  2016-04-21 03:38 EDT
== 
Summary:InstallRequiredSystemLibraries needs updating for
MSVS2015
Description: 
Many system DLL's required by MSVS2015 are not identified by
InstallRequiredSystemLibraries.


Steps to Reproduce: 
- add_executable a simple hello world
- Use InstallRequiredSystemLibraries to install the required libraries
- Build an installer using WiX (or whatever)
- Install it on Windows 7 (no updates)

BUG: executable cannot be run because of missing DLL's.

Note:
- Updates might have helped but I didn't try it.
- Probably also affects Windows 8/8.1.
- Might not affect Windows 10? (see link)

https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/


Additional Information: 
Right now I'm using the following code to select the additional required
libraries. Please integrate something similar into
InstallRequiredSystemLibraries:

# InstallRequiredSystemLibraries does not properly support MSVS 14 yet, so do it
manually.
unset(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_DEBUG)
unset(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_RELEASE)
if(DEFINED MSVC_VERSION AND NOT MSVC_VERSION LESS 1900)
# Internal: Architecture-appropriate library directory names.
if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM")
set(_winsdk_arch8 arm) # what the WDK for Win8+ calls this architecture
else()
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
set(_winsdk_arch8 x64) # what the WDK for Win8+ calls this
architecture
else()
set(_winsdk_arch8 x86) # what the WDK for Win8+ calls this
architecture
endif()
endif()

# The CRT is distributed with MSVS.
get_filename_component(MSVS_DIR
   
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;ShellFolder]"
ABSOLUTE)

# As of MSVC 19 the CRT depends on the 'univeral' CRT (which is part of
Windows development kit 10 and above).
#
http://blogs.msdn.com/b/vcblog/archive/2015/03/03/introducing-the-universal-crt.aspx
get_filename_component(WINDOWS_KIT_DIR
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed
Roots;KitsRoot10]" ABSOLUTE)

file(GLOB CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_DEBUG
   
"${MSVS_DIR}/VC/redist/debug_nonredist/${_winsdk_arch8}/Microsoft.VC140.DebugCRT/*.dll"
"${WINDOWS_KIT_DIR}/Redist/ucrt/DLLs/${_winsdk_arch8}/api-ms-win-*.dll"
"${WINDOWS_KIT_DIR}/bin/${_winsdk_arch8}/ucrt/*.dll"
)
file(GLOB CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_RELEASE
"${MSVS_DIR}/VC/redist/${_winsdk_arch8}/Microsoft.VC140.CRT/*.dll"
"${WINDOWS_KIT_DIR}/Redist/ucrt/DLLs/${_winsdk_arch8}/*.dll"
)
endif()

== 

Issue History 
Date ModifiedUsername   FieldChange   
== 
2016-04-21 03:38 Lewoco New Issue
==

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Autogen subdirectories patches

2016-04-21 Thread Sebastian Holtermann

Am 19.04.2016 um 19:28 schrieb Brad King:

On 04/19/2016 11:09 AM, Sebastian Holtermann wrote:

https://cmake.org/Bug/view.php?id=12873
https://cmake.org/Bug/view.php?id=16068

They introduce
- same name collision checks during moc/qrc/ui generation
- moc/qrc generation in subdirectories to support
sources with the name in different subdirectories
- A test for equally named sources in different subdirectories

Please review.


Thanks!  I've applied them locally and merged the cleanup/refactoring
commits to 'next' for testing first.  Once those test cleanly I'll move
on to the rest.


It is good too see the patches made it into the next branch.
Thanks and sorry for the wrong indentation btw..


Now there is another issue I have a partially fix for.

As of now all included mocs and uis get generated in
CMAKE_CURRENT_BINARY_DIR/
because they must be within INCLUDE_DIRECTORIES.
I think a more robust approach would be to generate them in
CMAKE_CURRENT_BINARY_DIR/TARGET_automoc.dir/
and to add the _automoc.dir to INCLUDE_DIRECTORIES.

I've attached a patch that does does so
- it is relative to current "next" branch.

It is incomplete though because I didn't manage to get
CMAKE_CURRENT_BINARY_DIR/TARGET_automoc.dir/
into INCLUDE_DIRECTORIES in Source/cmQtAutoGeneratorInitializer.cxx.
(GetAutogenTargetBuildDir() in Source/cmQtAutoGeneratorInitializer.cxx)

If someone could do that or give me pointers on how to do it
then this could be another improvement.

-Sebastian

>From aa246261ba1f98ca245f8c5a93b6c93c7fbe8ec5 Mon Sep 17 00:00:00 2001
From: Sebastian Holtermann 
Date: Thu, 21 Apr 2016 08:44:11 +0200
Subject: [PATCH] Autogen: Generate included moc and ui files in
 TARGET_automoc.dir/

---
 Source/cmQtAutoGenerators.cxx | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index c6ee751..29e2e47 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -564,6 +564,13 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
 this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
 }
 
+  // Prepend included mocs with build subdirectory
+  for(std::map::iterator
+  it = includedMocs.begin(); it != includedMocs.end(); ++it)
+{
+  it->second = this->TargetBuildSubDir + it->second;
+}
+
   {
   std::vector mocSkipped;
   cmSystemTools::ExpandListArgument(this->SkipMoc, mocSkipped);
@@ -1261,7 +1268,8 @@ bool cmQtAutoGenerators::GenerateUiFiles(
   {
   const std::string & uiFileName = *sit;
   const std::string uiInputFile = sourcePath + uiFileName + ".ui";
-  const std::string uiOutputFile = "ui_" + uiFileName + ".h";
+  const std::string uiOutputFile = this->TargetBuildSubDir
+   + "ui_" + uiFileName + ".h";
   sourceMap[uiInputFile] = uiOutputFile;
   testMap[uiInputFile] = uiOutputFile;
   }
@@ -1321,6 +1329,13 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
  );
   if (this->GenerateAll || !success || sourceNewerThanUi >= 0)
 {
+// make sure the directory for the resulting ui file exists
+std::string uiDir = uiBuildFile.substr(0, uiBuildFile.rfind('/'));
+if (!cmsys::SystemTools::FileExists(uiDir.c_str(), false))
+  {
+  cmsys::SystemTools::MakeDirectory(uiDir.c_str());
+  }
+
 std::string msg = "Generating ";
 msg += uiOutputFile;
 cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
-- 
2.8.0.rc3

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers