this is a simplified version of my cmake
cmake_minimum_required(VERSION 2.8.4)
project(math)
add_library(math math.cpp)
function(install_package)
install(TARGETS math
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
add_custom_command(TARGET math
POST_BUILD
COMMAND cmake ARGS -P cmake_install.cmake)
endfunction()
install_package()
But when I build Debug version I get the following error
CMake Error at cmake_install.cmake:55 (file):
file INSTALL cannot find
"<my project's root>/build/Release/math.lib".
Why is it looking in Release folder despite that I build for Debug?
When I build for Release then, obviously, everything works.
I tried to add CONFIGURATIONS option to install method, but it doesn't help.
I'm using Visual Studio 15.
If I look into my
cmake_install.cmake,Releaseis the default if you don't specify anything in youradd_custom_command()call:So if you look into
INSTALL.vcxprojthe call that CMake is generating looks like:Which would translate into: