Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkFunctionCMakeDoxygenFilterCompile.cmake
Go to the documentation of this file.
1 #!
2 #! \brief Download and compile a CMake doxygen input filter
3 #!
4 #! \param OUT <out-file> (optional) Supply an absolute filename for
5 #! the generated executable.
6 #! \param NAMESPACE <namespace> (optional) Supply a C++ namespace in
7 #! which the generated function declrarations
8 #! should be wrapped.
9 #!
10 #! \return This function sets the <code>CMakeDoxygenFilter_EXECUTABLE</code>
11 #! variable to the absolute path of the generated input filter executable
12 #! in the parent scope. If <out-file> is specified, they will be the same.
13 #!
14 #! This CMake function compiles the http://github.com/saschazelzer/CMakeDoxygenFilter
15 #! project into a doxygen input filter executable. See
16 #! http://github.com/saschazelzer/CMakeDoxygenFilter/blob/master/README for more details.
17 #!
19 
20  #-------------------- parse function arguments -------------------
21 
22  set(DEFAULT_ARGS)
23  set(prefix "FILTER")
24  set(arg_names "OUT;NAMESPACE")
25  set(option_names "")
26 
27  foreach(arg_name ${arg_names})
28  set(${prefix}_${arg_name})
29  endforeach(arg_name)
30 
31  foreach(option ${option_names})
32  set(${prefix}_${option} FALSE)
33  endforeach(option)
34 
35  set(current_arg_name DEFAULT_ARGS)
36  set(current_arg_list)
37 
38  foreach(arg ${ARGN})
39  set(larg_names ${arg_names})
40  list(FIND larg_names "${arg}" is_arg_name)
41  if(is_arg_name GREATER -1)
42  set(${prefix}_${current_arg_name} ${current_arg_list})
43  set(current_arg_name "${arg}")
44  set(current_arg_list)
45  else(is_arg_name GREATER -1)
46  set(loption_names ${option_names})
47  list(FIND loption_names "${arg}" is_option)
48  if(is_option GREATER -1)
49  set(${prefix}_${arg} TRUE)
50  else(is_option GREATER -1)
51  set(current_arg_list ${current_arg_list} "${arg}")
52  endif(is_option GREATER -1)
53  endif(is_arg_name GREATER -1)
54  endforeach(arg ${ARGN})
55 
56  set(${prefix}_${current_arg_name} ${current_arg_list})
57 
58  #------------------- finished parsing arguments ----------------------
59 
60  if(FILTER_OUT)
61  set(copy_file "${FILTER_OUT}")
62  else()
63  set(copy_file "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CMakeDoxygenFilter${CMAKE_EXECUTABLE_SUFFIX}")
64  endif()
65 
66  set(compile_defs "")
67  if(FILTER_NAMESPACE)
68  set(compile_defs "${compile_defs} -DUSE_NAMESPACE=${FILTER_NAMESPACE}")
69  endif()
70 
71  set(cmake_doxygen_filter_src "${CMAKE_CURRENT_SOURCE_DIR}/CMakeDoxygenFilter.cpp")
72 
73  try_compile(result_var
74  "${CMAKE_CURRENT_BINARY_DIR}"
75  "${cmake_doxygen_filter_src}"
76  COMPILE_DEFINITIONS ${compile_defs}
77  OUTPUT_VARIABLE compile_output
78  COPY_FILE ${copy_file}
79  )
80 
81  if(NOT result_var)
82  message(FATAL_ERROR "error: Faild to compile ${cmake_doxygen_filter_src} (result: ${result_var})\n${compile_output}")
83  endif()
84 
85  set(CMakeDoxygenFilter_EXECUTABLE "${copy_file}" PARENT_SCOPE)
86 
87 endfunction()
mitkFunctionCMakeDoxygenFilterCompile()
Download and compile a CMake doxygen input filter.