[CMake] Windows Visual Studio Install Configurations unexpected behaviour
David Cole
dlrdave at aol.com
Thu Oct 31 10:30:47 EDT 2013
> -----Original Message-----
> From: Dominic Walsh <DWalsh2 at slb.com>
> To: David Cole <dlrdave at aol.com>; cmake <cmake at cmake.org>
> Sent: Wed, Oct 30, 2013 6:06 am
> Subject: RE: [CMake] Windows Visual Studio Install Configurations
unexpected behaviour
>
> In Visual Studio | INSTALL project | Right mouse button "Build"
This does look like it must be a bug.
The following CMakeLists reproduces the issue using the Visual Studio
11 generator:
# <CMakeLists.txt>
cmake_minimum_required(VERSION 2.8.12)
project(b)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/bob.cpp.in" "
#include <iostream>
int bob_function(int argc, char *argv[])
{
std::cout << \"bob_function\" << std::endl;
return 0;
}
"
)
configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/bob.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/bob.cpp")
add_library(bob SHARED bob.cpp)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/i")
set(INSTALL_LIB_PATH "lib")
install(TARGETS bob
RUNTIME DESTINATION ${INSTALL_LIB_PATH}/Debug
LIBRARY DESTINATION ${INSTALL_LIB_PATH}/Debug
ARCHIVE DESTINATION ${INSTALL_LIB_PATH}/Debug
CONFIGURATIONS Debug
)
install(TARGETS bob
RUNTIME DESTINATION ${INSTALL_LIB_PATH}/Release
LIBRARY DESTINATION ${INSTALL_LIB_PATH}/Release
ARCHIVE DESTINATION ${INSTALL_LIB_PATH}/Release
CONFIGURATIONS Release
)
# </CMakeLists.txt>
To reproduce:
- configure and build only the Debug configuration using CMake 2.8.12
and Visual Studio 11
- right click "INSTALL" in VS and choose "Build"
- observe output similar to the following:
3> -- Install configuration: "Debug"
3> -- Installing: C:/dev/dcole/bob/b6/i/lib/Debug/bob.dll
3> -- Installing: C:/dev/dcole/bob/b6/i/lib/Release/bob.dll
Expected:
- only the "Debug/bob.dll" to be installed
- this is fairly bad because whichever config gets installed last will
write its own version of the dll to *both* Debug and Release install
folders
I don't think this is specific to VS version at all. I suspect it will
happen with any VS generator.
The generated cmake_install.cmake code is interesting in that it
appears to "do the right thing" for the static import library .lib file
associated with the dll (i.e., limit it only to those configs listed in
the CONFIGURATIONS argument), but then goes on to do all known configs
for the dll file...
# <cmake_install.cmake-snippet>
##
## this chunk is correct, note there is only a "Debug" IF clause:
##
IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL
"Unspecified")
IF("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
FILE(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/Debug" TYPE
STATIC_LIBRARY OPTIONAL FILES "C:/dev/dcole/bob/b6/Debug/bob.lib")
ENDIF()
ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}"
STREQUAL "Unspecified")
##
## this chunk is incorrect, note there are all known configs listed,
rather than only a "Debug" IF clause:
##
IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL
"Unspecified")
IF("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES "^([Dd][Ee][Bb][Uu][Gg])$")
FILE(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/Debug" TYPE
SHARED_LIBRARY FILES "C:/dev/dcole/bob/b6/Debug/bob.dll")
ELSEIF("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES
"^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$")
FILE(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/Debug" TYPE
SHARED_LIBRARY FILES "C:/dev/dcole/bob/b6/Release/bob.dll")
ELSEIF("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES
"^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$")
FILE(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/Debug" TYPE
SHARED_LIBRARY FILES "C:/dev/dcole/bob/b6/MinSizeRel/bob.dll")
ELSEIF("${CMAKE_INSTALL_CONFIG_NAME}" MATCHES
"^([Rr][Ee][Ll][Ww][Ii][Tt][Hh][Dd][Ee][Bb][Ii][Nn][Ff][Oo])$")
FILE(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/Debug" TYPE
SHARED_LIBRARY FILES "C:/dev/dcole/bob/b6/RelWithDebInfo/bob.dll")
ENDIF()
ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}"
STREQUAL "Unspecified")
## and then 2 similar chunks repeat for the "prefix/lib/Release"
install rules
# </cmake_install.cmake-snippet>
I glanced through the cmInstall* source files, but I couldn't see at
first glance where the problem is. Maybe one of the other CMake devs
who has a better grasp of that code can take a quick look?
HTH,
David
More information about the CMake
mailing list