Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4,159
    • Issues 4,159
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Gitlab will be updated March 24th, between 8AM and 9AM EST (UTC-5). Gitlab may have intermittent delays during that time.

  • CMakeCMake
  • CMakeCMake
  • Issues
  • #16846
Closed
Open
Issue created May 02, 2017 by Joseph Tremoulet@JosephTremoulet

Looking for way to select specific VS 2017 C/C++ compiler

VS is becoming more side-by-side friendly, so it's possible to have multiple "VS 2017" installations. The "Visual Studio 15 2017" generator picks the one with highest version number by default -- I'd like a way to override that, does one exist? I tried the generic "use a different compiler" suggestions in the FAQ, but either I'm doing it wrong or they don't work with this generator. Here's my attempt, note how I'm using the "2017" install's dev prompt and trying to force that compiler, but it keeps selecting the "Preview" install which has a higher version number:

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.0.26403.7
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise>where cl
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise>d:

D:\>cd OddJobs\hello_cpp

D:\OddJobs\hello_cpp>dir
 Volume in drive D is Development
 Volume Serial Number is 8AF2-374A

 Directory of D:\OddJobs\hello_cpp

05/02/2017  04:48 PM    <DIR>          .
05/02/2017  04:48 PM    <DIR>          ..
05/02/2017  11:12 AM                47 CMakeLists.txt
05/02/2017  10:54 AM                54 hello.c
               2 File(s)            101 bytes
               2 Dir(s)  272,663,502,848 bytes free

D:\OddJobs\hello_cpp>type CMakeLists.txt
project(hello)
add_executable(hello hello.c)

D:\OddJobs\hello_cpp>md bin1 & cd bin1 & cmake -G "Visual Studio 15 2017" ..
-- The C compiler identification is MSVC 19.11.25227.0
-- The CXX compiler identification is MSVC 19.11.25227.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/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/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/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: D:/OddJobs/hello_cpp/bin1

D:\OddJobs\hello_cpp\bin1>cd ..

D:\OddJobs\hello_cpp>md bin2 & cd bin2 & cmake -G "Visual Studio 15 2017" "-DCMAKE_C_COMPILER=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe" "-DCMAKE_CXX_COMPILER=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe" ..
-- The C compiler identification is MSVC 19.11.25227.0
-- The CXX compiler identification is MSVC 19.11.25227.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/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/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/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: D:/OddJobs/hello_cpp/bin2

D:\OddJobs\hello_cpp\bin2>cd ..

D:\OddJobs\hello_cpp>set CC=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe

D:\OddJobs\hello_cpp>set CXX=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe

D:\OddJobs\hello_cpp>md bin3 & cd bin3 & cmake -G "Visual Studio 15 2017" ..
-- The C compiler identification is MSVC 19.11.25227.0
-- The CXX compiler identification is MSVC 19.11.25227.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/bin/Hostx86/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/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/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/bin/Hostx86/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/Preview/Enterprise/VC/Tools/MSVC/14.11.25227/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: D:/OddJobs/hello_cpp/bin3
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking