Professional Documents
Culture Documents
CMake Lists
CMake Lists
8)
project(ettercap C)
set(VERSION "0.8.2")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
set(CMAKE_SCRIPT_PATH "${CMAKE_SOURCE_DIR}/cmake/Scripts")
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build.
Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME}
[options]' there.")
if(NOT CMAKE_BUILD_TYPE)
# Default to using "Release" as our build type.
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: ${VALID_BUILD_TYPES}." FORCE)
endif()
LIST(FIND VALID_BUILD_TYPES ${CMAKE_BUILD_TYPE} contains_valid)
if(contains_valid EQUAL -1)
message(FATAL_ERROR "Unknown CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}'. Valid
options are: ${VALID_BUILD_TYPES}")
endif()
UNSET(contains_valid)
include(CMakeDependentOption)
CMAKE_DEPENDENT_OPTION(SYSTEM_CURL
"Search for a system-provided version of Curl" ON
SYSTEM_LIBS OFF)
CMAKE_DEPENDENT_OPTION(BUNDLED_CURL
"Use bundled version of Curl if system-provided version is not found (or
disabled)" ON
BUNDLED_LIBS OFF)
CMAKE_DEPENDENT_OPTION(SYSTEM_LIBNET
"Search for a system-provided version of LIBNET" ON
SYSTEM_LIBS OFF)
CMAKE_DEPENDENT_OPTION(BUNDLED_LIBNET
"Use bundled version of LIBNET if system-provided version is not found (or
disabled)" ON
BUNDLED_LIBS OFF)
CMAKE_DEPENDENT_OPTION(SYSTEM_LUAJIT
"Search for a system-provided version of LUAJIT" ON
"SYSTEM_LIBS;ENABLE_LUA" OFF)
CMAKE_DEPENDENT_OPTION(BUNDLED_LUAJIT
"Use bundled version of LUAJIT if system-provided version is not found (or
disabled)" ON
"BUNDLED_LIBS;ENABLE_LUA" OFF)
if(ENABLE_TESTS)
CMAKE_DEPENDENT_OPTION(SYSTEM_LIBCHECK
"Search for a system-provided version of LIBCHECK" ON
SYSTEM_LIBS OFF)
CMAKE_DEPENDENT_OPTION(BUNDLED_LIBCHECK
"Use bundled version of LIBCHECK if system-provided version is not found (or
disabled)" ON
BUNDLED_LIBS OFF)
endif(ENABLE_TESTS)
include(CheckVariableInHeaders)
include(EttercapOSTest)
if (LIBRARY_BUILD)
set(ENABLE_GTK OFF)
set(ENABLE_CURSES OFF)
set(JUST_LIBRARY 1)
endif(LIBRARY_BUILD)
include(EttercapHeadersCheck)
include(EttercapLibCheck)
include(EttercapVariableCheck)
if(NOT DISABLE_RPATH)
# Ensure that, when we link to stuff outside of our build path, we include the
# library dir path in our RPATH.
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif(NOT DISABLE_RPATH)
set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb3 -DDEBUG -Wall -Wno-pointer-sign
-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Wextra
-Wredundant-decls" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS_RELEASE "-O2 -w -D_FORTIFY_SOURCE=2" CACHE STRING "" FORCE)
if(OS_DARWIN)
set(CMAKE_EXE_LINKER_FLAGS "-Wl" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-Wl" CACHE STRING "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "-Wl" CACHE STRING "" FORCE)
endif(OS_DARWIN)
if(ENABLE_LUA)
include(EttercapLuajit)
set(HAVE_EC_LUA 1)
endif(ENABLE_LUA)
add_subdirectory(src)
add_subdirectory(desktop)
if(HAVE_PLUGINS)
if(OS_MINGW)
message("Sorry, plugins support on Windows is currently unavailable")
else(OS_MINGW)
add_subdirectory(plug-ins)
endif(OS_MINGW)
endif(HAVE_PLUGINS)
add_subdirectory(utils)
add_subdirectory(share)
add_subdirectory(man)
if(ENABLE_IPV6)
set(WITH_IPV6 TRUE)
endif(ENABLE_IPV6)
if(ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif(ENABLE_TESTS)
# uninstall target
configure_file(
"${CMAKE_SCRIPT_PATH}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# Add a target that will ensure that the build directory is properly cleaned.
add_custom_target(clean-all
COMMAND ${CMAKE_BUILD_TOOL} clean
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SCRIPT_PATH}/clean-all.cmake
)