2 #! \brief Compile a CMake doxygen input filter
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
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.
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.
18 #! \ingroup CMakeUtilities
19 function(ctkFunctionCMakeDoxygenFilterCompile)
21 #-------------------- parse function arguments -------------------
25 set(arg_names "OUT;NAMESPACE")
28 foreach(arg_name ${arg_names})
29 set(${prefix}_${arg_name})
32 foreach(option ${option_names})
33 set(${prefix}_${option} FALSE)
36 set(current_arg_name DEFAULT_ARGS)
40 set(larg_names ${arg_names})
41 list(FIND larg_names "${arg}" is_arg_name)
42 if(is_arg_name GREATER -1)
43 set(${prefix}_${current_arg_name} ${current_arg_list})
44 set(current_arg_name "${arg}")
47 set(loption_names ${option_names})
48 list(FIND loption_names "${arg}" is_option)
49 if(is_option GREATER -1)
50 set(${prefix}_${arg} TRUE)
52 set(current_arg_list ${current_arg_list} "${arg}")
57 set(${prefix}_${current_arg_name} ${current_arg_list})
59 #------------------- finished parsing arguments ----------------------
62 set(copy_file "${FILTER_OUT}")
64 set(copy_file "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CMakeDoxygenFilter${CMAKE_EXECUTABLE_SUFFIX}")
69 set(compile_defs "${compile_defs} -DUSE_NAMESPACE=${FILTER_NAMESPACE}")
72 set(cmake_doxygen_filter_src "${CTK_SOURCE_DIR}/Documentation/CMakeDoxygenFilter.cpp")
74 try_compile(result_var
75 "${CMAKE_CURRENT_BINARY_DIR}"
76 "${cmake_doxygen_filter_src}"
77 COMPILE_DEFINITIONS ${compile_defs}
78 OUTPUT_VARIABLE compile_output
79 COPY_FILE ${copy_file}
83 message(FATAL_ERROR "error: Faild to compile ${cmake_doxygen_filter_src} (result: ${result_var})\n${compile_output}")
86 set(CMakeDoxygenFilter_EXECUTABLE "${copy_file}" PARENT_SCOPE)