Visual Studio 2019: CL.exe use of "command files" for /I additional includes - how to get working?

Daniel Lonsdale 21 Reputation points

I am trying to test a folder layout for large projects with many dependencies, to ensure I get this right in a basic setup first, before manually pulling in many many files and placing them in set locations.

One way of controlling all the source and header files' locations is by using CL command files, as described quite clearly here:

Consequently, I arranged my folder structure as I believe best reflects my requirements, (eg) as follows within c\users\me\source\repos:

> ExternHeaderGroup1 - to hold dependency headers, and in this case, also "Header1.h" for testing
> ExternHeaderGroup2
> ..
> ExternSrcGroup1 - to hold dependency source
> ExternSrcGroup2
> ...
> Projects - to hold many diff projects that all use the dependencies
>> Windows
>>> TestProject1 - has .sln file
>>>> TestProject1 - has .vcxproj file and "main.cpp" calling up "Header1.h"
>>>>> LocalHeaderTestFolder
>>>>> LocalSrcTestFolder
>>> ...
>> OtherTargetPlatform
>>> ...

Next, I create an ExternFilesLocations.txt, containing the text:


This file was placed alongside main.cpp and .vcxproj files.

(Nb #1 and Nb #2 here)

Then, in visual studio, TestProject1 -> right click 'properties' -> configuration properies -> C/C++ -> General -> Additional Include Directories, I place the text:


This resolves into a cl command line of:

/JMC /external:env:"EXTERNAL_INCLUDE" /permissive- /ifcOutput "x64\Debug\" /GS /W3 /Zc:wchar_t /I"@ExternFilesLocations.txt" /ZI /Gm- /Od /sdl /Fd"x64\Debug\vc142.pdb" /Zc:inline /fp:precise /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /Gd /showIncludes /MDd /FC /Fa"x64\Debug\" /EHsc /nologo /Fo"x64\Debug\" /Fp"x64\Debug\TestWildcardProject1.pch" /diagnostics:column

It appears that the compiler never finds (but never complains that it cannot find) the ExternFilesLocations.txt file. No variations of hard-coded/relative links, ExternFilesLocations.txt location etc seem to be recognised.

I also tried simplifying calling cl.exe from the Visual Studio command prompt with options such as;

c:\users\me\source\repos\testproject\projects\windows\testproject1\testproject1\> cl.exe \I@ExternFilesLocations.txt main.cpp
c:\users\me\source\repos\testproject\projects\windows\testproject1\testproject1\> cl.exe \I"@ExternFilesLocations.txt" main.cpp

and other variations described below.

In all cases, cl.exe will not find Header1.h.

Please let me know what I am missing?

Nb. #1 - I also tried changing the ExternFilesLocations.txt text to :

Nb. #2 - I also put the ExternFilesLocations.txt file in c:\ root and use the additional include directories as

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,562 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 112.9K Reputation points

    Try removing your current option, then add @ExternFilesLocations.txt to Additional Options field of C/C++, Command Line tab. The file must contain the /I"…" lines.

0 additional answers

Sort by: Most helpful