Re: ​Visual Studio 2017

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: ​Visual Studio 2017

Andrew Maclean-3

I actually use a .cmd file to specify everything I need. So the whole environment is set.
See the attached file for an example of setting the correct environment for building VTK for example in Windows. 
Note the call to vcvarsall.bat. 

Change the attachment name to KitwareDebug.cmd

Regards
   Andrew





-----Original Message-----
From:
​​
Robert Maynard [mailto:[hidden email]]
Sent: Monday, September 18, 2017 11:58 AM
To: Thompson, KT <[hidden email]>
Cc: [hidden email]
Subject: Re: [CMake] FW: Visual Studio 2017

From a default cmd.exe I see cmake 3.9 correctly finding VS2017 when
specifying the VS Generator.

C:\test\build>C:\support\cmake-3.9.2\bin\cmake -G "Visual Studio 15 2017" ../src
-- The C compiler identification is MSVC 19.11.25508.2
-- The CXX compiler identification is MSVC 19.11.25508.2
-- Check for working C compiler: C:/Program Files (x86)/Microsoft
Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft
Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
-- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft
Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft
Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
-- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/test/build

On Mon, Sep 18, 2017 at 10:49 AM, Thompson, KT <[hidden email]> wrote:
> Robert,
>
> That certainly doesn't work for me - but maybe I'm doing something non-standard.
>
> If I don't source the vcvarsall.bat file, SDK installations (c:\Program Files (x86)\Windows Kits\... and c:\Program Files (x86)\Microsoft SDKs\...) are not found by CMake.
>
> -kt
>
> -----Original Message-----
> From: Robert Maynard [mailto:[hidden email]]
> Sent: Monday, September 18, 2017 8:17 AM
> To: Thompson, KT <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [CMake] FW: Visual Studio 2017
>
> You shouldn't need to import VS17 vcvarsall to use the VS17 Generator,
> that should only be needed if using the MSYS or Ninja generators.
>
> As far as building from the command line, the easiest route is to use
> cmake --build <path to build directory>  --config <cfg>
>
> On Fri, Sep 15, 2017 at 3:05 PM, Thompson, KT <[hidden email]> wrote:
>> Randy,
>>
>> Miroslav's recommendation should work. To expand on his response, here are the commands that I use with VS2017 to allow cmake to run from the command line:
>>
>> - Start cmd session (should also work via powershell)
>> - To import VS17's command line environment run "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
>> - Add extra project specific environment variables (possibly including appending PATH with the location of cmake).
>>
>> I created a batch file that does these steps for me (and a shortcut on my desktop that runs the batch file).
>>
>> @echo off
>> rem cmake-with-vs17-env.bat
>> @call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 %*
>> set PATH=%PATH%;c:\MinGW\bin;C:\Program Files\CMake\bin;C:\Program Files\doxygen\bin;c:\Python27amd64
>> rem set CMAKE_PREFIX_PATH=<whatever>
>>
>> With this environment, I can run cmake from the command line (cmake-gui or cmake). I can generate "Visual Studio 15 2017" or "MSYS Makefiles" projects and I can build them with or w/o the GUI.
>>
>> I hope this helps!
>>
>> -kt
>>
>>
>> -----Original Message-----
>> From: CMake [mailto:[hidden email]] On Behalf Of Mateju Miroslav, Ing.
>> Sent: Friday, September 15, 2017 6:15 AM
>> To: Randy Heiland <[hidden email]>; [hidden email]
>> Subject: Re: [CMake] Visual Studio 2017
>>
>> Hello Randy,
>>
>> From: CMake [mailto:[hidden email]] On Behalf Of Randy Heiland
>> Sent: Friday, September 15, 2017 1:38 PM
>>
>>> Is there a "best way" to use cmake for VS17 (but same cakelists for Linux)? And by "best", I mean with minimal effort on users.
>>> To be more specific, on Windows, I *think* I'd like to have users install the cmake binary, then use Powershell to build an application.
>> Is there really a need for using PowerShell if you also want to use the same CMakeLists for Linux?
>>
>>> But my initial attempt to do so is confusing. I install VS17 (for C++), it installs in standard path, but 'cl' is not found in Powershell. I read that I shouldn't edit my PATH (nor do I really want users to have to), but run some .bat instead to setup my env. So, how should one specify the compiler for cmake? Oh yes, then I see that VS17 also has its own cmake??
>>
>>
>> Have you run CMake successfully yet? I am not really aware how it works but CMake *can* for sure detect VS in my CLI environment without having VS in PATH. If you use an IDE that understands CMake (like VS17 or Qt Creator, for example), you should be able to open a CMake project in the IDE and build it there. Please report your particular problem if it does not work for you.
>> If you prefer to run cl.exe in CLI, then vcvarsall.bat is the .bat file you are looking for.
>>
>> Best regards,
>>
>> Ing. Miroslav Matějů
>> Programmer Analyst
>>
>> AŽD Praha s.r.o.
>> Technology Division
>> Research and Development
>> Žirovnická 2/3146, 106 17  Prague
>> Czech Republic
>> Phone: +420 267 287 476
>> Web: www.azd.cz
>> --
>>
>> 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
>> --
>>
>> 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

--

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



--
___________________________________________
Andrew J. P. Maclean

___________________________________________

--

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

