Visual Studio 2017

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

Visual Studio 2017

Randy Heiland-2
Hello,

I've googled "site:cmake.org/pipermail/cmake visual studio 2017" looking for answers, but still confused, so thought I'd ask this list. 
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. 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??

I'd welcome suggestions.  Thanks!

--

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
Reply | Threaded
Open this post in threaded view
|

Re: Visual Studio 2017

Matějů Miroslav, Ing.
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
Reply | Threaded
Open this post in threaded view
|

FW: Visual Studio 2017

Thompson, KT
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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Robert Maynard
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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Thompson, KT
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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Robert Maynard
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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Randy Heiland-2
In reply to this post by Robert Maynard
I failed to send my previous reply to the list - see below for that. This is a follow-on, using the repo mentioned previously.

--- Attempt #1

#   Pointing out that my Command Prompt shell doesn't need to know about the 'cl' compiler, in order to run cmake:
C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cl
'cl' is not recognized as an internal or external command,
operable program or batch file.


C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cmake ..
-- Building for: Visual Studio 15 2017
-- 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
-- Found OpenMP_C: -openmp (found version "2.0")
-- Found OpenMP_CXX: -openmp (found version "2.0")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Owner/dev/cmake_learn/cmake_learn-master/build

This successfully builds the following files, but no Makefile so that I can simply run 'nmake' from the command line:

d-----        9/19/2017  10:26 AM                BioFVM
d-----        9/19/2017  10:26 AM                CMakeFiles
d-----        9/19/2017  10:26 AM                core
d-----        9/19/2017  10:26 AM                custom_modules
d-----        9/19/2017  10:26 AM                modules
-a----        9/19/2017  10:26 AM          62588 ALL_BUILD.vcxproj
-a----        9/19/2017  10:26 AM            304 ALL_BUILD.vcxproj.filters
-a----        9/19/2017  10:26 AM          14371 CMakeCache.txt
-a----        9/19/2017  10:26 AM           1841 cmake_install.cmake
-a----        9/19/2017  10:26 AM           7860 PhysiCell.sln
-a----        9/19/2017  10:26 AM          76341 PhysiCell.vcxproj
-a----        9/19/2017  10:26 AM            611 PhysiCell.vcxproj.filters
-a----        9/19/2017  10:26 AM            274 PhysiCellConfig.h
-a----        9/19/2017  10:26 AM          46027 ZERO_CHECK.vcxproj
-a----        9/19/2017  10:26 AM            547 ZERO_CHECK.vcxproj.filters

--------------------------------
--- Attempt #2 (without invoking vcvarsall.bat;  rf. https://dmerej.info/blog/post/cmake-visual-studio-and-the-command-line/ )

C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cmake -G"NMake Makefiles" ..
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:5 (project):
  The CMAKE_C_COMPILER:

    cl

  is not a full path and was not found in the PATH.

  To use the NMake generator with Visual C++, cmake must be run from a shell
  that can use the compiler cl from the command line.  This environment is
  unable to invoke the cl compiler.  To fix this problem, run cmake from the
  Visual Studio Command Prompt (vcvarsall.bat).

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.

--------------------------------
--- Attempt #3 (after invoking the vcvarsall.bat, thereby making my shell aware of the 'cl' compiler)

C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cmake -G"NMake Makefiles" ..
... successfully runs ...

Generates the following files, including a Makefile:

d-----        9/19/2017  10:46 AM                BioFVM
d-----        9/19/2017  10:45 AM                CMakeFiles
d-----        9/19/2017  10:45 AM                core
d-----        9/19/2017  10:46 AM                custom_modules
d-----        9/19/2017  10:46 AM                modules
-a----        9/19/2017  10:44 AM          15307 CMakeCache.txt
-a----        9/19/2017  10:44 AM           1839 cmake_install.cmake
-a----        9/19/2017  10:44 AM           7562 Makefile
-a----        9/19/2017  10:46 AM        1503232 PhysiCell.pdb
-a----        9/19/2017  10:44 AM            274 PhysiCellConfig.h

