-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
87 lines (78 loc) · 3.1 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
77
78
79
80
81
82
83
84
85
86
87
cmake_minimum_required(VERSION 3.30)
project(AbstractNexus VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 20)
add_subdirectory(vendor/fenster)
include_directories(vendor/fenster/include)
include_directories(vendor/glm)
include_directories(vendor/stb)
include_directories(include)
option(BUILD_FENSTER "Whether to build Fenster module" ON)
option(BUILD_OPENGL "Whether to build OpenGL module" ON)
set(ANEX_SOURCES
src/IEntity.cpp
src/IScene.cpp
src/IWindow.cpp
src/Logger.cpp
src/crypto/vector.cpp
src/images/ImageLoader.cpp)
if(BUILD_FENSTER)
list(APPEND ANEX_SOURCES src/modules/fenster/Fenster.cpp)
endif()
if(BUILD_OPENGL)
list(APPEND ANEX_SOURCES
src/modules/gl/GLWindow.cpp
src/modules/gl/GLEntity.cpp
src/modules/gl/GLScene.cpp
src/modules/gl/entities/Cube.cpp
src/modules/gl/entities/SkyBox.cpp
src/modules/gl/lights/DirectionalLight.cpp
src/modules/gl/lights/PointLight.cpp
src/modules/gl/lights/SpotLight.cpp
src/modules/gl/shaders/Shader.cpp
src/modules/gl/shaders/ShaderFactory.cpp
src/modules/gl/shaders/ShaderManager.cpp
src/modules/gl/textures/Texture.cpp
src/modules/gl/textures/TextureFactory.cpp
src/modules/gl/textures/TextureLoader.cpp
src/modules/gl/textures/Framebuffer.cpp
src/modules/gl/textures/FramebufferFactory.cpp
src/modules/gl/vaos/VAO.cpp
src/modules/gl/vaos/VAOFactory.cpp
src/modules/gl/vp/View.cpp
src/modules/gl/vp/VML.cpp
src/modules/gl/glad.c)
endif()
add_library(abstractnexus STATIC ${ANEX_SOURCES})
if(BUILD_FENSTER)
target_link_libraries(abstractnexus fenster)
endif()
if(BUILD_OPENGL)
if(WIN32)
find_package(OpenGL REQUIRED)
target_link_libraries(abstractnexus OpenGL::GL)
endif()
endif()
function(create_test TEST_NAME TEST_SOURCE TEST_ARGS)
add_executable(${TEST_NAME} ${TEST_SOURCE})
target_link_libraries(${TEST_NAME} abstractnexus)
if(UNIX AND NOT APPLE)
target_link_libraries(${TEST_NAME} ${X11_LIBRARIES})
endif()
add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE_DIR:${TEST_NAME}>/${TEST_NAME}${TEST_EXT} ${TEST_ARGS})
endfunction()
include(CTest)
enable_testing()
if(BUILD_FENSTER)
create_test(FensterWindow tests/FensterWindow.cpp "")
endif()
if(BUILD_OPENGL)
create_test(GLTest tests/GLTest.cpp "")
set(SKYBOX_OUT_DIRECTORY ${CMAKE_BINARY_DIR}/images/skybox)
file(MAKE_DIRECTORY ${SKYBOX_OUT_DIRECTORY})
configure_file(${CMAKE_SOURCE_DIR}/images/skybox/back.jpg ${SKYBOX_OUT_DIRECTORY}/back.jpg COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/images/skybox/front.jpg ${SKYBOX_OUT_DIRECTORY}/front.jpg COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/images/skybox/left.jpg ${SKYBOX_OUT_DIRECTORY}/left.jpg COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/images/skybox/right.jpg ${SKYBOX_OUT_DIRECTORY}/right.jpg COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/images/skybox/top.jpg ${SKYBOX_OUT_DIRECTORY}/top.jpg COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/images/skybox/bottom.jpg ${SKYBOX_OUT_DIRECTORY}/bottom.jpg COPYONLY)
endif()