Commit df1e1286 authored by Richard Torenvliet's avatar Richard Torenvliet

Add Testing framework as a submodule and test folder with example, closes #1

parent a3deb18d
# Ignore the user-specific initial_cache file
initial_cache.cmake
targets/*
install/*
build/*
3rdparty/*
examples/data/*.mtl
examples/data/*.obj
.idea/*
cmake-build-debug/*
......@@ -13,3 +13,6 @@
[submodule "3rdparty/mexplus"]
path = 3rdparty/mexplus
url = https://github.com/kyamagu/mexplus.git
[submodule "3rdparty/Catch"]
path = 3rdparty/Catch
url = https://github.com/philsquared/Catch.git
......@@ -64,6 +64,8 @@ option(GENERATE_PYTHON_BINDINGS "Build python bindings. Requires python to be in
message(STATUS "GENERATE_PYTHON_BINDINGS: ${GENERATE_PYTHON_BINDINGS}")
option(GENERATE_MATLAB_BINDINGS "Build Matlab bindings. Requires Matlab with the compiler installed or the Matlab Compiler Runtime." OFF)
message(STATUS "GENERATE_MATLAB_BINDINGS: ${GENERATE_MATLAB_BINDINGS}")
option(BUILD_TESTS "Build tests for this library." ON)
message(STATUS "BUILD_TESTS: ${BUILD_TESTS}")
# Build a CPack driven installer package:
......@@ -75,7 +77,7 @@ set(CPACK_PACKAGE_VERSION_PATCH "${eos_VERSION_PATCH}")
include(CPack)
# Find dependencies:
find_package(OpenCV 2.4.3 REQUIRED core)
find_package(OpenCV REQUIRED core)
message(STATUS "OpenCV include dir found at ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV lib dir found at ${OpenCV_LIB_DIR}")
......@@ -168,6 +170,10 @@ install(FILES ${CMAKE_SOURCE_DIR}/3rdparty/nanoflann/COPYING DESTINATION 3rdpart
install(DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty/eigen3-nnls/src/ DESTINATION 3rdparty/eigen3-nnls/src) # eigen3-nnls header
install(FILES ${CMAKE_SOURCE_DIR}/3rdparty/eigen3-nnls/README.md DESTINATION 3rdparty/eigen3-nnls/) # eigen3-nnls attribution
if(BUILD_TESTS)
add_subdirectory(tests)
endif()
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
......
project(tests)
cmake_minimum_required(VERSION 2.8.10)
# The examples need a few additional dependencies (e.g. boost filesystem and OpenCV highgui):
#check installed version in order to include the correct OpenCV libraries
#version variable is defined from project root's CMakeLists
if("${OpenCV_VERSION_MAJOR}$" EQUAL 2)
message(STATUS "OpenCV 2.x detected")
find_package(OpenCV 2.4.3 REQUIRED core imgproc highgui)
elseif("${OpenCV_VERSION_MAJOR}$" EQUAL 3)
message(STATUS "OpenCV 3.x detected - including imgcodecs for compatibility")
find_package(OpenCV 3.0.0 REQUIRED core imgproc imgcodecs)
endif()
message(STATUS "OpenCV include dir found at ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV lib dir found at ${OpenCV_LIB_DIR}")
# This allows us to compile in RelWithDebInfo. It'll use the Release-version of OpenCV:
set_target_properties(${OpenCV_LIBS} PROPERTIES MAP_IMPORTED_CONFIG_RELWITHDEBINFO RELEASE)
if(MSVC)
# The standard find_package for boost on Win finds the dynamic libs, so for dynamic linking to boost we need to #define:
add_definitions(-DBOOST_ALL_NO_LIB) # Don't use the automatic library linking by boost with VS (#pragma ...). Instead, we specify everything here in cmake.
add_definitions(-DBOOST_ALL_DYN_LINK) # Link against the dynamic boost lib - needs to match with the version that find_package finds.
endif()
find_package(Boost 1.50.0 COMPONENTS system filesystem program_options REQUIRED)
if(Boost_FOUND)
message(STATUS "Boost found at ${Boost_INCLUDE_DIRS}")
else(Boost_FOUND)
message(FATAL_ERROR "Boost not found")
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()
# Includes Catch in the project:
enable_testing(true) # Enables unit-testing.
# Expose required variable (CATCH_INCLUDE_DIR) to parent scope
set(CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/Catch/include CACHE INTERNAL "Path to include folder for Catch")
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
add_executable (fitting-test fitting/fitting_test.cpp)
target_link_libraries(fitting-test Catch ${OPENCV_LIBS} ${BOOST_LIBRARIES})
add_test (NAME fitting-test COMMAND fitting-test)
install(TARGETS fitting-test DESTINATION tests)
# Simple model fitting (orthographic camera & shape to landmarks) example:
#add_executable(fit-model-simple fit-model-simple.cpp)
#add_executable(fitting-tests )
#target_link_libraries(fit-model-simple ${OpenCV_LIBS} ${Boost_LIBRARIES})
# install target:
#install(TARGETS fit-model-simple DESTINATION bin)
#install(DIRECTORY ${CMAKE_SOURCE_DIR}/examples/data DESTINATION bin)
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
TEST_CASE("stupid/1=1", "Prove that one equals two" ){
int one = 1;
REQUIRE( one == 1 );
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment