0

I wish to change a $(something) variable in VS2010. I cannot for the life of me find where these $(something) variables are defined.

For the curios it is because I am compiling libpng and need to change $(ZLibSrcDir) so it points to where my zlib is. I know I could just put it where it expects it, but I would like to know how to change these variables none the less.

abatishchev
  • 98,240
  • 88
  • 296
  • 433

2 Answers2

4

The answer I was looking for was to edit the property sheet. This is the property sheet zlib.props that comes with the latest libpng source. It is in the same folder as the .sln file.

<?xml version="1.0" encoding="utf-8"?>
<!--
 * zlib.props - location of zlib source
 *
 * libpng version 1.5.2 - March 31, 2011
 *
 * Copyright (c) 1998-2010 Glenn Randers-Pehrson
 *
 * This code is released under the libpng license.
 * For conditions of distribution and use, see the disclaimer
 * and license in png.h

 * You must edit this file to record the location of the zlib
 * source code.
 -->

<Project ToolsVersion="4.0"
   xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Label="Globals">
    <!-- Place the name of the directory containing the source of zlib used for
     debugging in this property.
         The directory need only contain the '.c' and '.h' files from the
     source.
     If you use a relative directory name (as below) then it must be
     relative to the project directories; these are one level deepers than
     the directories containing this file.
     -->
    <ZLibSrcDir>..\..\..\..\zlib</ZLibSrcDir>
  </PropertyGroup>
</Project>

It is very well commented :)

0

Create environment variable %ZLibSrcDir% pointing where you need.

My Computer -> Properties -> Advanced -> Environment Variables

Why not?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
  • Well $(ZLibSrcDir) is not an environment variable, and it is already pointing somewhere (somewhere I don't want it to but somewhere anyway) and the variable came defined with the solution file... so all signs point to that $(ZLibSrcDir) can be defined per solution, and that defining an environment variable is a bad hack, that might not even work! –  Apr 22 '11 at 14:42
  • @Avram: Indeed, it is. In Windows environment variables has form `%var%`, and in VS variables, including imported from the environment - `$(var)` – abatishchev Apr 22 '11 at 14:47
  • No its not an environment variable! $(ZLibSrcDir) points to C:\Users\AC\Documents\Visual Studio 2010\Projects, and in my environment variables under my computer there is no definition of %ZLibSrcDir%. So obviously $(ZLibSrcDir) is defined somewhere else, somwhere not in my system env vars. –  Apr 22 '11 at 14:49
  • @Avram: The author of the project you're about to compile want from you to point his code to libzlib location using environment variable `%ZLibSrcDir%`, so he could use this path in VS via `$(ZLibSrcDir)`. – abatishchev Apr 22 '11 at 14:57
  • No, it already points somewhere. Why don't you understand this? –  Apr 22 '11 at 15:06
  • @Avram: ok, create pre-build event `echo $(ZLibSrcDir)` and look into Output, you will see where is it pointing too. I don't know [another way to define custom Solution/Project-scope variable](http://stackoverflow.com/questions/840472/macros-environment-variable-in-sln-and-vcproj-files-for-visual-studio) – abatishchev Apr 22 '11 at 15:10
  • Ok, I knew where it was pointing to :), I just wanted it to point somewhere else. It seems the only way to change it is hand editing property sheets. Thank you for your assistance anyway. –  Apr 22 '11 at 23:36
  • @Avram: How is it currently pointing somewhere? Just curiously – abatishchev Apr 23 '11 at 07:49
  • It was defined in a property sheet called zlibs.props –  Apr 25 '11 at 10:43