CMake install doesn't find binary that CMake built?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

CMake install doesn't find binary that CMake built?

Benjamin Shadwick
Using CMake 3.12.2.

Consider the following project:

project(myproject)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "" FORCE)
add_executable(myprog hello.cpp)
install(TARGETS myprog
   ARCHIVE DESTINATION lib
   LIBRARY DESTINATION lib
   RUNTIME DESTINATION bin)

'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"").

Seems like a bug/oversight. Possibly CMake is trying to move the file to where it already exists, destroying it in the process.

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:
- Forcing developers to run 'make install' instead of 'make' before they can run
- Setting up massive PATH and LD_LIBRARY_PATH variables so that everything can be found when it's scattered all over the build tree

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.

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake