From: Mike Stepanek (mstepane) Date: Wed, 30 Mar 2022 12:19:00 +0000 (+0000) Subject: Pull request #3327: build: compile against libatomic if present X-Git-Tag: 3.1.27.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e14cb535221cab70c6656ef1c92a624921318b8;p=thirdparty%2Fsnort3.git Pull request #3327: build: compile against libatomic if present Merge in SNORT/snort3 from ~OSERHIIE/snort3:libatomic to master Squashed commit of the following: commit 720d367bae80b58612840d74a6af2d626ba1e4ad Author: Oleksandr Serhiienko Date: Mon Mar 28 21:19:14 2022 +0300 build: compile against libatomic if present Thanks to W. Michael Petullo --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e80b12de..c76152321 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,6 +116,14 @@ else () DAQ Modules: Dynamic") endif () +if (HAVE_ATOMIC) + message("\ + libatomic: User-specified") +else () + message("\ + libatomic: System-provided") +endif () + if (HAVE_FLATBUFFERS) message("\ Flatbuffers: ON") diff --git a/cmake/FindAtomic.cmake b/cmake/FindAtomic.cmake new file mode 100644 index 000000000..f1c376f32 --- /dev/null +++ b/cmake/FindAtomic.cmake @@ -0,0 +1,11 @@ +find_library(ATOMIC_LIBRARIES NAMES atomic + HINTS ${ATOMIC_LIBRARIES_DIR_HINT}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Atomic DEFAULT_MSG ATOMIC_LIBRARIES) + +mark_as_advanced(ATOMIC_LIBRARIES) + +if (ATOMIC_LIBRARIES) + set(HAVE_ATOMIC "1") +endif() diff --git a/cmake/include_libraries.cmake b/cmake/include_libraries.cmake index 6e3f6f33c..4f4edeafa 100644 --- a/cmake/include_libraries.cmake +++ b/cmake/include_libraries.cmake @@ -15,6 +15,7 @@ if (ENABLE_UNIT_TESTS) endif (ENABLE_UNIT_TESTS) # optional libraries +find_package(Atomic QUIET) find_package(LibLZMA QUIET) find_package(Asciidoc QUIET) find_package(DBLATEX QUIET) diff --git a/configure_cmake.sh b/configure_cmake.sh index 8c2d2b147..6d901de1a 100755 --- a/configure_cmake.sh +++ b/configure_cmake.sh @@ -108,6 +108,8 @@ Optional Packages: libhs include directory --with-hyperscan-libraries=DIR libhs library directory + --with-atomic-libraries=DIR + atomic library directory --with-flatbuffers-includes=DIR flatbuffers include directory --with-flatbuffers-libraries=DIR @@ -447,6 +449,9 @@ while [ $# -ne 0 ]; do --with-hyperscan-libraries=*) append_cache_entry HS_LIBRARIES_DIR PATH $optarg ;; + --with-atomic-libraries=*) + append_cache_entry ATOMIC_LIBRARIES_DIR_HINT PATH $optarg + ;; --with-flatbuffers-includes=*) append_cache_entry FLATBUFFERS_INCLUDE_DIR_HINT PATH $optarg ;; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 756be1589..e737d536c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,6 +29,10 @@ if ( ENABLE_STATIC_DAQ ) LIST(APPEND EXTERNAL_LIBRARIES ${DAQ_STATIC_MODULE_LIBS}) endif () +if ( HAVE_ATOMIC ) + LIST(APPEND EXTERNAL_LIBRARIES ${ATOMIC_LIBRARIES}) +endif() + if ( HAVE_FLATBUFFERS ) LIST(APPEND EXTERNAL_LIBRARIES ${FLATBUFFERS_LIBRARIES}) endif()