Reputation: 19271
I was trying to use cmake
to install some libraries and executables that are built via cmake
.
I found What is cmake equivalent of 'configure --prefix=DIR && make all install '? which seemed to be easy. It looked like you just need to set the cmake
variable CMAKE_INSTALL_PREFIX
and then make install
should work.
I found that setting the cmake
variable alone did not fix make install
and I kept getting the error message "No rule to make target install".
How do you fix cmake .. && make install
"No rule to make target install"?
p.s. cmake
version is 2.8.x
Upvotes: 4
Views: 16044
Reputation: 19271
I consulted the Cmake textbook I have (or if you go to the cmake
tutorial). According to the textbook, in addition to setting the cmake
variable CMAKE_INSTALL_PREFIX
you also need to invoke the cmake
function install()
for anything you wish to be installed via the generated Makefile
.
So in my case I set the variable in my CMakeLists.txt via:
set(CMAKE_INSTALL_PREFIX path/to/directory)
then under each add_library()
and add_executable()
I added:
install(TARGETS name1
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
Then when I did cmake .. && make && make install
I was successful and the expected files were installed at the expected destination.
Upvotes: 9