<div dir="ltr"><div>Using CMake 3.12.2.</div><div><br></div><div>Consider the following project:</div><div><br></div><div>project(myproject)</div><div>set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)<br>set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)<br>set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)<br></div><div>set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "" FORCE)</div><div>add_executable(myprog hello.cpp)</div><div>install(TARGETS myprog</div><div>   ARCHIVE DESTINATION lib</div><div>   LIBRARY DESTINATION lib</div><div>   RUNTIME DESTINATION bin)</div><div><br></div><div>'make install' builds 'myprog', then it disappears, then CMake reports an error that it cannot find it ("file INSTALL cannot find "path_to_build_directory/bin/myprog"").</div><div><br></div><div>Seems like a bug/oversight. Possibly CMake is trying to move the file to where it already exists, destroying it in the process.<br></div><div><br></div><div>And since someone will be horrified at what I'm doing with paths, the reason is that I've got subprojects that generate hundreds of libraries and multiple executables, and I'd like to avoid both of the following:</div><div>- Forcing developers to run 'make install' instead of 'make' before they can run</div><div>- Setting up massive PATH and LD_LIBRARY_PATH variables so that everything can be found when it's scattered all over the build tree</div><div><br></div><div>I suppose my current setup will work fine as long as nobody uses 'make install', but I was hoping to leverage that to help with release packaging.<br></div></div>