mirror of
				https://gitlab.alpinelinux.org/alpine/aports.git
				synced 2025-10-31 00:12:05 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			72 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From: =?utf-8?q?Timo_R=C3=B6hling?= <timo.roehling@fkie.fraunhofer.de>
 | |
| Date: Tue, 31 Mar 2020 17:42:23 +0200
 | |
| Subject: Integrate unit tests into CMake build
 | |
| 
 | |
| Forwarded: not-needed
 | |
| ---
 | |
|  CMakeLists.txt       | 4 ++++
 | |
|  tests/CMakeLists.txt | 9 +++++++++
 | |
|  tests/tester.cc      | 4 ++--
 | |
|  3 files changed, 15 insertions(+), 2 deletions(-)
 | |
|  create mode 100644 tests/CMakeLists.txt
 | |
| 
 | |
| diff --git a/CMakeLists.txt b/CMakeLists.txt
 | |
| index ed6d0f7..23b5d82 100644
 | |
| --- a/CMakeLists.txt
 | |
| +++ b/CMakeLists.txt
 | |
| @@ -4,6 +4,7 @@ project(TinyGLTF VERSION ${TINYGLTF_VERSION} LANGUAGES CXX)
 | |
|  
 | |
|  include(GNUInstallDirs)
 | |
|  include(CMakePackageConfigHelpers)
 | |
| +include(CTest)
 | |
|  
 | |
|  find_package(nlohmann_json 3 REQUIRED)
 | |
|  find_package(Catch2 REQUIRED)
 | |
| @@ -76,3 +77,6 @@ install(FILES
 | |
|  	${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
 | |
|  	DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
 | |
|  )
 | |
| +
 | |
| +add_subdirectory(tests)
 | |
| +
 | |
| diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
 | |
| new file mode 100644
 | |
| index 0000000..80148fc
 | |
| --- /dev/null
 | |
| +++ b/tests/CMakeLists.txt
 | |
| @@ -0,0 +1,14 @@
 | |
| +if(BUILD_TESTING)
 | |
| +	add_executable(tester tester.cc)
 | |
| +	target_link_libraries(tester PRIVATE 
 | |
| +		${stb_LIBRARY}
 | |
| +		Catch2::Catch2 
 | |
| +		nlohmann_json::nlohmann_json
 | |
| +	)
 | |
| +	add_test(NAME tester COMMAND tester WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
 | |
| +	target_include_directories(tester PRIVATE
 | |
| +		${CMAKE_SOURCE_DIR}
 | |
| +		${stb_INCLUDE_DIRS}
 | |
| +	)
 | |
| +endif()
 | |
| +
 | |
| diff --git a/tests/tester.cc b/tests/tester.cc
 | |
| index 081d407..a598455 100644
 | |
| --- a/tests/tester.cc
 | |
| +++ b/tests/tester.cc
 | |
| @@ -1,13 +1,13 @@
 | |
|  #define TINYGLTF_IMPLEMENTATION
 | |
|  #define STB_IMAGE_IMPLEMENTATION
 | |
|  #define STB_IMAGE_WRITE_IMPLEMENTATION
 | |
| -#include "tiny_gltf.h"
 | |
| +#include <tiny_gltf.h>
 | |
|  
 | |
|  // Nlohmann json(include ../json.hpp)
 | |
|  #include <nlohmann/json.hpp>
 | |
|  
 | |
|  #define CATCH_CONFIG_MAIN  // This tells Catch to provide a main() - only do this in one cpp file
 | |
| -#include "catch.hpp"
 | |
| +#include <catch2/catch.hpp>
 | |
|  
 | |
|  #include <cstdio>
 | |
|  #include <cstdlib>
 |