0

I use cmake and make to build some libs in Linux. The install part of the CMakelist is given below:

add_library(RVO ${RVO_HEADERS} ${RVO_SOURCES})

if(WIN32)
    set_target_properties(RVO PROPERTIES COMPILE_DEFINITIONS NOMINMAX)
endif()

install(FILES ${RVO_HEADERS} DESTINATION include)
install(TARGETS RVO DESTINATION lib)

But when I run make, the lib is correctly built, but not moved to the corresponding foler "/lib" as expected, nor the "/include" folder is created with files copied in.

What is the problem here?

Nyaruko
  • 4,329
  • 9
  • 54
  • 105
  • 1
    Possible duplicate of [How to use CMAKE\_INSTALL\_PREFIX](http://stackoverflow.com/questions/6241922/how-to-use-cmake-install-prefix) – Florian Jan 19 '17 at 07:52
  • 5
    By default `make` runs `all` target. And `install` target isn't within its dependencies. So, run `make install`. – arrowd Jan 19 '17 at 07:53
  • @arrowd That should be an answer. – Angew is no longer proud of SO Jan 19 '17 at 08:01
  • I have tried, but now it gives an error says file INSTALL cannot copy file "/home/shupeng/Documents/trajectorygenerationtoolbox/RVO2/src/RVO.h" to "/usr/local/include/RVO.h". I do not want to create the include folder under /usr/bin, but rather locally. – Nyaruko Jan 19 '17 at 08:03

1 Answers1

3

When you want to change where files are installed (relative to CMAKE_INSTALL_PREFIX), you use DESTINATION keyword in install() command call. To perform an installation, use need to run make install, because running just make will only build the project.

To alter locations where built binaries are placed (within building tree), you need to set LIBRARY_OUTPUT_DIRECTORY property on RVO target. You can also set its default value with CMAKE_LIBRARY_OUTPUT_DIRECTORY.

arrowd
  • 33,231
  • 8
  • 79
  • 110