mirror of
https://github.com/zeek/zeek.git
synced 2025-10-01 22:28:20 +00:00
Move build defaults from configure to CMake
Moving the defaults for build variables from the `configure` script to `CMakeLists.txt` gives the same default behavior on platforms where the `configure` script is not available (Windows) and also allows a pure CMake-based work flow (e.g., the standard `cmake -S . -B build`) without having to manually adjust the defaults. The `configure` script also becomes much simpler as a result.
This commit is contained in:
parent
3a172bde38
commit
7af3611807
2 changed files with 63 additions and 48 deletions
57
configure
vendored
57
configure
vendored
|
@ -12,6 +12,9 @@ command="$0 $*"
|
|||
usage="\
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
-h, --help display this help and exit
|
||||
--show-config display the most relevant config parameters of an existing build
|
||||
|
||||
Build Options:
|
||||
--cmake=PATH custom path to a CMake binary
|
||||
--builddir=DIR place build files in directory [build]
|
||||
|
@ -149,42 +152,10 @@ append_cache_entry() {
|
|||
CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
|
||||
}
|
||||
|
||||
# Function to remove a CMake cache entry definition from the
|
||||
# CMakeCacheEntries variable
|
||||
# $1 is the cache entry variable name
|
||||
remove_cache_entry() {
|
||||
CMakeCacheEntries="$CMakeCacheEntries -U $1"
|
||||
|
||||
# Even with -U, cmake still warns by default if
|
||||
# added previously with -D.
|
||||
CMakeCacheEntries="$CMakeCacheEntries --no-warn-unused-cli"
|
||||
}
|
||||
|
||||
# set defaults
|
||||
builddir=build
|
||||
prefix=/usr/local/zeek
|
||||
CMakeCacheEntries=""
|
||||
display_cmake=0
|
||||
append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
|
||||
append_cache_entry ZEEK_ROOT_DIR PATH $prefix
|
||||
append_cache_entry ZEEK_SCRIPT_INSTALL_PATH STRING $prefix/share/zeek
|
||||
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $prefix/etc
|
||||
append_cache_entry ENABLE_DEBUG BOOL false
|
||||
append_cache_entry ENABLE_PERFTOOLS BOOL false
|
||||
append_cache_entry ENABLE_JEMALLOC BOOL false
|
||||
append_cache_entry ENABLE_ZEEK_UNIT_TESTS BOOL true
|
||||
append_cache_entry BUILD_SHARED_LIBS BOOL true
|
||||
append_cache_entry INSTALL_AUX_TOOLS BOOL true
|
||||
append_cache_entry INSTALL_BTEST BOOL true
|
||||
append_cache_entry INSTALL_BTEST_PCAPS BOOL true
|
||||
append_cache_entry INSTALL_ZEEK_ARCHIVER BOOL true
|
||||
append_cache_entry INSTALL_ZEEK_CLIENT BOOL true
|
||||
append_cache_entry INSTALL_ZEEKCTL BOOL true
|
||||
append_cache_entry INSTALL_ZKG BOOL true
|
||||
append_cache_entry CPACK_SOURCE_IGNORE_FILES STRING
|
||||
append_cache_entry ZEEK_SANITIZERS STRING ""
|
||||
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING ""
|
||||
append_cache_entry PREALLOCATE_PORT_ARRAY BOOL true
|
||||
|
||||
# parse arguments
|
||||
while [ $# -ne 0 ]; do
|
||||
|
@ -198,6 +169,14 @@ while [ $# -ne 0 ]; do
|
|||
echo "${usage}" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
--show-config)
|
||||
if [ ! -f "$builddir/CMakeCache.txt" ]; then
|
||||
echo "Error: no CMake build found under '$builddir'." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
grep -E "^ENABLE_|^ZEEK_|^INSTALL_|^CMAKE_INSTALL_PRE|^CMAKE_C.*_FLAGS|^CMAKE_BUILD" "$builddir/CMakeCache.txt" | grep -v ':INTERNAL'
|
||||
exit 0
|
||||
;;
|
||||
-D)
|
||||
shift
|
||||
if [ $# -eq 0 ]; then
|
||||
|
@ -217,10 +196,6 @@ while [ $# -ne 0 ]; do
|
|||
;;
|
||||
--build-type=*)
|
||||
append_cache_entry CMAKE_BUILD_TYPE STRING $optarg
|
||||
|
||||
if [ $(echo "$optarg" | tr [:upper:] [:lower:]) = "debug" ]; then
|
||||
append_cache_entry ENABLE_DEBUG BOOL true
|
||||
fi
|
||||
;;
|
||||
--generator=*)
|
||||
CMakeGenerator="$optarg"
|
||||
|
@ -235,9 +210,7 @@ while [ $# -ne 0 ]; do
|
|||
append_cache_entry ZEEK_INCLUDE_PLUGINS STRING \"$optarg\"
|
||||
;;
|
||||
--prefix=*)
|
||||
prefix=$optarg
|
||||
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
|
||||
append_cache_entry ZEEK_ROOT_DIR PATH $optarg
|
||||
;;
|
||||
--libdir=*)
|
||||
append_cache_entry CMAKE_INSTALL_LIBDIR PATH $optarg
|
||||
|
@ -454,14 +427,6 @@ if [ -z "$CMakeCommand" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [ "$user_set_scriptdir" != "true" ]; then
|
||||
append_cache_entry ZEEK_SCRIPT_INSTALL_PATH STRING $prefix/share/zeek
|
||||
fi
|
||||
|
||||
if [ "$user_set_conffilesdir" != "true" ]; then
|
||||
append_cache_entry ZEEK_ETC_INSTALL_DIR PATH $prefix/etc
|
||||
fi
|
||||
|
||||
if [ -d $builddir ]; then
|
||||
# If build directory exists, check if it has a CMake cache
|
||||
if [ -f $builddir/CMakeCache.txt ]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue