2014-06-18 22:49:17 +10:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2014 Blender Foundation.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#
|
|
|
|
# Inspired on the Testing.cmake from Libmv
|
|
|
|
#
|
|
|
|
#=============================================================================
|
|
|
|
|
2015-06-29 18:15:02 +02:00
|
|
|
macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
|
2019-04-17 06:35:54 +02:00
|
|
|
if(WITH_GTESTS)
|
2019-08-28 16:32:52 +02:00
|
|
|
set(TARGET_NAME ${NAME}_test)
|
2019-04-17 06:35:54 +02:00
|
|
|
get_property(_current_include_directories
|
|
|
|
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
PROPERTY INCLUDE_DIRECTORIES)
|
|
|
|
set(TEST_INC
|
|
|
|
${_current_include_directories}
|
|
|
|
${CMAKE_SOURCE_DIR}/tests/gtests
|
2019-08-28 16:30:39 +02:00
|
|
|
)
|
|
|
|
set(TEST_INC_SYS
|
2019-04-17 06:35:54 +02:00
|
|
|
${GLOG_INCLUDE_DIRS}
|
|
|
|
${GFLAGS_INCLUDE_DIRS}
|
|
|
|
${CMAKE_SOURCE_DIR}/extern/gtest/include
|
|
|
|
${CMAKE_SOURCE_DIR}/extern/gmock/include
|
|
|
|
)
|
|
|
|
unset(_current_include_directories)
|
2014-06-18 22:49:17 +10:00
|
|
|
|
2019-08-28 16:32:52 +02:00
|
|
|
add_executable(${TARGET_NAME} ${SRC})
|
|
|
|
target_include_directories(${TARGET_NAME} PUBLIC "${TEST_INC}")
|
|
|
|
target_include_directories(${TARGET_NAME} SYSTEM PUBLIC "${TEST_INC_SYS}")
|
|
|
|
target_link_libraries(${TARGET_NAME}
|
2019-04-17 06:35:54 +02:00
|
|
|
${EXTRA_LIBS}
|
|
|
|
${PLATFORM_LINKLIBS}
|
|
|
|
bf_testing_main
|
|
|
|
bf_intern_eigen
|
|
|
|
bf_intern_guardedalloc
|
|
|
|
extern_gtest
|
|
|
|
extern_gmock
|
|
|
|
# needed for glog
|
|
|
|
${PTHREADS_LIBRARIES}
|
|
|
|
${GLOG_LIBRARIES}
|
|
|
|
${GFLAGS_LIBRARIES})
|
|
|
|
if(WITH_OPENMP_STATIC)
|
2019-08-28 16:32:52 +02:00
|
|
|
target_link_libraries(${TARGET_NAME} ${OpenMP_LIBRARIES})
|
2019-04-17 06:35:54 +02:00
|
|
|
endif()
|
2019-08-28 16:32:52 +02:00
|
|
|
set_target_properties(${TARGET_NAME} PROPERTIES
|
2019-04-17 06:35:54 +02:00
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${TESTS_OUTPUT_DIR}"
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}"
|
2019-08-28 16:30:39 +02:00
|
|
|
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${TESTS_OUTPUT_DIR}")
|
2019-04-17 06:35:54 +02:00
|
|
|
if(${DO_ADD_TEST})
|
2019-08-28 16:32:52 +02:00
|
|
|
add_test(NAME ${TARGET_NAME} COMMAND ${TESTS_OUTPUT_DIR}/${TARGET_NAME} WORKING_DIRECTORY $<TARGET_FILE_DIR:blender>)
|
2019-08-02 16:09:59 +02:00
|
|
|
|
|
|
|
# Don't fail tests on leaks since these often happen in external libraries
|
|
|
|
# that we can't fix.
|
2019-08-28 16:32:52 +02:00
|
|
|
set_tests_properties(${TARGET_NAME} PROPERTIES ENVIRONMENT LSAN_OPTIONS=exitcode=0)
|
2019-04-17 06:35:54 +02:00
|
|
|
endif()
|
2019-08-28 16:29:02 +02:00
|
|
|
unset(TEST_INC)
|
|
|
|
unset(TEST_INC_SYS)
|
2019-08-28 16:32:52 +02:00
|
|
|
unset(TARGET_NAME)
|
2019-04-17 06:35:54 +02:00
|
|
|
endif()
|
2014-06-18 22:49:17 +10:00
|
|
|
endmacro()
|
|
|
|
|
2015-06-29 18:15:02 +02:00
|
|
|
macro(BLENDER_SRC_GTEST NAME SRC EXTRA_LIBS)
|
2019-04-17 06:35:54 +02:00
|
|
|
BLENDER_SRC_GTEST_EX("${NAME}" "${SRC}" "${EXTRA_LIBS}" "TRUE")
|
2015-06-29 18:15:02 +02:00
|
|
|
endmacro()
|
|
|
|
|
2014-06-18 22:49:17 +10:00
|
|
|
macro(BLENDER_TEST NAME EXTRA_LIBS)
|
2019-04-17 06:35:54 +02:00
|
|
|
BLENDER_SRC_GTEST_EX("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}" "TRUE")
|
2015-06-29 18:15:02 +02:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(BLENDER_TEST_PERFORMANCE NAME EXTRA_LIBS)
|
2019-04-17 06:35:54 +02:00
|
|
|
BLENDER_SRC_GTEST_EX("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}" "FALSE")
|
2014-06-18 22:49:17 +10:00
|
|
|
endmacro()
|