Browse Source

* refactor CMakeLists.txt to use pkg-config

master
Alex 'AdUser' Z 2 years ago
parent
commit
2dfe4a1a88
  1. 3
      CMakeLists.txt
  2. 14
      src/backends/CMakeLists.txt
  3. 0
      src/backends/ipset6.c
  4. 4
      src/filters/CMakeLists.txt
  5. 4
      src/sources/CMakeLists.txt

3
CMakeLists.txt

@ -40,9 +40,6 @@ if (WITH_HARDENING)
add_definitions("-D_FORTIFY_SOURCE=2")
endif ()
pkg_check_modules(IPSET "libipset")
pkg_check_modules(REDIS "hiredis")
pkg_check_modules(PCRE "libpcre")
pkg_check_modules(READLINE "readline" REQUIRED)
message(STATUS "----------------------------------------")

14
src/backends/CMakeLists.txt

@ -5,16 +5,20 @@ set(BACKENDS "")
add_library("b_exec" MODULE "exec.c" "../strlcpy.c")
list(APPEND BACKENDS "exec")
find_library(REDIS_FOUND "hiredis")
if (WITH_REDIS AND REDIS_FOUND)
if (WITH_REDIS)
pkg_check_modules(REDIS "hiredis" REQUIRED)
add_library("b_redis" MODULE "redis.c" "../strlcpy.c")
target_link_libraries("b_redis" "hiredis")
list(APPEND BACKENDS "redis")
endif ()
find_library(IPSET_FOUND "ipset")
if (WITH_IPSET AND IPSET_FOUND)
add_library("b_ipset" MODULE "ipset.c" "../strlcpy.c")
if (WITH_IPSET)
pkg_check_modules(IPSET "libipset" REQUIRED)
if (IPSET_VERSION VERSION_LESS 7)
add_library("b_ipset" MODULE "ipset6.c" "../strlcpy.c")
else ()
message(SEND_ERROR "ipset version >= 7.X not supported yet")
endif ()
target_link_libraries("b_ipset" "ipset")
list(APPEND BACKENDS "ipset")
endif ()

0
src/backends/ipset.c → src/backends/ipset6.c

4
src/filters/CMakeLists.txt

@ -5,8 +5,8 @@ set(FILTERS "")
add_library("f_preg" MODULE "preg.c" "../strlcpy.c" "../fnv32a.c")
list(APPEND FILTERS "preg")
find_library(PCRE_FOUND "pcre")
if (WITH_PCRE AND PCRE_FOUND)
if (WITH_PCRE)
pkg_check_modules(PCRE "libpcre" REQUIRED)
add_library("f_pcre" MODULE "pcre.c" "../strlcpy.c" "../fnv32a.c")
target_link_libraries("f_pcre" "pcre")
list(APPEND FILTERS "pcre")

4
src/sources/CMakeLists.txt

@ -8,8 +8,8 @@ list(APPEND SOURCES "files")
add_library("s_portknock" MODULE "portknock.c" "../strlcpy.c" "../fnv32a.c")
list(APPEND SOURCES "portknock")
find_library(REDIS_FOUND "hiredis")
if (WITH_REDIS AND REDIS_FOUND)
if (WITH_REDIS)
pkg_check_modules(REDIS "hiredis" REQUIRED)
add_library("s_redis" MODULE "redis.c" "../strlcpy.c")
target_link_libraries("s_redis" "hiredis")
list(APPEND SOURCES "redis")

Loading…
Cancel
Save