binpac: Add missing .cmake-format.json, reformat with pre-commit

This commit is contained in:
Tim Wojtulewicz 2025-05-09 16:23:40 -07:00
parent dacfe747b9
commit 670c4dcbcf
4 changed files with 86 additions and 106 deletions

View file

@ -4,16 +4,13 @@ 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})
@ -31,15 +28,13 @@ 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 ()
@ -47,15 +42,10 @@ 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
CACHE STRING "BinPAC library" FORCE)
else () else ()
set(BinPAC_LIBRARY set(BinPAC_LIBRARY binpac_static CACHE STRING "BinPAC library" FORCE)
binpac_static
CACHE STRING "BinPAC library" FORCE)
endif () 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)

View file

@ -1,19 +1,11 @@
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
APPEND_STRING
PROPERTY COMPILE_FLAGS "/wd4018")
else () else ()
set_property( set_property(SOURCE pac_scan.cc APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-sign-compare")
SOURCE pac_scan.cc
APPEND_STRING
PROPERTY COMPILE_FLAGS "-Wno-sign-compare")
endif () endif ()
include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src)
@ -123,6 +115,4 @@ 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)