osquery-1/CMakeLists.txt

116 lines
3.1 KiB
CMake
Raw Normal View History

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
2014-07-31 00:35:19 +00:00
PROJECT(OSQUERY)
2014-09-05 14:54:41 +00:00
if(APPLE)
2014-09-23 03:40:28 +00:00
set(OS_COMPILE_FLAGS "-std=c++11 -stdlib=libc++")
2014-09-06 01:12:37 +00:00
set(OS_WHOLELINK_PRE "-Wl,-all_load")
set(OS_WHOLELINK_POST "")
2014-09-05 14:54:41 +00:00
else()
set(OS_COMPILE_FLAGS "-std=c++11")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(OS_COMPILE_FLAGS "${OS_COMPILE_FLAGS} -g -DDEBUG")
endif()
2014-09-06 01:12:37 +00:00
set(OS_WHOLELINK_PRE "-Wl,-whole-archive")
set(OS_WHOLELINK_POST "-Wl,-no-whole-archive")
endif()
# Use osquery language to set platform/os
execute_process(
COMMAND ${CMAKE_SOURCE_DIR}/tools/provision.sh get_platform
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE PLATFORM
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REPLACE "." "_" PLATFORM "${PLATFORM}")
string(TOUPPER "${PLATFORM}" PLATFORM)
list(GET PLATFORM 0 OSQUERY_BUILD_OS)
list(GET PLATFORM 1 OSQUERY_BUILD_DISTRO)
# Make sure deps were built before compiling
execute_process(
COMMAND ${CMAKE_SOURCE_DIR}/tools/provision.sh check ${CMAKE_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE OSQUERY_DEPS_MESSAGE
RESULT_VARIABLE OSQUERY_DEPS_CHECK
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(OSQUERY_DEPS_CHECK)
string(ASCII 27 Esc)
2014-11-11 15:59:42 +00:00
message(WARNING "${Esc}[31m${OSQUERY_DEPS_MESSAGE}${Esc}[m")
endif()
if(APPLE)
message("-- Building for OS X")
elseif(OSQUERY_BUILD_OS STREQUAL "UBUNTU")
set(UBUNTU TRUE)
message("-- Building for Ubuntu")
elseif(OSQUERY_BUILD_OS STREQUAL "CENTOS")
set(CENTOS TRUE)
message("-- Building for CentOS")
endif()
if(BUILD_SHARED_LIBS)
2014-09-21 01:53:49 +00:00
set(USER_COMPILE_FLAGS "-fPIC")
else()
# Building/linking statically (no libosquery)
2014-09-23 03:40:28 +00:00
set(USER_COMPILE_FLAGS "-static")
2014-09-05 14:54:41 +00:00
endif()
2014-09-06 01:12:37 +00:00
set(OS_COMPILE_FLAGS "${OS_COMPILE_FLAGS} ${USER_COMPILE_FLAGS}")
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake" ${CMAKE_MODULE_PATH})
FIND_PACKAGE(Gtest REQUIRED)
FIND_PACKAGE(Sqlite3 REQUIRED)
2014-09-24 02:44:58 +00:00
FIND_PACKAGE(BZip2 REQUIRED)
FIND_PACKAGE(Glog REQUIRED)
FIND_PACKAGE(Gflags REQUIRED)
FIND_PACKAGE(Thrift 0.9.1 REQUIRED)
FIND_PACKAGE(Readline REQUIRED)
FIND_PACKAGE(OpenSSL REQUIRED)
FIND_PACKAGE(Snappy REQUIRED)
FIND_PACKAGE(RocksDB REQUIRED)
FIND_PACKAGE(Crypto REQUIRED)
FIND_PACKAGE(Dl REQUIRED)
if(NOT APPLE)
FIND_PACKAGE(Unwind REQUIRED)
FIND_PACKAGE(LZMA REQUIRED)
endif()
2014-09-06 01:12:37 +00:00
2014-09-24 05:06:32 +00:00
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}")
INCLUDE_DIRECTORIES("/usr/local/include")
LINK_DIRECTORIES("/usr/local/lib")
ENABLE_TESTING()
ADD_SUBDIRECTORY(osquery)
ADD_SUBDIRECTORY(tools)
2014-09-24 03:12:53 +00:00
# make docs
FIND_PACKAGE(Doxygen)
if(DOXYGEN_FOUND)
ADD_CUSTOM_TARGET(
docs
${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif(DOXYGEN_FOUND)
2014-09-24 06:38:23 +00:00
# make format-all
2014-09-24 06:38:23 +00:00
ADD_CUSTOM_TARGET(
format-all
2014-09-24 06:38:23 +00:00
find osquery include tools \( -name "*.h" -o -name "*.cpp" -o -name "*.mm" \) -exec clang-format -i {} +
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Formatting all osquery code with clang-format" VERBATIM
2014-09-24 06:38:23 +00:00
)
ADD_CUSTOM_TARGET(
format
python tools/git-clang-format.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Formatting code staged code changes with clang-format" VERBATIM
)