View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008884CMakeModulespublic2009-04-14 05:502016-06-10 14:30
Reporterjneuhaus 
Assigned ToBill Hoffman 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusclosedResolutionmoved 
PlatformVisual Studio 2008OSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0008884: Set Visual Studio project "custom environment variables" setting with CMake
DescriptionFeature Request

In Visual Studio, you can add custom environment variables that will
exist if you run your application from visual studio. They are at
[executable project]-->Properties-->Configuration
Properties-->Debugging-->Environment

Setting these is especially useful to add the correct (Debug/Release) include paths to your project.

Example:
My project needs to have a debug version of ITKCommon.dll in its PATH
when running in Debug mode and a Release version of the DLL in Release
mode respectively. Otherwise it will crash with a

Manually setting the project environment setting to
"PATH=%ITK_DIR%\bin\$(OutType);%PATH%" allows me to automatically use
the correct path, as is suggested in the VTK FAQ
(<http://vtkedge.org/Wiki/VTK_FAQ#Shared_builds_of_VTK_and_debugging_QVT [^]
KWidget_using_Visual_Studio>). But the next CMake run will overwrite this setting. Therefore, a posibility to set this with CMake would be really useful. Other use cases exist too. For example, it can be used to set other environment variables as well, that could be read by the application.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0017457)
Bill Hoffman (manager)
2009-09-14 14:07

I am not sure if this is possible. I think those env vars are stored globally maybe in some registry entry, not sure, but I don't think they are in the project files.
(0017814)
Mateusz Loskot (reporter)
2009-09-29 06:21

Bill,

I believe it is possible and it should be fairly straightforward.
This setting is stored in user-specific configuration file: PROJECT.vcproj.DOMAINNAME.USER.user
(I'm not sure but this form should work as well: PROJECT.vcproj.user)

Here is explantion of .user file template for CMake:

http://stackoverflow.com/questions/1005901/how-to-set-path-environment-variable-using-cmake-and-visual-studio-to-run-test [^]
(0017815)
Mateusz Loskot (reporter)
2009-09-29 06:24

There is related bug report in CMake database:

http://www.itk.org/Bug/view.php?id=7885 [^]
(0018025)
jneuhaus (reporter)
2009-10-08 08:35

It is definitely possible to store custom environment variables per project in the project files.
They are stored in a file with the following naming scheme at the same folder as the .vcproj file: [project name].vcproj.[user domain].[user name].user

To set them with the VS GUI:
[executable project]-->Properties-->Configuration
Properties-->Debugging-->Environment

They will become active when the project is executed.
(0018040)
Mateusz Loskot (reporter)
2009-10-08 14:40

@jneuhaus I know well that it's possible to configure environment for Visual Studio projects using GUI of the IDE. What I'm interested in is exactly what is requested in this feature request: Set Visual Studio project "custom environment variables" setting with CMake.
(0018053)
Patrick Moseley (reporter)
2009-10-09 15:19

We have the case of using CMake in a cross platform environment and would like to have this functionality not only for Visual Studio, but for Eclipse and XCode as well.

Rather than coming up with something for each of the different generators for the different platforms, it would be nice to have a CMake command that would allow you to set locations of additional "shared libraries" needed to execute the application built with CMake inside the various IDEs supported as generator targets. So on Windows (Visual Studio) it would add the directories to the PATH environment variable, on Unix (Eclipse) it would set the LD_LIBRARY_PATH, and on Mac (XCode) it would set the DYLD_LIBRARY_PATH environment variable.
(0018057)
jneuhaus (reporter)
2009-10-12 04:23

Our project needs the correct Debug/Release version of multiple DLLs.
VS allows to use the keyword '$(OutType)' in the custom PATH setting. It will be replaced by Debug/Release when the executable is started by Visual Studio. Therefore, we can simply switch between Debug/Release configuration in Visual Studio and it will find the correct DLLs.

Another use case is that we want to set certain environment variables with different values for different executable projects in the same solution.

It would be nice, if CMake would allow to set the custom environment variables, so that we do not have to re-set them after cmake re-generates the project.
(0028445)
Andrew Hill (reporter)
2012-02-01 23:22

Relates to (or duplicates) 2582 if following Patrick Moseley's suggestion

http://cmake.org/Bug/view.php?id=2582 [^]
(0041542)
Kitware Robot (administrator)
2016-06-10 14:27

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2009-04-14 05:50 jneuhaus New Issue
2009-09-14 14:06 Bill Hoffman Status new => assigned
2009-09-14 14:06 Bill Hoffman Assigned To => Bill Hoffman
2009-09-14 14:07 Bill Hoffman Note Added: 0017457
2009-09-29 06:21 Mateusz Loskot Note Added: 0017814
2009-09-29 06:24 Mateusz Loskot Note Added: 0017815
2009-10-08 08:35 jneuhaus Note Added: 0018025
2009-10-08 14:40 Mateusz Loskot Note Added: 0018040
2009-10-09 15:19 Patrick Moseley Note Added: 0018053
2009-10-12 04:23 jneuhaus Note Added: 0018057
2012-02-01 23:15 Andrew Hill Note Added: 0028444
2012-02-01 23:16 Andrew Hill Note Edited: 0028444
2012-02-01 23:19 Andrew Hill Note Deleted: 0028444
2012-02-01 23:22 Andrew Hill Note Added: 0028445
2016-06-10 14:27 Kitware Robot Note Added: 0041542
2016-06-10 14:27 Kitware Robot Status assigned => resolved
2016-06-10 14:27 Kitware Robot Resolution open => moved
2016-06-10 14:30 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team