PS C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build> nmake

Microsoft (R) Program Maintenance Utility Version 14.11.25508.2
... builds most of the way OK ...
... (but currently get an error at the end, trying to build code in my 'cmake_learn' repo)


-Randy

On Mon, Sep 18, 2017 at 10:22 PM, Randy Heiland <[hidden email]> wrote:
Thanks everyone for your replies! I continue to learn/play, but still have problems it seems. I've created a repo, in case anyone would be willing to show me the error of my ways:

On Win10, I too *seem* to have to run the vcvarsall.bat to have things (sort of) work.

I'm using cmake 3.9.2.

-Randy


On Mon, Sep 18, 2017 at 1:57 PM, Robert Maynard <[hidden email]> wrote:
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: <a href="tel:+420%20267%20287%20476" value="+420267287476" target="_blank">+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



--

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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Hendrik Sattler


Am 19. September 2017 17:51:31 MESZ schrieb Randy Heiland <[hidden email]>:

>I failed to send my previous reply to the list - see below for that.
>This
>is a follow-on, using the repo mentioned previously.
>
>--- Attempt #1
>
>#   Pointing out that my Command Prompt shell doesn't need to know
>about
>the 'cl' compiler, in order to run cmake:
>C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cl
>'cl' is not recognized as an internal or external command,
>operable program or batch file.
>
>
>C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cmake ..
>-- Building for: Visual Studio 15 2017
>-- 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
>-- Found OpenMP_C: -openmp (found version "2.0")
>-- Found OpenMP_CXX: -openmp (found version "2.0")
>-- Configuring done
>-- Generating done
>-- Build files have been written to: C:/Users/Owner/dev/cmake_learn
>/cmake_learn-master/build
>
>This successfully builds the following files, but no Makefile so that I
>can
>simply run 'nmake' from the command line:

Maybe you should realize that any purposed use of nmake is outdated by years. You can build .sln files from command line just fine. CMake even wraps the command with --build option.

Only use nmake when you have no other options.

HS

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
--

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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Randy Heiland-2
I'd love to learn more about this option, assuming it's a simple workflow via the command line. If there's a writeup related to cmake, would welcome a pointer. If you can't tell, I'm not really a Windows guy; I'm just trying to support that community. Hopefully what you're describing would not require a user having to fiddle with their PATH env var.

On Tue, Sep 19, 2017 at 2:47 PM, Hendrik Sattler <[hidden email]> wrote:


Am 19. September 2017 17:51:31 MESZ schrieb Randy Heiland <[hidden email]>:
>I failed to send my previous reply to the list - see below for that.
>This
>is a follow-on, using the repo mentioned previously.
>
>--- Attempt #1
>
>#   Pointing out that my Command Prompt shell doesn't need to know
>about
>the 'cl' compiler, in order to run cmake:
>C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cl
>'cl' is not recognized as an internal or external command,
>operable program or batch file.
>
>
>C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cmake ..
>-- Building for: Visual Studio 15 2017
>-- 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
>-- Found OpenMP_C: -openmp (found version "2.0")
>-- Found OpenMP_CXX: -openmp (found version "2.0")
>-- Configuring done
>-- Generating done
>-- Build files have been written to: C:/Users/Owner/dev/cmake_learn
>/cmake_learn-master/build
>
>This successfully builds the following files, but no Makefile so that I
>can
>simply run 'nmake' from the command line:

Maybe you should realize that any purposed use of nmake is outdated by years. You can build .sln files from command line just fine. CMake even wraps the command with --build option.

Only use nmake when you have no other options.

HS

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.


--

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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Hendrik Sattler


Am 19. September 2017 22:05:36 MESZ schrieb Randy Heiland <[hidden email]>:
>I'd love to learn more about this option, assuming it's a simple
>workflow
>via the command line. If there's a writeup related to cmake, would
>welcome
>a pointer. If you can't tell, I'm not really a Windows guy; I'm just
>trying
>to support that community. Hopefully what you're describing would not
>require a user having to fiddle with their PATH env var.

