[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] Ignore installation failure
From:       David Adam <zanchey () ucc ! gu ! uwa ! edu ! au>
Date:       2018-02-20 13:10:18
Message-ID: alpine.DEB.2.20.1802202107330.1675 () motsugo ! ucc ! gu ! uwa ! edu ! au
[Download RAW message or body]

On Sun, 18 Feb 2018, David Adam wrote:
> Our project installs an empty directory for other programs to drop files 
> in, the location of which is overrideable with a cache variable. Some 
> environments set the location of this directory outside the writeable 
> area and create it themselves, so I'd like to set up CMake so that it 
> tries to create the directory but skips over it if there is a failure.
> 
> At the moment we use:
> 
> SET(extra_completionsdir
> ${rel_datadir}/fish/vendor_completions.d
> CACHE STRING "Path for extra completions")
> INSTALL(DIRECTORY DESTINATION ${extra_completionsdir})
> 
> but that fails if the destination is not writeable.
> 
> Is there an idiomatic way of ignoring a failed installation step? At the 
> moment, I'm trying various install(script code execute_process(... 
> incantations, but I'm aware there's lots of corner cases with DESTDIR and 
> so on.

For the record, I ended up implementing just enough to make our use case 
work:

FUNCTION(FISH_TRY_CREATE_DIRS)
  FOREACH(dir ${ARGV})
    IF(NOT IS_ABSOLUTE ${dir})
      SET(abs_dir "\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${dir}")
    ELSE()
      SET(abs_dir "\$ENV{DESTDIR}${dir}")
    ENDIF()
    INSTALL(SCRIPT CODE "EXECUTE_PROCESS(COMMAND mkdir -p ${abs_dir} OUTPUT_QUIET \
                ERROR_QUIET)
                         EXECUTE_PROCESS(COMMAND chmod 755 ${abs_dir} OUTPUT_QUIET \
ERROR_QUIET)  ")
  ENDFOREACH()
ENDFUNCTION(FISH_TRY_CREATE_DIRS)

Perhaps that will help someone in a similar situation in the future.

David Adam
zanchey@ucc.gu.uwa.edu.au

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: \
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information \
on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at \
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic