Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you fix `cmake .. && make install` "No rule to make target install"?

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

like image 473
Trevor Boyd Smith Avatar asked Sep 02 '25 01:09

Trevor Boyd Smith


1 Answers

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.

like image 148
Trevor Boyd Smith Avatar answered Sep 04 '25 14:09

Trevor Boyd Smith