Just type "cmake --build" to see all options.

"cmake --build . --config release" will build the release configuration of a generated .sln file.

>On Tue, Sep 19, 2017 at 2:47 PM, Hendrik Sattler
><[hidden email]>
>wrote:
>
>>
>>
>> Am 19. September 2017 17:51:31 MESZ schrieb Randy Heiland <
>> [hidden email]>:
>> >I failed to send my previous reply to the list - see below for that.
>> >This
>> >is a follow-on, using the repo mentioned previously.
>> >
>> >--- Attempt #1
>> >
>> >#   Pointing out that my Command Prompt shell doesn't need to know
>> >about
>> >the 'cl' compiler, in order to run cmake:
>> >C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cl
>> >'cl' is not recognized as an internal or external command,
>> >operable program or batch file.
>> >
>> >
>> >C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cmake ..
>> >-- Building for: Visual Studio 15 2017
>> >-- 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
>> >-- Found OpenMP_C: -openmp (found version "2.0")
>> >-- Found OpenMP_CXX: -openmp (found version "2.0")
>> >-- Configuring done
>> >-- Generating done
>> >-- Build files have been written to: C:/Users/Owner/dev/cmake_learn
>> >/cmake_learn-master/build
>> >
>> >This successfully builds the following files, but no Makefile so
>that I
>> >can
>> >simply run 'nmake' from the command line:
>>
>> Maybe you should realize that any purposed use of nmake is outdated
>by
>> years. You can build .sln files from command line just fine. CMake
>even
>> wraps the command with --build option.
>>
>> Only use nmake when you have no other options.
>>
>> HS
>>
>> --
>> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>> gesendet.
>>

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
--

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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Randy Heiland-2
What I'm finding online so far seems to indicate that one would need to open the Visual Studio app in order to do something with the .sln. Is that true? If so, it's not really desirable... well, maybe it is for some users, but, in general, I'd like to provide a command line solution. Is that possible?

related links:
https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file


On Tue, Sep 19, 2017 at 4:26 PM, Hendrik Sattler <[hidden email]> wrote:


Am 19. September 2017 22:05:36 MESZ schrieb Randy Heiland <[hidden email]>:
>I'd love to learn more about this option, assuming it's a simple
>workflow
>via the command line. If there's a writeup related to cmake, would
>welcome
>a pointer. If you can't tell, I'm not really a Windows guy; I'm just
>trying
>to support that community. Hopefully what you're describing would not
>require a user having to fiddle with their PATH env var.

Just type "cmake --build" to see all options.

"cmake --build . --config release" will build the release configuration of a generated .sln file.

>On Tue, Sep 19, 2017 at 2:47 PM, Hendrik Sattler
><[hidden email]>
>wrote:
>
>>
>>
>> Am 19. September 2017 17:51:31 MESZ schrieb Randy Heiland <
>> [hidden email]>:
>> >I failed to send my previous reply to the list - see below for that.
>> >This
>> >is a follow-on, using the repo mentioned previously.
>> >
>> >--- Attempt #1
>> >
>> >#   Pointing out that my Command Prompt shell doesn't need to know
>> >about
>> >the 'cl' compiler, in order to run cmake:
>> >C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cl
>> >'cl' is not recognized as an internal or external command,
>> >operable program or batch file.
>> >
>> >
>> >C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cmake ..
>> >-- Building for: Visual Studio 15 2017
>> >-- 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
>> >-- Found OpenMP_C: -openmp (found version "2.0")
>> >-- Found OpenMP_CXX: -openmp (found version "2.0")
>> >-- Configuring done
>> >-- Generating done
>> >-- Build files have been written to: C:/Users/Owner/dev/cmake_learn
>> >/cmake_learn-master/build
>> >
>> >This successfully builds the following files, but no Makefile so
>that I
>> >can
>> >simply run 'nmake' from the command line:
>>
>> Maybe you should realize that any purposed use of nmake is outdated
>by
>> years. You can build .sln files from command line just fine. CMake
>even
>> wraps the command with --build option.
>>
>> Only use nmake when you have no other options.
>>
>> HS
>>
>> --
>> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>> gesendet.
>>

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.


