Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
usFunctionGetResourceSource.cmake
Go to the documentation of this file.
1 #! \ingroup MicroServicesCMake
2 #! \brief Get a source file name for handling resource dependencies
3 #!
4 #! This CMake function retrieves the name of a generated file which has to be added
5 #! to a modules source file list to set-up resource file dependencies. This ensures
6 #! that changed resource files will automatically be re-added to the module.
7 #!
8 #! Example usage:
9 #! \code{.cmake}
10 #! set(module_srcs mylib.cpp)
11 #! usFunctionGetResourceSource(TARGET mylib
12 #! OUT module_srcs
13 #! )
14 #! add_library(mylib ${module_srcs})
15 #! \endcode
16 #!
17 #! \param TARGET (required) The name of the target to which the resource files are added.
18 #! \param OUT (required) A list variable to which the file name will be appended.
19 #! \param LINK (optional) Generate a suitable source file for LINK mode.
20 #! \param APPEND (optional) Generate a suitable source file for APPEND mode.
21 #!
22 #! \sa usFunctionAddResources
23 #! \sa usFunctionEmbedResources
24 #!
26  cmake_parse_arguments(_res "LINK;APPEND" "TARGET;OUT" "" "" ${ARGN})
27  if(NOT _res_TARGET)
28  message(SEND_ERROR "TARGET must not be empty")
29  endif()
30  if(NOT _res_OUT)
31  message(SEND_ERROR "OUT argument must not be empty")
32  endif()
33  if(_res_LINK AND _res_APPEND)
34  message(SEND_ERROR "Both LINK and APPEND options given.")
35  endif()
36 
37  set(_out "${CMAKE_CURRENT_BINARY_DIR}/us_${_res_TARGET}/us_resources")
38  if(_res_LINK)
39  set(_out "${_out}${US_RESOURCE_SOURCE_SUFFIX_LINK}")
40  elseif(_res_APPEND)
41  set(_out "${_out}${US_RESOURCE_SOURCE_SUFFIX_APPEND}")
42  else()
43  set(_out "${_out}${US_RESOURCE_SOURCE_SUFFIX}")
44  endif()
45 
46  set(${_res_OUT} ${${_res_OUT}} ${_out} PARENT_SCOPE)
47 endfunction()
usFunctionGetResourceSource()
Get a source file name for handling resource dependencies.
const std::string LINK