add gtest, temp disable swig

(cherry picked from commit 4008d163d77f503e6acbd7ddc1d87ac6d479c897)
This commit is contained in:
Martina Rivizzigno 2019-10-14 17:29:35 +02:00 committed by Mathieu Bresciani
parent 9b4b24ee71
commit fcea13eef8
4 changed files with 41 additions and 12 deletions

View File

@ -90,7 +90,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(
-pedantic
-Wall
-Wextra
-Werror
@ -102,7 +102,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
# testing
include(CTest)
enable_testing()
if(BUILD_TESTING)
option(ECL_TESTS "Build ECL tests" ON)
@ -196,17 +196,17 @@ endif()
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
option(BUILD_DOXYGEN "Build doxygen documentation" OFF)
if (BUILD_DOXYGEN)
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
# note the option ALL which allows to build the docs together with the application
add_custom_target(doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
@ -216,9 +216,24 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
VERBATIM
USES_TERMINAL
)
else()
message(FATAL_ERROR "Doxygen needs to be installed to generate documentation")
endif()
endif()
endif()
enable_testing()
include_directories(${GTEST_INCLUDE_DIR})
add_subdirectory("/usr/src/gtest" ${CMAKE_BINARY_DIR}/gtest)
set(SRCS
test/main.cpp
test/test_example.cpp
)
add_executable(TestECL ${SRCS})
target_include_directories(TestECL PRIVATE ${GTEST_INCLUDE_DIRS})
target_link_libraries(TestECL gtest gtest_main)
add_test(NAME TestECL COMMAND TestECL)

View File

@ -58,10 +58,10 @@ set_target_properties(ecl_EKF PROPERTIES PUBLIC_HEADER "ekf.h")
target_compile_options(ecl_EKF PRIVATE -fno-associative-math)
if(EKF_PYTHON_TESTS)
add_subdirectory(swig)
endif()
#if(EKF_PYTHON_TESTS)
# add_subdirectory(swig)
#endif()
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
#if(BUILD_TESTING)
# add_subdirectory(tests)
#endif()

7
test/main.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <gtest/gtest.h>
int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv);
std::cout << "init test \n";
return RUN_ALL_TESTS();
}

7
test/test_example.cpp Normal file
View File

@ -0,0 +1,7 @@
#include "gtest/gtest.h"
TEST(test_example, sample_test)
{
printf("blabla \n" );
EXPECT_EQ(1, 1);
}