--

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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Robert Maynard
While the preshing article on CMake is really good, it didn't clearly
cover the fact that Visual Studio projects generated by CMake can be
built from the command line using cmake --build <build_dir> --config <
Release/Debug/... >

On Tue, Sep 19, 2017 at 4:44 PM, Randy Heiland <[hidden email]> wrote:

> What I'm finding online so far seems to indicate that one would need to open
> the Visual Studio app in order to do something with the .sln. Is that true?
> If so, it's not really desirable... well, maybe it is for some users, but,
> in general, I'd like to provide a command line solution. Is that possible?
>
> related links:
> http://preshing.com/20170511/how-to-build-a-cmake-based-project/#building-with-visual-studio
> https://docs.microsoft.com/en-us/visualstudio/extensibility/internals/solution-dot-sln-file
>
>
>
> On Tue, Sep 19, 2017 at 4:26 PM, Hendrik Sattler <[hidden email]>
> wrote:
>>
>>
>>
>> Am 19. September 2017 22:05:36 MESZ schrieb Randy Heiland
>> <[hidden email]>:
>> >I'd love to learn more about this option, assuming it's a simple
>> >workflow
>> >via the command line. If there's a writeup related to cmake, would
>> >welcome
>> >a pointer. If you can't tell, I'm not really a Windows guy; I'm just
>> >trying
>> >to support that community. Hopefully what you're describing would not
>> >require a user having to fiddle with their PATH env var.
>>
>> Just type "cmake --build" to see all options.
>>
>> "cmake --build . --config release" will build the release configuration of
>> a generated .sln file.
>>
>> >On Tue, Sep 19, 2017 at 2:47 PM, Hendrik Sattler
>> ><[hidden email]>
>> >wrote:
>> >
>> >>
>> >>
>> >> Am 19. September 2017 17:51:31 MESZ schrieb Randy Heiland <
>> >> [hidden email]>:
>> >> >I failed to send my previous reply to the list - see below for that.
>> >> >This
>> >> >is a follow-on, using the repo mentioned previously.
>> >> >
>> >> >--- Attempt #1
>> >> >
>> >> >#   Pointing out that my Command Prompt shell doesn't need to know
>> >> >about
>> >> >the 'cl' compiler, in order to run cmake:
>> >> >C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cl
>> >> >'cl' is not recognized as an internal or external command,
>> >> >operable program or batch file.
>> >> >
>> >> >
>> >> >C:\Users\Owner\dev\cmake_learn\cmake_learn-master\build>cmake ..
>> >> >-- Building for: Visual Studio 15 2017
>> >> >-- 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
>> >> >-- Found OpenMP_C: -openmp (found version "2.0")
>> >> >-- Found OpenMP_CXX: -openmp (found version "2.0")
>> >> >-- Configuring done
>> >> >-- Generating done
>> >> >-- Build files have been written to: C:/Users/Owner/dev/cmake_learn
>> >> >/cmake_learn-master/build
>> >> >
>> >> >This successfully builds the following files, but no Makefile so
>> >that I
>> >> >can
>> >> >simply run 'nmake' from the command line:
>> >>
>> >> Maybe you should realize that any purposed use of nmake is outdated
>> >by
>> >> years. You can build .sln files from command line just fine. CMake
>> >even
>> >> wraps the command with --build option.
>> >>
>> >> Only use nmake when you have no other options.
>> >>
>> >> HS
>> >>
>> >> --
>> >> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>> >> gesendet.
>> >>
>>
>> --
>> Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail
>> gesendet.
>
>
>
> --
>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Thompson, KT
In reply to this post by Robert Maynard
Hi Robert,

