Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add options to disable tests/benchmarks #8245

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ project(TNT)
# ==================================================================================================
# Options
# ==================================================================================================
option(FILAMENT_TESTS "Build tests" ON)

option(FILAMENT_BENCHMARKS "Build benchmarks" ON)

option(FILAMENT_USE_EXTERNAL_GLES3 "Experimental: Compile Filament against OpenGL ES 3" OFF)

option(FILAMENT_ENABLE_LTO "Enable link-time optimizations if supported by the compiler" OFF)
Expand Down Expand Up @@ -731,7 +735,9 @@ endfunction()
# ==================================================================================================

# Common to all platforms
if(FILAMENT_TESTS)
add_subdirectory(${EXTERNAL}/libgtest/tnt)
endif()
add_subdirectory(${LIBRARIES}/camutils)
add_subdirectory(${LIBRARIES}/filabridge)
add_subdirectory(${LIBRARIES}/filaflat)
Expand All @@ -754,7 +760,9 @@ add_subdirectory(${EXTERNAL}/civetweb/tnt)
add_subdirectory(${EXTERNAL}/imgui/tnt)
add_subdirectory(${EXTERNAL}/robin-map/tnt)
add_subdirectory(${EXTERNAL}/smol-v/tnt)
if(FILAMENT_BENCHMARKS)
add_subdirectory(${EXTERNAL}/benchmark/tnt)
endif()
add_subdirectory(${EXTERNAL}/meshoptimizer/tnt)
add_subdirectory(${EXTERNAL}/mikktspace)
add_subdirectory(${EXTERNAL}/cgltf/tnt)
Expand Down
4 changes: 4 additions & 0 deletions filament/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -640,5 +640,9 @@ install(FILES "../LICENSE" DESTINATION .)
# Sub-projects
# ==================================================================================================
add_subdirectory(backend)
if(FILAMENT_TESTS)
add_subdirectory(test)
endif()
if(FILAMENT_BENCHMARKS)
add_subdirectory(benchmark)
endif()
4 changes: 4 additions & 0 deletions filament/backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ install(DIRECTORY ${PUBLIC_HDR_DIR}/backend DESTINATION include)
# ==================================================================================================
# Test
# ==================================================================================================
if(FILAMENT_TESTS)

option(INSTALL_BACKEND_TEST "Install the backend test library so it can be consumed on iOS" OFF)

if (APPLE OR LINUX)
Expand Down Expand Up @@ -554,3 +556,5 @@ target_link_libraries(metal_utils_test PRIVATE
set_target_properties(metal_utils_test PROPERTIES FOLDER Tests)

endif()

endif(FILAMENT_TESTS)
2 changes: 2 additions & 0 deletions libs/bluegl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ endif()
install(TARGETS ${TARGET} ARCHIVE DESTINATION lib/${DIST_DIR})

# Build the tests...
if(FILAMENT_TESTS)
add_executable(test_${TARGET}
tests/OpenGLSupport.cpp
tests/OpenGLSupport.hpp
Expand All @@ -74,3 +75,4 @@ endif()
target_link_libraries(test_${TARGET} LINK_PUBLIC ${TARGET})
target_link_libraries(test_${TARGET} LINK_PUBLIC gtest)
set_target_properties(test_${TARGET} PROPERTIES FOLDER Tests)
endif()
2 changes: 1 addition & 1 deletion libs/bluevk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR})
set_target_properties(${TARGET} PROPERTIES FOLDER Libs)

