-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (63 loc) · 2.51 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
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(ComputerGraphics C CXX)
option(USE_PREBUILT_INTERSECT "Enable using prebuilt intersection library" ON)
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/framework")
# Create framework library and include CMake scripts (compiler warnings, sanitizers and static analyzers).
add_subdirectory("framework")
set(REFERENCE_MODE OFF)
else()
# During development the framework lives in parent folder.
add_subdirectory("../../../framework/" "${CMAKE_BINARY_DIR}/framework/")
set(REFERENCE_MODE ON)
endif()
find_package(OpenGL REQUIRED)
find_package(OpenMP REQUIRED)
add_library(FinalProjectLib
"src/bvh.cpp"
"src/scene.cpp"
"src/draw.cpp"
"src/screen.cpp"
"src/light.cpp"
"src/config.cpp"
"src/texture.cpp"
"src/shading.cpp"
"src/interpolate.cpp"
"src/recursive.cpp"
"src/render.cpp"
"src/extra.cpp"
"src/verification.cpp"
)
target_include_directories(FinalProjectLib PUBLIC "src")
target_link_libraries(FinalProjectLib PUBLIC CGFramework OpenGL::GLU OpenMP::OpenMP_CXX)
target_compile_features(FinalProjectLib PUBLIC cxx_std_20)
enable_sanitizers(FinalProjectLib)
set_project_warnings(FinalProjectLib)
if (USE_PREBUILT_INTERSECT)
add_library(Intersect2 STATIC IMPORTED)
if (WIN32)
set_target_properties(Intersect2 PROPERTIES IMPORTED_LOCATION_DEBUG "${CMAKE_SOURCE_DIR}/prebuilt/Intersect_x64_debug.lib")
set_target_properties(Intersect2 PROPERTIES IMPORTED_LOCATION_RELWITHDEBINFO "${CMAKE_SOURCE_DIR}/prebuilt/Intersect_x64_release.lib")
set_target_properties(Intersect2 PROPERTIES IMPORTED_LOCATION_RELEASE "${CMAKE_SOURCE_DIR}/prebuilt/Intersect_x64_release.lib")
elseif (APPLE)
set_target_properties(Intersect2 PROPERTIES IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/prebuilt/libIntersect_mac_arm64.a")
else()
set_target_properties(Intersect2 PROPERTIES IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/prebuilt/libIntersect_linux_x64.a")
endif()
target_link_libraries(FinalProjectLib PUBLIC Intersect2)
else()
target_sources(FinalProjectLib PRIVATE "src/intersect.cpp")
endif()
target_compile_definitions(FinalProjectLib PUBLIC
"-DDATA_DIR=\"${CMAKE_CURRENT_LIST_DIR}/data/\"")
add_executable(FinalProject "src/main.cpp")
target_link_libraries(FinalProject PUBLIC FinalProjectLib)
target_compile_features(FinalProject PUBLIC cxx_std_20)
enable_sanitizers(FinalProject)
set_project_warnings(FinalProject)
# Add test files
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/tests/")
add_subdirectory("tests")
endif()
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/grading_tests/")
add_subdirectory("grading_tests")
endif()