MantisBT - CMake
View Issue Details
0010940CMakeCPackpublic2010-07-06 02:582016-06-10 14:31
Bo Thorsen 
Kitware Robot 
normalfeaturealways
closedmoved 
CMake-2-8 
 
0010940: Access to the -C variable
It's currently quite difficult to figure out the build directory in CPack with Visual Studio. It would be trivial, if the contents of the -C argument would have this. And if no -C argument is given, it should of course have the default.

Right now, you have to take the complete path to an existing target file and strip the filename to get the build directory.

If I could write something like this instead:

INSTALL(FILES ${CPACK_BUILD_DIR}/myoddfile DESTINATION...)

where ${CPACK_BUILD_DIR} would be the normal build dir for the directory, modified for the -C argument, if it's there, or otherwise have Release in it.
No tags attached.
Issue History
2010-07-06 02:58Bo ThorsenNew Issue
2010-12-19 06:52Eric NOULARDNote Added: 0024263
2011-01-17 15:06David ColeAssigned To => David Cole
2011-01-17 15:06David ColeStatusnew => assigned
2011-10-25 22:56David ColeAssigned ToDavid Cole =>
2011-10-25 22:56David ColeStatusassigned => backlog
2013-06-04 09:21Mark StijnmanNote Added: 0033230
2016-06-10 14:28Kitware RobotNote Added: 0041723
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0024263)
Eric NOULARD   
2010-12-19 06:52   
Hi Bo,

In which case would you have to install
something from build dir you don't know ?
Doesn't

INSTALL(FILES myoddfile DESTINATION...)

work as expected if the command is in inside the appropriate CMakeLists.txt?

If it doesn't did you try using "CMAKE_CFG_INTDIR", like in:

INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/myoddfile DESTINATION...)

Now if your INSTALL command is done in a script launched by CMake (and not directly in some CMakeLists.txt) then
$ENV{CMAKE_CONFIG_TYPE} should contain the value of the -C argument
or nothing if none was specified, so you should be able to build
CPACK_BUILD_DIR with something like:

set(config_type $ENV{CMAKE_CONFIG_TYPE})
if (MSVC)
if(config_type)
  set(CPACK_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/${config_type}")
else(config_type)
  set(CPACK_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/Release")
endif(config_type)
endif(MSVC)
(0033230)
Mark Stijnman   
2013-06-04 09:21   
I ended up here when searching for the same information, because I want to use the build configuration name in the package name. While this is a different use case than the original submitter, I'm posting my solution here for those who are searching for the same: the information from -C is available in the variable CPACK_BUILD_CONFIG. Note that this variable is only available inside your project-specific CPack configuration file (as specified by CPACK_PROJECT_CONFIG_FILE).

This is not in the documentation, as far as I could tell. I found this from studying the source code, and doing some experimentation. So since this is currently an undocumented feature, I don't know if we can depend on this in the future. Maybe this should be made an officially supported feature, and have it added to the documentation? That should completely address this ticket, in my view.
(0041723)
Kitware Robot   
2016-06-10 14:28   
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.