"Fossies" - the Fresh Open Source Software Archive

Member "gvm-libs-11.0.1/util/CMakeLists.txt" (12 May 2020, 8060 Bytes) of package /linux/misc/openvas/gvm-libs-11.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 11.0.0_vs_11.0.1.

    1 # Copyright (C) 2016-2019 Greenbone Networks GmbH
    2 #
    3 # SPDX-License-Identifier: GPL-2.0-or-later
    4 #
    5 # This program is free software; you can redistribute it and/or
    6 # modify it under the terms of the GNU General Public License
    7 # as published by the Free Software Foundation; either version 2
    8 # of the License, or (at your option) any later version.
    9 #
   10 # This program is distributed in the hope that it will be useful,
   11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 # GNU General Public License for more details.
   14 #
   15 # You should have received a copy of the GNU General Public License
   16 # along with this program; if not, write to the Free Software
   17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18 
   19 ## Library
   20 
   21 include (FindPkgConfig)
   22 
   23 if (NOT PKG_CONFIG_FOUND)
   24   message(FATAL_ERROR "pkg-config executable not found. Aborting.")
   25 endif (NOT PKG_CONFIG_FOUND)
   26 
   27 ## Dependency checks
   28 
   29 # for all modules we need glib
   30 pkg_check_modules (GLIB REQUIRED glib-2.0>=2.42)
   31 
   32 # for compressutils we need zlib
   33 pkg_check_modules (ZLIB REQUIRED zlib>=1.2.8)
   34 
   35 # for fileutils we need giolib
   36 pkg_check_modules (GIO REQUIRED gio-2.0>=2.42)
   37 
   38 # for serverutils, sshutils and xmlutils we need gnutls
   39 pkg_check_modules (GNUTLS REQUIRED gnutls>=3.2.15)
   40 
   41 # for uuidutils we need uuidlib
   42 pkg_check_modules (UUID REQUIRED uuid>=2.25.0)
   43 
   44 # for sshutils we need libssh
   45 pkg_check_modules (LIBSSH REQUIRED libssh>=0.6.0)
   46 
   47 # for kb we need libhiredis
   48 pkg_check_modules (REDIS REQUIRED hiredis>=0.10.1)
   49 
   50 # for fast XML we need libxml2
   51 pkg_check_modules (LIBXML2 REQUIRED libxml-2.0>=2.0)
   52 
   53 # Set NVTICACHE name with the version
   54 set (NVTICACHE_STR "nvticache${PROJECT_VERSION}")
   55 add_definitions (-DNVTICACHE_STR="${NVTICACHE_STR}")
   56 
   57 #for gpgmeutils we need libgpgme
   58 set (GPGME_MIN_VERSION "1.1.2")
   59 message (STATUS "Looking for gpgme...")
   60 find_library (GPGME gpgme)
   61 if (NOT GPGME)
   62   message (SEND_ERROR "The gpgme library is required.")
   63 else (NOT GPGME)
   64   execute_process (COMMAND gpgme-config --version
   65     OUTPUT_VARIABLE GPGME_VERSION
   66     OUTPUT_STRIP_TRAILING_WHITESPACE)
   67   message (STATUS "Found gpgme: ${GPGME}, version ${GPGME_VERSION}")
   68   if (GPGME_VERSION VERSION_LESS GPGME_MIN_VERSION)
   69     message (SEND_ERROR "The gpgme library >= ${GPGME_MIN_VERSION} is required.")
   70   else (GPGME_VERSION VERSION_LESS GPGME_MIN_VERSION)
   71     execute_process (COMMAND gpgme-config --libs
   72       OUTPUT_VARIABLE GPGME_LDFLAGS
   73       OUTPUT_STRIP_TRAILING_WHITESPACE)
   74     execute_process (COMMAND gpgme-config --cflags
   75       OUTPUT_VARIABLE GPGME_CFLAGS
   76       OUTPUT_STRIP_TRAILING_WHITESPACE)
   77     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1")
   78     string(REPLACE "-I" "" GPGME_INCLUDE_DIRS "${GPGME_CFLAGS}")
   79   endif (GPGME_VERSION VERSION_LESS GPGME_MIN_VERSION)
   80 endif (NOT GPGME)
   81 
   82 message (STATUS "Looking for libgcrypt...")
   83 find_library (GCRYPT gcrypt)
   84 message (STATUS "Looking for libgcrypt... ${GCRYPT}")
   85 if (NOT GCRYPT)
   86 message (SEND_ERROR "The libgcrypt library is required.")
   87 else (NOT GCRYPT)
   88 execute_process (COMMAND libgcrypt-config --libs
   89     OUTPUT_VARIABLE GCRYPT_LDFLAGS
   90     OUTPUT_STRIP_TRAILING_WHITESPACE)
   91 execute_process (COMMAND libgcrypt-config --cflags
   92     OUTPUT_VARIABLE GCRYPT_CFLAGS
   93     OUTPUT_STRIP_TRAILING_WHITESPACE)
   94 string(REPLACE "-I" "" GCRYPT_INCLUDE_DIRS "${GCRYPT_CFLAGS}")
   95 endif (NOT GCRYPT)
   96 
   97 option (BUILD_WITH_RADIUS "Try to build with Radius support" ON)
   98 option (BUILD_WITH_LDAP "Try to build with LDAP support" ON)
   99 
  100 if (BUILD_WITH_RADIUS)
  101   #for radiusutils we need freerdius-client library
  102   message (STATUS "Looking for freeradius-client library...")
  103   find_library (LIBFREERADIUS freeradius-client)
  104   if (NOT LIBFREERADIUS)
  105     message (STATUS "Looking for radcli library...")
  106     find_library (LIBRADCLI radcli)
  107   endif (NOT LIBFREERADIUS)
  108   if (NOT LIBFREERADIUS AND NOT LIBRADCLI)
  109     message (STATUS "  No suitable radius library found - radius support disabled")
  110   elseif (LIBFREERADIUS)
  111     message (STATUS "  Found ${LIBFREERADIUS} - radius support enabled")
  112     set (RADIUS_LDFLAGS "-lfreeradius-client")
  113     add_definitions (-DENABLE_RADIUS_AUTH=1 -DRADIUS_AUTH_FREERADIUS=1)
  114   elseif (LIBRADCLI)
  115     message (STATUS "  Found ${LIBRADCLI} - radius support enabled")
  116     set (RADIUS_LDFLAGS "-lradcli")
  117     add_definitions (-DENABLE_RADIUS_AUTH=1 -DRADIUS_AUTH_RADCLI=1)
  118   endif (NOT LIBFREERADIUS AND NOT LIBRADCLI)
  119 endif (BUILD_WITH_RADIUS)
  120 
  121 if (BUILD_WITH_LDAP)
  122   #for ldaputils we need ldap library
  123   message (STATUS "Looking for libldap...")
  124   find_library (LIBLDAP ldap2)
  125   if (NOT LIBLDAP)
  126     find_library (LIBLDAP ldap)
  127   endif (NOT LIBLDAP)
  128   if (NOT LIBLDAP)
  129     message (STATUS "  No ldap library found - ldap support disabled")
  130   else (NOT LIBLDAP)
  131     message (STATUS "  Found ${LIBLDAP} - ldap support enabled")
  132     add_definitions (-DENABLE_LDAP_AUTH=1)
  133     set (LDAP_LDFLAGS "-lldap")
  134   endif (NOT LIBLDAP)
  135 endif (BUILD_WITH_LDAP)
  136 
  137 include_directories (${GLIB_INCLUDE_DIRS} ${GPGME_INCLUDE_DIRS} ${GCRYPT_INCLUDE_DIRS}
  138                      ${LIBXML2_INCLUDE_DIRS})
  139 
  140 set (FILES authutils.c compressutils.c fileutils.c gpgmeutils.c kb.c ldaputils.c
  141            nvticache.c radiusutils.c serverutils.c sshutils.c uuidutils.c
  142            xmlutils.c)
  143 
  144 set (HEADERS authutils.h compressutils.h fileutils.h gpgmeutils.h kb.h
  145              ldaputils.h nvticache.h radiusutils.h serverutils.h sshutils.h
  146              uuidutils.h xmlutils.h)
  147 
  148 if (BUILD_STATIC)
  149   add_library (gvm_util_static STATIC ${FILES})
  150   set_target_properties (gvm_util_static PROPERTIES OUTPUT_NAME "gvm_util")
  151   set_target_properties (gvm_util_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  152   set_target_properties (gvm_util_static PROPERTIES PUBLIC_HEADER "${HEADERS}")
  153 endif (BUILD_STATIC)
  154 
  155 if (BUILD_SHARED)
  156   add_library (gvm_util_shared SHARED ${FILES})
  157   set_target_properties (gvm_util_shared PROPERTIES OUTPUT_NAME "gvm_util")
  158   set_target_properties (gvm_util_shared PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  159   set_target_properties (gvm_util_shared PROPERTIES SOVERSION "${PROJECT_VERSION_MAJOR}")
  160   set_target_properties (gvm_util_shared PROPERTIES VERSION "${CPACK_PACKAGE_VERSION}")
  161   set_target_properties (gvm_util_shared PROPERTIES PUBLIC_HEADER "${HEADERS}")
  162 
  163   target_link_libraries (gvm_util_shared LINK_PRIVATE ${GLIB_LDFLAGS}
  164                          ${GIO_LDFLAGS} ${GPGME_LDFLAGS} ${ZLIB_LDFLAGS}
  165                          ${RADIUS_LDFLAGS} ${LIBSSH_LDFLAGS} ${GNUTLS_LDFLAGS}
  166                          ${GCRYPT_LDFLAGS} ${LDAP_LDFLAGS} ${REDIS_LDFLAGS}
  167                          ${LIBXML2_LDFLAGS} ${UUID_LDFLAGS}
  168                          ${LINKER_HARDENING_FLAGS})
  169 endif (BUILD_SHARED)
  170 
  171 
  172 ## Tests
  173 
  174 if (BUILD_TESTS)
  175   add_executable (xmlutils-test
  176                   EXCLUDE_FROM_ALL
  177                   xmlutils_tests.c)
  178 
  179   add_test (xmlutils-test xmlutils-test)
  180 
  181   target_include_directories (xmlutils-test PRIVATE ${CGREEN_INCLUDE_DIRS})
  182 
  183   target_link_libraries (xmlutils-test ${CGREEN_LIBRARIES}
  184                         ${GLIB_LDFLAGS} ${GIO_LDFLAGS} ${GPGME_LDFLAGS} ${ZLIB_LDFLAGS}
  185               ${RADIUS_LDFLAGS} ${LIBSSH_LDFLAGS} ${GNUTLS_LDFLAGS}
  186               ${GCRYPT_LDFLAGS} ${LDAP_LDFLAGS} ${REDIS_LDFLAGS}
  187               ${LIBXML2_LDFLAGS} ${UUID_LDFLAGS}
  188               ${LINKER_HARDENING_FLAGS})
  189 
  190   add_custom_target (tests-xmlutils
  191                     DEPENDS xmlutils-test)
  192 
  193 endif (BUILD_TESTS)
  194 
  195 ## Install
  196 configure_file (libgvm_util.pc.in ${CMAKE_BINARY_DIR}/libgvm_util.pc @ONLY)
  197 
  198 install (FILES ${CMAKE_BINARY_DIR}/libgvm_util.pc
  199          DESTINATION ${LIBDIR}/pkgconfig)
  200 
  201 if (BUILD_STATIC)
  202   install (TARGETS gvm_util_static
  203     RUNTIME DESTINATION ${BINDIR}
  204     ARCHIVE DESTINATION ${LIBDIR}
  205     PUBLIC_HEADER DESTINATION "${INCLUDEDIR}/gvm/util")
  206 endif (BUILD_STATIC)
  207 
  208 if (BUILD_SHARED)
  209   install (TARGETS gvm_util_shared
  210     RUNTIME DESTINATION ${BINDIR}
  211     LIBRARY DESTINATION ${LIBDIR}
  212     ARCHIVE DESTINATION ${LIBDIR}
  213     PUBLIC_HEADER DESTINATION "${INCLUDEDIR}/gvm/util")
  214 endif (BUILD_SHARED)
  215 
  216 ## End