Warning, /libraries/kdb/cmake/modules/KDbGenerateHeaders.cmake is written in an unsupported language. File is not indexed.
0001 #.rst: 0002 # ECMGenerateHeaders 0003 # ------------------ 0004 # 0005 # Generate C/C++ CamelCase forwarding headers. 0006 # 0007 # :: 0008 # 0009 # ecm_generate_headers(<camelcase_forwarding_headers_var> 0010 # HEADER_NAMES <CamelCaseName> [<CamelCaseName> [...]] 0011 # [ORIGINAL <CAMELCASE|LOWERCASE>] 0012 # [OUTPUT_DIR <output_dir>] 0013 # [PREFIX <prefix>] 0014 # [REQUIRED_HEADERS <variable>] 0015 # [RELATIVE <relative_path>]) 0016 # 0017 # For each CamelCase header name passed to HEADER_NAMES, a file of that name 0018 # will be generated that will include a version with ``.h`` appended. 0019 # For example, the generated header ``ClassA`` will include ``classa.h`` (or 0020 # ``ClassA.h``, see ORIGINAL). 0021 # The file locations of these generated headers will be stored in 0022 # <camelcase_forwarding_headers_var>. 0023 # 0024 # ORIGINAL specifies how the name of the original header is written: lowercased 0025 # or also camelcased. The default is LOWERCASE. Since 1.8.0. 0026 # 0027 # PREFIX places the generated headers in subdirectories. This should be a 0028 # CamelCase name like ``KParts``, which will cause the CamelCase forwarding 0029 # headers to be placed in the ``KParts`` directory (e.g. ``KParts/Part``). It 0030 # will also, for the convenience of code in the source distribution, generate 0031 # forwarding headers based on the original names (e.g. ``kparts/part.h``). This 0032 # allows includes like ``"#include <kparts/part.h>"`` to be used before 0033 # installation, as long as the include_directories are set appropriately. 0034 # 0035 # OUTPUT_DIR specifies where the files will be generated; this should be within 0036 # the build directory. By default, ``${CMAKE_CURRENT_BINARY_DIR}`` will be used. 0037 # This option can be used to avoid file conflicts. 0038 # 0039 # REQUIRED_HEADERS specifies an output variable name where all the required 0040 # headers will be appended so that they can be installed together with the 0041 # generated ones. This is mostly intended as a convenience so that adding a new 0042 # header to a project only requires specifying the CamelCase variant in the 0043 # CMakeLists.txt file; the original variant will then be added to this 0044 # variable. 0045 # 0046 # The RELATIVE argument indicates where the original headers can be found 0047 # relative to CMAKE_CURRENT_SOURCE_DIR. It does not affect the generated 0048 # CamelCase forwarding files, but ecm_generate_headers() uses it when checking 0049 # that the original header exists, and to generate originally named forwarding 0050 # headers when PREFIX is set. 0051 # 0052 # To allow other parts of the source distribution (eg: tests) to use the 0053 # generated headers before installation, it may be desirable to set the 0054 # INCLUDE_DIRECTORIES property for the library target to output_dir. For 0055 # example, if OUTPUT_DIR is CMAKE_CURRENT_BINARY_DIR (the default), you could do 0056 # 0057 # .. code-block:: cmake 0058 # 0059 # target_include_directories(MyLib PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>") 0060 # 0061 # Example usage (without PREFIX): 0062 # 0063 # .. code-block:: cmake 0064 # 0065 # ecm_generate_headers( 0066 # MyLib_FORWARDING_HEADERS 0067 # HEADERS 0068 # MLFoo 0069 # MLBar 0070 # # etc 0071 # REQUIRED_HEADERS MyLib_HEADERS 0072 # ) 0073 # install(FILES ${MyLib_FORWARDING_HEADERS} ${MyLib_HEADERS} 0074 # DESTINATION ${CMAKE_INSTALL_PREFIX}/include 0075 # COMPONENT Devel) 0076 # 0077 # Example usage (with PREFIX): 0078 # 0079 # .. code-block:: cmake 0080 # 0081 # ecm_generate_headers( 0082 # MyLib_FORWARDING_HEADERS 0083 # HEADERS 0084 # Foo 0085 # Bar 0086 # # etc 0087 # PREFIX MyLib 0088 # REQUIRED_HEADERS MyLib_HEADERS 0089 # ) 0090 # install(FILES ${MyLib_FORWARDING_HEADERS} 0091 # DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MyLib 0092 # COMPONENT Devel) 0093 # install(FILES ${MyLib_HEADERS} 0094 # DESTINATION ${CMAKE_INSTALL_PREFIX}/include/mylib 0095 # COMPONENT Devel) 0096 # 0097 # Since pre-1.0.0. 0098 0099 #============================================================================= 0100 # Copyright 2013 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0101 # Copyright 2014 Alex Merry <alex.merry@kdemail.net> 0102 # 0103 # Distributed under the OSI-approved BSD License (the "License"); 0104 # see accompanying file COPYING-CMAKE-SCRIPTS for details. 0105 # 0106 # This software is distributed WITHOUT ANY WARRANTY; without even the 0107 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 0108 # See the License for more information. 0109 #============================================================================= 0110 # (To distribute this file outside of extra-cmake-modules, substitute the full 0111 # License text for the above reference.) 0112 0113 include(CMakeParseArguments) 0114 0115 function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var) 0116 set(options) 0117 set(oneValueArgs ORIGINAL OUTPUT_DIR PREFIX REQUIRED_HEADERS RELATIVE SOURCE_DIR) 0118 set(multiValueArgs HEADER_NAMES) 0119 cmake_parse_arguments(EGH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 0120 0121 if (EGH_UNPARSED_ARGUMENTS) 0122 message(FATAL_ERROR "Unexpected arguments to ECM_GENERATE_HEADERS: ${EGH_UNPARSED_ARGUMENTS}") 0123 endif() 0124 0125 if(NOT EGH_HEADER_NAMES) 0126 message(FATAL_ERROR "Missing header_names argument to ECM_GENERATE_HEADERS") 0127 endif() 0128 0129 if(NOT EGH_ORIGINAL) 0130 # default 0131 set(EGH_ORIGINAL "LOWERCASE") 0132 endif() 0133 if(NOT EGH_ORIGINAL STREQUAL "LOWERCASE" AND NOT EGH_ORIGINAL STREQUAL "CAMELCASE") 0134 message(FATAL_ERROR "Unexpected value for original argument to ECM_GENERATE_HEADERS: ${EGH_ORIGINAL}") 0135 endif() 0136 0137 if(NOT EGH_OUTPUT_DIR) 0138 set(EGH_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") 0139 endif() 0140 0141 # Make sure EGH_RELATIVE is /-terminated when it's not empty 0142 if (EGH_RELATIVE AND NOT "${EGH_RELATIVE}" MATCHES "^.*/$") 0143 set(EGH_RELATIVE "${EGH_RELATIVE}/") 0144 endif() 0145 0146 if (EGH_PREFIX) 0147 if (NOT "${EGH_PREFIX}" MATCHES "^.*/$") 0148 set(EGH_PREFIX "${EGH_PREFIX}/") 0149 endif() 0150 if (EGH_ORIGINAL STREQUAL "CAMELCASE") 0151 set(originalprefix "${EGH_PREFIX}") 0152 else() 0153 string(TOLOWER "${EGH_PREFIX}" originalprefix) 0154 endif() 0155 endif() 0156 0157 foreach(_CLASSNAME ${EGH_HEADER_NAMES}) 0158 if (EGH_ORIGINAL STREQUAL "CAMELCASE") 0159 set(originalclassname "${_CLASSNAME}") 0160 else() 0161 string(TOLOWER "${_CLASSNAME}" originalclassname) 0162 endif() 0163 set(FANCY_HEADER_FILE "${EGH_OUTPUT_DIR}/${EGH_PREFIX}${_CLASSNAME}") 0164 if (EGH_SOURCE_DIR) 0165 set(_actualheader "${EGH_SOURCE_DIR}/${EGH_RELATIVE}${originalclassname}.h") 0166 else() 0167 set(_actualheader "${CMAKE_CURRENT_SOURCE_DIR}/${EGH_RELATIVE}${originalclassname}.h") 0168 endif() 0169 if (NOT EXISTS ${_actualheader}) 0170 message(FATAL_ERROR "Could not find \"${_actualheader}\"") 0171 endif() 0172 if (NOT EXISTS ${FANCY_HEADER_FILE}) 0173 file(WRITE ${FANCY_HEADER_FILE} "#include \"${originalprefix}${originalclassname}.h\"\n") 0174 endif() 0175 list(APPEND ${camelcase_forwarding_headers_var} "${FANCY_HEADER_FILE}") 0176 if (EGH_REQUIRED_HEADERS) 0177 list(APPEND ${EGH_REQUIRED_HEADERS} "${_actualheader}") 0178 endif() 0179 if (EGH_PREFIX) 0180 # Local forwarding header, for namespaced headers, e.g. kparts/part.h 0181 set(REGULAR_HEADER_NAME ${EGH_OUTPUT_DIR}/${originalprefix}${originalclassname}.h) 0182 if (NOT EXISTS ${REGULAR_HEADER_NAME}) 0183 file(WRITE ${REGULAR_HEADER_NAME} "#include \"${_actualheader}\"\n") 0184 endif() 0185 endif() 0186 endforeach() 0187 0188 set(${camelcase_forwarding_headers_var} ${${camelcase_forwarding_headers_var}} PARENT_SCOPE) 0189 if (NOT EGH_REQUIRED_HEADERS STREQUAL "") 0190 set(${EGH_REQUIRED_HEADERS} ${${EGH_REQUIRED_HEADERS}} PARENT_SCOPE) 0191 endif () 0192 endfunction()