# test_bluevk is not supported on mobile or Windows
if (NOT ANDROID AND NOT IOS AND NOT WIN32 AND NOT FILAMENT_SKIP_SDL2)
if(FILAMENT_TESTS AND NOT ANDROID AND NOT IOS AND NOT WIN32 AND NOT FILAMENT_SKIP_SDL2)
add_executable(test_bluevk tests/test_bluevk_sdl.cpp)
target_link_libraries(test_bluevk PRIVATE dl bluevk sdl2)
endif()
Expand Down
2 changes: 1 addition & 1 deletion libs/camutils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ install(DIRECTORY ${PUBLIC_HDR_DIR}/camutils DESTINATION include)
# ==================================================================================================
# Tests
# ==================================================================================================
if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
if(FILAMENT_TESTS AND NOT ANDROID AND NOT WEBGL AND NOT IOS)
add_executable(test_${TARGET} tests/test_camutils.cpp)
target_link_libraries(test_${TARGET} PRIVATE camutils gtest)
set_target_properties(test_${TARGET} PROPERTIES FOLDER Tests)
Expand Down
3 changes: 2 additions & 1 deletion libs/filamat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ install(DIRECTORY ${PUBLIC_HDR_DIR}/filamat DESTINATION include)
# ==================================================================================================
# Tests
# ==================================================================================================
if(FILAMENT_TESTS)
project(test_filamat)
set(TARGET test_filamat)
set(SRCS
Expand All @@ -159,4 +160,4 @@ target_include_directories(${TARGET} PRIVATE src)
target_link_libraries(${TARGET} filamat gtest)

set_target_properties(${TARGET} PROPERTIES FOLDER Tests)

endif()
2 changes: 1 addition & 1 deletion libs/filameshio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ install(FILES ${DIST_HDRS} DESTINATION include/${TARGET})
# ==================================================================================================
# Tests
# ==================================================================================================
if (NOT IOS AND NOT WEBGL AND NOT ANDROID)
if(FILAMENT_TESTS AND NOT IOS AND NOT WEBGL AND NOT ANDROID)
add_executable(test_${TARGET} tests/test_filamesh.cpp )
target_link_libraries(test_${TARGET} PRIVATE filameshio gtest)
set_target_properties(test_${TARGET} PROPERTIES FOLDER Tests)
Expand Down
2 changes: 1 addition & 1 deletion libs/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ install(FILES "${GEOMETRY_COMBINED_OUTPUT}" DESTINATION lib/${DIST_DIR} RENAME $
# ==================================================================================================
# Tests
# ==================================================================================================
if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
if(FILAMENT_TESTS AND NOT ANDROID AND NOT WEBGL AND NOT IOS)
set(TARGET test_transcoder)
add_executable(${TARGET} tests/test_transcoder.cpp)
target_link_libraries(${TARGET} PRIVATE geometry gtest)
Expand Down
2 changes: 2 additions & 0 deletions libs/gltfio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ endif()
# Tests
# ==================================================================================================

if(FILAMENT_TESTS)
set(GLTF_TEST_FILES)
function(add_test_gltf SOURCE TARGET)
set(source_path "${ROOT_DIR}/${SOURCE}")
Expand Down Expand Up @@ -259,6 +260,7 @@ if (TNT_DEV AND NOT WEBGL AND NOT ANDROID AND NOT IOS)
endif()
set_target_properties(${TEST_TARGET} PROPERTIES FOLDER Tests)
endif()
endif()

# ==================================================================================================
# Installation
Expand Down
2 changes: 1 addition & 1 deletion libs/image/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ install(DIRECTORY ${PUBLIC_HDR_DIR}/image DESTINATION include)
# ==================================================================================================
# Tests
# ==================================================================================================
if (NOT ANDROID AND NOT WEBGL AND NOT IOS AND NOT FILAMENT_SKIP_SDL2)
if(FILAMENT_TESTS AND NOT ANDROID AND NOT WEBGL AND NOT IOS AND NOT FILAMENT_SKIP_SDL2)
add_executable(test_${TARGET} tests/test_image.cpp)
target_link_libraries(test_${TARGET} PRIVATE imageio gtest)
set_target_properties(test_${TARGET} PROPERTIES FOLDER Tests)
Expand Down
2 changes: 1 addition & 1 deletion libs/ktxreader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ endfunction()
add_testfile(color_grid_uastc_zstd.ktx2)
add_testfile(lightroom_ibl.ktx)

if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
if(FILAMENT_TESTS AND NOT ANDROID AND NOT WEBGL AND NOT IOS)
add_executable(test_ktxreader tests/test_ktxreader.cpp ${TESTFILES})
target_link_libraries(test_ktxreader PRIVATE ${TARGET} gtest)
set_target_properties(test_ktxreader PROPERTIES FOLDER Tests)
Expand Down
5 changes: 4 additions & 1 deletion libs/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ install(DIRECTORY ${PUBLIC_HDR_DIR}/math DESTINATION include)
# ==================================================================================================
# Tests
# ==================================================================================================
if(FILAMENT_TESTS)
add_executable(test_${TARGET}
tests/test_fast.cpp
tests/test_half.cpp
Expand All @@ -61,11 +62,12 @@ add_executable(test_${TARGET}
)
target_link_libraries(test_${TARGET} PRIVATE math gtest)
set_target_properties(test_${TARGET} PROPERTIES FOLDER Tests)
endif()

# ==================================================================================================
# Benchmarks
# ==================================================================================================

if(FILAMENT_BENCHMARKS)
set(BENCHMARK_SRCS
benchmarks/benchmark_fast.cpp include/math/mathfwd.h)

Expand All @@ -76,3 +78,4 @@ target_compile_options(benchmark_${TARGET} PRIVATE ${OPTIMIZATION_FLAGS})
target_link_libraries(benchmark_${TARGET} PRIVATE benchmark_main utils math)

set_target_properties(benchmark_${TARGET} PROPERTIES FOLDER Benchmarks)
endif()
5 changes: 3 additions & 2 deletions libs/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ if (WEBGL_PTHREADS)
endif()

# The Path tests are platform-specific
if(FILAMENT_TESTS)
if (NOT WEBGL)
if (WIN32)
list(APPEND TEST_SRCS test/test_WinPath.cpp)
Expand All @@ -185,12 +186,12 @@ add_executable(test_${TARGET} ${TEST_SRCS})

target_link_libraries(test_${TARGET} PRIVATE gtest utils tsl math)
set_target_properties(test_${TARGET} PROPERTIES FOLDER Tests)
endif()

# ==================================================================================================
# Benchmarks
# ==================================================================================================

if (NOT WEBGL)
if(FILAMENT_BENCHMARKS AND NOT WEBGL)

add_library(benchmark_${TARGET}_callee SHARED benchmark/benchmark_callee.cpp)
set_target_properties(benchmark_${TARGET}_callee PROPERTIES FOLDER Benchmarks)
Expand Down
2 changes: 1 addition & 1 deletion libs/viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ install(DIRECTORY ${PUBLIC_HDR_DIR}/viewer DESTINATION include)
# ==================================================================================================
# Tests
# ==================================================================================================
if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
if(FILAMENT_TESTS AND NOT ANDROID AND NOT WEBGL AND NOT IOS)
add_executable(test_settings tests/test_settings.cpp)
target_link_libraries(test_settings PRIVATE ${TARGET} gtest)
set_target_properties(test_settings PROPERTIES FOLDER Tests)
Expand Down
2 changes: 1 addition & 1 deletion tools/cmgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
# ==================================================================================================
# Tests
# ==================================================================================================
if (NOT ANDROID)
if(FILAMENT_TESTS AND NOT ANDROID)
add_executable(test_${TARGET} tests/test_cmgen.cpp)
target_link_libraries(test_${TARGET} PRIVATE imageio gtest)
set_target_properties(test_${TARGET} PROPERTIES FOLDER Tests)
Expand Down
2 changes: 1 addition & 1 deletion tools/glslminifier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
# ==================================================================================================
# Tests
# ==================================================================================================
if (NOT ANDROID)
if(FILAMENT_TESTS AND NOT ANDROID)
add_executable(test_${TARGET}
src/GlslMinify.cpp
tests/test_glslminifier.cpp
Expand Down
2 changes: 2 additions & 0 deletions tools/matc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ install(TARGETS ${TARGET} RUNTIME DESTINATION bin)
# ==================================================================================================
# Tests
# ==================================================================================================
if(FILAMENT_TESTS)
project(test_matc)
set(TARGET test_matc)
set(SRCS
Expand All @@ -96,3 +97,4 @@ add_executable(${TARGET} ${SRCS})
target_link_libraries(${TARGET} matlang gtest)

set_target_properties(test_matc PROPERTIES FOLDER Tests)
endif()