mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
binpac: Remove submodule, adapt CMake configuration for Zeek build
This commit is contained in:
parent
79733d9390
commit
0377486637
7 changed files with 34 additions and 166 deletions
|
@ -1,86 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
|
||||
project(BinPAC C CXX)
|
||||
include(cmake/CommonCMakeConfig.cmake)
|
||||
include(cmake/RequireCXXStd.cmake)
|
||||
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" BINPAC_VERSION LIMIT_COUNT 1)
|
||||
string(REPLACE "." " " _version_numbers ${BINPAC_VERSION})
|
||||
separate_arguments(_version_numbers)
|
||||
list(GET _version_numbers 0 BINPAC_VERSION_MAJOR)
|
||||
list(GET _version_numbers 1 BINPAC_VERSION_MINOR)
|
||||
string(REGEX REPLACE "-[0-9]*$" "" BINPAC_VERSION_MINOR ${BINPAC_VERSION_MINOR})
|
||||
|
||||
# The SO number shall increase only if binary interface changes.
|
||||
set(BINPAC_SOVERSION 0)
|
||||
|
||||
set(ENABLE_SHARED true)
|
||||
|
||||
if (ENABLE_STATIC_ONLY)
|
||||
set(ENABLE_STATIC true)
|
||||
set(ENABLE_SHARED false)
|
||||
endif ()
|
||||
|
||||
# Set default install paths
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# ##############################################################################
|
||||
# Dependency Configuration
|
||||
|
||||
find_package(FLEX REQUIRED)
|
||||
find_package(BISON REQUIRED)
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(/J) # Similar to -funsigned-char on other platforms
|
||||
endif ()
|
||||
|
||||
# ##############################################################################
|
||||
# System Introspection
|
||||
|
||||
configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h)
|
||||
|
||||
include_directories(BEFORE ${PROJECT_BINARY_DIR})
|
||||
|
||||
# ##############################################################################
|
||||
# Recurse on sub-directories
|
||||
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(src)
|
||||
|
||||
# ##############################################################################
|
||||
# Build Summary
|
||||
|
||||
if (CMAKE_BUILD_TYPE)
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
||||
endif ()
|
||||
|
||||
macro (display test desc summary)
|
||||
if (${test})
|
||||
set(${summary} ${desc})
|
||||
else ()
|
||||
set(${summary} no)
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
display(ENABLE_SHARED yes shared_summary)
|
||||
display(ENABLE_STATIC yes static_summary)
|
||||
|
||||
message(
|
||||
"\n==================| BinPAC Build Summary |===================="
|
||||
"\nVersion: ${BINPAC_VERSION}"
|
||||
"\nSO version: ${BINPAC_SOVERSION}"
|
||||
"\n"
|
||||
"\nBuild Type: ${CMAKE_BUILD_TYPE}"
|
||||
"\nDebug mode: ${ENABLE_DEBUG}"
|
||||
"\nInstall prefix: ${CMAKE_INSTALL_PREFIX}"
|
||||
"\nShared libs: ${shared_summary}"
|
||||
"\nStatic libs: ${static_summary}"
|
||||
"\n"
|
||||
"\nCC: ${CMAKE_C_COMPILER}"
|
||||
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
|
||||
"\nCXX: ${CMAKE_CXX_COMPILER}"
|
||||
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}"
|
||||
"\nCPP: ${CMAKE_CXX_COMPILER}"
|
||||
"\n"
|
||||
"\n================================================================\n")
|
||||
|
||||
include(UserChangedWarning)
|
||||
|
|
|
@ -10,23 +10,27 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
|||
set(binpac_headers ${CMAKE_CURRENT_BINARY_DIR}/binpac.h binpac_analyzer.h binpac_buffer.h
|
||||
binpac_bytestring.h binpac_exception.h binpac_regex.h)
|
||||
|
||||
set(binpac_lib_SRCS binpac_buffer.cc binpac_bytestring.cc binpac_regex.cc ${binpac_headers})
|
||||
set(binpac_lib_SRCS binpac_buffer.cc binpac_bytestring.cc binpac_regex.cc)
|
||||
|
||||
if (ENABLE_SHARED)
|
||||
add_library(binpac_lib SHARED ${binpac_lib_SRCS})
|
||||
set_target_properties(
|
||||
binpac_lib
|
||||
PROPERTIES SOVERSION ${BINPAC_SOVERSION}
|
||||
VERSION ${BINPAC_VERSION_MAJOR}.${BINPAC_VERSION_MINOR}
|
||||
MACOSX_RPATH true
|
||||
OUTPUT_NAME binpac)
|
||||
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif ()
|
||||
|
||||
if (ENABLE_STATIC)
|
||||
add_library(binpac_static STATIC ${binpac_lib_SRCS})
|
||||
if (BUILD_STATIC_BINPAC)
|
||||
add_library(binpac_static STATIC)
|
||||
target_sources(binpac_static PRIVATE ${binpac_lib_SRCS})
|
||||
set_target_properties(binpac_static PROPERTIES OUTPUT_NAME binpac)
|
||||
install(TARGETS binpac_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if (MSVC)
|
||||
target_compile_options(binpac_static PRIVATE "/J")
|
||||
endif ()
|
||||
set(BinPAC_LIBRARY binpac_static CACHE STRING "BinPAC library" FORCE)
|
||||
else ()
|
||||
add_library(binpac_lib SHARED)
|
||||
target_sources(binpac_lib PRIVATE ${binpac_lib_SRCS})
|
||||
target_sources(binpac_lib INTERFACE ${binpac_headers})
|
||||
set_target_properties(binpac_lib PROPERTIES MACOSX_RPATH true OUTPUT_NAME binpac)
|
||||
if (MSVC)
|
||||
target_compile_options(binpac_lib PRIVATE "/J")
|
||||
endif ()
|
||||
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
set(BinPAC_LIBRARY binpac_lib CACHE STRING "BinPAC library" FORCE)
|
||||
endif ()
|
||||
|
||||
if (ZEEK_ROOT_DIR)
|
||||
|
@ -36,13 +40,5 @@ else ()
|
|||
install(FILES ${binpac_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
endif ()
|
||||
|
||||
# This is set to assist superprojects that want to build BinPac from source and
|
||||
# rely on it as a target
|
||||
if (ENABLE_SHARED)
|
||||
set(BinPAC_LIBRARY binpac_lib CACHE STRING "BinPAC library" FORCE)
|
||||
else ()
|
||||
set(BinPAC_LIBRARY binpac_static CACHE STRING "BinPAC library" FORCE)
|
||||
endif ()
|
||||
|
||||
set(BinPAC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
CACHE STRING "BinPAC header directories" FORCE)
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
bison_target(PACParser pac_parse.yy ${BinPAC_BINARY_DIR}/src/pac_parse.cc
|
||||
DEFINES_FILE ${BinPAC_BINARY_DIR}/src/pac_parse.h COMPILE_FLAGS "--debug")
|
||||
flex_target(PACScanner pac_scan.ll ${BinPAC_BINARY_DIR}/pac_scan.cc)
|
||||
find_package(FLEX REQUIRED)
|
||||
find_package(BISON REQUIRED)
|
||||
|
||||
bison_target(PACParser pac_parse.yy ${CMAKE_CURRENT_BINARY_DIR}/pac_parse.cc
|
||||
DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/pac_parse.h COMPILE_FLAGS "--debug")
|
||||
flex_target(PACScanner pac_scan.ll ${CMAKE_CURRENT_BINARY_DIR}/pac_scan.cc)
|
||||
add_flex_bison_dependency(PACScanner PACParser)
|
||||
if (MSVC)
|
||||
set_property(SOURCE pac_scan.cc APPEND_STRING PROPERTY COMPILE_FLAGS "/wd4018")
|
||||
|
@ -8,8 +11,6 @@ else ()
|
|||
set_property(SOURCE pac_scan.cc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-sign-compare")
|
||||
endif ()
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src)
|
||||
|
||||
set(binpac_SRCS
|
||||
${BISON_PACParser_INPUT}
|
||||
${FLEX_PACScanner_INPUT}
|
||||
|
@ -52,62 +53,19 @@ set(binpac_SRCS
|
|||
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_nullptr.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)
|
||||
|
||||
include(${PROJECT_SOURCE_DIR}/cmake/RequireCXXStd.cmake)
|
||||
pac_main.cc)
|
||||
|
||||
add_executable(binpac ${binpac_SRCS})
|
||||
|
||||
target_include_directories(binpac BEFORE PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(binpac BEFORE PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(binpac PUBLIC "/J")
|
||||
# If building separately from zeek, we need to add the libunistd subdirectory
|
||||
# so that linking doesn't fail.
|
||||
if ("${CMAKE_PROJECT_NAME}" STREQUAL "BinPAC")
|
||||
add_subdirectory(auxil/libunistd EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}auxil/libunistd EXCLUDE_FROM_ALL)
|
||||
endif ()
|
||||
target_link_libraries(binpac PRIVATE libunistd)
|
||||
endif ()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "pac_common.h"
|
||||
#include "pac_decl.h"
|
||||
#include "pac_exception.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue