2013-01-28 15:48:04 +00:00
|
|
|
# OpenClonk, http://www.openclonk.org
|
|
|
|
#
|
2015-02-07 16:33:51 +00:00
|
|
|
# Copyright (c) 2013-2015, The OpenClonk Team and contributors
|
2013-01-28 15:48:04 +00:00
|
|
|
#
|
2015-02-07 14:55:05 +00:00
|
|
|
# Distributed under the terms of the ISC license; see accompanying file
|
|
|
|
# "COPYING" for details.
|
2013-01-28 15:48:04 +00:00
|
|
|
#
|
2015-02-07 14:55:05 +00:00
|
|
|
# "Clonk" is a registered trademark of Matthes Bender, used with permission.
|
|
|
|
# See accompanying file "TRADEMARK" for details.
|
2013-01-28 15:48:04 +00:00
|
|
|
#
|
2015-02-07 14:55:05 +00:00
|
|
|
# To redistribute this file separately, substitute the full license texts
|
|
|
|
# for the above references.
|
2013-01-28 15:48:04 +00:00
|
|
|
|
|
|
|
# used by c4script and by the unit tests
|
|
|
|
set(C4SCRIPT_SOURCES
|
|
|
|
../include/c4script/c4script.h
|
|
|
|
../src/C4Include.cpp
|
|
|
|
../src/script/C4ScriptStandalone.cpp
|
2015-12-07 17:36:36 +00:00
|
|
|
../src/script/C4ScriptStandaloneStubs.cpp
|
2013-01-28 15:48:04 +00:00
|
|
|
)
|
|
|
|
|
2015-02-08 14:01:32 +00:00
|
|
|
# Look for GTest and GMock
|
|
|
|
# GMock's source package ships GTest too, so look for it first
|
|
|
|
find_path(GMOCK_ROOT
|
2017-02-17 19:21:47 +00:00
|
|
|
NAMES "gmock-all.cc" "src/gmock-all.cc" "gmock/gmock-all.cc"
|
2015-02-08 14:01:32 +00:00
|
|
|
PATHS "/usr/src/gmock"
|
|
|
|
)
|
|
|
|
find_path(GMOCK_INCLUDE_DIR
|
|
|
|
NAMES "gmock/gmock.h"
|
|
|
|
HINTS "${GMOCK_ROOT}"
|
|
|
|
PATH_SUFFIXES "include"
|
|
|
|
)
|
|
|
|
find_file(GMOCK_SOURCE_ALL
|
|
|
|
NAMES "gmock-all.cc"
|
|
|
|
HINTS "${GMOCK_ROOT}"
|
|
|
|
PATH_SUFFIXES "src" "gtest"
|
|
|
|
NO_DEFAULT_PATH
|
|
|
|
)
|
|
|
|
|
2015-02-07 16:33:51 +00:00
|
|
|
find_path(GTEST_ROOT
|
2015-02-08 14:01:32 +00:00
|
|
|
NAMES "src/gtest-all.cc" "gtest/gtest-all.cc"
|
|
|
|
PATHS "${GMOCK_ROOT}" "/usr/src/gtest"
|
2015-02-07 16:33:51 +00:00
|
|
|
)
|
|
|
|
find_path(GTEST_INCLUDE_DIR
|
2015-02-08 14:01:32 +00:00
|
|
|
NAMES "gtest/gtest.h"
|
2015-02-07 16:33:51 +00:00
|
|
|
HINTS "${GTEST_ROOT}"
|
|
|
|
PATH_SUFFIXES "include"
|
|
|
|
)
|
|
|
|
find_file(GTEST_SOURCE_ALL
|
2015-02-08 14:01:32 +00:00
|
|
|
NAMES "gtest-all.cc"
|
2015-02-07 16:33:51 +00:00
|
|
|
HINTS "${GTEST_ROOT}"
|
2015-02-08 14:01:32 +00:00
|
|
|
PATH_SUFFIXES "src" "gtest"
|
2015-02-07 16:33:51 +00:00
|
|
|
NO_DEFAULT_PATH
|
|
|
|
)
|
2013-01-29 12:50:40 +00:00
|
|
|
|
2015-02-08 14:01:32 +00:00
|
|
|
if (GMOCK_SOURCE_ALL AND GMOCK_INCLUDE_DIR)
|
|
|
|
add_library(gmock STATIC
|
|
|
|
"${GMOCK_SOURCE_ALL}"
|
|
|
|
"${GMOCK_INCLUDE_DIR}/gmock/gmock.h"
|
|
|
|
)
|
2015-12-30 12:48:54 +00:00
|
|
|
set_property(TARGET gmock PROPERTY FOLDER "Third-party libraries")
|
2015-02-08 14:01:32 +00:00
|
|
|
if (GMOCK_ROOT)
|
|
|
|
include_directories("${GMOCK_ROOT}")
|
|
|
|
endif()
|
|
|
|
include_directories("${GMOCK_INCLUDE_DIR}")
|
|
|
|
set(GMOCK_FOUND 1)
|
|
|
|
endif()
|
|
|
|
|
2015-02-07 16:33:51 +00:00
|
|
|
if (GTEST_SOURCE_ALL AND GTEST_INCLUDE_DIR)
|
|
|
|
add_library(gtest STATIC
|
|
|
|
"${GTEST_SOURCE_ALL}"
|
|
|
|
"${GTEST_INCLUDE_DIR}/gtest/gtest.h"
|
|
|
|
)
|
2015-12-30 12:48:54 +00:00
|
|
|
set_property(TARGET gtest PROPERTY FOLDER "Third-party libraries")
|
2015-02-07 16:33:51 +00:00
|
|
|
if (GTEST_ROOT)
|
|
|
|
include_directories("${GTEST_ROOT}")
|
2015-12-13 13:33:02 +00:00
|
|
|
endif()
|
|
|
|
if(HAVE_PTHREAD)
|
|
|
|
target_link_libraries(gtest pthread)
|
2015-02-07 16:33:51 +00:00
|
|
|
endif()
|
|
|
|
include_directories("${GTEST_INCLUDE_DIR}")
|
|
|
|
set(GTEST_FOUND 1)
|
|
|
|
endif()
|
2013-01-28 15:48:04 +00:00
|
|
|
|
2015-02-08 14:01:32 +00:00
|
|
|
include(CMakeParseArguments)
|
|
|
|
function(create_test testName)
|
|
|
|
set(oneValueArgs "")
|
|
|
|
set(multiValueArgs SOURCES LIBRARIES)
|
|
|
|
CMAKE_PARSE_ARGUMENTS(CT "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
2016-01-23 02:17:06 +00:00
|
|
|
add_executable("${testName}" EXCLUDE_FROM_ALL
|
|
|
|
${CT_SOURCES}
|
|
|
|
TestLog.cpp
|
|
|
|
TestLog.h
|
|
|
|
main.cpp
|
|
|
|
)
|
|
|
|
target_include_directories("${testName}" PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
|
2015-12-30 12:48:54 +00:00
|
|
|
set_property(TARGET "${testName}" PROPERTY FOLDER "Testing")
|
2016-01-23 02:17:06 +00:00
|
|
|
target_link_libraries("${testName}" gtest gmock ${CT_LIBRARIES})
|
2015-02-08 14:01:32 +00:00
|
|
|
add_test(NAME "${testName}" COMMAND "${testName}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if (GTEST_FOUND AND GMOCK_FOUND)
|
|
|
|
enable_testing()
|
|
|
|
|
2015-03-01 18:43:50 +00:00
|
|
|
create_test(StdMeshMath
|
|
|
|
SOURCES
|
|
|
|
"../src/lib/StdMeshMath.cpp"
|
|
|
|
"../src/lib/StdMeshMath.h"
|
|
|
|
"math/StdMeshVectorTest.cpp"
|
2015-03-02 22:18:32 +00:00
|
|
|
"math/StdMeshQuaternionTest.cpp"
|
2015-03-01 18:43:50 +00:00
|
|
|
)
|
|
|
|
|
2015-02-07 16:33:51 +00:00
|
|
|
AUX_SOURCE_DIRECTORY("${CMAKE_CURRENT_LIST_DIR}" TESTS_SOURCES)
|
2015-12-30 12:48:54 +00:00
|
|
|
add_executable(tests EXCLUDE_FROM_ALL ${TESTS_SOURCES} ${C4SCRIPT_SOURCES})
|
|
|
|
set_property(TARGET "tests" PROPERTY FOLDER "Testing")
|
2019-02-02 22:52:02 +00:00
|
|
|
target_link_libraries(tests gtest gmock libc4script libmisc)
|
2013-01-29 12:50:40 +00:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
target_link_libraries(tests rt)
|
|
|
|
endif()
|
2015-02-08 11:45:02 +00:00
|
|
|
if(WIN32)
|
|
|
|
target_link_libraries(tests winmm)
|
|
|
|
endif()
|
2015-12-07 17:35:54 +00:00
|
|
|
|
|
|
|
create_test(aul_test
|
|
|
|
SOURCES
|
2016-01-22 23:12:45 +00:00
|
|
|
aul/AulTest.cpp
|
|
|
|
aul/AulTest.h
|
|
|
|
aul/AulMathTest.cpp
|
2016-01-22 23:32:41 +00:00
|
|
|
aul/AulPredefinedFunctionTest.cpp
|
2016-06-05 11:36:32 +00:00
|
|
|
aul/AulDeathTest.cpp
|
2017-02-15 10:53:38 +00:00
|
|
|
aul/AulDiagnosticsTest.cpp
|
2016-10-20 15:20:55 +00:00
|
|
|
aul/AulSyntaxTest.cpp
|
|
|
|
aul/AulSyntaxTestDetail.h
|
2016-07-25 12:57:54 +00:00
|
|
|
aul/ErrorHandler.h
|
2015-12-07 17:35:54 +00:00
|
|
|
../src/script/C4ScriptStandaloneStubs.cpp
|
2015-12-19 23:30:52 +00:00
|
|
|
../src/script/C4ScriptStandalone.cpp
|
2015-12-07 17:35:54 +00:00
|
|
|
LIBRARIES
|
|
|
|
libmisc
|
|
|
|
libc4script)
|
2013-01-29 12:50:40 +00:00
|
|
|
else()
|
2015-02-07 16:33:51 +00:00
|
|
|
set(_gtest_missing "")
|
2013-01-29 12:50:40 +00:00
|
|
|
if (NOT GTEST_INCLUDE_DIR)
|
2015-02-07 16:33:51 +00:00
|
|
|
set(_gtest_missing "${_gtest_missing} gtest/gtest.h")
|
2013-01-29 12:50:40 +00:00
|
|
|
endif()
|
2015-02-07 16:33:51 +00:00
|
|
|
if (NOT GTEST_SOURCE_ALL)
|
|
|
|
set(_gtest_missing "${_gtest_missing} gtest-all.cc")
|
2013-01-29 12:50:40 +00:00
|
|
|
endif()
|
2015-02-08 14:01:32 +00:00
|
|
|
if (NOT GMOCK_INCLUDE_DIR)
|
|
|
|
set(_gtest_missing "${_gtest_missing} gmock/gmock.h")
|
|
|
|
endif()
|
|
|
|
if (NOT GMOCK_SOURCE_ALL)
|
|
|
|
set(_gtest_missing "${_gtest_missing} gmock-all.cc")
|
|
|
|
endif()
|
|
|
|
message(STATUS "Could NOT find GTest/GMock (missing:${_gtest_missing})")
|
2013-01-28 15:48:04 +00:00
|
|
|
endif()
|