2021-03-03 03:22:02 +08:00
|
|
|
|
add_executable(cesium-native-tests "")
|
2024-02-23 11:56:52 +08:00
|
|
|
|
set_property(TARGET cesium-native-tests PROPERTY FOLDER "Tests")
|
2021-03-03 03:22:02 +08:00
|
|
|
|
configure_cesium_library(cesium-native-tests)
|
|
|
|
|
|
|
|
|
|
|
|
# Add tests here, ensure they define the TEST_SOURCES / TEST_HEADERS
|
|
|
|
|
|
# properties.
|
2021-03-04 09:47:31 +08:00
|
|
|
|
set(cesium_native_targets
|
2023-08-23 09:30:06 +08:00
|
|
|
|
Cesium3DTiles
|
2023-11-02 16:48:57 +08:00
|
|
|
|
Cesium3DTilesContent
|
2021-10-11 07:36:26 +08:00
|
|
|
|
Cesium3DTilesReader
|
2021-07-15 21:33:29 +08:00
|
|
|
|
Cesium3DTilesSelection
|
2024-03-05 18:14:47 +08:00
|
|
|
|
Cesium3DTilesWriter
|
2021-10-12 19:38:09 +08:00
|
|
|
|
CesiumAsync
|
|
|
|
|
|
CesiumGeometry
|
2021-03-03 03:22:02 +08:00
|
|
|
|
CesiumGeospatial
|
|
|
|
|
|
CesiumGltf
|
2024-04-10 17:40:01 +08:00
|
|
|
|
CesiumGltfContent
|
2021-03-03 03:22:02 +08:00
|
|
|
|
CesiumGltfReader
|
2021-03-03 06:10:48 +08:00
|
|
|
|
CesiumGltfWriter
|
2022-01-20 08:40:38 +08:00
|
|
|
|
CesiumIonClient
|
2025-03-12 05:57:53 +08:00
|
|
|
|
CesiumITwinClient
|
2025-04-03 05:18:53 +08:00
|
|
|
|
CesiumVectorData
|
2024-04-10 12:07:11 +08:00
|
|
|
|
CesiumQuantizedMeshTerrain
|
2023-11-14 15:57:47 +08:00
|
|
|
|
CesiumRasterOverlays
|
2021-03-03 03:22:02 +08:00
|
|
|
|
CesiumUtility
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-07-01 23:00:06 +08:00
|
|
|
|
if(NOT CESIUM_DISABLE_CURL)
|
|
|
|
|
|
list(APPEND cesium_native_targets CesiumCurl)
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
2023-11-02 16:48:57 +08:00
|
|
|
|
cesium_glob_files(test_sources
|
|
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/src/*.cpp
|
|
|
|
|
|
)
|
|
|
|
|
|
cesium_glob_files(test_headers
|
|
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/include/CesiumNativeTests/*.h
|
|
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/generated/include/CesiumNativeTests/*.h
|
|
|
|
|
|
)
|
|
|
|
|
|
set(test_include_directories ${CMAKE_CURRENT_LIST_DIR}/include)
|
2021-03-03 03:22:02 +08:00
|
|
|
|
|
2025-10-23 11:47:23 +08:00
|
|
|
|
if(CESIUM_TARGET_WASM)
|
|
|
|
|
|
target_link_options(
|
|
|
|
|
|
cesium-native-tests
|
|
|
|
|
|
PRIVATE
|
|
|
|
|
|
"-sEXIT_RUNTIME=1"
|
|
|
|
|
|
)
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
2021-03-03 03:22:02 +08:00
|
|
|
|
# Iterate through all targets, extracting their private sources and test sources / test headers
|
|
|
|
|
|
foreach(target ${cesium_native_targets})
|
|
|
|
|
|
get_target_property(target_test_sources ${target} TEST_SOURCES)
|
|
|
|
|
|
get_target_property(target_test_headers ${target} TEST_HEADERS)
|
|
|
|
|
|
|
|
|
|
|
|
if ("${target_test_sources}" MATCHES ".*NOTFOUND$")
|
|
|
|
|
|
message(FATAL_ERROR "${target} did not define TEST_SOURCES property. Use quotes to prevent an empty list from generating this error.")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if ("${target_test_headers}" MATCHES ".*NOTFOUND$")
|
|
|
|
|
|
message(FATAL_ERROR "${target} did not define TEST_HEADERS property. Use quotes to prevent an empty list from generating this error.")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
list(APPEND test_sources "${target_test_sources}")
|
|
|
|
|
|
list(APPEND test_headers "${target_test_headers}")
|
|
|
|
|
|
|
|
|
|
|
|
# Workaround to extract the private include directories from a target.
|
|
|
|
|
|
# (public ∪ private) - interface = private in CMake
|
|
|
|
|
|
get_target_property(_public_private_include_directories ${target} INCLUDE_DIRECTORIES)
|
|
|
|
|
|
get_target_property(_interface_include_directories ${target} INTERFACE_INCLUDE_DIRECTORIES)
|
|
|
|
|
|
set(_private_include_directories "")
|
|
|
|
|
|
list(APPEND _private_include_directories ${_public_private_include_directories})
|
|
|
|
|
|
list(REMOVE_ITEM _private_include_directories ${_interface_include_directories})
|
|
|
|
|
|
list(APPEND test_include_directories ${_private_include_directories})
|
|
|
|
|
|
|
|
|
|
|
|
# Add hardcoded defines to test data directories if they defined
|
|
|
|
|
|
# the `TEST_DATA_DIR` property on their targets.
|
|
|
|
|
|
get_target_property(target_test_data_dir ${target} TEST_DATA_DIR)
|
|
|
|
|
|
if (NOT "${target_test_data_dir}" MATCHES ".*NOTFOUND$")
|
|
|
|
|
|
target_compile_definitions(
|
|
|
|
|
|
cesium-native-tests
|
|
|
|
|
|
PRIVATE
|
|
|
|
|
|
${target}_TEST_DATA_DIR=\"${target_test_data_dir}\"
|
|
|
|
|
|
)
|
|
|
|
|
|
endif()
|
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
2025-09-21 09:49:52 +08:00
|
|
|
|
if(CESIUM_TARGET_WASM)
|
|
|
|
|
|
file(GLOB directories_list LIST_DIRECTORIES true "${CMAKE_SOURCE_DIR}/Cesium*")
|
2025-11-06 12:36:39 +08:00
|
|
|
|
set(FILE_PACKAGER_ARGS "")
|
|
|
|
|
|
set(TEST_DATA_FILES "")
|
2025-09-21 09:49:52 +08:00
|
|
|
|
foreach(dir ${directories_list})
|
|
|
|
|
|
if(IS_DIRECTORY ${dir}/test/data)
|
2025-11-06 12:36:39 +08:00
|
|
|
|
list(APPEND FILE_PACKAGER_ARGS "--embed" "${dir}/test/data")
|
|
|
|
|
|
|
|
|
|
|
|
file(GLOB_RECURSE data_files "${dir}/test/data/*")
|
|
|
|
|
|
list(APPEND TEST_DATA_FILES ${data_files})
|
2025-09-21 09:49:52 +08:00
|
|
|
|
endif()
|
|
|
|
|
|
endforeach()
|
|
|
|
|
|
|
2025-11-06 12:36:39 +08:00
|
|
|
|
list(APPEND FILE_PACKAGER_ARGS "--embed" "${CMAKE_SOURCE_DIR}/data")
|
2025-09-21 09:49:52 +08:00
|
|
|
|
|
2025-11-07 18:04:56 +08:00
|
|
|
|
if(CESIUM_WASM64)
|
|
|
|
|
|
list(APPEND FILE_PACKAGER_ARGS "--wasm64")
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
2025-09-21 09:49:52 +08:00
|
|
|
|
set(CESIUM_NATIVE_TESTS_DATA_OBJ ${CMAKE_CURRENT_BINARY_DIR}/cesium-native-tests-data.o)
|
2025-11-06 12:36:39 +08:00
|
|
|
|
add_custom_command(
|
|
|
|
|
|
COMMENT "Generating test data object file"
|
|
|
|
|
|
OUTPUT ${CESIUM_NATIVE_TESTS_DATA_OBJ}
|
|
|
|
|
|
COMMAND ${EMSCRIPTEN_ROOT_PATH}/tools/file_packager none.data ${FILE_PACKAGER_ARGS} --obj-output=${CESIUM_NATIVE_TESTS_DATA_OBJ}
|
|
|
|
|
|
VERBATIM
|
|
|
|
|
|
DEPENDS ${TEST_DATA_FILES}
|
|
|
|
|
|
)
|
2025-11-06 19:53:27 +08:00
|
|
|
|
|
|
|
|
|
|
target_sources(
|
|
|
|
|
|
cesium-native-tests
|
|
|
|
|
|
PRIVATE
|
|
|
|
|
|
${CESIUM_NATIVE_TESTS_DATA_OBJ}
|
|
|
|
|
|
)
|
2025-09-21 09:49:52 +08:00
|
|
|
|
endif()
|
|
|
|
|
|
|
2021-03-03 03:22:02 +08:00
|
|
|
|
target_sources(
|
|
|
|
|
|
cesium-native-tests
|
|
|
|
|
|
PRIVATE
|
|
|
|
|
|
${test_sources}
|
|
|
|
|
|
${test_headers}
|
|
|
|
|
|
src/test-main.cpp
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
target_include_directories(
|
|
|
|
|
|
cesium-native-tests
|
|
|
|
|
|
PRIVATE
|
|
|
|
|
|
${test_include_directories}
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2024-02-23 11:56:52 +08:00
|
|
|
|
target_link_libraries(cesium-native-tests
|
|
|
|
|
|
PUBLIC
|
2025-01-16 05:58:03 +08:00
|
|
|
|
doctest::doctest
|
2021-03-04 10:32:20 +08:00
|
|
|
|
${cesium_native_targets}
|
2024-02-23 11:56:52 +08:00
|
|
|
|
PRIVATE
|
|
|
|
|
|
s2::s2
|
2021-03-03 03:22:02 +08:00
|
|
|
|
)
|
2021-03-03 04:15:59 +08:00
|
|
|
|
|
2024-08-22 18:40:31 +08:00
|
|
|
|
target_compile_definitions(cesium-native-tests
|
|
|
|
|
|
PRIVATE
|
2025-09-21 09:49:52 +08:00
|
|
|
|
CESIUM_NATIVE_DATA_DIR=\"${CMAKE_SOURCE_DIR}/data\"
|
2024-08-22 18:40:31 +08:00
|
|
|
|
)
|
2024-02-23 11:56:52 +08:00
|
|
|
|
|
2021-03-03 04:15:59 +08:00
|
|
|
|
include(CTest)
|
2025-01-16 05:58:03 +08:00
|
|
|
|
include(doctest)
|
2025-09-21 09:49:52 +08:00
|
|
|
|
if(NOT CESIUM_TARGET_WASM)
|
|
|
|
|
|
# doctest_discover_tests can't handle the target being an html file, so we just avoid it on a wasm build
|
|
|
|
|
|
doctest_discover_tests(cesium-native-tests)
|
|
|
|
|
|
endif()
|