Warning, /kdevelop/kdevelop-pg-qt/KDevelop-PG-QtConfig.cmake.in is written in an unsupported language. File is not indexed.
0001 # 0002 # Find the KDevelop Parser Generator and set various variables accordingly 0003 # 0004 # KDEVPGQT_DIR and can be set to adjust the directory where the kdevelop-pg-qt 0005 # headers and executable are searched. This should point to the installation 0006 # directory of kdevelop-pg-qt 0007 # 0008 # KDEVPGQT_FOUND - set to TRUE if KDevelop-PG was found FALSE otherwise 0009 # 0010 # KDEVPGQT_INCLUDE_DIR - include dir of kdevelop-pg, for example /usr/include/kdevelop-pg 0011 # can be set by the user to select different include dirs 0012 # KDEVPGQT_EXECUTABLE - the absolute path to the kdevelop-pg executable 0013 # 0014 # KDEVPGQT_GENERATE(SRC_FILE_VAR OUTPUT language 0015 # [NAMESPACE ns] [DEBUG_VISITOR] [TOKEN_TEXT] [DUMP_INFO] 0016 # GRAMMARFILE ADDITIONALDEPS) 0017 # macro to add a custom target for the generation of the parser 0018 # OUTPUT will be given to kdev-pg as the --output parameter and thus sets the filename prefix 0019 # NAMESPACE can be given to choose a namespace different from the OUTPUT value 0020 # DEBUG_VISITOR will run kdevelop-pg with the --debug-visitor argument to generate a simple 0021 # visitor that will print debug messages 0022 # TOKEN_TEXT will run kdevelop-pg with the --token-text argument to generate a simple 0023 # function that returns a readable name of a token 0024 # DUMP_INFO will tell kdevelop-pg to dump extra information about symbols, terminals and rules 0025 # into files in the binary dir 0026 # ENFORCE_COMPATIBLE_ERROR_AWARE_CODE will ensure that --compatible-error-aware-code is also 0027 # passed in case of GCC. By default it only is set for non-GNU compilers. 0028 # Note: The macro only exists when KDEVPG was found 0029 # 0030 # Copyright (c) 2007 Andreas Pakulat <apaku@gmx.de> 0031 # Redistribution and use is allowed according to the terms of the BSD license. 0032 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0033 0034 @PACKAGE_INIT@ 0035 0036 if( KDEVPGQT_INCLUDE_DIR AND KDEVPGQT_EXECUTABLE ) 0037 set(KDevelop-PG-Qt_FIND_QUIETLY TRUE) 0038 endif() 0039 0040 if(WIN32) 0041 file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _progFiles) 0042 set(_KDEVPGQT_DIR ${_progFiles}/kdevelop-pg-qt) 0043 endif() 0044 0045 if( NOT KDEVPGQT_DIR ) 0046 find_path( _kdevpgqtIncDir kdevelop-pg-qt/kdev-pg-token-stream.h 0047 PATHS 0048 ${CMAKE_INSTALL_PREFIX}/include 0049 ${_KDEVPGQT_DIR}/include 0050 ) 0051 if( _kdevpgqtIncDir ) 0052 set(KDEVPGQT_INCLUDE_DIR ${_kdevpgqtIncDir}/kdevelop-pg-qt) 0053 endif() 0054 find_program( KDEVPGQT_EXECUTABLE NAMES kdev-pg-qt 0055 PATHS 0056 ${CMAKE_INSTALL_PREFIX}/bin 0057 ${_KDEVPGQT_DIR}/bin 0058 ) 0059 0060 set(KDEVPGQT_INCLUDE_DIR ${KDEVPGQT_INCLUDE_DIR} CACHE PATH "kdevelop-pg-qt include directory containing the headers") 0061 set( KDEVPGQT_EXECUTABLE ${KDEVPGQT_EXECUTABLE} CACHE PATH "executable for kdevelop-pg-qt" ) 0062 else() 0063 find_path( _kdevpgqtIncDir kdevelop-pg-qt/kdev-pg-token-stream.h 0064 PATHS 0065 ${CMAKE_INSTALL_PREFIX}/include 0066 ${_KDEVPGQT_DIR}/include 0067 ${KDEVPGQT_DIR}/include 0068 ) 0069 set(KDEVPGQT_INCLUDE_DIR ${_kdevpgIncDir}/kdevelop-pg-qt) 0070 find_program( KDEVPGQT_EXECUTABLE NAMES kdev-pg-qt 0071 PATHS 0072 ${CMAKE_INSTALL_PREFIX}/bin 0073 ${_KDEVPGQT_DIR}/bin 0074 ${KDEVPGQT_DIR}/bin 0075 ) 0076 set(KDEVPGQT_INCLUDE_DIR ${KDEVPGQT_INCLUDE_DIR} CACHE PATH "kdevelop-pg-qt include directory containing the headers") 0077 set( KDEVPGQT_EXECUTABLE ${KDEVPGQT_EXECUTABLE} CACHE PATH "executable for kdevelop-pg-qt" ) 0078 endif() 0079 if( KDEVPGQT_INCLUDE_DIR 0080 AND KDEVPGQT_EXECUTABLE) 0081 0082 if( NOT KDevelop-PG-Qt_FIND_QUIETLY ) 0083 message(STATUS "Found KDevelop-PG-Qt") 0084 message(STATUS " Using kdevelop-pg-qt include dir: ${KDEVPGQT_INCLUDE_DIR}") 0085 message(STATUS " Using kdevelop-pg-qt executable: ${KDEVPGQT_EXECUTABLE}") 0086 endif() 0087 0088 # if all modules found 0089 set(KDEVPGQT_FOUND TRUE) 0090 0091 macro(KDEVPGQT_GENERATE _srcVar _language ) 0092 set(_outputList 0093 "${CMAKE_CURRENT_BINARY_DIR}/${_language}tokentype.h") 0094 set(_depList ${ARGN}) 0095 set(_astList 0096 "${CMAKE_CURRENT_BINARY_DIR}/${_language}ast.h") 0097 set(_parserList 0098 "${CMAKE_CURRENT_BINARY_DIR}/${_language}parser.h" 0099 "${CMAKE_CURRENT_BINARY_DIR}/${_language}parser.cpp" 0100 "${CMAKE_CURRENT_BINARY_DIR}/${_language}visitor.h" 0101 "${CMAKE_CURRENT_BINARY_DIR}/${_language}visitor.cpp" 0102 "${CMAKE_CURRENT_BINARY_DIR}/${_language}defaultvisitor.h" 0103 "${CMAKE_CURRENT_BINARY_DIR}/${_language}defaultvisitor.cpp") 0104 set(_lexerList) 0105 set(_dbgVisit) 0106 set(_namespace) 0107 set(_tokenText) 0108 set(_dumpInfo) 0109 if(CMAKE_COMPILER_IS_GNUCC) 0110 set(_beautifulCode) 0111 else() 0112 set(_beautifulCode --compatible-error-aware-code) 0113 endif() 0114 set(_conflicts) 0115 while(1) 0116 list(GET _depList 0 _arg) 0117 if( ${_arg} STREQUAL "NAMESPACE" ) 0118 list(GET _depList 1 _namespace) 0119 list(REMOVE_AT _depList 0 1) 0120 set(_namespace --namespace=${_namespace}) 0121 elseif( ${_arg} STREQUAL "DEBUG_VISITOR" ) 0122 list(REMOVE_AT _depList 0) 0123 set(_dbgVisit "--debug-visitor") 0124 set(_outputList ${_outputList} 0125 "${CMAKE_CURRENT_BINARY_DIR}/${_language}debugvisitor.h" 0126 ) 0127 elseif( ${_arg} STREQUAL "TOKEN_TEXT" ) 0128 list(REMOVE_AT _depList 0) 0129 set(_tokenText "--token-text") 0130 set(_outputList ${_outputList} 0131 "${CMAKE_CURRENT_BINARY_DIR}/${_language}tokentext.h" 0132 ) 0133 elseif( ${_arg} STREQUAL "DUMP_INFO" ) 0134 list(REMOVE_AT _depList 0) 0135 set(_dumpInfo --terminals --symbols --rules) 0136 set(_outputList ${_outputList} 0137 "${CMAKE_CURRENT_BINARY_DIR}/kdev-pg-terminals" 0138 "${CMAKE_CURRENT_BINARY_DIR}/kdev-pg-symbols" 0139 "${CMAKE_CURRENT_BINARY_DIR}/kdev-pg-rules" 0140 ) 0141 elseif( ${_arg} STREQUAL "BEAUTIFUL_CODE" ) 0142 list(REMOVE_AT _depList 0) 0143 set(_beautifulCode --beautiful-code) 0144 elseif( ${_arg} STREQUAL "ENFORCE_COMPATIBLE_ERROR_AWARE_CODE" ) 0145 list(REMOVE_AT _depList 0) 0146 set(_beautifulCode --compatible-error-aware-code) 0147 elseif( ${_arg} STREQUAL "STRICT_CONFLICTS" ) 0148 list(REMOVE_AT _depList 0) 0149 set(_conflicts --strict-conflicts) 0150 elseif( ${_arg} STREQUAL "IGNORE_CONFLICTS" ) 0151 list(REMOVE_AT _depList 0) 0152 set(_conflicts --ignore-conflicts) 0153 elseif( ${_arg} STREQUAL "GENERATE_LEXER" ) 0154 list(REMOVE_AT _depList 0) 0155 set(_lexerList 0156 "${CMAKE_CURRENT_BINARY_DIR}/${_language}lexer.h" 0157 "${CMAKE_CURRENT_BINARY_DIR}/${_language}lexer.cpp") 0158 else() 0159 break() 0160 endif() 0161 endwhile(1) 0162 0163 set(_outputList ${_outputList} ${_lexerList} ${_astList} ${_parserList}) 0164 0165 list(GET _depList 0 _grammarFile) 0166 list(REMOVE_AT _depList 0) 0167 if(NOT _grammarFile) 0168 message(ERROR "No grammar file given to KDEVPGQT_GENERATE macro") 0169 endif() 0170 add_custom_command( 0171 OUTPUT 0172 ${_outputList} 0173 MAIN_DEPENDENCY "${_grammarFile}" 0174 DEPENDS ${_depList} ${KDEVPGQT_EXECUTABLE} 0175 COMMAND ${KDEVPGQT_EXECUTABLE} 0176 ARGS --output=${_language} ${_namespace} 0177 ${_dbgVisit} ${_dumpInfo} ${_beautifulCode} ${_conflicts} "${_grammarFile}" 0178 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" 0179 ) 0180 set_source_files_properties(${_outputList} PROPERTIES 0181 GENERATED TRUE 0182 SKIP_AUTOMOC ON 0183 ) 0184 set( ${_srcVar} 0185 "${_outputList}" 0186 ) 0187 endmacro(KDEVPGQT_GENERATE) 0188 0189 0190 else( KDEVPGQT_INCLUDE_DIR 0191 AND KDEVPGQT_EXECUTABLE) 0192 0193 if( KDevelop-PG-Qt_FIND_REQUIRED) 0194 message(FATAL_ERROR "Couldn't find KDevelop-PG-Qt.") 0195 else() 0196 message(STATUS "Couldn't find KDevelop-PG-Qt.") 0197 endif() 0198 message(STATUS "You can set KDEVPGQT_DIR to help cmake find KDevelop-PG-Qt") 0199 set(KDEVPGQT_FOUND FALSE) 0200 0201 endif( KDEVPGQT_INCLUDE_DIR 0202 AND KDEVPGQT_EXECUTABLE)