How to set the Output and Intermediate Directory in Visual Studio C++ projects generated by CMake, using Visual Studio Macros?

Here is the final desired result in Visual Studio 2019 for any C/C++ project:

enter image description here

The key part that I am looking for are the top 2 lines in this MSVC project properties dialog:

  • "Output Directory": $(Configuration)-$(PlatformArchitecture)\
  • "Intermediate Directory": $(Configuration)-$(PlatformArchitecture)\$(ProjectName)\

As you can see, both use Visual Studio $(xyz) macros to define the target paths.

The question(s) that I've been struggling with:

  1. How can I make CMake spit out these strings instead of already expanded paths into the generated vcxproj files?

  2. If I want this to happen to multiple (or all) generated MSVC C/C++ project files (libraries, executables, etc.), where do I set this up then? Do I need to patch template files or can this be done via commandline or configuration file settings, which then override the CMakeLists.txt internally defined values?

  3. Anything special I need to mind / watch out for, if I want this setting for all vcxproj build targets as shown in the screenshot?

    (in my case that's generally Debug+Release for both x86 and x64, so 2 Configurations and 2 Platforms in Visual Studio speak)

The other questions on SO (at least the ones I dug up) do not address this at all AFAICT as they replace one 'hardcoded' path with another using CMake (just using different CMake variables, but all expand to absolute paths before the vcxproj is produced).



from Recent Questions - Stack Overflow https://ift.tt/3822849
https://ift.tt/3b6oh39

Comments

Popular posts from this blog

Network Error and Timeout on Authorize.net JS

Spring Elasticsearch Operations

Object oriented programming concepts (OOPs)