Skip to content

Commit

Permalink
Change: try first pkg-config and then with find_library for ksba and …
Browse files Browse the repository at this point in the history
…gpgme (#1339)

* Change: try first pkg-config and then with find_library for ksba

It seems libksba 1.6.x had dropped the ksba-config support completely

* Change: try first pkg-config and then with find_library for gpgme

* Change: remove leading whitespaces from LDFLAGS for libpcap
  • Loading branch information
jjnicola committed Feb 28, 2023
1 parent 9c181d0 commit 19c12ef
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 33 deletions.
1 change: 1 addition & 0 deletions misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if (PCAP_CONFIG)
execute_process (COMMAND pcap-config --libs
OUTPUT_VARIABLE PCAP_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(STRIP ${PCAP_LDFLAGS} PCAP_LDFLAGS)
execute_process (COMMAND pcap-config --cflags
OUTPUT_VARIABLE PCAP_CFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand Down
74 changes: 41 additions & 33 deletions nasl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,52 @@ pkg_check_modules (OPENVAS_WMICLIENT libopenvas_wmiclient>=1.0.5)
# for 'nasl' binary
pkg_check_modules (LIBSSH REQUIRED libssh>=0.6.0)


set (KSBA_MIN_VERSION "1.0.7")
message (STATUS "Looking for ksba >= ${KSBA_MIN_VERSION}...")
find_library (KSBA ksba)
message (STATUS "Looking for ksba >= ${KSBA_MIN_VERSION}... ${KSBA}")
if (NOT KSBA)
message (SEND_ERROR "The ksba library is required.")
else (NOT KSBA)
execute_process (COMMAND ksba-config --version
OUTPUT_VARIABLE KSBA_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
message (STATUS "Found ksba ${KSBA_VERSION}...")
if (${KSBA_VERSION} VERSION_LESS ${KSBA_MIN_VERSION})
message (SEND_ERROR "The ksba library >= ${KSBA_MIN_VERSION} is required.")
else (${KSBA_VERSION} VERSION_LESS ${KSBA_MIN_VERSION})
execute_process (COMMAND ksba-config --libs
OUTPUT_VARIABLE KSBA_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ksba-config --cflags
OUTPUT_VARIABLE KSBA_CFLAGS
# try with package config
pkg_check_modules (KSBA REQUIRED ksba>=1.0.7)
if (NOT KSBA_FOUND)
# try with find library
find_library (KSBA ksba)
message (STATUS "Looking for ksba >= ${KSBA_MIN_VERSION}...")
if (NOT KSBA)
message (SEND_ERROR "The ksba library is required.")
else (NOT KSBA)
execute_process (COMMAND ksba-config --version
OUTPUT_VARIABLE KSBA_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif (${KSBA_VERSION} VERSION_LESS ${KSBA_MIN_VERSION})
endif (NOT KSBA)
message (STATUS "Found ksba ${KSBA_VERSION}...")
if (${KSBA_VERSION} VERSION_LESS ${KSBA_MIN_VERSION})
message (SEND_ERROR "The ksba library >= ${KSBA_MIN_VERSION} is required.")
else (${KSBA_VERSION} VERSION_LESS ${KSBA_MIN_VERSION})
execute_process (COMMAND ksba-config --libs
OUTPUT_VARIABLE KSBA_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND ksba-config --cflags
OUTPUT_VARIABLE KSBA_CFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif (${KSBA_VERSION} VERSION_LESS ${KSBA_MIN_VERSION})
endif (NOT KSBA)
endif (NOT KSBA_FOUND)

message (STATUS "Looking for pcap...")
find_library (PCAP pcap)

find_library (GPGME gpgme)
message (STATUS "Looking for gpgme... ${GPGME}")
if (NOT GPGME)
message (SEND_ERROR "The gpgme library is required.")
endif (NOT GPGME)
pkg_check_modules (GPGME REQUIRED gpgme)
if (NOT GPGME_FOUND)
find_library (GPGME gpgme)
message (STATUS "Looking for gpgme... ${GPGME}")
if (NOT GPGME)
message (SEND_ERROR "The gpgme library is required.")
endif (NOT GPGME)

execute_process (COMMAND gpgme-config --libs
OUTPUT_VARIABLE GPGME_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND gpgme-config --cflags
OUTPUT_VARIABLE GPGME_CFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND gpgme-config --libs
OUTPUT_VARIABLE GPGME_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process (COMMAND gpgme-config --cflags
OUTPUT_VARIABLE GPGME_CFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif (NOT GPGME_FOUND)

message (STATUS "Looking for netsnmp...")
find_library (SNMP netsnmp)
Expand Down Expand Up @@ -155,9 +163,9 @@ if (NOT OPENVAS_WMICLIENT_FOUND)
set (FILES smb_interface_stub.c wmi_interface_stub.c ${FILES})
endif (NOT OPENVAS_WMICLIENT_FOUND)

if (KSBA)
if (KSBA OR KSBA_FOUND)
add_definitions (-DHAVE_LIBKSBA)
endif (KSBA)
endif (KSBA OR KSBA_FOUND)

if (OPENVAS_CONF)
add_definitions (-DOPENVAS_CONF="${OPENVAS_CONF}")
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ if (PCAP_CONFIG)
execute_process (COMMAND pcap-config --libs
OUTPUT_VARIABLE PCAP_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(STRIP ${PCAP_LDFLAGS} PCAP_LDFLAGS)
execute_process (COMMAND pcap-config --cflags
OUTPUT_VARIABLE PCAP_CFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand Down

0 comments on commit 19c12ef

Please sign in to comment.