I thought I would expand my example a little - maybe I'm doing something really stupid that I should correct. Can you comment on why wsock32.lib isn't found when I run cmake from a 'clean' cmd prompt, but *is* found after sourcing vcvars.bat?

----------------------------------------
Here's my CMakeList.txt

cmake_minimum_required( VERSION 3.9 )
project( cmc CXX )
message( "C++: ${CMAKE_CXX_COMPILER}" )
find_library( Lib_win_winsock NAMES wsock32;winsock32;ws2_32 )
if( EXISTS "${Lib_win_winsock}" )
  message("Winsock found at ${Lib_win_winsock}")
else()
  message( FATAL_ERROR "winsock not found.")
endif()

----------------------------------------
From a command prompt:

E:\toycode\b>cmake -G "Visual Studio 15 2017" ..
-- The CXX compiler identification is MSVC 19.11.25508.2
-- 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
C++: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
CMake Error at CMakeLists.txt:9 (message):
  winsock not found.

----------------------------------------
After sourcing vcvars.bat

E:\toycode\b>cmake -G "Visual Studio 15 2017" ..
-- The CXX compiler identification is MSVC 19.11.25508.2
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.255
03/bin/HostX86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.255
03/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
C++: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
Winsock found at C:/Program Files (x86)/Windows Kits/10/Lib/10.0.15063.0/um/x86/WSock32.Lib
-- Configuring done
-- Generating done

----------------------------------------

Thanks for your feedback!

-kt

-----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
Reply | Threaded
Open this post in threaded view
|

Re: FW: Visual Studio 2017

Hendrik Sattler


Am 20. September 2017 01:00:58 MESZ schrieb "Thompson, KT" <[hidden email]>:
>Hi Robert,
>
>I thought I would expand my example a little - maybe I'm doing
>something really stupid that I should correct. Can you comment on why
>wsock32.lib isn't found when I run cmake from a 'clean' cmd prompt, but
>*is* found after sourcing vcvars.bat?

For libraries shipped with the compiler, you should just use -lws2_32 instead of find_library().
For Microsoft compilers, this is always ws2_32 for this library.

>----------------------------------------
>Here's my CMakeList.txt
>
>cmake_minimum_required( VERSION 3.9 )
>project( cmc CXX )
>message( "C++: ${CMAKE_CXX_COMPILER}" )
>find_library( Lib_win_winsock NAMES wsock32;winsock32;ws2_32 )
>if( EXISTS "${Lib_win_winsock}" )
>  message("Winsock found at ${Lib_win_winsock}")
>else()
>  message( FATAL_ERROR "winsock not found.")
>endif()
>
>----------------------------------------
>From a command prompt:
>
>E:\toycode\b>cmake -G "Visual Studio 15 2017" ..
>-- The CXX compiler identification is MSVC 19.11.25508.2
>-- 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
>C++: C:/Program Files (x86)/Microsoft Visual
>Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
>CMake Error at CMakeLists.txt:9 (message):
>  winsock not found.
>
>----------------------------------------
>After sourcing vcvars.bat
>
>E:\toycode\b>cmake -G "Visual Studio 15 2017" ..
>-- The CXX compiler identification is MSVC 19.11.25508.2
>-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft
>Visual Studio/2017/Community/VC/Tools/MSVC/14.11.255
>03/bin/HostX86/x86/cl.exe
>-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft
>Visual Studio/2017/Community/VC/Tools/MSVC/14.11.255
>03/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
>C++: C:/Program Files (x86)/Microsoft Visual
>Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/HostX86/x86/cl.exe
>Winsock found at C:/Program Files (x86)/Windows
>Kits/10/Lib/10.0.15063.0/um/x86/WSock32.Lib
>-- Configuring done
>-- Generating done
>
>----------------------------------------
>
>Thanks for your feedback!
>
>-kt
>
>-----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

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
--

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