[CMake] install() question

Robert Dailey rcdailey at gmail.com
Thu Oct 13 16:56:06 EDT 2011


On Thu, Oct 13, 2011 at 3:47 PM, Michael Hertling <mhertling at online.de>wrote:

> You might use an installation component for the concerned headers:
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)
> PROJECT(INSTCOMP C)
> SET(CMAKE_VERBOSE_MAKEFILE ON)
> SET(F_PREFIX "/dev/shm" CACHE PATH "")
> FILE(WRITE ${CMAKE_BINARY_DIR}/f.h "void f(void);\n")
> INSTALL(FILES ${CMAKE_BINARY_DIR}/f.h
>    DESTINATION ${F_PREFIX}/include
>    COMPONENT f)
> ADD_CUSTOM_TARGET(f_install
>    ${CMAKE_COMMAND} -DCOMPONENT=f -P cmake_install.cmake)
> FILE(WRITE ${CMAKE_BINARY_DIR}/main.c
> "#include <${F_PREFIX}/include/f.h>
> int main(void){return 0;}
> ")
> ADD_EXECUTABLE(main main.c)
> ADD_DEPENDENCIES(main f_install)
>
> The f.h header is selectively installed via the f_install custom
> target, and due to the main-on-f_install dependency, it will be
> installed before the main target is built.


Thanks for the info.

After I posted I found out about file( COPY ) and used that instead.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111013/f12f9387/attachment-0001.htm>


More information about the CMake mailing list