Re: [cmake-developers] Debug through config/gen inside Visual Studio

2016-09-16 Thread Brad King
On 09/16/2016 06:32 AM, csiga.b...@aol.com wrote:
> Now it’s only up to me to understand the entire process of Makefile 
> generation.
> Global/Local Generators, LocalMakeFileGenerator3 (does 3 correspond to the
> third layer of makefiles? If yes, where is 2?)

The 3 is the third generation of makefile generator design.  The older
versions are only available in version control history.

> The code is fairly convoluted (seems a bit more complex than neccessary,
> but it might be my lack of understanding that makes me feel this way).

There are many years of redesigns and partial refactors accumulated ;)

> One sidequestion: what is the reason for eliding STL algorithms?
> There are nice iterators all over the place, yet no algorithms used,
> even when it were possible. Algorithms make the code much easier to
> understand (the name of the algorithm states the intent of the for-loop)

Only in the last few years have we dropped support for ancient compilers
that don't have all that implemented correctly.  Some progress has been
made on modernizing some of the internals, but no thorough sweep has
been done.  Any place you see that can have a loop replaced with an
algorithm is fair game to update (with normal review of course).

> plus when C++17 hits (configure-time check?), parallel STL invocations
> could speed up the configuration process automatically with minimal
> code impact. Would you accept such patches, where loops are exchanged
> for algorithms where possible?

We do need to continue supporting C++98-only builds because we still
support platforms where C++11 compilers are hard to come by.  We do
allow compiling as any newer standard on compilers that support it
(e.g. the nightly binaries currently all build as C++11 or above).
One can see some configure-time checks for things like unordered_map.
Other optional optimizations like this are allowed, so long as they
do not produce too much clutter or layers of macros.

-Brad

-- 

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] Debug through config/gen inside Visual Studio

2016-09-16 Thread Mate Nagy-Egri via cmake-developers
Thank you Brad. I took the aggressive way and completely wiped the environment 
inside the debugged process. For those anyone wishing to do something similar, 
here’s what I’ve done:

I wrote a PowerShell oneliner:

gci Env: | foreach { $_.Name + "=" + $_.Value } | Out-File -FilePath 
.\Desktop\env.txt -Append

When invoked inside a Visual Command Prompt this outputs a complete environment 
into a file in a format that can be copy-pasted into the Visual Studio Project 
Property Page. Make sure to set Merge Environment option to No. After this it 
worked like a charm.

Now it’s only up to me to understand the entire process of Makefile generation. 
Global/Local Generators, LocalMakeFileGenerator3 (does 3 correspond to the 
third layer of makefiles? If yes, where is 2?)… The code is fairly convoluted 
(seems a bit more complex than neccessary, but it might be my lack of 
understanding that makes me feel this way).

One sidequestion: what is the reason for eliding STL algorithms? There are nice 
iterators all over the place, yet no algorithms used, even when it were 
possible. Algorithms make the code much easier to understand (the name of the 
algorithm states the intent of the for-loop), plus when C++17 hits 
(configure-time check?), parallel STL invocations could speed up the 
configuration process automatically with minimal code impact. Would you accept 
such patches, where loops are exchanged for algorithms where possible?


Feladó: Brad King-- 

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] Debug through config/gen inside Visual Studio

2016-09-15 Thread Brad King
On 09/15/2016 10:33 AM, csiga.b...@aol.com wrote:
>   RC Pass 1:
> 
>/foCMakeFiles\cmTC_14330.dir/manifest.res 
> CMakeFiles\cmTC_14330.dir/manifest.rc

The "rc" tool is missing from the beginning of this command line.
It needs to be in the PATH within the VS environment.

-Brad

-- 

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] Debug through config/gen inside Visual Studio

2016-09-15 Thread Mate Nagy-Egri via cmake-developers
Some very interesting things are happening. I am walking through the code with 
F11, F10, Shift+F10 and trying to understand what’s happening. What really 
makes this process hard is that occasionally it succeeds generating the 
Makefile and the exit code is 0. Ultimately if I try to run the generated 
makefile it terminates with a linker error:

PS C:\Users\Matty> Import-VisualEnvironment -Version 14 -Architecture Win64
PS C:\Users\Matty> cl.exe
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]
PS C:\Users\Matty> cd .\Build\CMake_Example\NMake\
PS C:\Users\Matty\Build\CMake_Example\NMake> nmake clean

Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

PS C:\Users\Matty\Build\CMake_Example\NMake> nmake

Microsoft (R) Program Maintenance Utility Version 14.00.24210.0
Copyright (C) Microsoft Corporation.  All rights reserved.

[ 20%] Building CXX object phys/CMakeFiles/Phys.dir/src/stuff.cpp.obj
stuff.cpp
[ 40%] Building CXX object phys/CMakeFiles/Phys.dir/src/more.cpp.obj
more.cpp
[ 60%] Linking CXX static library Phys.lib
[ 60%] Built target Phys
[ 80%] Building CXX object app/CMakeFiles/Application.dir/src/main.cpp.obj
main.cpp
[100%] Linking CXX executable Application.exe
[100%] Built target Application

Import-VisualEnvironment is a PowerShell Commandlet made by me which 
essentially calls vcvarsall.bat.

The extra info I gained through the VERBOSE=1 env var is this:

Linking C executable cmTC_14330.exe

C:\Users\Matty\Build\CMake\VS14\bin\Debug\cmake.exe -E vs_link_exe
  --intdir=CMakeFiles\cmTC_14330.dir --manifests --
  C:\Kellekek\MICROS~1\VISUAL~1\14.0\VC\bin\amd64\link.exe /nologo
  @CMakeFiles\cmTC_14330.dir\objects1.rsp
  @C:\Users\Matty\AppData\Local\Temp\nm32CF.tmp

  Visual Studio Incremental Link with embedded manifests

  Create CMakeFiles\cmTC_14330.dir/manifest.rc

  Create empty: CMakeFiles\cmTC_14330.dir/embed.manifest

  RC Pass 1:

   /foCMakeFiles\cmTC_14330.dir/manifest.res 
CMakeFiles\cmTC_14330.dir/manifest.rc

  RC Pass 1 failed to run.

However, this part I do not understand. I believe something is not quite 
consistent within the generation process, sometimes succeeding and somethimes 
not. Any ideas?


Thanks Brad for the tips thus far,
Máté


Feladó: Brad King
Elküldve: 2016. szeptember 15., csütörtök 15:11
Címzett: csiga.b...@aol.com
Másolatot kap: cmake-developers@cmake.org
Tárgy: Re: [cmake-developers] Debug through config/gen inside Visual Studio

On 09/15/2016 09:04 AM, csiga.b...@aol.com wrote:
> That is exactly what I’m doing. I am generating a VS solution, and
> inside that I setup the debugging environment, but the process I want
> to debug is not the VS solution generation, but the NMake Makefile
> generation process.

Okay, misread your original message.  I've never actually tried that.

> What should I put inside the Environment dialog to make things work?
> Even when it’s empty, it finds cl.exe, but cmake fails trying to use it.

Add "VERBOSE=1" to the environment to get a little more output about
the "RC Pass 1 failed to run" failure.

-Brad


-- 

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] Debug through config/gen inside Visual Studio

2016-09-15 Thread Brad King
On 09/15/2016 09:04 AM, csiga.b...@aol.com wrote:
> That is exactly what I’m doing. I am generating a VS solution, and
> inside that I setup the debugging environment, but the process I want
> to debug is not the VS solution generation, but the NMake Makefile
> generation process.

Okay, misread your original message.  I've never actually tried that.

> What should I put inside the Environment dialog to make things work?
> Even when it’s empty, it finds cl.exe, but cmake fails trying to use it.

Add "VERBOSE=1" to the environment to get a little more output about
the "RC Pass 1 failed to run" failure.

-Brad

-- 

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] Debug through config/gen inside Visual Studio

2016-09-15 Thread Brad King
On 09/14/2016 10:10 AM, Mate Nagy-Egri via cmake-developers wrote:
> How do you setup Visual Studio to debug through a config/gen process?

