mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 01:55:20 +00:00
gtest: Fix tuple breakage on CentOS (#3809)
This commit is contained in:
parent
c769aefcff
commit
6db57de94c
@ -43,9 +43,9 @@ macro(SET_OSQUERY_COMPILE TARGET)
|
||||
list(LENGTH OPTIONAL_FLAGS NUM_OPTIONAL_FLAGS)
|
||||
if(${NUM_OPTIONAL_FLAGS} GREATER 0)
|
||||
set_target_properties(${TARGET} PROPERTIES COMPILE_FLAGS "${OPTIONAL_FLAGS}")
|
||||
if(DO_CLANG_TIDY AND NOT "${TARGET}" STREQUAL "osquery_extensions")
|
||||
set_target_properties(${TARGET} PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
|
||||
endif()
|
||||
endif()
|
||||
if(DO_CLANG_TIDY AND NOT "${TARGET}" STREQUAL "osquery_extensions")
|
||||
set_target_properties(${TARGET} PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
|
||||
endif()
|
||||
endmacro(SET_OSQUERY_COMPILE)
|
||||
|
||||
@ -250,7 +250,6 @@ macro(ADD_OSQUERY_LIBRARY IS_CORE TARGET)
|
||||
endforeach()
|
||||
add_library(${TARGET} OBJECT ${ARGN})
|
||||
add_dependencies(${TARGET} osquery_extensions)
|
||||
SET_OSQUERY_COMPILE(${TARGET} "${CXX_COMPILE_FLAGS}")
|
||||
if(${IS_CORE})
|
||||
list(APPEND OSQUERY_SOURCES $<TARGET_OBJECTS:${TARGET}>)
|
||||
set(OSQUERY_SOURCES ${OSQUERY_SOURCES} PARENT_SCOPE)
|
||||
@ -264,7 +263,6 @@ endmacro(ADD_OSQUERY_LIBRARY TARGET)
|
||||
macro(ADD_OSQUERY_EXTENSION TARGET)
|
||||
add_executable(${TARGET} ${ARGN})
|
||||
TARGET_OSQUERY_LINK_WHOLE(${TARGET} libosquery)
|
||||
set_target_properties(${TARGET} PROPERTIES COMPILE_FLAGS "${CXX_COMPILE_FLAGS}")
|
||||
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME "${TARGET}.ext")
|
||||
endmacro(ADD_OSQUERY_EXTENSION)
|
||||
|
||||
|
@ -60,7 +60,7 @@ if(NOT DEFINED ENV{SKIP_CCACHE})
|
||||
endif()
|
||||
|
||||
# osquery additional compiler flags added by CMake.
|
||||
set(C_COMPILE_FLAGS "")
|
||||
set(CXX_STD "c++14")
|
||||
set(CXX_COMPILE_FLAGS "")
|
||||
|
||||
find_program(PYTHON_EXECUTABLE "python" ${BUILD_DEPS} ENV PATH)
|
||||
@ -102,7 +102,7 @@ if(APPLE)
|
||||
-mmacosx-version-min=${OSX_VERSION_MIN}
|
||||
)
|
||||
|
||||
set(CXX_COMPILE_FLAGS "${CXX_COMPILE_FLAGS} -std=c++14 -stdlib=libc++")
|
||||
set(CMAKE_CXX_FLAGS "-std=${CXX_STD} -stdlib=libc++" CACHE STRING "" FORCE)
|
||||
set(OS_WHOLELINK_PRE "-Wl,-force_load")
|
||||
set(OS_WHOLELINK_POST "")
|
||||
# Special compile flags for Objective-C++
|
||||
@ -124,10 +124,10 @@ else()
|
||||
set(FREEBSD TRUE)
|
||||
include_directories("/usr/local/include")
|
||||
include_directories("/usr/include")
|
||||
set(CXX_COMPILE_FLAGS "${CXX_COMPILE_FLAGS} -std=c++14 -stdlib=libc++")
|
||||
set(CMAKE_CXX_FLAGS "-std=${CXX_STD} -stdlib=libc++" CACHE STRING "" FORCE)
|
||||
else()
|
||||
set(LINUX TRUE)
|
||||
set(CXX_COMPILE_FLAGS "${CXX_COMPILE_FLAGS} -std=c++14 -stdlib=libstdc++")
|
||||
set(CMAKE_CXX_FLAGS "-std=${CXX_STD} -stdlib=libstdc++" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
set(POSIX TRUE)
|
||||
endif()
|
||||
@ -245,8 +245,6 @@ else()
|
||||
endif()
|
||||
add_definitions(-DNDEBUG)
|
||||
# Do not enable fortify with clang: http://llvm.org/bugs/show_bug.cgi?id=16821
|
||||
#set(C_COMPILE_FLAGS "${C_COMPILE_FLAGS} -D_FORTIFY_SOURCE=2")
|
||||
|
||||
# Visual Studio does not support generation of PIC code
|
||||
if(POSIX)
|
||||
# TSAN and MSAN do not like PIE/PIC on Linux 4.1.
|
||||
@ -506,6 +504,11 @@ elseif(LINUX)
|
||||
endif()
|
||||
|
||||
if(POSIX)
|
||||
set(CMAKE_REQUIRED_INCLUDES
|
||||
"${BUILD_DEPS}/legacy/include"
|
||||
"${BUILD_DEPS}/include"
|
||||
)
|
||||
|
||||
include_directories(SYSTEM "${BUILD_DEPS}/legacy/include")
|
||||
include_directories(SYSTEM "${BUILD_DEPS}/include")
|
||||
include_directories("${BUILD_DEPS}/include/openssl")
|
||||
@ -577,6 +580,9 @@ endif()
|
||||
# We can supply the known include paths within each test as compile flags.
|
||||
enable_testing()
|
||||
set(CTEST_TEST_TIMEOUT 600)
|
||||
set(BUILD_GTEST TRUE)
|
||||
|
||||
include(Thrift)
|
||||
|
||||
# Detect TR1 usage.
|
||||
include(CheckIncludeFileCXX)
|
||||
@ -587,24 +593,18 @@ else()
|
||||
endif()
|
||||
|
||||
if(FREEBSD OR "${HAVE_TR1_TUPLE}" STREQUAL "")
|
||||
set(GTEST_FLAGS "-DGTEST_USE_OWN_TR1_TUPLE=1")
|
||||
else()
|
||||
set(GTEST_FLAGS "-DGTEST_USE_OWN_TR1_TUPLE=0")
|
||||
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=1)
|
||||
else()
|
||||
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=0)
|
||||
endif()
|
||||
|
||||
set(GTEST_FLAGS
|
||||
${GTEST_FLAGS}
|
||||
"-I${CMAKE_SOURCE_DIR}/third-party/googletest/googletest/include"
|
||||
"-I${CMAKE_SOURCE_DIR}/third-party/googletest/googlemock/include"
|
||||
)
|
||||
join("${GTEST_FLAGS}" " " GTEST_FLAGS)
|
||||
|
||||
set(BUILD_GTEST TRUE)
|
||||
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/googletest")
|
||||
|
||||
include(Thrift)
|
||||
|
||||
add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/sqlite3")
|
||||
|
||||
add_subdirectory(osquery)
|
||||
|
@ -237,7 +237,6 @@ endif()
|
||||
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)
|
||||
|
||||
@ -319,7 +318,7 @@ if(NOT OSQUERY_BUILD_SDK_ONLY)
|
||||
)
|
||||
|
||||
ADD_DEFAULT_LINKS(daemon TRUE)
|
||||
SET_OSQUERY_COMPILE(daemon "${CXX_COMPILE_FLAGS}")
|
||||
SET_OSQUERY_COMPILE(daemon)
|
||||
set_target_properties(daemon PROPERTIES OUTPUT_NAME osqueryd)
|
||||
|
||||
# A friendly echo printed before building the daemon
|
||||
@ -377,14 +376,14 @@ if(NOT SKIP_TESTS)
|
||||
# osquery testing library (testing helper methods/libs).
|
||||
add_library(libosquery_testing STATIC tests/test_util.cpp)
|
||||
add_dependencies(libosquery_testing libosquery)
|
||||
SET_OSQUERY_COMPILE(libosquery_testing "${CXX_COMPILE_FLAGS}")
|
||||
SET_OSQUERY_COMPILE(libosquery_testing)
|
||||
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})
|
||||
ADD_DEFAULT_LINKS(osquery_tests FALSE)
|
||||
target_link_libraries(osquery_tests gtest gmock libosquery_testing)
|
||||
SET_OSQUERY_COMPILE(osquery_tests "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS}")
|
||||
SET_OSQUERY_COMPILE(osquery_tests "${GTEST_FLAGS}")
|
||||
add_test(osquery_tests osquery_tests ${TEST_ARGS})
|
||||
|
||||
# osquery kernel tests.
|
||||
@ -392,7 +391,7 @@ if(NOT SKIP_TESTS)
|
||||
add_executable(osquery_kernel_tests main/tests.cpp ${OSQUERY_KERNEL_TESTS})
|
||||
ADD_DEFAULT_LINKS(osquery_kernel_tests TRUE)
|
||||
target_link_libraries(osquery_kernel_tests gtest gmock libosquery_testing)
|
||||
SET_OSQUERY_COMPILE(osquery_kernel_tests "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS} -DKERNEL_TEST=1")
|
||||
SET_OSQUERY_COMPILE(osquery_kernel_tests "${GTEST_FLAGS} -DKERNEL_TEST=1")
|
||||
endif()
|
||||
|
||||
# osquery benchmarks.
|
||||
@ -400,7 +399,7 @@ if(NOT SKIP_TESTS)
|
||||
add_executable(osquery_benchmarks main/benchmarks.cpp ${OSQUERY_BENCHMARKS})
|
||||
target_link_libraries(osquery_benchmarks benchmark libosquery_testing pthread)
|
||||
ADD_DEFAULT_LINKS(osquery_benchmarks TRUE)
|
||||
SET_OSQUERY_COMPILE(osquery_benchmarks "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS}")
|
||||
SET_OSQUERY_COMPILE(osquery_benchmarks "${GTEST_FLAGS}")
|
||||
set(BENCHMARK_TARGET "$<TARGET_FILE:osquery_benchmarks>")
|
||||
|
||||
# osquery kernel benchmarks.
|
||||
@ -408,7 +407,7 @@ if(NOT SKIP_TESTS)
|
||||
add_executable(osquery_kernel_benchmarks main/benchmarks.cpp ${OSQUERY_KERNEL_BENCHMARKS})
|
||||
target_link_libraries(osquery_kernel_benchmarks benchmark libosquery_testing pthread)
|
||||
ADD_DEFAULT_LINKS(osquery_kernel_benchmarks TRUE)
|
||||
SET_OSQUERY_COMPILE(osquery_kernel_benchmarks "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS} -DKERNEL_TEST=1")
|
||||
SET_OSQUERY_COMPILE(osquery_kernel_benchmarks "${GTEST_FLAGS} -DKERNEL_TEST=1")
|
||||
endif()
|
||||
|
||||
# make benchmark
|
||||
@ -425,14 +424,14 @@ if(NOT SKIP_TESTS)
|
||||
add_executable(osquery_additional_tests tests/test_additional_util.cpp main/tests.cpp ${OSQUERY_ADDITIONAL_TESTS})
|
||||
ADD_DEFAULT_LINKS(osquery_additional_tests TRUE)
|
||||
target_link_libraries(osquery_additional_tests gtest gmock libosquery_testing)
|
||||
SET_OSQUERY_COMPILE(osquery_additional_tests "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS}")
|
||||
SET_OSQUERY_COMPILE(osquery_additional_tests "${GTEST_FLAGS}")
|
||||
add_test(osquery_additional_tests osquery_additional_tests ${TEST_ARGS})
|
||||
|
||||
# osquery tables set of unit tests (extracted for organization).
|
||||
add_executable(osquery_tables_tests tests/test_additional_util.cpp main/tests.cpp ${OSQUERY_TABLES_TESTS})
|
||||
ADD_DEFAULT_LINKS(osquery_tables_tests TRUE)
|
||||
target_link_libraries(osquery_tables_tests gtest gmock libosquery_testing)
|
||||
SET_OSQUERY_COMPILE(osquery_tables_tests "${GTEST_FLAGS} ${CXX_COMPILE_FLAGS}")
|
||||
SET_OSQUERY_COMPILE(osquery_tables_tests "${GTEST_FLAGS}")
|
||||
add_test(osquery_tables_tests osquery_tables_tests ${TEST_ARGS})
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user