mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 05:28:20 +00:00
binpac: Initial, working CMake build added.
This commit is contained in:
parent
c8665318e6
commit
65668d3ea6
4 changed files with 189 additions and 1 deletions
63
tools/binpac/CMakeLists.txt
Normal file
63
tools/binpac/CMakeLists.txt
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
##
|
||||||
|
## CMake Configuration
|
||||||
|
##
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
||||||
|
|
||||||
|
# Prohibit in-source builds.
|
||||||
|
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" source_build)
|
||||||
|
if (source_build)
|
||||||
|
message(FATAL_ERROR "In-source builds are not allowed\n."
|
||||||
|
"Please create a separate build directory and invoke cmake from there.")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# If the build configuration file does not exist, copy it over.
|
||||||
|
set(build_config BuildOptions.cmake)
|
||||||
|
find_file(build_config_file
|
||||||
|
NAMES BuildOptions.cmake
|
||||||
|
PATHS ${CMAKE_BINARY_DIR}
|
||||||
|
DOC "Build configuration"
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
if (NOT build_config_file)
|
||||||
|
message("No build configuration found, using default.")
|
||||||
|
configure_file(${CMAKE_SOURCE_DIR}/${build_config}
|
||||||
|
${CMAKE_BINARY_DIR}/${build_config}
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
mark_as_advanced(build_config_file)
|
||||||
|
|
||||||
|
include(${CMAKE_BINARY_DIR}/${build_config})
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules/)
|
||||||
|
|
||||||
|
##
|
||||||
|
## Project Configuration
|
||||||
|
##
|
||||||
|
|
||||||
|
project(BinPAC)
|
||||||
|
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
||||||
|
check_include_files(memory.h HAVE_MEMORY_H)
|
||||||
|
check_include_files(stdint.h HAVE_STDINT_H)
|
||||||
|
check_include_files(stdlib.h HAVE_STDLIB_H)
|
||||||
|
check_include_files(strings.h HAVE_STRINGS_H)
|
||||||
|
check_include_files(string.h HAVE_STRING_H)
|
||||||
|
check_include_files(sys/stat.h HAVE_SYS_STAT_H)
|
||||||
|
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
|
||||||
|
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||||
|
|
||||||
|
include(TestBigEndian)
|
||||||
|
test_big_endian(WORDS_BIGENDIAN)
|
||||||
|
|
||||||
|
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" BINPAC_VERSION LIMIT_COUNT 1)
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
add_subdirectory(lib)
|
||||||
|
add_subdirectory(src)
|
24
tools/binpac/lib/CMakeLists.txt
Normal file
24
tools/binpac/lib/CMakeLists.txt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
include(TestBigEndian)
|
||||||
|
test_big_endian(HOST_BIGENDIAN)
|
||||||
|
|
||||||
|
include(CheckTypeSize)
|
||||||
|
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
|
||||||
|
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/binpac.h.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/binpac.h)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
set(binpac_LIB_SRCS
|
||||||
|
binpac_buffer.cc
|
||||||
|
binpac_bytestring.cc
|
||||||
|
binpac.h
|
||||||
|
binpac_analyzer.h
|
||||||
|
binpac_buffer.h
|
||||||
|
binpac_bytestring.h
|
||||||
|
binpac_exception.h
|
||||||
|
binpac_regex.h
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(binpac_lib STATIC ${binpac_LIB_SRCS})
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
|
||||||
@HOST_BIGENDIAN@
|
#cmakedefine HOST_BIGENDIAN
|
||||||
#ifdef HOST_BIGENDIAN
|
#ifdef HOST_BIGENDIAN
|
||||||
# define HOST_BYTEORDER bigendian
|
# define HOST_BYTEORDER bigendian
|
||||||
#else
|
#else
|
||||||
|
|
101
tools/binpac/src/CMakeLists.txt
Normal file
101
tools/binpac/src/CMakeLists.txt
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
find_package(FLEX REQUIRED)
|
||||||
|
find_package(BISON REQUIRED)
|
||||||
|
|
||||||
|
bison_target(PACParser pac_parse.yy ${CMAKE_CURRENT_BINARY_DIR}/pac_parse.cc
|
||||||
|
COMPILE_FLAGS "-t" HEADER ${CMAKE_CURRENT_BINARY_DIR}/pac_parse.h)
|
||||||
|
flex_target(PACScanner pac_scan.ll ${CMAKE_CURRENT_BINARY_DIR}/pac_scan.cc)
|
||||||
|
add_flex_bison_dependency(PACScanner PACParser)
|
||||||
|
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
set(binpac_SRCS
|
||||||
|
${BISON_PACParser_OUTPUTS}
|
||||||
|
${FLEX_PACScanner_OUTPUTS}
|
||||||
|
pac_action.cc
|
||||||
|
pac_analyzer.cc
|
||||||
|
pac_array.cc
|
||||||
|
pac_attr.cc
|
||||||
|
pac_btype.cc
|
||||||
|
pac_case.cc
|
||||||
|
pac_conn.cc
|
||||||
|
pac_context.cc
|
||||||
|
pac_cstr.cc
|
||||||
|
pac_datadep.cc
|
||||||
|
pac_dataptr.cc
|
||||||
|
pac_dataunit.cc
|
||||||
|
pac_decl.cc
|
||||||
|
pac_embedded.cc
|
||||||
|
pac_enum.cc
|
||||||
|
pac_expr.cc
|
||||||
|
pac_exttype.cc
|
||||||
|
pac_field.cc
|
||||||
|
pac_flow.cc
|
||||||
|
pac_func.cc
|
||||||
|
pac_id.cc
|
||||||
|
pac_inputbuf.cc
|
||||||
|
pac_let.cc
|
||||||
|
pac_param.cc
|
||||||
|
pac_paramtype.cc
|
||||||
|
pac_primitive.cc
|
||||||
|
pac_record.cc
|
||||||
|
pac_redef.cc
|
||||||
|
pac_regex.cc
|
||||||
|
pac_state.cc
|
||||||
|
pac_strtype.cc
|
||||||
|
pac_type.cc
|
||||||
|
pac_typedecl.cc
|
||||||
|
pac_withinput.cc
|
||||||
|
pac_output.cc
|
||||||
|
pac_utils.cc
|
||||||
|
pac_exception.cc
|
||||||
|
pac_main.cc
|
||||||
|
pac_action.h
|
||||||
|
pac_analyzer.h
|
||||||
|
pac_array.h
|
||||||
|
pac_attr.h
|
||||||
|
pac_btype.h
|
||||||
|
pac_case.h
|
||||||
|
pac_cclass.h
|
||||||
|
pac_common.h
|
||||||
|
pac_conn.h
|
||||||
|
pac_context.h
|
||||||
|
pac_cstr.h
|
||||||
|
pac_ctype.h
|
||||||
|
pac_datadep.h
|
||||||
|
pac_dataptr.h
|
||||||
|
pac_dataunit.h
|
||||||
|
pac_dbg.h
|
||||||
|
pac_decl-inl.h
|
||||||
|
pac_decl.h
|
||||||
|
pac_embedded.h
|
||||||
|
pac_enum.h
|
||||||
|
pac_exception.h
|
||||||
|
pac_expr.h
|
||||||
|
pac_exttype.h
|
||||||
|
pac_field.h
|
||||||
|
pac_flow.h
|
||||||
|
pac_func.h
|
||||||
|
pac_id.h
|
||||||
|
pac_inputbuf.h
|
||||||
|
pac_let.h
|
||||||
|
pac_number.h
|
||||||
|
pac_output.h
|
||||||
|
pac_param.h
|
||||||
|
pac_paramtype.h
|
||||||
|
pac_primitive.h
|
||||||
|
pac_record.h
|
||||||
|
pac_redef.h
|
||||||
|
pac_regex.h
|
||||||
|
pac_state.h
|
||||||
|
pac_strtype.h
|
||||||
|
pac_type.h
|
||||||
|
pac_typedecl.h
|
||||||
|
pac_utils.h
|
||||||
|
pac_varfield.h
|
||||||
|
pac_withinput.h
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(binpac ${binpac_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(binpac)
|
Loading…
Add table
Add a link
Reference in a new issue