mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Customizable error messages for missing prereqs.
Adds the FindRequiredPackage() macro that wraps the functionality of the standard find_package() macro.
This commit is contained in:
parent
ffdf9e7474
commit
efce9dbfe2
4 changed files with 63 additions and 12 deletions
|
@ -1,6 +1,4 @@
|
|||
########################################################################
|
||||
## CMake Configuration
|
||||
|
||||
######################################################################## ## CMake Configuration
|
||||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
||||
|
||||
# Prohibit in-source builds.
|
||||
|
@ -46,6 +44,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_COMPILE_FLAGS}")
|
|||
########################################################################
|
||||
## Dependency Configuration
|
||||
|
||||
include(FindRequiredPackage)
|
||||
|
||||
# Check cache value first to avoid displaying "Found sed" messages everytime
|
||||
if (NOT SED_EXE)
|
||||
find_program(SED_EXE sed)
|
||||
|
@ -56,17 +56,24 @@ if (NOT SED_EXE)
|
|||
endif ()
|
||||
endif ()
|
||||
|
||||
find_package(Perl REQUIRED)
|
||||
find_package(FLEX REQUIRED)
|
||||
find_package(BISON REQUIRED)
|
||||
find_package(PCAP REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(BIND REQUIRED)
|
||||
FindRequiredPackage(Perl)
|
||||
FindRequiredPackage(FLEX)
|
||||
FindRequiredPackage(BISON)
|
||||
FindRequiredPackage(PCAP)
|
||||
FindRequiredPackage(OpenSSL)
|
||||
FindRequiredPackage(BIND)
|
||||
|
||||
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/aux/binpac/CMakeLists.txt)
|
||||
add_subdirectory(aux/binpac)
|
||||
endif ()
|
||||
find_package(BinPAC REQUIRED)
|
||||
FindRequiredPackage(BinPAC)
|
||||
|
||||
if (MISSING_PREREQS)
|
||||
foreach (prereq ${MISSING_PREREQ_DESCS})
|
||||
message(SEND_ERROR ${prereq})
|
||||
endforeach ()
|
||||
message(FATAL_ERROR "Configuration aborted due to missing prerequisites")
|
||||
endif ()
|
||||
|
||||
include_directories(BEFORE
|
||||
${PCAP_INCLUDE_DIR}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#
|
||||
# Variables defined by this module:
|
||||
#
|
||||
# LIBGeoIP_FOUND System has GeoIP libraries and headers
|
||||
# LIBGEOIP_FOUND System has GeoIP libraries and headers
|
||||
# LibGeoIP_LIBRARY The GeoIP library
|
||||
# LibGeoIP_INCLUDE_DIR The location of GeoIP headers
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#
|
||||
# Variables defined by this module:
|
||||
#
|
||||
# OpenSSL_FOUND System has openssl, include and library dirs found
|
||||
# OPENSSL_FOUND System has openssl, include and library dirs found
|
||||
# OpenSSL_INCLUDE_DIR The openssl include directories.
|
||||
# OpenSSL_LIBRARIES The openssl libraries.
|
||||
# OpenSSL_CYRPTO_LIBRARY The openssl crypto library.
|
||||
|
|
44
cmake/FindRequiredPackage.cmake
Normal file
44
cmake/FindRequiredPackage.cmake
Normal file
|
@ -0,0 +1,44 @@
|
|||
# A wrapper macro around the standard CMake find_package macro that
|
||||
# facilitates displaying better error messages by default, or even
|
||||
# accepting custom error messages on a per package basis.
|
||||
#
|
||||
# If a package is not found, then the MISSING_PREREQS variable gets
|
||||
# set to true and either a default or custom error message appended
|
||||
# to MISSING_PREREQ_DESCS.
|
||||
#
|
||||
# The caller can use these variables to display a list of any missing
|
||||
# packages and abort the build/configuration if there were any.
|
||||
#
|
||||
# Use as follows:
|
||||
#
|
||||
# include(FindRequiredPackage)
|
||||
# FindRequiredPackage(Perl)
|
||||
# FindRequiredPackage(FLEX "You need to install flex (Fast Lexical Analyzer)")
|
||||
#
|
||||
# if (MISSING_PREREQS)
|
||||
# foreach (prereq ${MISSING_PREREQ_DESCS})
|
||||
# message(SEND_ERROR ${prereq})
|
||||
# endforeach ()
|
||||
# message(FATAL_ERROR "Configuration aborted due to missing prerequisites")
|
||||
# endif ()
|
||||
|
||||
macro(FindRequiredPackage packageName)
|
||||
find_package(${packageName})
|
||||
string(TOUPPER ${packageName} canonPackageName)
|
||||
if (NOT ${canonPackageName}_FOUND)
|
||||
set(MISSING_PREREQS true)
|
||||
|
||||
set(customDesc)
|
||||
foreach (descArg ${ARGN})
|
||||
set(customDesc "${customDesc} ${descArg}")
|
||||
endforeach ()
|
||||
|
||||
if (customDesc)
|
||||
# append the custom error message that was provided as an argument
|
||||
list(APPEND MISSING_PREREQ_DESCS ${customDesc})
|
||||
else ()
|
||||
list(APPEND MISSING_PREREQ_DESCS
|
||||
" Could not find prerequisite package '${packageName}'")
|
||||
endif ()
|
||||
endif ()
|
||||
endmacro(FindRequiredPackage)
|
Loading…
Add table
Add a link
Reference in a new issue