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") add_definitions("-D_FORTIFY_SOURCE=2")
endif () endif ()
pkg_check_modules(IPSET "libipset")
pkg_check_modules(REDIS "hiredis")
pkg_check_modules(PCRE "libpcre")
pkg_check_modules(READLINE "readline" REQUIRED) pkg_check_modules(READLINE "readline" REQUIRED)
message(STATUS "----------------------------------------") message(STATUS "----------------------------------------")

14
src/backends/CMakeLists.txt

@ -5,16 +5,20 @@ set(BACKENDS "")
add_library("b_exec" MODULE "exec.c" "../strlcpy.c") add_library("b_exec" MODULE "exec.c" "../strlcpy.c")
list(APPEND BACKENDS "exec") list(APPEND BACKENDS "exec")
find_library(REDIS_FOUND "hiredis") if (WITH_REDIS)
if (WITH_REDIS AND REDIS_FOUND) pkg_check_modules(REDIS "hiredis" REQUIRED)
add_library("b_redis" MODULE "redis.c" "../strlcpy.c") add_library("b_redis" MODULE "redis.c" "../strlcpy.c")
target_link_libraries("b_redis" "hiredis") target_link_libraries("b_redis" "hiredis")
list(APPEND BACKENDS "redis") list(APPEND BACKENDS "redis")
endif () endif ()
find_library(IPSET_FOUND "ipset") if (WITH_IPSET)
if (WITH_IPSET AND IPSET_FOUND) pkg_check_modules(IPSET "libipset" REQUIRED)
add_library("b_ipset" MODULE "ipset.c" "../strlcpy.c") 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") target_link_libraries("b_ipset" "ipset")
list(APPEND BACKENDS "ipset") list(APPEND BACKENDS "ipset")
endif () 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") add_library("f_preg" MODULE "preg.c" "../strlcpy.c" "../fnv32a.c")
list(APPEND FILTERS "preg") list(APPEND FILTERS "preg")
find_library(PCRE_FOUND "pcre") if (WITH_PCRE)
if (WITH_PCRE AND PCRE_FOUND) pkg_check_modules(PCRE "libpcre" REQUIRED)
add_library("f_pcre" MODULE "pcre.c" "../strlcpy.c" "../fnv32a.c") add_library("f_pcre" MODULE "pcre.c" "../strlcpy.c" "../fnv32a.c")
target_link_libraries("f_pcre" "pcre") target_link_libraries("f_pcre" "pcre")
list(APPEND FILTERS "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") add_library("s_portknock" MODULE "portknock.c" "../strlcpy.c" "../fnv32a.c")
list(APPEND SOURCES "portknock") list(APPEND SOURCES "portknock")
find_library(REDIS_FOUND "hiredis") if (WITH_REDIS)
if (WITH_REDIS AND REDIS_FOUND) pkg_check_modules(REDIS "hiredis" REQUIRED)
add_library("s_redis" MODULE "redis.c" "../strlcpy.c") add_library("s_redis" MODULE "redis.c" "../strlcpy.c")
target_link_libraries("s_redis" "hiredis") target_link_libraries("s_redis" "hiredis")
list(APPEND SOURCES "redis") list(APPEND SOURCES "redis")

Loading…
Cancel
Save