-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
68 lines (56 loc) · 2.08 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
67
68
cmake_minimum_required(VERSION 3.10)
project(Battleship)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "-g -O0")
# Define the paths
set(CPPUNIT_PATH /usr/local/lib)
set(BATTLESHIP_LIB_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/Battleship.Ascii.Lib)
set(GAMECONTROLLER_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/Battleship.GameController.Lib)
# Include directories
include_directories(${CPPUNIT_PATH})
include_directories(${BATTLESHIP_LIB_INCLUDE_PATH})
include_directories(${GAMECONTROLLER_INCLUDE_PATH})
# Add the executable for the main target
add_executable(Battleship
../Battleship.Ascii/Battleship.Ascii.cpp
../Battleship.Ascii.Lib/Program.cpp
../Battleship.GameController.Lib/Ship.cpp
../Battleship.GameController.Lib/Position.cpp
../Battleship.GameController.Lib/Letters.cpp
../Battleship.GameController.Lib/GameController.cpp
)
# Add the libraries
add_library(Program STATIC ../Battleship.Ascii.Lib/Program.cpp)
add_library(GameController STATIC
../Battleship.GameController.Lib/Ship.cpp
../Battleship.GameController.Lib/Position.cpp
../Battleship.GameController.Lib/Letters.cpp
../Battleship.GameController.Lib/GameController.cpp
)
# Link the libraries to the main target
target_link_libraries(Battleship Program GameController)
# Find and include Google Test
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})
# Add the executable for the tests
add_executable(TestRunner
../Battleship.GameController.Tests/CheckIsHitTests.cpp
../Battleship.GameController.Tests/IsShipValidTests.cpp
../Battleship.Ascii.Tests/ParsePositionTests.cpp
../Battleship.GameController.Tests/TestRunner.cpp
)
# Link the libraries and Google Test to the test runner
target_link_libraries(TestRunner
Program
GameController
${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
pthread
)
# Enable testing and add the test
enable_testing()
# Add the test executable to CTest
add_test(NAME AllTests COMMAND TestRunner --gtest_color=yes)
# Set the output format for CTest
set(CTEST_OUTPUT_ON_FAILURE ON)
set(CTEST_CUSTOM_TEST_OUTPUT_DIR ${CMAKE_BINARY_DIR}/test_results)