[CMake] install() question

Michael Hertling mhertling at online.de
Thu Oct 13 17:01:25 EDT 2011


On 10/13/2011 10:56 PM, Robert Dailey wrote:
> 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.

In that way, the headers are not automatically reinstalled when they
change; you need to reconfigure the overall project to achieve this.

Regards,

Michael


More information about the CMake mailing list