MantisBT - CMake
View Issue Details
0006813CMakeCMakepublic2008-04-15 22:292008-04-21 19:28
Surya Kiran 
Brad King 
normalmajoralways
closedno change required 
CMake-2-6 
 
0006813: Install command not honoring Configurations option.
Hello all,
I'm building a library in debug and in release modes. I want the built library to go at different locations for each configuration. So I've done something like this.

===============================
set (mytarget "mylib")
Add_Library (${mytarget} ${mysrcs})

Set_Target_Properties (${mytarget} PROPERTIES DEBUG_POSTFIX d)

INSTALL (
TARGETS ${mytarget}
RUNTIME DESTINATION bin_debug
LIBRARY DESTINATION lib_debug
CONFIGURATIONS Debug
)

INSTALL (
TARGETS ${mytarget}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
CONFIGURATIONS Release
)
==================================

Both the debug and release libraries are built properly. But the problem is the library is getting installed to both the directories for both the configurations.

That means the ${CMAKE_INSTALL_DIR}/bin contains mylibd.dll and mylib.dll and same is the case for ${CMAKE_INSTALL_DIR}/bin_debug.

No tags attached.
Issue History
2008-04-15 22:29Surya KiranNew Issue
2008-04-15 22:35Surya KiranNote Added: 0011381
2008-04-21 18:16Bill HoffmanStatusnew => assigned
2008-04-21 18:16Bill HoffmanAssigned To => Brad King
2008-04-21 19:28Brad KingStatusassigned => closed
2008-04-21 19:28Brad KingNote Added: 0011470
2008-04-21 19:28Brad KingResolutionopen => no change required

Notes
(0011381)
Surya Kiran   
2008-04-15 22:35   
I've tested this on Windows Xp with cmake-2.4 and cmake-2.6 with Visual Studio 2005 solution file generator
(0011470)
Brad King   
2008-04-21 19:28   
The install command signature is:

         install(TARGETS targets... [EXPORT <export-name>]
                 [[ARCHIVE|LIBRARY|RUNTIME|FRAMEWORK|BUNDLE|
                   PRIVATE_HEADER|PUBLIC_HEADER|RESOURCE]
                  [DESTINATION <dir>]
                  [PERMISSIONS permissions...]
                  [CONFIGURATIONS [Debug|Release|...]]
                  [COMPONENT <component>]
                  [OPTIONAL] [NAMELINK_ONLY|NAMELINK_SKIP]
                 ] [...])

Note that the CONFIGURATIONS option is one of the things that is switched by the RUNTIME, LIBRARY, and ARCHIVE options. Therefore your example says "install the runtime (.dll) part for all configurations and the library (.so on unix) only in this configuration". You are not actually installing the import library (.lib) part.

Your install command should be

INSTALL (
TARGETS ${mytarget}
CONFIGURATIONS Debug
RUNTIME DESTINATION bin_debug
LIBRARY DESTINATION lib_debug
ARCHIVE DESTINATION lib_debug
)

INSTALL (
TARGETS ${mytarget}
CONFIGURATIONS Release
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)