mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
108 lines
3.4 KiB
CMake
108 lines
3.4 KiB
CMake
project(BinPAC)
|
|
|
|
########################################################################
|
|
## CMake Configuration
|
|
|
|
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
|
|
|
# Prohibit in-source builds.
|
|
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
|
message(FATAL_ERROR "In-source builds are not allowed. Please use "
|
|
"./configure to choose a build directory and "
|
|
"initialize the build configuration.")
|
|
endif ()
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
if ("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
|
|
# uninstall target
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
@ONLY)
|
|
|
|
add_custom_target(uninstall COMMAND
|
|
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
endif ()
|
|
|
|
########################################################################
|
|
## Project/Build Configuration
|
|
|
|
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" BINPAC_VERSION LIMIT_COUNT 1)
|
|
|
|
if (ENABLE_DEBUG)
|
|
set(CMAKE_BUILD_TYPE Debug)
|
|
else ()
|
|
set(CMAKE_BUILD_TYPE RelWithDebInfo)
|
|
endif ()
|
|
|
|
# don't set extra compile flags again if already declared in this scope
|
|
# (i.e. this project is included from Bro)
|
|
if (NOT EXTRA_COMPILE_FLAGS)
|
|
set(EXTRA_COMPILE_FLAGS "-Wall -Wno-unused")
|
|
|
|
if (ENABLE_DEBUG)
|
|
set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -DDEBUG")
|
|
endif ()
|
|
|
|
# Compiler flags may already exist in CMake cache (e.g. when specifying
|
|
# CFLAGS environment variable before running cmake for the the first time)
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_COMPILE_FLAGS}")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_COMPILE_FLAGS}")
|
|
endif ()
|
|
|
|
########################################################################
|
|
## Dependency Configuration
|
|
|
|
include(FindRequiredPackage)
|
|
|
|
FindRequiredPackage(FLEX)
|
|
FindRequiredPackage(BISON)
|
|
|
|
if (MISSING_PREREQS)
|
|
foreach (prereq ${MISSING_PREREQ_DESCS})
|
|
message(SEND_ERROR ${prereq})
|
|
endforeach ()
|
|
message(FATAL_ERROR "Configuration aborted due to missing prerequisites")
|
|
endif ()
|
|
|
|
########################################################################
|
|
## System Introspection
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
|
|
|
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
########################################################################
|
|
## Recurse on sub-directories
|
|
|
|
add_subdirectory(lib)
|
|
add_subdirectory(src)
|
|
|
|
########################################################################
|
|
## Build Summary
|
|
|
|
if (BinPAC_SKIP_INSTALL)
|
|
set(binpac_install_summary "Install skipped")
|
|
else ()
|
|
set(binpac_install_summary "${CMAKE_INSTALL_PREFIX}")
|
|
endif ()
|
|
|
|
if (CMAKE_BUILD_TYPE)
|
|
string(TOUPPER ${CMAKE_BUILD_TYPE} BuildType)
|
|
endif ()
|
|
|
|
message(
|
|
"\n==================| BinPAC Build Summary |===================="
|
|
"\n"
|
|
"\nInstall prefix: ${binpac_install_summary}"
|
|
"\nDebug mode: ${ENABLE_DEBUG}"
|
|
"\n"
|
|
"\nCC: ${CMAKE_C_COMPILER}"
|
|
"\nCFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${BuildType}}"
|
|
"\nCXX: ${CMAKE_CXX_COMPILER}"
|
|
"\nCXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${BuildType}}"
|
|
"\nCPP: ${CMAKE_CXX_COMPILER}"
|
|
"\n"
|
|
"\n================================================================\n"
|
|
)
|