KitwareDebug_cmd.txt (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ​Visual Studio 2017

Thompson, KT

Andrew,

 

Thanks for the example.  Your workflow is very similar to mine. 

 

I setup environments for Qt, Git, LLVM, LAPACK, Metis, Parmetis, Microsoft MPI, etc.

 

-kt

 

From: Andrew Maclean [mailto:[hidden email]]
Sent: Tuesday, September 19, 2017 7:33 PM
To: [hidden email]; Thompson, KT <[hidden email]>; [hidden email]
Subject: Re:​Visual Studio 2017

 

 

I actually use a .cmd file to specify everything I need. So the whole environment is set.

See the attached file for an example of setting the correct environment for building VTK for example in Windows. 

Note the call to vcvarsall.bat. 

 

Change the attachment name to KitwareDebug.cmd

 

Regards

   Andrew

 

 

 

 


-----Original Message-----
From:

​​

Robert Maynard [mailto:[hidden email]

[hidden email]]
Sent: Monday, September 18, 2017 11:58 AM
To: Thompson, KT <[hidden email]

[hidden email]>
Cc: [hidden email]
Subject: Re: [CMake] FW: Visual Studio 2017

From a default cmd.exe I see cmake 3.9 correctly finding VS2017 when
specifying the VS Generator.

C:\test\build>C:\support\cmake-3.9.2\bin\cmake -G "Visual Studio 15 2017" ../src
-- The C compiler identification is MSVC 19.11.25508.2
-- The CXX compiler identification is MSVC 19.11.25508.2
-- Check for working C compiler: C:/Program Files (x86)/Microsoft
Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft
Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
-- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft
Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft
Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
-- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/test/build

On Mon, Sep 18, 2017 at 10:49 AM, Thompson, KT <[hidden email]> wrote:
> Robert,
>
> That certainly doesn't work for me - but maybe I'm doing something non-standard.
>
> If I don't source the vcvarsall.bat file, SDK installations (c:\Program Files (x86)\Windows Kits\... and c:\Program Files (x86)\Microsoft SDKs\...) are not found by CMake.
>
> -kt
>
> -----Original Message-----
> From: Robert Maynard [mailto:[hidden email]]
> Sent: Monday, September 18, 2017 8:17 AM
> To: Thompson, KT <[hidden email]>
> Cc: [hidden email]
> Subject: Re: [CMake] FW: Visual Studio 2017
>
> You shouldn't need to import VS17 vcvarsall to use the VS17 Generator,
> that should only be needed if using the MSYS or Ninja generators.
>
> As far as building from the command line, the easiest route is to use
> cmake --build <path to build directory>  --config <cfg>
>
> On Fri, Sep 15, 2017 at 3:05 PM, Thompson, KT <[hidden email]> wrote:
>> Randy,
>>
>> Miroslav's recommendation should work. To expand on his response, here are the commands that I use with VS2017 to allow cmake to run from the command line:
>>
>> - Start cmd session (should also work via powershell)
>> - To import VS17's command line environment run "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
>> - Add extra project specific environment variables (possibly including appending PATH with the location of cmake).
>>
>> I created a batch file that does these steps for me (and a shortcut on my desktop that runs the batch file).
>>
>> @echo off
>> rem cmake-with-vs17-env.bat
>> @call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 %*
>> set PATH=%PATH%;c:\MinGW\bin;C:\Program Files\CMake\bin;C:\Program Files\doxygen\bin;c:\Python27amd64
>> rem set CMAKE_PREFIX_PATH=<whatever>
>>
>> With this environment, I can run cmake from the command line (cmake-gui or cmake). I can generate "Visual Studio 15 2017" or "MSYS Makefiles" projects and I can build them with or w/o the GUI.
>>
>> I hope this helps!
>>
>> -kt
>>
>>
>> -----Original Message-----
>> From: CMake [mailto:[hidden email]] On Behalf Of Mateju Miroslav, Ing.
>> Sent: Friday, September 15, 2017 6:15 AM
>> To: Randy Heiland <[hidden email]>; [hidden email]
>> Subject: Re: [CMake] Visual Studio 2017
>>
>> Hello Randy,
>>
>> From: CMake [mailto:[hidden email]] On Behalf Of Randy Heiland
>> Sent: Friday, September 15, 2017 1:38 PM
>>
>>> Is there a "best way" to use cmake for VS17 (but same cakelists for Linux)? And by "best", I mean with minimal effort on users.
>>> To be more specific, on Windows, I *think* I'd like to have users install the cmake binary, then use Powershell to build an application.
>> Is there really a need for using PowerShell if you also want to use the same CMakeLists for Linux?
>>
>>> But my initial attempt to do so is confusing. I install VS17 (for C++), it installs in standard path, but 'cl' is not found in Powershell. I read that I shouldn't edit my PATH (nor do I really want users to have to), but run some .bat instead to setup my env. So, how should one specify the compiler for cmake? Oh yes, then I see that VS17 also has its own cmake??
>>
>>
>> Have you run CMake successfully yet? I am not really aware how it works but CMake *can* for sure detect VS in my CLI environment without having VS in PATH. If you use an IDE that understands CMake (like VS17 or Qt Creator, for example), you should be able to open a CMake project in the IDE and build it there. Please report your particular problem if it does not work for you.
>> If you prefer to run cl.exe in CLI, then vcvarsall.bat is the .bat file you are looking for.
>>
>> Best regards,
>>
>> Ing. Miroslav Matějů
>> Programmer Analyst
>>
>> AŽD Praha s.r.o.
>> Technology Division
>> Research and Development
>> Žirovnická 2/3146, 106 17  Prague
>> Czech Republic
>> Phone: +420 267 287 476
>> Web: www.azd.cz
>> --
>>
>> 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
>> --
>>
>> 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

--

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



 

--

___________________________________________
Andrew J. P. Maclean

___________________________________________


--

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