"Fossies" - the Fresh Open Source Software Archive

Member "gvm-libs-11.0.1/CMakeLists.txt" (12 May 2020, 7960 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) 2011-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 cmake_minimum_required(VERSION 3.0)
   20 
   21 message ("-- Configuring the Greenbone Vulnerability Management Libraries...")
   22 
   23 project (gvm-libs
   24   VERSION 11.0.1
   25   LANGUAGES C)
   26 
   27 if (POLICY CMP0005)
   28   cmake_policy (SET CMP0005 NEW)
   29 endif (POLICY CMP0005)
   30 
   31 if (NOT CMAKE_BUILD_TYPE)
   32   set (CMAKE_BUILD_TYPE Debug)
   33 endif (NOT CMAKE_BUILD_TYPE)
   34 
   35 OPTION(BUILD_STATIC "Build static versions of the libraries" OFF)
   36 OPTION(ENABLE_COVERAGE "Enable support for coverage analysis" OFF)
   37 OPTION(BUILD_TESTS "Build tests for the libraries" OFF)
   38 
   39 if (NOT BUILD_STATIC)
   40   set (BUILD_SHARED ON)
   41 else (NOT BUILD_STATIC)
   42   set (BUILD_SHARED OFF)
   43 endif (NOT BUILD_STATIC)
   44 
   45 ## Retrieve git revision (at configure time)
   46 find_package (Git)
   47 
   48 ## make format
   49 message (STATUS "Looking for clang-format...")
   50 find_program (CLANG_FORMAT clang-format)
   51 
   52 if (CLANG_FORMAT)
   53   message (STATUS "Looking for clang-format... ${CLANG_FORMAT}")
   54   add_custom_target(format COMMAND ${CLANG_FORMAT} "-i" "./base/*.c" "./gmp/*.c"
   55                     "./osp/*.c" "./util/*.c" "./base/*.h" "./gmp/*.h" "./osp/*.h"
   56                     "./util/*.h" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
   57 else (CLANG_FORMAT)
   58   message (STATUS "clang-format not found...")
   59 endif (CLANG_FORMAT)
   60 
   61 
   62 macro (Git_GET_REVISION dir variable)
   63   execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
   64                   WORKING_DIRECTORY ${dir}
   65                   OUTPUT_VARIABLE GIT_BRANCH
   66                   OUTPUT_STRIP_TRAILING_WHITESPACE)
   67   execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
   68                   WORKING_DIRECTORY ${dir}
   69                   OUTPUT_VARIABLE GIT_COMMIT_HASH
   70                   OUTPUT_STRIP_TRAILING_WHITESPACE)
   71   string (REPLACE "/" "_" GIT_BRANCH ${GIT_BRANCH})
   72   set (${variable} "${GIT_COMMIT_HASH}-${GIT_BRANCH}")
   73 endmacro (Git_GET_REVISION)
   74 
   75 if (NOT CMAKE_BUILD_TYPE MATCHES "Release")
   76   if (EXISTS "${CMAKE_SOURCE_DIR}/.git/")
   77     if (GIT_FOUND)
   78       Git_GET_REVISION(${CMAKE_SOURCE_DIR} ProjectRevision)
   79       set (GIT_REVISION "~git-${ProjectRevision}")
   80     else (GIT_FOUND)
   81       set (GIT_REVISION "~git")
   82     endif (GIT_FOUND)
   83   endif (EXISTS "${CMAKE_SOURCE_DIR}/.git/")
   84 endif (NOT CMAKE_BUILD_TYPE MATCHES "Release")
   85 
   86 # Set beta version if this is a beta release series,
   87 # unset if this is a stable release series.
   88 set (PROJECT_BETA_RELEASE 0)
   89 
   90 if (GIT_REVISION)
   91   set (PROJECT_VERSION_GIT "${GIT_REVISION}")
   92 endif (GIT_REVISION)
   93 
   94 # If PROJECT_BETA_RELEASE is set, the version string will be set to:
   95 #   "major.minor+beta${PROJECT_BETA_RELEASE}"
   96 # If PROJECT_BETA_RELEASE is NOT set, the version string will be set to:
   97 #   "major.minor.patch"
   98 if (PROJECT_BETA_RELEASE)
   99   set (PROJECT_VERSION_SUFFIX "+beta${PROJECT_BETA_RELEASE}")
  100 else (PROJECT_BETA_RELEASE)
  101   set (PROJECT_VERSION_SUFFIX ".${PROJECT_VERSION_PATCH}")
  102 endif (PROJECT_BETA_RELEASE)
  103 
  104 set (PROJECT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}${PROJECT_VERSION_SUFFIX}")
  105 
  106 ## CPack configuration
  107 
  108 set (CPACK_CMAKE_GENERATOR "Unix Makefiles")
  109 set (CPACK_GENERATOR "TGZ")
  110 set (CPACK_INSTALL_CMAKE_PROJECTS ".;gvm-libs;ALL;/")
  111 set (CPACK_MODULE_PATH "")
  112 set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
  113 set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
  114 set (CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/README.md")
  115 set (CPACK_SOURCE_GENERATOR "TGZ")
  116 set (CPACK_SOURCE_TOPLEVEL_TAG "")
  117 set (CPACK_SYSTEM_NAME "")
  118 set (CPACK_TOPLEVEL_TAG "")
  119 
  120 set (CPACK_PACKAGE_VERSION "${PROJECT_VERSION_STRING}${PROJECT_VERSION_GIT}")
  121 
  122 set (CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
  123 set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
  124 set (CPACK_PACKAGE_VENDOR "Greenbone Networks")
  125 set (CPACK_SOURCE_IGNORE_FILES
  126 "${CMAKE_BINARY_DIR}"
  127 "/.git/"
  128 "swp$"
  129 )
  130 
  131 include (CPack)
  132 
  133 ## Variables
  134 
  135 if (SYSCONF_INSTALL_DIR)
  136   set (SYSCONFDIR "${SYSCONF_INSTALL_DIR}")
  137 endif (SYSCONF_INSTALL_DIR)
  138 
  139 if (NOT SYSCONFDIR)
  140   set (SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc")
  141 endif (NOT SYSCONFDIR)
  142 
  143 if (NOT EXEC_PREFIX)
  144   set (EXEC_PREFIX "${CMAKE_INSTALL_PREFIX}")
  145 endif (NOT EXEC_PREFIX)
  146 
  147 if (NOT BINDIR)
  148   set (BINDIR "${EXEC_PREFIX}/bin")
  149 endif (NOT BINDIR)
  150 
  151 if (NOT SBINDIR)
  152   set (SBINDIR "${EXEC_PREFIX}/sbin")
  153 endif (NOT SBINDIR)
  154 
  155 if (NOT LIBDIR)
  156   set (_DEFAULT_LIBRARY_INSTALL_DIR lib)
  157   if (EXISTS "${EXEC_PREFIX}/lib32/" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
  158     set (_DEFAULT_LIBRARY_INSTALL_DIR lib32)
  159   endif (EXISTS "${EXEC_PREFIX}/lib32/" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
  160   if (EXISTS "${CMAKE_INSTALL_PREFIX}/lib64/" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
  161     set (_DEFAULT_LIBRARY_INSTALL_DIR lib64)
  162   endif (EXISTS "${CMAKE_INSTALL_PREFIX}/lib64/" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
  163   set( LIBRARY_INSTALL_DIR "${_DEFAULT_LIBRARY_INSTALL_DIR}")
  164   set (LIBDIR "${EXEC_PREFIX}/${LIBRARY_INSTALL_DIR}")
  165 endif (NOT LIBDIR)
  166 
  167 if (NOT LOCALSTATEDIR)
  168   set (LOCALSTATEDIR "${CMAKE_INSTALL_PREFIX}/var")
  169 endif (NOT LOCALSTATEDIR)
  170 
  171 if (NOT INCLUDEDIR)
  172   set (INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
  173 endif (NOT INCLUDEDIR)
  174 
  175 if (NOT DATADIR)
  176   set (DATADIR "${CMAKE_INSTALL_PREFIX}/share")
  177 endif (NOT DATADIR)
  178 
  179 if (NOT GVM_PID_DIR)
  180   set (GVM_PID_DIR "${LOCALSTATEDIR}/run")
  181 endif (NOT GVM_PID_DIR)
  182 
  183 if (NOT GVM_SYSCONF_DIR)
  184   set (GVM_SYSCONF_DIR "${SYSCONFDIR}/gvm")
  185 endif (NOT GVM_SYSCONF_DIR)
  186 
  187 
  188 if (NOT REDIS_SOCKET_PATH)
  189   set (REDIS_SOCKET_PATH "/run/redis/redis.sock")
  190 endif ()
  191 
  192 add_definitions (-DREDIS_SOCKET_PATH="${REDIS_SOCKET_PATH}")
  193 message ("-- Using redis socket ${REDIS_SOCKET_PATH}")
  194 
  195 message ("-- Install prefix: ${CMAKE_INSTALL_PREFIX}")
  196 
  197 if (ENABLE_COVERAGE)
  198   set (COVERAGE_FLAGS "--coverage")
  199 endif (ENABLE_COVERAGE)
  200 
  201 set (HARDENING_FLAGS "-Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -fstack-protector")
  202 set (LINKER_HARDENING_FLAGS "-Wl,-z,relro -Wl,-z,now")
  203 set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -Werror ${COVERAGE_FLAGS}")
  204 set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${HARDENING_FLAGS}")
  205 
  206 
  207 ## Version
  208 
  209 if (PROJECT_BETA_RELEASE)
  210   set (LIBGVMCONFIG_VERSION "${PROJECT_VERSION}")
  211 else (PROJECT_BETA_RELEASE)
  212   set (LIBGVMCONFIG_VERSION "${PROJECT_VERSION_STRING}")
  213 endif (PROJECT_BETA_RELEASE)
  214 
  215 add_definitions(-DGVM_LIBS_VERSION="${LIBGVMCONFIG_VERSION}")
  216 
  217 # Configure Doxyfile with version number
  218 configure_file (doc/Doxyfile.in ${CMAKE_BINARY_DIR}/doc/Doxyfile @ONLY)
  219 configure_file (doc/Doxyfile_full.in ${CMAKE_BINARY_DIR}/doc/Doxyfile_full @ONLY)
  220 configure_file (doc/Doxyfile_xml.in ${CMAKE_BINARY_DIR}/doc/Doxyfile_xml @ONLY)
  221 configure_file (VERSION.in ${CMAKE_BINARY_DIR}/VERSION @ONLY)
  222 
  223 ## Testing
  224 
  225 if (BUILD_TESTS AND NOT SKIP_SRC)
  226   enable_testing ()
  227 
  228   find_package (cgreen REQUIRED)
  229 
  230   add_custom_target (tests
  231                     DEPENDS array-test xmlutils-test version-test)
  232 
  233 endif (BUILD_TESTS AND NOT SKIP_SRC)
  234 
  235 ## Program
  236 
  237 if (NOT SKIP_SRC)
  238   add_subdirectory (base)
  239   add_subdirectory (util)
  240   add_subdirectory (osp)
  241   add_subdirectory (gmp)
  242 endif (NOT SKIP_SRC)
  243 
  244 ## Documentation
  245 
  246 add_subdirectory (doc)
  247 
  248 if (BUILD_TESTS AND NOT SKIP_SRC)
  249   add_subdirectory (tests)
  250   add_test (NAME testhosts COMMAND test-hosts localhost)
  251 endif (BUILD_TESTS AND NOT SKIP_SRC)
  252 
  253 ## End