2016-08-10 03:27:42 +00:00
|
|
|
# The 'core' source files define the osquery SDK (libosquery).
|
|
|
|
# There are macros throughout CMake to append sources to this list.
|
2015-01-05 16:05:41 +00:00
|
|
|
set(OSQUERY_SOURCES "")
|
2016-08-10 03:27:42 +00:00
|
|
|
|
|
|
|
# A separate list of library links (and linking options) is maintained for
|
|
|
|
# the 'core' set of sources.
|
2015-01-05 16:05:41 +00:00
|
|
|
set(OSQUERY_LINKS "")
|
2016-08-10 03:27:42 +00:00
|
|
|
|
|
|
|
# Finally a set of 'core' tests and kernel-tests, and benchmark tests, is kept.
|
2015-04-27 09:12:58 +00:00
|
|
|
set(OSQUERY_TESTS "")
|
2015-06-30 21:20:04 +00:00
|
|
|
set(OSQUERY_KERNEL_TESTS "")
|
2015-07-23 23:42:46 +00:00
|
|
|
set(OSQUERY_BENCHMARKS "")
|
|
|
|
set(OSQUERY_KERNEL_BENCHMARKS "")
|
|
|
|
|
2016-08-10 03:27:42 +00:00
|
|
|
# The 'additional' source files are NOT included with SDK (libosquery_additional).
|
2015-01-05 16:05:41 +00:00
|
|
|
set(OSQUERY_ADDITIONAL_SOURCES "")
|
|
|
|
set(OSQUERY_ADDITIONAL_LINKS "")
|
2015-04-27 09:12:58 +00:00
|
|
|
set(OSQUERY_ADDITIONAL_TESTS "")
|
|
|
|
set(OSQUERY_TABLES_TESTS "")
|
2014-11-09 00:55:19 +00:00
|
|
|
|
2016-03-05 17:29:51 +00:00
|
|
|
# Add all and extra for osquery code.
|
2016-08-10 03:27:42 +00:00
|
|
|
if(WINDOWS)
|
2017-02-11 02:10:22 +00:00
|
|
|
add_compile_options(/W3 /WX /guard:cf)
|
2016-04-15 21:01:16 +00:00
|
|
|
else()
|
2016-11-06 09:17:04 +00:00
|
|
|
add_compile_options(
|
|
|
|
-Wall
|
|
|
|
-Wextra
|
|
|
|
-Wshadow
|
|
|
|
-pedantic
|
|
|
|
-Wuseless-cast
|
|
|
|
-Wno-c99-extensions
|
|
|
|
-Wno-zero-length-array
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Wno-gnu-case-range
|
|
|
|
)
|
2016-04-15 21:01:16 +00:00
|
|
|
endif()
|
2016-03-05 17:29:51 +00:00
|
|
|
|
2016-08-10 03:27:42 +00:00
|
|
|
if(WINDOWS)
|
2016-12-06 22:25:08 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("ws2_32.lib")
|
|
|
|
ADD_OSQUERY_LINK_CORE("iphlpapi.lib")
|
2016-07-31 18:32:31 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("netapi32.lib")
|
|
|
|
ADD_OSQUERY_LINK_CORE("rpcrt4.lib")
|
|
|
|
ADD_OSQUERY_LINK_CORE("shlwapi.lib")
|
2017-01-08 21:19:09 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("Wtsapi32.lib")
|
2016-07-31 18:32:31 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("wbemuuid.lib")
|
2016-08-10 03:27:42 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("linenoise.lib")
|
2016-08-22 22:27:12 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("libboost_system-vc140-mt-s-1_59")
|
|
|
|
ADD_OSQUERY_LINK_CORE("libboost_regex-vc140-mt-s-1_59")
|
|
|
|
ADD_OSQUERY_LINK_CORE("libboost_filesystem-vc140-mt-s-1_59")
|
2016-08-10 21:06:47 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("rocksdblib")
|
|
|
|
ADD_OSQUERY_LINK_CORE("snappy64")
|
|
|
|
ADD_OSQUERY_LINK_CORE("gflags_static")
|
|
|
|
ADD_OSQUERY_LINK_CORE("thriftmd")
|
2016-08-22 22:27:12 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("glog_static")
|
2016-08-31 23:45:06 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("ssleay32")
|
|
|
|
ADD_OSQUERY_LINK_CORE("eay32")
|
2016-09-20 21:18:58 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("zlibstatic")
|
2017-02-11 02:10:22 +00:00
|
|
|
|
|
|
|
# Enable control flow guard
|
|
|
|
ADD_OSQUERY_LINK_CORE("-guard:cf")
|
2016-05-11 21:16:32 +00:00
|
|
|
else()
|
2016-07-31 18:32:31 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("libpthread")
|
|
|
|
ADD_OSQUERY_LINK_CORE("libz")
|
2016-08-10 21:06:47 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("gflags")
|
|
|
|
ADD_OSQUERY_LINK_CORE("thrift")
|
2016-08-11 00:03:54 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("lz4")
|
2016-08-22 22:27:12 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("glog")
|
2016-03-05 17:29:51 +00:00
|
|
|
endif()
|
2016-01-13 17:26:51 +00:00
|
|
|
|
2016-03-07 09:30:20 +00:00
|
|
|
if(APPLE OR LINUX)
|
2016-07-31 18:32:31 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("libdl")
|
2017-02-27 02:25:49 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("boost_system-mt")
|
|
|
|
ADD_OSQUERY_LINK_CORE("boost_filesystem-mt")
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("rocksdb_lite")
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("boost_regex-mt")
|
2016-03-07 09:30:20 +00:00
|
|
|
elseif(FREEBSD)
|
2015-05-20 20:27:53 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("icuuc")
|
2017-02-27 02:25:49 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("boost_system")
|
|
|
|
ADD_OSQUERY_LINK_CORE("boost_filesystem")
|
|
|
|
ADD_OSQUERY_LINK_CORE("boost_thread")
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("rocksdb")
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("boost_regex")
|
2015-05-05 20:55:49 +00:00
|
|
|
endif()
|
|
|
|
|
2016-07-31 18:32:31 +00:00
|
|
|
if(LINUX OR FREEBSD)
|
|
|
|
ADD_OSQUERY_LINK_CORE("librt")
|
|
|
|
ADD_OSQUERY_LINK_CORE("libc")
|
2016-03-15 02:51:03 +00:00
|
|
|
endif()
|
|
|
|
|
2016-08-10 21:06:47 +00:00
|
|
|
# Remaining additional development libraries.
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("cppnetlib-uri")
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("cppnetlib-client-connections")
|
2016-04-15 21:01:16 +00:00
|
|
|
|
2016-08-31 23:45:06 +00:00
|
|
|
if(NOT WINDOWS)
|
2016-11-06 09:17:48 +00:00
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("snappy")
|
2016-08-10 21:06:47 +00:00
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("ssl")
|
2016-07-31 18:32:31 +00:00
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("yara")
|
2016-08-10 21:06:47 +00:00
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("crypto")
|
2016-11-15 09:19:08 +00:00
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("libpthread")
|
|
|
|
|
2016-11-06 09:17:48 +00:00
|
|
|
# Linenoise will be used when compiling osqueryi.
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("linenoise")
|
2016-04-15 21:01:16 +00:00
|
|
|
endif()
|
2014-11-09 00:55:19 +00:00
|
|
|
|
2016-07-31 18:32:31 +00:00
|
|
|
if(APPLE)
|
|
|
|
ADD_OSQUERY_LINK_CORE("liblzma libbz2")
|
2017-02-15 22:17:40 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("boost_thread-mt")
|
2016-07-31 18:32:31 +00:00
|
|
|
else()
|
2016-08-10 21:06:47 +00:00
|
|
|
if(NOT WINDOWS)
|
|
|
|
ADD_OSQUERY_LINK_CORE("lzma")
|
|
|
|
endif()
|
|
|
|
ADD_OSQUERY_LINK_CORE("bz2")
|
2016-07-31 18:32:31 +00:00
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("bz2")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# The platform-specific SDK + core linker flags.
|
2016-08-10 21:06:47 +00:00
|
|
|
if(NOT WINDOWS)
|
|
|
|
ADD_OSQUERY_LINK_CORE("-rdynamic")
|
|
|
|
endif()
|
2016-07-31 18:32:31 +00:00
|
|
|
if(APPLE)
|
|
|
|
ADD_OSQUERY_LINK_CORE("-Wl,-dead_strip")
|
|
|
|
ADD_OSQUERY_LINK_CORE("-mmacosx-version-min=${OSX_VERSION_MIN}")
|
|
|
|
elseif(LINUX OR FREEBSD)
|
2016-08-01 05:41:37 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("-Wl,-zrelro -Wl,-znow")
|
2016-07-31 18:32:31 +00:00
|
|
|
if(NOT ${REDHAT_BASED})
|
|
|
|
ADD_OSQUERY_LINK_CORE("-Wl,--gc-sections")
|
|
|
|
endif()
|
2016-08-29 13:54:10 +00:00
|
|
|
if(NOT DEFINED ENV{SANITIZE} AND NOT DEFINED ENV{DEBUG})
|
2016-08-01 05:41:37 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE("-pie")
|
|
|
|
endif()
|
2016-07-31 18:32:31 +00:00
|
|
|
endif()
|
|
|
|
|
2015-05-04 03:02:01 +00:00
|
|
|
if(DEFINED ENV{SANITIZE})
|
|
|
|
if(DEFINED ENV{SANITIZE_THREAD})
|
2015-05-20 20:27:53 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE(-fsanitize=thread)
|
2015-05-04 03:02:01 +00:00
|
|
|
else()
|
2015-05-20 20:27:53 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE(-fsanitize=address -fsanitize=leak)
|
2015-05-04 03:02:01 +00:00
|
|
|
endif()
|
2015-05-20 20:27:53 +00:00
|
|
|
ADD_OSQUERY_LINK_CORE(-fsanitize-blacklist=${SANITIZE_BLACKLIST})
|
2015-05-04 03:02:01 +00:00
|
|
|
endif()
|
|
|
|
|
2014-12-24 04:07:12 +00:00
|
|
|
# Construct a set of all object files, starting with third-party and all
|
|
|
|
# of the osquery core objects (sources from ADD_CORE_LIBRARY macros).
|
2014-12-28 06:42:59 +00:00
|
|
|
set(OSQUERY_OBJECTS $<TARGET_OBJECTS:osquery_sqlite>)
|
2014-12-24 04:07:12 +00:00
|
|
|
|
2014-09-24 00:55:54 +00:00
|
|
|
# Add subdirectories
|
2014-12-28 06:42:59 +00:00
|
|
|
add_subdirectory(config)
|
|
|
|
add_subdirectory(core)
|
|
|
|
add_subdirectory(database)
|
|
|
|
add_subdirectory(devtools)
|
|
|
|
add_subdirectory(dispatcher)
|
2016-07-25 18:58:55 +00:00
|
|
|
add_subdirectory(distributed)
|
2014-12-28 06:42:59 +00:00
|
|
|
add_subdirectory(events)
|
2015-02-04 03:55:16 +00:00
|
|
|
add_subdirectory(extensions)
|
2014-12-28 06:42:59 +00:00
|
|
|
add_subdirectory(filesystem)
|
|
|
|
add_subdirectory(logger)
|
2015-01-30 18:44:25 +00:00
|
|
|
add_subdirectory(registry)
|
2015-02-03 05:21:36 +00:00
|
|
|
add_subdirectory(sql)
|
2016-09-20 21:18:58 +00:00
|
|
|
add_subdirectory(remote)
|
2016-07-21 06:48:55 +00:00
|
|
|
|
2017-01-28 21:19:47 +00:00
|
|
|
# Add externals directory from parent
|
|
|
|
add_subdirectory("${CMAKE_SOURCE_DIR}/external" "${CMAKE_BINARY_DIR}/external")
|
|
|
|
|
2016-07-31 18:32:31 +00:00
|
|
|
if(NOT DEFINED ENV{SKIP_TABLES})
|
2015-05-24 01:52:42 +00:00
|
|
|
add_subdirectory(tables)
|
2014-12-24 04:07:12 +00:00
|
|
|
|
2016-07-31 18:32:31 +00:00
|
|
|
# Amalgamate the utility tables needed to compile.
|
|
|
|
GENERATE_UTILITIES("${CMAKE_SOURCE_DIR}")
|
|
|
|
AMALGAMATE("${CMAKE_SOURCE_DIR}" "utils" AMALGAMATION_UTILS)
|
|
|
|
ADD_OSQUERY_LIBRARY_CORE(osquery_amalgamation ${AMALGAMATION_UTILS})
|
|
|
|
endif()
|
2014-09-02 08:00:58 +00:00
|
|
|
|
2016-11-06 09:17:48 +00:00
|
|
|
if(LINUX)
|
|
|
|
ADD_OSQUERY_LINK_CORE("libgcc_s")
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("uuid")
|
|
|
|
if(DEFINED ENV{OSQUERY_BUILD_SHARED})
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("-L${BUILD_DEPS}/legacy/lib")
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED ENV{OSQUERY_BUILD_LINK_SHARED})
|
|
|
|
ADD_OSQUERY_LINK_CORE("-static-libstdc++")
|
|
|
|
ADD_OSQUERY_LINK_ADDITIONAL("-static-libstdc++")
|
|
|
|
endif()
|
|
|
|
# For Ubuntu/CentOS packages add the build SHA1.
|
|
|
|
ADD_OSQUERY_LINK_CORE("-Wl,--build-id")
|
|
|
|
endif()
|
|
|
|
|
2015-04-27 09:12:58 +00:00
|
|
|
# Bubble the subdirectory (component) sources and links for this build.
|
2014-12-24 04:07:12 +00:00
|
|
|
list(APPEND OSQUERY_OBJECTS ${OSQUERY_SOURCES})
|
|
|
|
list(APPEND OSQUERY_LIBS ${OSQUERY_LINKS})
|
2014-12-23 22:35:48 +00:00
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
set(CMAKE_MACOSX_RPATH 0)
|
2015-05-04 03:02:01 +00:00
|
|
|
set(CMAKE_SKIP_RPATH TRUE)
|
2015-05-20 20:27:53 +00:00
|
|
|
|
2016-08-10 03:27:42 +00:00
|
|
|
# A final map from CMake build platform to a enum using for runtime detection.
|
|
|
|
# The goal is to provide a minimum set of compile code paths.
|
|
|
|
# See ./include/core.h for the enum class.
|
|
|
|
# POSIX = 0x01
|
|
|
|
# WINDOWS = 0x02
|
|
|
|
# BSD = 0x04
|
|
|
|
# LINUX = 0x08 && POSIX
|
|
|
|
# OS X = 0x10 && BSD && POSIX
|
|
|
|
# FREEBSD = 0x20 && BSD && POSIX
|
|
|
|
if(WINDOWS)
|
2016-08-13 02:25:28 +00:00
|
|
|
math(EXPR PLATFORM_MASK "2")
|
2016-08-10 03:27:42 +00:00
|
|
|
elseif(LINUX)
|
2016-08-13 02:25:28 +00:00
|
|
|
math(EXPR PLATFORM_MASK "1 + 8")
|
2016-08-10 03:27:42 +00:00
|
|
|
elseif(APPLE)
|
2016-08-13 02:25:28 +00:00
|
|
|
math(EXPR PLATFORM_MASK "1 + 4 + 16")
|
2016-08-10 03:27:42 +00:00
|
|
|
elseif(FREEBSD)
|
2016-08-13 02:25:28 +00:00
|
|
|
math(EXPR PLATFORM_MASK "1 + 4 + 32")
|
2016-08-10 03:27:42 +00:00
|
|
|
endif()
|
|
|
|
|
2015-05-20 20:27:53 +00:00
|
|
|
# Create the static libosquery (everything but non-utility tables).
|
2016-08-13 02:25:28 +00:00
|
|
|
set(OSQUERY_LIBRARY_FLAGS
|
|
|
|
-DOSQUERY_BUILD_VERSION=${OSQUERY_BUILD_VERSION}
|
|
|
|
-DOSQUERY_PLATFORM_MASK=${PLATFORM_MASK}
|
|
|
|
${CXX_COMPILE_FLAGS}
|
|
|
|
)
|
|
|
|
join("${OSQUERY_LIBRARY_FLAGS}" " " OSQUERY_LIBRARY_FLAGS)
|
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
add_library(libosquery STATIC main/lib.cpp ${OSQUERY_OBJECTS})
|
|
|
|
target_link_libraries(libosquery ${OSQUERY_LIBS})
|
|
|
|
set_target_properties(libosquery PROPERTIES OUTPUT_NAME osquery)
|
2016-08-13 02:25:28 +00:00
|
|
|
set_target_properties(libosquery PROPERTIES COMPILE_FLAGS "${OSQUERY_LIBRARY_FLAGS}")
|
2014-09-06 01:12:37 +00:00
|
|
|
|
2016-07-31 18:32:31 +00:00
|
|
|
# Create the dynamic libosquery.
|
|
|
|
if(DEFINED ENV{OSQUERY_BUILD_SHARED})
|
|
|
|
add_library(libosquery_shared SHARED main/lib.cpp ${OSQUERY_OBJECTS})
|
2016-11-06 09:17:48 +00:00
|
|
|
target_link_libraries(libosquery_shared PRIVATE ${OSQUERY_LIBS})
|
2016-08-13 02:25:28 +00:00
|
|
|
set_target_properties(libosquery_shared PROPERTIES COMPILE_FLAGS "${OSQUERY_LIBRARY_FLAGS}")
|
2016-07-31 18:32:31 +00:00
|
|
|
set_target_properties(libosquery_shared PROPERTIES OUTPUT_NAME osquery)
|
|
|
|
endif()
|
|
|
|
|
2015-04-27 09:12:58 +00:00
|
|
|
# A friendly echo printed after the library is built.
|
|
|
|
add_custom_target(osquery_library ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold
|
2016-08-10 21:06:47 +00:00
|
|
|
"-- Built libosquery: $<TARGET_FILE:libosquery>"
|
2016-08-10 03:27:42 +00:00
|
|
|
DEPENDS libosquery
|
2015-02-26 22:10:39 +00:00
|
|
|
)
|
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
# make devel (implies install)
|
2015-01-08 23:53:51 +00:00
|
|
|
add_custom_target(devel
|
2016-08-10 03:27:42 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -D COMPONENT=devel -P cmake_install.cmake
|
|
|
|
DEPENDS libosquery_basic
|
2015-01-08 23:53:51 +00:00
|
|
|
)
|
2015-02-03 05:21:36 +00:00
|
|
|
add_dependencies(devel libosquery)
|
2015-01-08 23:53:51 +00:00
|
|
|
|
2016-03-15 16:30:40 +00:00
|
|
|
if(NOT ${OSQUERY_BUILD_SDK_ONLY})
|
2016-07-31 18:32:31 +00:00
|
|
|
if(NOT DEFINED ENV{SKIP_TABLES})
|
|
|
|
# Generate the osquery additional tables (the non-util).
|
|
|
|
GENERATE_TABLES("${CMAKE_SOURCE_DIR}")
|
|
|
|
AMALGAMATE("${CMAKE_SOURCE_DIR}" "additional" AMALGAMATION)
|
|
|
|
ADD_OSQUERY_LIBRARY_ADDITIONAL(osquery_additional_amalgamation ${AMALGAMATION})
|
|
|
|
endif()
|
|
|
|
|
2016-04-11 16:33:45 +00:00
|
|
|
AMALGAMATE("${CMAKE_SOURCE_DIR}" "foreign" AMALGAMATION_FOREIGN)
|
|
|
|
ADD_OSQUERY_LIBRARY_ADDITIONAL(osquery_foreign_amalgamation ${AMALGAMATION_FOREIGN})
|
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
# Create the static libosquery_additional.
|
|
|
|
add_library(libosquery_additional STATIC ${OSQUERY_ADDITIONAL_SOURCES})
|
|
|
|
target_link_libraries(libosquery_additional ${OSQUERY_ADDITIONAL_LINKS})
|
|
|
|
set_target_properties(libosquery_additional PROPERTIES OUTPUT_NAME osquery_additional)
|
|
|
|
|
2016-07-31 18:32:31 +00:00
|
|
|
# Create the dynamic libosquery_additional.
|
|
|
|
if(DEFINED ENV{OSQUERY_BUILD_SHARED})
|
|
|
|
add_library(libosquery_additional_shared SHARED ${OSQUERY_ADDITIONAL_SOURCES})
|
2016-11-06 09:17:48 +00:00
|
|
|
target_link_libraries(libosquery_additional_shared PRIVATE ${OSQUERY_ADDITIONAL_LINKS})
|
2016-07-31 18:32:31 +00:00
|
|
|
set_target_properties(libosquery_additional_shared PROPERTIES OUTPUT_NAME osquery_additional)
|
|
|
|
endif()
|
|
|
|
|
2015-03-05 07:10:38 +00:00
|
|
|
add_executable(shell devtools/shell.cpp main/shell.cpp)
|
2016-08-13 02:25:28 +00:00
|
|
|
ADD_DEFAULT_LINKS(shell TRUE)
|
2015-04-27 09:12:58 +00:00
|
|
|
SET_OSQUERY_COMPILE(shell "${CXX_COMPILE_FLAGS}")
|
2017-02-27 02:25:49 +00:00
|
|
|
target_link_libraries(shell)
|
2015-02-03 05:21:36 +00:00
|
|
|
set_target_properties(shell PROPERTIES OUTPUT_NAME osqueryi)
|
|
|
|
|
2016-07-21 06:48:55 +00:00
|
|
|
add_executable(daemon main/${PROCESS_FAMILY}/daemon.cpp)
|
2016-08-13 02:25:28 +00:00
|
|
|
ADD_DEFAULT_LINKS(daemon TRUE)
|
2015-04-27 09:12:58 +00:00
|
|
|
SET_OSQUERY_COMPILE(daemon "${CXX_COMPILE_FLAGS}")
|
2015-02-03 05:21:36 +00:00
|
|
|
set_target_properties(daemon PROPERTIES OUTPUT_NAME osqueryd)
|
|
|
|
|
|
|
|
# Include the public API includes if make devel.
|
|
|
|
install(TARGETS libosquery ARCHIVE DESTINATION lib COMPONENT devel OPTIONAL)
|
2015-05-11 16:36:15 +00:00
|
|
|
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/osquery"
|
2015-05-08 21:00:09 +00:00
|
|
|
DESTINATION include
|
|
|
|
COMPONENT devel OPTIONAL
|
|
|
|
PATTERN ".*" EXCLUDE
|
|
|
|
)
|
2015-02-03 05:21:36 +00:00
|
|
|
|
2016-08-10 21:06:47 +00:00
|
|
|
# A friendly echo printed before building the shell
|
|
|
|
add_custom_command(TARGET shell PRE_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold
|
|
|
|
"-- Building osqueryi: $<TARGET_FILE:shell>"
|
|
|
|
)
|
|
|
|
|
|
|
|
# A friendly echo printed before building the daemon
|
|
|
|
add_custom_command(TARGET daemon PRE_BUILD
|
2016-03-18 02:11:18 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold
|
2016-08-10 21:06:47 +00:00
|
|
|
"-- Building osqueryd: $<TARGET_FILE:daemon>"
|
2016-03-18 02:11:18 +00:00
|
|
|
)
|
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
# make install (executables)
|
|
|
|
install(TARGETS shell RUNTIME DESTINATION bin COMPONENT main)
|
|
|
|
install(TARGETS daemon RUNTIME DESTINATION bin COMPONENT main)
|
2015-07-15 18:32:55 +00:00
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/tools/deployment/osqueryctl"
|
|
|
|
DESTINATION bin COMPONENT main)
|
2015-02-03 05:21:36 +00:00
|
|
|
|
|
|
|
# make install (config files)
|
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/tools/deployment/osquery.example.conf"
|
2015-01-22 19:07:19 +00:00
|
|
|
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/osquery/" COMPONENT main)
|
2015-07-23 23:05:51 +00:00
|
|
|
install(DIRECTORY DESTINATION "${CMAKE_INSTALL_PREFIX}/var/osquery")
|
2015-07-17 23:03:15 +00:00
|
|
|
|
|
|
|
install(DIRECTORY "${CMAKE_SOURCE_DIR}/packs/"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/osquery/packs" COMPONENT main)
|
2015-02-03 05:21:36 +00:00
|
|
|
if(APPLE)
|
|
|
|
install(FILES "${CMAKE_SOURCE_DIR}/tools/deployment/com.facebook.osqueryd.plist"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/osquery/" COMPONENT main)
|
|
|
|
else()
|
|
|
|
install(PROGRAMS "${CMAKE_SOURCE_DIR}/tools/deployment/osqueryd.initd"
|
|
|
|
DESTINATION "/etc/init.d/" RENAME "osqueryd" COMPONENT main)
|
|
|
|
endif()
|
2015-01-08 23:53:51 +00:00
|
|
|
endif()
|
2015-01-08 02:55:14 +00:00
|
|
|
|
2015-04-27 09:12:58 +00:00
|
|
|
if(NOT DEFINED ENV{SKIP_TESTS})
|
|
|
|
# osquery testing library (testing helper methods/libs).
|
2016-06-09 17:49:26 +00:00
|
|
|
add_library(libosquery_testing STATIC tests/test_util.cpp)
|
2015-04-27 09:12:58 +00:00
|
|
|
add_dependencies(libosquery_testing libosquery)
|
|
|
|
SET_OSQUERY_COMPILE(libosquery_testing "${CXX_COMPILE_FLAGS}")
|
|
|
|
set_target_properties(libosquery_testing PROPERTIES OUTPUT_NAME osquery_testing)
|
|
|
|
|
|
|
|
# osquery core set of unit tests build with SDK.
|
|
|
|
add_executable(osquery_tests main/tests.cpp ${OSQUERY_TESTS})
|
2016-08-13 02:25:28 +00:00
|
|
|
ADD_DEFAULT_LINKS(osquery_tests FALSE)
|
2016-07-21 19:33:14 +00:00
|
|
|
target_link_libraries(osquery_tests gtest gmock libosquery_testing)
|
2016-07-31 18:32:31 +00:00
|
|
|
SET_OSQUERY_COMPILE(osquery_tests "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS}")
|
2015-04-27 09:12:58 +00:00
|
|
|
add_test(osquery_tests osquery_tests)
|
|
|
|
|
2015-06-30 21:20:04 +00:00
|
|
|
# osquery kernel tests.
|
2016-08-10 03:27:42 +00:00
|
|
|
if(NOT ${OSQUERY_BUILD_SDK_ONLY} AND NOT WINDOWS)
|
2016-03-15 16:30:40 +00:00
|
|
|
add_executable(osquery_kernel_tests main/tests.cpp ${OSQUERY_KERNEL_TESTS})
|
2016-08-13 02:25:28 +00:00
|
|
|
ADD_DEFAULT_LINKS(osquery_kernel_tests TRUE)
|
2016-07-21 19:33:14 +00:00
|
|
|
target_link_libraries(osquery_kernel_tests gtest gmock libosquery_testing)
|
2016-07-31 18:32:31 +00:00
|
|
|
SET_OSQUERY_COMPILE(osquery_kernel_tests "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS} -DKERNEL_TEST=1")
|
2016-03-15 16:30:40 +00:00
|
|
|
endif()
|
2015-06-30 21:20:04 +00:00
|
|
|
|
2015-07-23 23:42:46 +00:00
|
|
|
# osquery benchmarks.
|
2016-03-15 16:30:40 +00:00
|
|
|
if(NOT DEFINED ENV{SKIP_BENCHMARKS} AND NOT ${OSQUERY_BUILD_SDK_ONLY})
|
2015-10-11 21:37:49 +00:00
|
|
|
add_executable(osquery_benchmarks main/benchmarks.cpp ${OSQUERY_BENCHMARKS})
|
2016-11-15 09:19:08 +00:00
|
|
|
target_link_libraries(osquery_benchmarks benchmark libosquery_testing pthread)
|
2016-08-14 02:38:55 +00:00
|
|
|
ADD_DEFAULT_LINKS(osquery_benchmarks TRUE)
|
2016-07-31 18:32:31 +00:00
|
|
|
SET_OSQUERY_COMPILE(osquery_benchmarks "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS}")
|
2015-10-11 21:37:49 +00:00
|
|
|
set(BENCHMARK_TARGET "$<TARGET_FILE:osquery_benchmarks>")
|
|
|
|
|
|
|
|
# osquery kernel benchmarks.
|
|
|
|
add_executable(osquery_kernel_benchmarks main/benchmarks.cpp ${OSQUERY_KERNEL_BENCHMARKS})
|
2016-11-15 09:19:08 +00:00
|
|
|
target_link_libraries(osquery_kernel_benchmarks benchmark libosquery_testing pthread)
|
2016-08-13 02:25:28 +00:00
|
|
|
ADD_DEFAULT_LINKS(osquery_kernel_benchmarks TRUE)
|
2016-07-31 18:32:31 +00:00
|
|
|
SET_OSQUERY_COMPILE(osquery_kernel_benchmarks "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS} -DKERNEL_TEST=1")
|
2015-10-11 21:37:49 +00:00
|
|
|
|
|
|
|
# make benchmark
|
|
|
|
add_custom_target(
|
|
|
|
run-benchmark
|
|
|
|
COMMAND bash -c "${BENCHMARK_TARGET} $ENV{BENCHMARK_TO_FILE}"
|
|
|
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
|
|
|
DEPENDS osquery_benchmarks
|
|
|
|
)
|
|
|
|
endif()
|
2015-07-24 16:52:29 +00:00
|
|
|
|
2016-03-15 16:30:40 +00:00
|
|
|
if(NOT ${OSQUERY_BUILD_SDK_ONLY})
|
2015-04-27 09:12:58 +00:00
|
|
|
# osquery core (additional) set of unit tests built outside of SDK.
|
2016-11-03 00:08:44 +00:00
|
|
|
add_executable(osquery_additional_tests tests/test_additional_util.cpp main/tests.cpp ${OSQUERY_ADDITIONAL_TESTS})
|
2016-08-13 02:25:28 +00:00
|
|
|
ADD_DEFAULT_LINKS(osquery_additional_tests TRUE)
|
2016-04-01 21:59:24 +00:00
|
|
|
target_link_libraries(osquery_additional_tests gtest gmock libosquery_testing)
|
2016-07-31 18:32:31 +00:00
|
|
|
SET_OSQUERY_COMPILE(osquery_additional_tests "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS}")
|
2015-04-27 09:12:58 +00:00
|
|
|
add_test(osquery_additional_tests osquery_additional_tests)
|
|
|
|
|
|
|
|
# osquery tables set of unit tests (extracted for organization).
|
|
|
|
add_executable(osquery_tables_tests main/tests.cpp ${OSQUERY_TABLES_TESTS})
|
2016-08-13 02:25:28 +00:00
|
|
|
ADD_DEFAULT_LINKS(osquery_tables_tests TRUE)
|
2016-07-21 19:33:14 +00:00
|
|
|
target_link_libraries(osquery_tables_tests gtest gmock libosquery_testing)
|
2016-07-31 18:32:31 +00:00
|
|
|
SET_OSQUERY_COMPILE(osquery_tables_tests "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS}")
|
2015-04-27 09:12:58 +00:00
|
|
|
add_test(osquery_tables_tests osquery_tables_tests)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Build the example extension with the SDK.
|
2015-04-21 22:40:02 +00:00
|
|
|
ADD_OSQUERY_EXTENSION(example_extension examples/example_extension.cpp)
|
2015-03-04 02:40:24 +00:00
|
|
|
|
2015-04-27 09:12:58 +00:00
|
|
|
# Build the example extension module with the SDK.
|
2015-04-21 22:40:02 +00:00
|
|
|
ADD_OSQUERY_MODULE(modexample examples/example_module.cpp)
|
|
|
|
endif()
|