object-introspection/test/integration/CMakeLists.txt

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

102 lines
3.3 KiB
CMake
Raw Normal View History

file(GLOB_RECURSE INTEGRATION_TEST_CONFIGS
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
CONFIGURE_DEPENDS
*.toml
)
set(THRIFT_TEST_CONFIGS
thrift_isset.toml
thrift_isset_missing.toml
thrift_namespaces.toml
thrift_unions.toml
2022-12-19 14:37:51 +00:00
)
find_package(Thrift)
if (${THRIFT_FOUND})
# Add test definition files requiring the Thrift compiler to this list:
set(THRIFT_TESTS ${THRIFT_TEST_CONFIGS})
list(TRANSFORM THRIFT_TESTS REPLACE ".toml$" "")
else()
list(REMOVE_ITEM INTEGRATION_TEST_CONFIGS ${THRIFT_TEST_CONFIGS})
2022-12-19 14:37:51 +00:00
endif()
list(TRANSFORM INTEGRATION_TEST_CONFIGS PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
# Disable position independent executables that oid can't yet handle
add_link_options(-no-pie)
2022-12-19 14:37:51 +00:00
set(INTEGRATION_TEST_TARGET_SRC integration_test_target.cpp)
set(INTEGRATION_TEST_RUNNER_SRC integration_test_runner.cpp)
2024-04-16 12:06:47 +01:00
find_program(PYTHON_CMD NAMES python3.9 python3)
2022-12-19 14:37:51 +00:00
set(INTEGRATION_TEST_THRIFT_SRCS ${THRIFT_TESTS})
list(TRANSFORM INTEGRATION_TEST_THRIFT_SRCS APPEND ".thrift")
add_custom_command(
OUTPUT
${INTEGRATION_TEST_TARGET_SRC}
${INTEGRATION_TEST_RUNNER_SRC}
${INTEGRATION_TEST_THRIFT_SRCS}
COMMAND ${PYTHON_CMD}
${CMAKE_CURRENT_SOURCE_DIR}/gen_tests.py
${INTEGRATION_TEST_TARGET_SRC}
${INTEGRATION_TEST_RUNNER_SRC}
${INTEGRATION_TEST_CONFIGS}
MAIN_DEPENDENCY gen_tests.py
DEPENDS ${INTEGRATION_TEST_CONFIGS})
add_executable(integration_test_target
${INTEGRATION_TEST_TARGET_SRC}
folly_shims.cpp)
2022-12-19 14:37:51 +00:00
target_compile_options(integration_test_target PRIVATE -O1)
target_link_libraries(integration_test_target PRIVATE oil_jit Boost::headers ${Boost_LIBRARIES})
2022-12-19 14:37:51 +00:00
add_executable(integration_test_runner ${INTEGRATION_TEST_RUNNER_SRC} runner_common.cpp)
target_include_directories(integration_test_runner PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(integration_test_runner PRIVATE
2023-07-20 11:37:09 +01:00
GTest::gmock_main
2022-12-19 14:37:51 +00:00
Boost::headers
${Boost_LIBRARIES}
2023-05-25 11:42:20 +01:00
toml
)
2022-12-19 14:37:51 +00:00
target_compile_definitions(integration_test_runner PRIVATE
TARGET_EXE_PATH="${CMAKE_CURRENT_BINARY_DIR}/integration_test_target"
OID_EXE_PATH="$<TARGET_FILE:oid>"
CONFIG_FILE_PATH="${CMAKE_BINARY_DIR}/testing.oid.toml")
if (${THRIFT_FOUND})
foreach(THRIFT_TEST IN LISTS THRIFT_TESTS)
set(THRIFT_SRC "${THRIFT_TEST}.thrift")
set(THRIFT_TYPES_H "thrift/annotation/gen-cpp2/${THRIFT_TEST}_types.h")
set(THRIFT_DATA_CPP "thrift/annotation/gen-cpp2/${THRIFT_TEST}_data.cpp")
add_custom_command(
OUTPUT
${THRIFT_TYPES_H}
${THRIFT_DATA_CPP}
COMMAND
${THRIFT_COMPILER}
-r
--gen mstch_cpp2
-o thrift/annotation/
-I ${THRIFT_INCLUDE_DIRS}
${THRIFT_SRC}
MAIN_DEPENDENCY ${THRIFT_SRC})
add_custom_target(integration_test_thrift_sources_${THRIFT_TEST} DEPENDS ${THRIFT_TYPES_H})
add_dependencies(integration_test_target integration_test_thrift_sources_${THRIFT_TEST})
target_sources(integration_test_target PRIVATE ${THRIFT_DATA_CPP})
endforeach()
target_include_directories(integration_test_target PRIVATE
${THRIFT_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(integration_test_target PRIVATE glog::glog)
endif()
if (DEFINED ENV{CI})
gtest_discover_tests(integration_test_runner EXTRA_ARGS "--verbose" "--preserve-on-failure")
else()
gtest_discover_tests(integration_test_runner)
endif()