mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
binpac: Add missing .cmake-format.json, reformat with pre-commit
This commit is contained in:
parent
dacfe747b9
commit
670c4dcbcf
4 changed files with 86 additions and 106 deletions
|
@ -14,10 +14,10 @@ set(BINPAC_SOVERSION 0)
|
||||||
|
|
||||||
set(ENABLE_SHARED true)
|
set(ENABLE_SHARED true)
|
||||||
|
|
||||||
if(ENABLE_STATIC_ONLY)
|
if (ENABLE_STATIC_ONLY)
|
||||||
set(ENABLE_STATIC true)
|
set(ENABLE_STATIC true)
|
||||||
set(ENABLE_SHARED false)
|
set(ENABLE_SHARED false)
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
# Set default install paths
|
# Set default install paths
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
@ -28,9 +28,9 @@ include(GNUInstallDirs)
|
||||||
find_package(FLEX REQUIRED)
|
find_package(FLEX REQUIRED)
|
||||||
find_package(BISON REQUIRED)
|
find_package(BISON REQUIRED)
|
||||||
|
|
||||||
if(MSVC)
|
if (MSVC)
|
||||||
add_compile_options(/J) # Similar to -funsigned-char on other platforms
|
add_compile_options(/J) # Similar to -funsigned-char on other platforms
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
# System Introspection
|
# System Introspection
|
||||||
|
@ -48,17 +48,17 @@ add_subdirectory(src)
|
||||||
# ##############################################################################
|
# ##############################################################################
|
||||||
# Build Summary
|
# Build Summary
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE)
|
if (CMAKE_BUILD_TYPE)
|
||||||
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
macro(display test desc summary)
|
macro (display test desc summary)
|
||||||
if(${test})
|
if (${test})
|
||||||
set(${summary} ${desc})
|
set(${summary} ${desc})
|
||||||
else()
|
else ()
|
||||||
set(${summary} no)
|
set(${summary} no)
|
||||||
endif()
|
endif ()
|
||||||
endmacro()
|
endmacro ()
|
||||||
|
|
||||||
display(ENABLE_SHARED yes shared_summary)
|
display(ENABLE_SHARED yes shared_summary)
|
||||||
display(ENABLE_STATIC yes static_summary)
|
display(ENABLE_STATIC yes static_summary)
|
||||||
|
|
|
@ -4,18 +4,15 @@ test_big_endian(HOST_BIGENDIAN)
|
||||||
include(CheckTypeSize)
|
include(CheckTypeSize)
|
||||||
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
|
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/binpac.h.in
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/binpac.h.in ${CMAKE_CURRENT_BINARY_DIR}/binpac.h)
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/binpac.h)
|
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
set(binpac_headers
|
set(binpac_headers ${CMAKE_CURRENT_BINARY_DIR}/binpac.h binpac_analyzer.h binpac_buffer.h
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/binpac.h binpac_analyzer.h binpac_buffer.h
|
|
||||||
binpac_bytestring.h binpac_exception.h binpac_regex.h)
|
binpac_bytestring.h binpac_exception.h binpac_regex.h)
|
||||||
|
|
||||||
set(binpac_lib_SRCS binpac_buffer.cc binpac_bytestring.cc binpac_regex.cc
|
set(binpac_lib_SRCS binpac_buffer.cc binpac_bytestring.cc binpac_regex.cc ${binpac_headers})
|
||||||
${binpac_headers})
|
|
||||||
|
|
||||||
if(ENABLE_SHARED)
|
if (ENABLE_SHARED)
|
||||||
add_library(binpac_lib SHARED ${binpac_lib_SRCS})
|
add_library(binpac_lib SHARED ${binpac_lib_SRCS})
|
||||||
target_compile_features(binpac_lib PRIVATE cxx_std_17)
|
target_compile_features(binpac_lib PRIVATE cxx_std_17)
|
||||||
set_target_properties(
|
set_target_properties(
|
||||||
|
@ -26,36 +23,29 @@ if(ENABLE_SHARED)
|
||||||
MACOSX_RPATH true
|
MACOSX_RPATH true
|
||||||
OUTPUT_NAME binpac)
|
OUTPUT_NAME binpac)
|
||||||
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(TARGETS binpac_lib DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
if(ENABLE_STATIC)
|
if (ENABLE_STATIC)
|
||||||
add_library(binpac_static STATIC ${binpac_lib_SRCS})
|
add_library(binpac_static STATIC ${binpac_lib_SRCS})
|
||||||
target_compile_features(binpac_static PRIVATE cxx_std_17)
|
target_compile_features(binpac_static PRIVATE cxx_std_17)
|
||||||
set_target_properties(binpac_static PROPERTIES CXX_EXTENSIONS OFF OUTPUT_NAME
|
set_target_properties(binpac_static PROPERTIES CXX_EXTENSIONS OFF OUTPUT_NAME binpac)
|
||||||
binpac)
|
|
||||||
install(TARGETS binpac_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
install(TARGETS binpac_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
if(ZEEK_ROOT_DIR)
|
if (ZEEK_ROOT_DIR)
|
||||||
# Installed in binpac subdir just for organization purposes.
|
# Installed in binpac subdir just for organization purposes.
|
||||||
install(FILES ${binpac_headers}
|
install(FILES ${binpac_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/binpac)
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/binpac)
|
else ()
|
||||||
else()
|
|
||||||
install(FILES ${binpac_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
install(FILES ${binpac_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
# This is set to assist superprojects that want to build BinPac from source and
|
# This is set to assist superprojects that want to build BinPac from source and
|
||||||
# rely on it as a target
|
# rely on it as a target
|
||||||
if(ENABLE_SHARED)
|
if (ENABLE_SHARED)
|
||||||
set(BinPAC_LIBRARY
|
set(BinPAC_LIBRARY binpac_lib CACHE STRING "BinPAC library" FORCE)
|
||||||
binpac_lib
|
else ()
|
||||||
CACHE STRING "BinPAC library" FORCE)
|
set(BinPAC_LIBRARY binpac_static CACHE STRING "BinPAC library" FORCE)
|
||||||
else()
|
endif ()
|
||||||
set(BinPAC_LIBRARY
|
|
||||||
binpac_static
|
|
||||||
CACHE STRING "BinPAC library" FORCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(BinPAC_INCLUDE_DIR
|
set(BinPAC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
CACHE STRING "BinPAC header directories" FORCE)
|
CACHE STRING "BinPAC header directories" FORCE)
|
||||||
|
|
|
@ -1,20 +1,12 @@
|
||||||
bison_target(
|
bison_target(PACParser pac_parse.yy ${BinPAC_BINARY_DIR}/src/pac_parse.cc
|
||||||
PACParser pac_parse.yy ${BinPAC_BINARY_DIR}/src/pac_parse.cc
|
DEFINES_FILE ${BinPAC_BINARY_DIR}/src/pac_parse.h COMPILE_FLAGS "--debug")
|
||||||
DEFINES_FILE ${BinPAC_BINARY_DIR}/src/pac_parse.h
|
|
||||||
COMPILE_FLAGS "--debug")
|
|
||||||
flex_target(PACScanner pac_scan.ll ${BinPAC_BINARY_DIR}/pac_scan.cc)
|
flex_target(PACScanner pac_scan.ll ${BinPAC_BINARY_DIR}/pac_scan.cc)
|
||||||
add_flex_bison_dependency(PACScanner PACParser)
|
add_flex_bison_dependency(PACScanner PACParser)
|
||||||
if(MSVC)
|
if (MSVC)
|
||||||
set_property(
|
set_property(SOURCE pac_scan.cc APPEND_STRING PROPERTY COMPILE_FLAGS "/wd4018")
|
||||||
SOURCE pac_scan.cc
|
else ()
|
||||||
APPEND_STRING
|
set_property(SOURCE pac_scan.cc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-sign-compare")
|
||||||
PROPERTY COMPILE_FLAGS "/wd4018")
|
endif ()
|
||||||
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)
|
include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src)
|
||||||
|
|
||||||
|
@ -110,19 +102,17 @@ add_executable(binpac ${binpac_SRCS})
|
||||||
target_compile_features(binpac PRIVATE cxx_std_17)
|
target_compile_features(binpac PRIVATE cxx_std_17)
|
||||||
set_target_properties(binpac PROPERTIES CXX_EXTENSIONS OFF)
|
set_target_properties(binpac PROPERTIES CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
if(MSVC)
|
if (MSVC)
|
||||||
# If building separately from zeek, we need to add the libunistd subdirectory
|
# If building separately from zeek, we need to add the libunistd subdirectory
|
||||||
# so that linking doesn't fail.
|
# so that linking doesn't fail.
|
||||||
if("${CMAKE_PROJECT_NAME}" STREQUAL "BinPAC")
|
if ("${CMAKE_PROJECT_NAME}" STREQUAL "BinPAC")
|
||||||
add_subdirectory(auxil/libunistd EXCLUDE_FROM_ALL)
|
add_subdirectory(auxil/libunistd EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif ()
|
||||||
target_link_libraries(binpac PRIVATE libunistd)
|
target_link_libraries(binpac PRIVATE libunistd)
|
||||||
endif()
|
endif ()
|
||||||
|
|
||||||
install(TARGETS binpac DESTINATION bin)
|
install(TARGETS binpac DESTINATION bin)
|
||||||
|
|
||||||
# This is set to assist superprojects that want to build BinPac from source and
|
# This is set to assist superprojects that want to build BinPac from source and
|
||||||
# rely on it as a target
|
# rely on it as a target
|
||||||
set(BinPAC_EXE
|
set(BinPAC_EXE binpac CACHE STRING "BinPAC executable" FORCE)
|
||||||
binpac
|
|
||||||
CACHE STRING "BinPAC executable" FORCE)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue