[CMake] creating symlinks on install

Clinton Stimpson clinton at elemtech.com
Tue Apr 20 10:45:29 EDT 2010


On 04/20/2010 08:26 AM, Michael Surette wrote:
> I am using CMake 2.8.1 and have the following in my main CMakeLists.txt
>
> ---
>
> install(DIRECTORY ${FLTK_SOURCE_DIR}/FL
>    DESTINATION ${PREFIX_INCLUDE} USE_SOURCE_PERMISSIONS
>    PATTERN ".svn" EXCLUDE
>    )
>
> if(CMAKE_HOST_UNIX)
>    install(SCRIPT ${FLTK_SOURCE_DIR}/CMake/install-symlinks.cmake)
> endif(CMAKE_HOST_UNIX)
>
> ---
>
> The contents of ${FLTK_SOURCE_DIR}/CMake/install-symlinks.cmake are:
>
> ---
>
> if(NOT EXISTS ${PREFIX_INCLUDE}/Fl)
>    EXECUTE_PROCESS(COMMAND ln -s FL Fl
>       WORKING_DIRECTORY ${PREFIX_INCLUDE}
>       )
> endif(NOT EXISTS ${PREFIX_INCLUDE}/Fl)
>
> ---
>
> When I run this, I get the following error
>
> ---
>
> CMake Error at 
> /home/msurette/work/fltk-1.3/CMake/install-symlinks.cmake:4 
> (EXECUTE_PROCESS):
>   execute_process called with no value for WORKING_DIRECTORY.
>
> ---
>
> which tells me that ${PREFIX_INCLUDE} which is a cache variable, is 
> not available to the script.
>
> What can I do to fix this?  Alternatively, is there a better way to 
> create symlinks on install?

You can use configure_file() to create the script with the variables 
expanded, or you can use the
install(CODE "...") and cmake will do the expansion for you.

if(CMAKE_HOST_UNIX)
    install(CODE "
    EXECUTE_PROCESS(COMMAND ln -sf FL Fl
       WORKING_DIRECTORY ${PREFIX_INCLUDE}
       )
    ")
endif(CMAKE_HOST_UNIX)

Clint



More information about the CMake mailing list