-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (59 loc) · 2.92 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
cmake_minimum_required(VERSION 3.12)
#-------------------------------------------------------------------------------------------
# I'm going to use vcpk in most cases for our install of 3rd party libs
# this is going to check the environment variable for CMAKE_TOOLCHAIN_FILE and this must point to where
# vcpkg.cmake is in the University this is set in your .bash_profile to
# export CMAKE_TOOLCHAIN_FILE=/public/devel/2020/vcpkg/scripts/buildsystems/vcpkg.cmake
# to build see the NGL instructions
# Windows :- mkdir build; cd build ; cmake -DCMAKE_PREFIX_PATH=~/NGL/ .. ; cmake --build .
# Linux / Mac mkdir build; cd build; cmake -DCMAKE_PREFIX_PATH~/NGL/ .. ; make
#-------------------------------------------------------------------------------------------
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{CMAKE_TOOLCHAIN_FILE})
set(CMAKE_TOOLCHAIN_FILE $ENV{CMAKE_TOOLCHAIN_FILE})
endif()
# Name of the project
project(RBDBuild)
# This is the name of the Exe change this and it will change everywhere
set(TargetName RBD)
# This will include the file NGLConfig.cmake, you need to add the location to this either using
# -DCMAKE_PREFIX_PATH=~/NGL or as a system environment variable.
find_package(NGL CONFIG REQUIRED)
# Instruct CMake to run moc automatically when needed (Qt projects only)
set(CMAKE_AUTOMOC ON)
# find Qt libs
find_package(Qt5Widgets)
# use C++ 17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOUIC_SEARCH_PATHS ${PROJECT_SOURCE_DIR}/ui)
# Set the name of the executable we want to build
add_executable(${TargetName})
# Add NGL include path
include_directories(include $ENV{HOME}/NGL/include)
target_sources(${TargetName} PRIVATE ${PROJECT_SOURCE_DIR}/src/main.cpp
${PROJECT_SOURCE_DIR}/src/NGLScene.cpp
${PROJECT_SOURCE_DIR}/src/NGLSceneMouseControls.cpp
${PROJECT_SOURCE_DIR}/src/Ball.cpp
${PROJECT_SOURCE_DIR}/src/MainWindow.cpp
${PROJECT_SOURCE_DIR}/include/NGLScene.h
${PROJECT_SOURCE_DIR}/include/Ball.h
${PROJECT_SOURCE_DIR}/include/Container.h
${PROJECT_SOURCE_DIR}/include/Pile.h
${PROJECT_SOURCE_DIR}/include/MainWindow.h
${PROJECT_SOURCE_DIR}/ui/MainWindow.ui
)
target_link_libraries(${TargetName} PRIVATE NGL Qt5::Widgets)
find_package(GTest CONFIG REQUIRED)
include(GoogleTest)
enable_testing()
add_executable(RBDTests)
target_sources(RBDTests PRIVATE tests/RBDTests.cpp src/Ball.cpp include/Ball.h include/Container.h include/Pile.h)
target_link_libraries(RBDTests PRIVATE GTest::gtest GTest::gtest_main )
gtest_discover_tests(RBDTests)
add_custom_target(${TargetName}CopyShaders ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/shaders
$<TARGET_FILE_DIR:${TargetName}>/shaders
)