2015-01-05 16:05:41 +00:00
|
|
|
# Fill this in with objects and (linker/linker options) for libosquery.
|
|
|
|
set(OSQUERY_SOURCES "")
|
|
|
|
set(OSQUERY_LINKS "")
|
|
|
|
# Fill this in in with non-core links and linker options (for plugins).
|
|
|
|
set(OSQUERY_ADDITIONAL_SOURCES "")
|
|
|
|
set(OSQUERY_ADDITIONAL_LINKS "")
|
2014-09-06 01:12:37 +00:00
|
|
|
|
2015-01-05 16:05:41 +00:00
|
|
|
set(Boost_USE_STATIC_LIBS ON)
|
|
|
|
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
|
|
|
|
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
|
2014-11-09 00:55:19 +00:00
|
|
|
|
2015-01-05 16:05:41 +00:00
|
|
|
# The core set of osquery libraries most discovered with find_package.
|
|
|
|
set(OSQUERY_LIBS
|
|
|
|
${THRIFT_LIB}
|
|
|
|
${ROCKSDB_STATIC_LIBRARIES}
|
|
|
|
${ROCKSDB_SNAPPY_LIBRARY}
|
|
|
|
${GLOG_LIBRARY}
|
|
|
|
${GFLAGS_LIBRARY}
|
|
|
|
${OPENSSL_CRYPTO_LIBRARY}
|
|
|
|
${OPENSSL_SSL_LIBRARY}
|
2014-12-23 19:39:03 +00:00
|
|
|
|
2015-01-05 16:05:41 +00:00
|
|
|
readline
|
|
|
|
pthread
|
2014-12-23 19:39:03 +00:00
|
|
|
dl
|
2014-11-18 21:03:13 +00:00
|
|
|
bz2
|
2014-12-23 19:39:03 +00:00
|
|
|
z
|
2014-11-13 20:00:41 +00:00
|
|
|
)
|
|
|
|
|
2015-03-04 16:45:21 +00:00
|
|
|
# Add default linking details
|
|
|
|
ADD_OSQUERY_LINK(TRUE "-rdynamic")
|
|
|
|
|
2015-01-05 16:05:41 +00:00
|
|
|
# The platform-specific core libraries.
|
|
|
|
if(APPLE)
|
2015-02-03 05:21:36 +00:00
|
|
|
ADD_OSQUERY_LINK(TRUE "-mmacosx-version-min=${APPLE_MIN_ABI}")
|
|
|
|
ADD_OSQUERY_LINK(TRUE "boost_thread-mt")
|
|
|
|
ADD_OSQUERY_LINK(TRUE "lz4")
|
2014-12-03 23:14:02 +00:00
|
|
|
else()
|
2015-02-03 05:21:36 +00:00
|
|
|
ADD_OSQUERY_LINK(TRUE "boost_thread")
|
|
|
|
ADD_OSQUERY_LINK(TRUE "rt")
|
2014-10-29 10:38:21 +00:00
|
|
|
endif()
|
|
|
|
|
2015-01-05 16:05:41 +00:00
|
|
|
# The remaining boost libraries are discovered with find_library.
|
2015-02-03 05:21:36 +00:00
|
|
|
ADD_OSQUERY_LINK(TRUE "boost_system")
|
|
|
|
ADD_OSQUERY_LINK(TRUE "boost_filesystem")
|
2014-11-09 00:55:19 +00:00
|
|
|
|
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)
|
2015-02-26 19:35:54 +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)
|
2014-12-28 06:42:59 +00:00
|
|
|
add_subdirectory(scheduler)
|
2015-02-03 05:21:36 +00:00
|
|
|
add_subdirectory(sql)
|
2014-12-28 06:42:59 +00:00
|
|
|
add_subdirectory(tables)
|
2014-12-24 04:07:12 +00:00
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
# Finally amalgamate the tables needed to compile.
|
2015-03-04 16:45:21 +00:00
|
|
|
GENERATE_UTILITIES("${CMAKE_SOURCE_DIR}/osquery/tables")
|
2014-12-25 20:46:59 +00:00
|
|
|
AMALGAMATE("${CMAKE_SOURCE_DIR}" "utils" AMALGAMATION_UTILS)
|
2015-02-03 05:21:36 +00:00
|
|
|
ADD_OSQUERY_LIBRARY(TRUE osquery_utils_amalgamation ${AMALGAMATION_UTILS})
|
2014-09-02 08:00:58 +00:00
|
|
|
|
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
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
# Create the static libosquery (everything but non-util tables).
|
2014-11-09 00:55:19 +00:00
|
|
|
set(CMAKE_MACOSX_RPATH 0)
|
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)
|
2014-09-06 01:12:37 +00:00
|
|
|
|
2015-02-26 22:10:39 +00:00
|
|
|
add_custom_target(BUILD_LIB_SUCCESS ALL
|
|
|
|
DEPENDS libosquery
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold "Built libosquery: ${CMAKE_BINARY_DIR}"
|
|
|
|
)
|
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
# make devel (implies install)
|
2015-01-08 23:53:51 +00:00
|
|
|
add_custom_target(devel
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-D COMPONENT=devel
|
|
|
|
-P cmake_install.cmake
|
|
|
|
DEPENDS libosquery_basic
|
|
|
|
)
|
2015-02-03 05:21:36 +00:00
|
|
|
add_dependencies(devel libosquery)
|
2015-01-08 23:53:51 +00:00
|
|
|
|
2015-02-03 05:21:36 +00:00
|
|
|
# Generate the osquery additional tables (the non-util).
|
2015-03-04 16:45:21 +00:00
|
|
|
GENERATE_TABLES("${CMAKE_SOURCE_DIR}/osquery/tables")
|
2015-02-03 05:21:36 +00:00
|
|
|
AMALGAMATE("${CMAKE_SOURCE_DIR}" "additional" AMALGAMATION)
|
|
|
|
ADD_OSQUERY_LIBRARY(FALSE osquery_amalgamation ${AMALGAMATION})
|
|
|
|
|
|
|
|
if(NOT OSQUERY_BUILD_SDK_ONLY)
|
|
|
|
# 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)
|
|
|
|
|
|
|
|
add_executable(shell main/shell.cpp)
|
|
|
|
TARGET_OSQUERY_LINK_WHOLE(shell libosquery)
|
|
|
|
TARGET_OSQUERY_LINK_WHOLE(shell libosquery_additional)
|
2015-03-04 02:40:24 +00:00
|
|
|
set_target_properties(shell PROPERTIES COMPILE_FLAGS "${CXX_COMPILE_FLAGS}")
|
2015-02-03 05:21:36 +00:00
|
|
|
set_target_properties(shell PROPERTIES OUTPUT_NAME osqueryi)
|
|
|
|
|
2015-02-09 00:00:43 +00:00
|
|
|
add_executable(daemon main/daemon.cpp)
|
2015-02-03 05:21:36 +00:00
|
|
|
TARGET_OSQUERY_LINK_WHOLE(daemon libosquery)
|
|
|
|
TARGET_OSQUERY_LINK_WHOLE(daemon libosquery_additional)
|
2015-03-04 02:40:24 +00:00
|
|
|
set_target_properties(daemon PROPERTIES COMPILE_FLAGS "${CXX_COMPILE_FLAGS}")
|
2015-02-03 05:21:36 +00:00
|
|
|
set_target_properties(daemon PROPERTIES OUTPUT_NAME osqueryd)
|
|
|
|
|
|
|
|
add_executable(run main/run.cpp)
|
|
|
|
TARGET_OSQUERY_LINK_WHOLE(run libosquery)
|
|
|
|
TARGET_OSQUERY_LINK_WHOLE(run libosquery_additional)
|
2015-03-04 02:40:24 +00:00
|
|
|
set_target_properties(run PROPERTIES COMPILE_FLAGS "${CXX_COMPILE_FLAGS}")
|
2015-02-03 05:21:36 +00:00
|
|
|
|
|
|
|
# Include the public API includes if make devel.
|
|
|
|
install(TARGETS libosquery ARCHIVE DESTINATION lib COMPONENT devel OPTIONAL)
|
|
|
|
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION include COMPONENT devel OPTIONAL)
|
|
|
|
|
|
|
|
# make install (executables)
|
|
|
|
install(TARGETS shell RUNTIME DESTINATION bin COMPONENT main)
|
|
|
|
install(TARGETS daemon RUNTIME DESTINATION bin COMPONENT main)
|
|
|
|
|
|
|
|
# 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-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-02-19 23:19:00 +00:00
|
|
|
# Build the example extension with the SDK
|
2015-03-04 02:40:24 +00:00
|
|
|
ADD_OSQUERY_EXTENSION(example_extension examples/example_extension.cpp)
|
|
|
|
|
|
|
|
# Build the example extension module with the SDK
|
|
|
|
ADD_OSQUERY_MODULE(modexample examples/example_module.cpp)
|