user1036908
user1036908

Reputation: 871

Cmake INSTALL command for debug and release mode

I have to execute the following cmake command while building a VS2012 solution.

#Install Debug .pdb and .exp files
INSTALL(
    CODE "FILE( GLOB PDB_EXP \"${PROJECT_BINARY_DIR}/Debug/*.pdb\" \"${PROJECT_BINARY_DIR}/Debug/*.exp\")"
    CODE "FILE( INSTALL \${PDB_EXP} DESTINATION \"${CMAKE_INSTALL_PREFIX}/lib\")"
)

Pdb and exp files are meant for debug mode. However, this command is executed in both debug and release configurations. Can I have separate INSTALL commands for debug and release configurations?

Upvotes: 2

Views: 5269

Answers (2)

P. B.
P. B.

Reputation: 687

Although this is an old question: Since CMake 3.14 it is possible to use "generator expressions" with the syntax $<...> in install(CODE <code>). This would allow for something like the following:

install(
  CODE [[
    if($<CONFIG:Release>)
    ...
    endif()
    if($<CONFIG:Debug>)
    ...
    endif()
  ]]
)

Upvotes: 1

ComicSansMS
ComicSansMS

Reputation: 54737

Take a look at INSTALL's CONFIGURATIONS option:

CONFIGURATIONS

Specify a list of build configurations for which the install rule applies (Debug, Release, etc.).

Note that you need to use INSTALL(FILE [...]) instead of INSTALL(CODE [...]) + FILE for this purpose. In my experience, this is preferable anyway, as using the install mechanism all the way through tends to be more robust than globbing.

Obtaining the locations of the pdbs without doing the GLOB can be a bit fiddly, but you can infer it from the target properties of the targets in the install set.

Upvotes: 4

Related Questions