Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
usFunctionGenerateModuleInit.cmake
Go to the documentation of this file.
1 #! \ingroup MicroServicesCMake
2 #! \brief Generate a source file which handles proper initialization of a module.
3 #!
4 #! This CMake function will store the path to a generated source file in the
5 #! src_var variable, which should be compiled into a module. The modules source
6 #! code must be compiled with the US_MODULE_NAME pre-processor definition.
7 #! Example usage:
8 #!
9 #! \code{.cmake}
10 #! set(module_srcs )
11 #! usFunctionGenerateModuleInit(module_srcs)
12 #! add_library(mylib ${module_srcs})
13 #! set_property(TARGET ${mylib} APPEND PROPERTY COMPILE_DEFINITIONS US_MODULE_NAME=MyModule)
14 #! \endcode
15 #!
16 #! \param src_var (required) The name of a list variable to which the path of the generated
17 #! source file will be appended.
18 #!
19 #! \see \ref MicroServices_AutoLoading
20 #!
21 function(usFunctionGenerateModuleInit src_var)
22 
23  set(module_init_src_file "${CMAKE_CURRENT_BINARY_DIR}/us_init.cpp")
24  configure_file(${US_MODULE_INIT_TEMPLATE} ${module_init_src_file} @ONLY)
25 
26  set(_src ${module_init_src_file} ${${src_var}})
27  set(${src_var} ${_src} PARENT_SCOPE)
28 
29 endfunction()
usFunctionGenerateModuleInit(src_var)
Generate a source file which handles proper initialization of a module.