--- /dev/null +++ tests/CMakeLists.txt @@ -0,0 +1,9 @@ +if(TINYGLTF_BUILD_TESTS) + add_executable(tester tester.cc) + set_property(TARGET tester PROPERTY CXX_STANDARD 11) + add_test(NAME tester COMMAND tester WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + target_include_directories(tester PRIVATE + ${CMAKE_SOURCE_DIR} + ${stb_INCLUDE_DIRS} + ) +endif() --- CMakeLists.txt.orig +++ CMakeLists.txt @@ -20,6 +20,7 @@ option(TINYGLTF_BUILD_BUILDER_EXAMPLE "Build glTF builder example" OFF) option(TINYGLTF_HEADER_ONLY "On: header-only mode. Off: create tinygltf library(No TINYGLTF_IMPLEMENTATION required in your project)" OFF) option(TINYGLTF_INSTALL "Install tinygltf files during install step. Usually set to OFF if you include tinygltf through add_subdirectory()" ON) +option(TINYGLTF_BUILD_TESTS "Build tests" OFF) if (TINYGLTF_BUILD_LOADER_EXAMPLE) add_executable(loader_example @@ -65,3 +66,8 @@ NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) install(FILES tiny_gltf.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +if(TINYGLTF_BUILD_TESTS) + include(CTest) + add_subdirectory(tests) +endif(TINYGLTF_BUILD_TESTS)