-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (61 loc) · 2.29 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
69
70
71
72
73
74
75
76
cmake_minimum_required(VERSION 3.14)
project(shotscope)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(PROJECT_SRC_DIR ${PROJECT_SOURCE_DIR}/src)
set(PROJECT_TEST_DIR ${PROJECT_SOURCE_DIR}/test)
include_directories(${PROJECT_INCLUDE_DIR})
set(SOURCES
${PROJECT_SRC_DIR}/math_utils.cpp
${PROJECT_SRC_DIR}/GolfBallPhysicsVariables.cpp
${PROJECT_SRC_DIR}/Simulator.cpp
${PROJECT_SRC_DIR}/GolfBallFlight.cpp
)
set(HEADERS
${PROJECT_INCLUDE_DIR}/libshotscope.hpp
${PROJECT_INCLUDE_DIR}/math_constants.hpp
${PROJECT_INCLUDE_DIR}/golf_ball.hpp
${PROJECT_INCLUDE_DIR}/math_utils.hpp
${PROJECT_INCLUDE_DIR}/GolfBallPhysicsVariables.hpp
${PROJECT_INCLUDE_DIR}/atmosphere.hpp
${PROJECT_INCLUDE_DIR}/GolfBallFlight.hpp
${PROJECT_INCLUDE_DIR}/Simulator.hpp
)
# Create the static library
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
# Set compilation flags
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
# Include Google Test
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# Enable testing
enable_testing()
# Specify the test source files
set(TEST_SOURCES
${PROJECT_TEST_DIR}/test_ball_physics_vars.cpp
${PROJECT_TEST_DIR}/test_simulation.cpp
${PROJECT_TEST_DIR}/test_math_utils.cpp
${PROJECT_TEST_DIR}/test_ball_flight.cpp
${PROJECT_SRC_DIR}/GolfBallPhysicsVariables.cpp
${PROJECT_SRC_DIR}/math_utils.cpp
)
# Add test executable and link with gtest_main and the static library
add_executable(libshotscope_tests ${TEST_SOURCES})
target_link_libraries(libshotscope_tests ${PROJECT_NAME} GTest::gtest_main)
# Eamples
add_executable(calculate_ball_landing examples/calculate_ball_landing.cpp)
target_link_libraries(calculate_ball_landing ${PROJECT_NAME})
add_executable(calculate_ball_trajectory examples/calculate_ball_trajectory.cpp)
target_link_libraries(calculate_ball_trajectory ${PROJECT_NAME})
# Discover tests
include(GoogleTest)
gtest_discover_tests(libshotscope_tests)
install(TARGETS shotscope DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)