CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkFunctionCMakeDoxygenFilterCompile.cmake
Go to the documentation of this file.
1#!
2#! \brief 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#!
18#! \ingroup CMakeUtilities
19function(ctkFunctionCMakeDoxygenFilterCompile)
20
21 #-------------------- parse function arguments -------------------
22
23 set(DEFAULT_ARGS)
24 set(prefix "FILTER")
25 set(arg_names "OUT;NAMESPACE")
26 set(option_names "")
27
28 foreach(arg_name ${arg_names})
29 set(${prefix}_${arg_name})
30 endforeach()
31
32 foreach(option ${option_names})
33 set(${prefix}_${option} FALSE)
34 endforeach()
35
36 set(current_arg_name DEFAULT_ARGS)
37 set(current_arg_list)
38
39 foreach(arg ${ARGN})
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}")
45 set(current_arg_list)
46 else()
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)
51 else()
52 set(current_arg_list ${current_arg_list} "${arg}")
53 endif()
54 endif()
55 endforeach()
56
57 set(${prefix}_${current_arg_name} ${current_arg_list})
58
59 #------------------- finished parsing arguments ----------------------
60
61 if(FILTER_OUT)
62 set(copy_file "${FILTER_OUT}")
63 else()
64 set(copy_file "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CMakeDoxygenFilter${CMAKE_EXECUTABLE_SUFFIX}")
65 endif()
66
67 set(compile_defs "")
68 if(FILTER_NAMESPACE)
69 set(compile_defs "${compile_defs} -DUSE_NAMESPACE=${FILTER_NAMESPACE}")
70 endif()
71
72 set(cmake_doxygen_filter_src "${CTK_SOURCE_DIR}/Documentation/CMakeDoxygenFilter.cpp")
73
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}
80 )
81
82 if(NOT result_var)
83 message(FATAL_ERROR "error: Faild to compile ${cmake_doxygen_filter_src} (result: ${result_var})\n${compile_output}")
84 endif()
85
86 set(CMakeDoxygenFilter_EXECUTABLE "${copy_file}" PARENT_SCOPE)
87
88endfunction()