Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/tests/CMakeLists.txt
- This file was added.
| # ***** BEGIN GPL LICENSE BLOCK ***** | |||||
| # | |||||
| # This program is free software; you can redistribute it and/or | |||||
| # modify it under the terms of the GNU General Public License | |||||
| # as published by the Free Software Foundation; either version 2 | |||||
| # of the License, or (at your option) any later version. | |||||
| # | |||||
| # This program is distributed in the hope that it will be useful, | |||||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| # GNU General Public License for more details. | |||||
| # | |||||
| # You should have received a copy of the GNU General Public License | |||||
| # along with this program; if not, write to the Free Software Foundation, | |||||
| # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||||
| # | |||||
| # The Original Code is Copyright (C) 2020, Blender Foundation | |||||
| # All rights reserved. | |||||
| # ***** END GPL LICENSE BLOCK ***** | |||||
| function(includes_for_test DEST_LIST INC) | |||||
| # Pretty much all tests need these: | |||||
| set(_test_inc | |||||
| ${CMAKE_SOURCE_DIR}/extern/gflags/src | |||||
| ${CMAKE_SOURCE_DIR}/extern/gtest/include | |||||
| ${CMAKE_SOURCE_DIR}/extern/glog/include | |||||
| ${CMAKE_SOURCE_DIR}/tests/gtests | |||||
| ) | |||||
| # Paths in $INC are used by the main (as opposed to test) sources, and thus | |||||
| # are relative to the parent directory. Since tests are in a subdirectory, | |||||
| # relative paths have to be rewritten to a new base directory. | |||||
| foreach(PATH ${INC}) | |||||
| if(IS_ABSOLUTE ${PATH}) | |||||
| list(APPEND _test_inc ${PATH}) | |||||
| else() | |||||
| get_filename_component(ABS_PATH ${PATH} ABSOLUTE BASE_DIR "..") | |||||
| list(APPEND _test_inc ${ABS_PATH}) | |||||
| endif() | |||||
| endforeach() | |||||
| # ARGN contains any extra parameters after the last parameter. | |||||
| set(${DEST_LIST} "${_test_inc};${ARGN}" PARENT_SCOPE) | |||||
| endfunction() | |||||
| function(append_test_lib DEST_LIST LIB_NAME) | |||||
| # DEST_LIST contains the list name, so | |||||
| # ${DEST_LIST} is the list name, and | |||||
| # ${${DEST_LIST}} is the list itself. | |||||
| set(lib_list ${${DEST_LIST}}) | |||||
| if(WIN32) | |||||
| list(APPEND lib_list "bf_blenkernel_tests") | |||||
| elseif(CMAKE_COMPILER_IS_GNUCXX) | |||||
| list(APPEND lib_list "-Wl,--whole-archive" "bf_blenkernel_tests" "-Wl,--no-whole-archive") | |||||
| elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") | |||||
| list(APPEND lib_list "-Wl,-force_load" "bf_blenkernel_tests") | |||||
| else() | |||||
| message(FATAL_ERROR "Unknown how to link whole-archive with your compiler ${CMAKE_CXX_COMPILER_ID}") | |||||
| endif() | |||||
| set(${DEST_LIST} ${lib_list} PARENT_SCOPE) | |||||
| endfunction() | |||||
| set(TEST_SRC | |||||
| BKE_armature_test.cc | |||||
| BKE_fcurve_test.cc | |||||
| ) | |||||
| includes_for_test(TEST_INC "${INC}" | |||||
| ${CMAKE_SOURCE_DIR}/source/blender/editors/include | |||||
| ) | |||||
| remove_strict_flags() | |||||
| blender_add_lib(bf_blenkernel_tests "${TEST_SRC}" "${TEST_INC}" "${INC_SYS}" "extern_gtest") | |||||
| append_test_lib(LIB bf_blenkernel_tests) | |||||
| set(LIB ${LIB} PARENT_SCOPE) | |||||