forked from JACoders/OpenJK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
66 lines (59 loc) · 2.21 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#============================================================================
# Copyright (C) 2013 - 2015, OpenJK contributors
#
# This file is part of the OpenJK source code.
#
# OpenJK is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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, see <http://www.gnu.org/licenses/>.
#============================================================================
# Make sure the user is not executing this script directly
if(NOT InOpenJK)
message(FATAL_ERROR "Use the top-level cmake script!")
endif(NOT InOpenJK)
set(TestFiles
"main.cpp"
"safe/string.cpp"
"safe/limited_vector.cpp"
"${SharedDir}/qcommon/safe/string.cpp"
)
if(MSVC)
set(TestFiles
${TestFiles}
"${SharedDir}/openjk.natvis"
)
endif()
source_group( "tests" REGULAR_EXPRESSION ".*")
source_group( "tests\\safe" REGULAR_EXPRESSION "safe/.*" )
source_group( "qcommon\\safe" REGULAR_EXPRESSION "${SharedDir}/qcommon/safe/.*" )
if(MSVC)
set( Boost_USE_STATIC_LIBS ON )
endif()
find_package( Boost COMPONENTS unit_test_framework REQUIRED )
set(TestTarget "UnitTests")
set(TestLibraries "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
set(TestIncludeDirectories
"${Boost_INCLUDE_DIRS}"
"${SharedDir}"
"${GSLIncludeDirectory}"
)
set(TestDefines "${SharedDefines}")
add_executable(${TestTarget} ${TestFiles})
set_target_properties(${TestTarget} PROPERTIES COMPILE_DEFINITIONS "${TestDefines}")
set_target_properties(${TestTarget} PROPERTIES INCLUDE_DIRECTORIES "${TestIncludeDirectories}")
set_target_properties(${TestTarget} PROPERTIES PROJECT_LABEL "Unit Tests")
target_link_libraries(${TestTarget} ${TestLibraries})
install(TARGETS ${TestTarget} DESTINATION ".")
if(NOT MSVC)
#Generate a main function
target_compile_definitions(${TestTarget} PRIVATE BOOST_TEST_DYN_LINK)
endif()
add_test(NAME unittests COMMAND ${TestTarget})