The easiest way is to use one of the VS IDE generators rather than
NMake Makefiles.  Then in the IDE use the properties dialog on the
"cmake" target to set up a command line and working directory, and
finally use the IDE menu option to start debugging.

-Brad

-- 

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] Debug through config/gen inside Visual Studio

2016-09-14 Thread Mate Nagy-Egri via cmake-developers
Apologies, there is one important moment I failed mention. If I do not set any 
env vars for the debugger, cmake still finds cl.exe with the „NMake Makefiles” 
generator, which clearly states that it is not a clean user environment I get 
inside the debugger.


Feladó: csiga.b...@aol.com-- 

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] Debug through config/gen inside Visual Studio

2016-09-14 Thread Mate Nagy-Egri via cmake-developers
Hi everyone!

I wanted to see how CMake actually Works under the covers to see how much 
actual work it would take to implement a feature I proposed quite a while ago. 
My problem is that even though I built CMake with the  „Visual Studio 14 2015 
Win64” generator, I setup the cmake target to use:

Command Arguments: -G "NMake Makefiles" 
C:\Users\Matty\OneDrive\Develop\Tests\CMake\CMake_example
Working Directory: C:\Users\Matty\Build\CMake_Example\NMake

There is even an option to create new environtment variables prior to 
debugging. My problem is that even though I checked what vcvarsall.bat creates 
on the command line, I exported the same variables, but the compiler fails 
according to CMake (see at the end).

How do you setup Visual Studio to debug through a config/gen process?

Thanks in advance,
Máté


-- The C compiler identification is MSVC 19.0.24213.1
-- The CXX compiler identification is MSVC 19.0.24213.1
-- Check for working C compiler: C:/Kellekek/Microsoft/Visual 
Studio/14.0/VC/bin/amd64/cl.exe
-- Check for working C compiler: C:/Kellekek/Microsoft/Visual 
Studio/14.0/VC/bin/amd64/cl.exe -- broken
CMake Error at 
C:/Users/Matty/Source/Repos/CMake/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "C:/Kellekek/Microsoft/Visual
  Studio/14.0/VC/bin/amd64/cl.exe" is not able to compile a simple test
  program.

  It fails with the following output:

   Change Dir: C:/Users/Matty/Build/CMake_Example/NMake/CMakeFiles/CMakeTmp



  Run Build Command:"nmake" "/NOLOGO" "cmTC_064d4\fast"

"C:\Kellekek\Microsoft\Visual Studio\14.0\VC\bin\amd64\nmake.exe" -f
  CMakeFiles\cmTC_064d4.dir\build.make /nologo -L
  CMakeFiles\cmTC_064d4.dir\build

  Building C object CMakeFiles/cmTC_064d4.dir/testCCompiler.c.obj

C:\Kellekek\MICROS~1\VISUAL~1\14.0\VC\bin\amd64\cl.exe
  @C:\Users\Matty\AppData\Local\Temp\nmBF98.tmp

  testCCompiler.c

  Linking C executable cmTC_064d4.exe

C:\Users\Matty\Build\CMake\VS14\bin\Debug\cmake.exe -E vs_link_exe
  --intdir=CMakeFiles\cmTC_064d4.dir --manifests --
  C:\Kellekek\MICROS~1\VISUAL~1\14.0\VC\bin\amd64\link.exe /nologo
  @CMakeFiles\cmTC_064d4.dir\objects1.rsp
  @C:\Users\Matty\AppData\Local\Temp\nmC1FA.tmp

  RC Pass 1 failed to run.

  NMAKE : fatal error U1077:
  'C:\Users\Matty\Build\CMake\VS14\bin\Debug\cmake.exe' : return code
  '0x'

  Stop.

  NMAKE : fatal error U1077: '"C:\Kellekek\Microsoft\Visual
  Studio\14.0\VC\bin\amd64\nmake.exe"' : return code '0x2'

  Stop.





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:5 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/Matty/Build/CMake_Example/NMake/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Matty/Build/CMake_Example/NMake/CMakeFiles/CMakeError.log".
Press any key to continue . . .

-- 

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