CMake: Remove mention of extern_redcode, it was removed
[blender.git] / build_files / cmake / Modules / GTestTesting.cmake
1 #=============================================================================
2 # Copyright 2014 Blender Foundation.
3 #
4 # Distributed under the OSI-approved BSD License (the "License");
5 # see accompanying file Copyright.txt for details.
6 #
7 # This software is distributed WITHOUT ANY WARRANTY; without even the
8 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 # See the License for more information.
10 #
11 # Inspired on the Testing.cmake from Libmv
12 #
13 #=============================================================================
14
15 macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST)
16         if(WITH_GTESTS)
17                 get_property(_current_include_directories
18                              DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
19                              PROPERTY INCLUDE_DIRECTORIES)
20                 set(TEST_INC
21                         ${_current_include_directories}
22                         ${CMAKE_SOURCE_DIR}/tests/gtests
23                         ${CMAKE_SOURCE_DIR}/extern/glog/src
24                         ${CMAKE_SOURCE_DIR}/extern/gflags/src
25                         ${CMAKE_SOURCE_DIR}/extern/gtest/include
26                 )
27                 unset(_current_include_directories)
28
29                 add_executable(${NAME}_test ${SRC})
30                 target_link_libraries(${NAME}_test
31                                       ${EXTRA_LIBS}
32                                       bf_testing_main
33                                       bf_intern_guardedalloc
34                                       extern_gtest
35                                       # needed for glog
36                                       ${PTHREADS_LIBRARIES}
37                                       extern_glog
38                                       extern_gflags)
39                 set_target_properties(${NAME}_test PROPERTIES
40                                       RUNTIME_OUTPUT_DIRECTORY         "${TESTS_OUTPUT_DIR}"
41                                       RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}"
42                                       RUNTIME_OUTPUT_DIRECTORY_DEBUG   "${TESTS_OUTPUT_DIR}"
43                                       INCLUDE_DIRECTORIES              "${TEST_INC}")
44                 if(${DO_ADD_TEST})
45                         add_test(${NAME}_test ${TESTS_OUTPUT_DIR}/${NAME}_test)
46                 endif()
47         endif()
48 endmacro()
49
50 macro(BLENDER_SRC_GTEST NAME SRC EXTRA_LIBS)
51         BLENDER_SRC_GTEST_EX("${NAME}" "${SRC}" "${EXTRA_LIBS}" "TRUE")
52 endmacro()
53
54 macro(BLENDER_TEST NAME EXTRA_LIBS)
55         BLENDER_SRC_GTEST_EX("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}" "TRUE")
56 endmacro()
57
58 macro(BLENDER_TEST_PERFORMANCE NAME EXTRA_LIBS)
59         BLENDER_SRC_GTEST_EX("${NAME}" "${NAME}_test.cc" "${EXTRA_LIBS}" "FALSE")
60 endmacro()