| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- # add the extra targets in the case we want on-the-fly grammar compiler
- find_package ( BISON QUIET )
- set ( BISON_DIR "${MANTICORE_BINARY_DIR}/config" )
- set ( BIS_FLAGS "" )
- if (BISON_VERSION VERSION_GREATER 3.0)
- set ( BIS_FLAGS "-Wno-deprecated" )
- endif ()
- function ( MY_BISON_ALLOWING_UNITY ParserName ParserSrc Dependency TargetBison )
- if (NOT BISON_FOUND)
- if (EXISTS "${BISON_DIR}/bis${ParserSrc}.c" AND EXISTS "${BISON_DIR}/bis${ParserSrc}.h")
- infomsg ( "Will use pre-built ${BISON_DIR}/bis${ParserSrc}.c and ${BISON_DIR}/bis${ParserSrc}.h for grammar parser ${ParserName}" )
- return ()
- else ()
- message ( FATAL_ERROR "No pre-compiled grammar files bis${ParserSrc}.c and bis${ParserSrc}.h for ${ParserSrc}.y exists, and Bison not found. Can't continue" )
- endif ()
- endif ()
- LIST ( APPEND ${TargetBison}_BISON "${ParserSrc}.y" )
- set ( ${TargetBison}_BISON ${${TargetBison}_BISON} PARENT_SCOPE )
- BISON_TARGET ( ${ParserName} "${CMAKE_CURRENT_SOURCE_DIR}/${ParserSrc}.y" "${BISON_DIR}/bis${ParserSrc}.c" COMPILE_FLAGS ${BIS_FLAGS} )
- set_source_files_properties ( ${Dependency} PROPERTIES OBJECT_DEPENDS ${BISON_${ParserName}_OUTPUT_SOURCE} )
- endfunction ()
- function ( MY_BISON ParserName ParserSrc Dependency TargetBison )
- if (NOT BISON_FOUND)
- if (EXISTS "${BISON_DIR}/bis${ParserSrc}.c" AND EXISTS "${BISON_DIR}/bis${ParserSrc}.h")
- infomsg ( "Will use pre-built ${BISON_DIR}/bis${ParserSrc}.c and ${BISON_DIR}/bis${ParserSrc}.h for grammar parser ${ParserName}" )
- return ()
- else ()
- message ( FATAL_ERROR "No pre-compiled grammar files bis${ParserSrc}.c and bis${ParserSrc}.h for ${ParserSrc}.y exists, and Bison not found. Can't continue" )
- endif ()
- endif ()
- LIST ( APPEND ${TargetBison}_BISON "${ParserSrc}.y" )
- set ( ${TargetBison}_BISON ${${TargetBison}_BISON} PARENT_SCOPE )
- BISON_TARGET ( ${ParserName} "${CMAKE_CURRENT_SOURCE_DIR}/${ParserSrc}.y" "${BISON_DIR}/bis${ParserSrc}.c" COMPILE_FLAGS ${BIS_FLAGS} )
- set_source_files_properties ( ${Dependency} PROPERTIES OBJECT_DEPENDS ${BISON_${ParserName}_OUTPUT_SOURCE} SKIP_UNITY_BUILD_INCLUSION ON )
- endfunction ()
- find_package ( FLEX QUIET )
- set ( FLEX_DIR "${MANTICORE_BINARY_DIR}/config" )
- function ( MY_FLEX LexerName LexerSrc Dependency TargetFlex )
- if (NOT FLEX_FOUND)
- if (EXISTS "${FLEX_DIR}/flex${LexerSrc}.c")
- infomsg ( "Will use pre-built ${FLEX_DIR}/flex${LexerSrc}.c for lexer ${LexerName}" )
- return ()
- else ()
- message ( FATAL_ERROR "No pre-compiled lexer file flex${LexerSrc}.c for ${LexerSrc}.l exists, and Flex not found. Can't continue" )
- endif ()
- endif ()
- LIST ( APPEND ${TargetFlex}_FLEX "${LexerSrc}.l" )
- set ( ${TargetFlex}_FLEX ${${TargetFlex}_FLEX} PARENT_SCOPE )
- FLEX_TARGET ( ${LexerName} "${CMAKE_CURRENT_SOURCE_DIR}/${LexerSrc}.l" "${FLEX_DIR}/flex${LexerSrc}.c" )
- set_property ( SOURCE ${Dependency} APPEND PROPERTY OBJECT_DEPENDS ${FLEX_${LexerName}_OUTPUTS} )
- endfunction ()
|