forked from calpoly-graphics/CSC-474-Base-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·153 lines (128 loc) · 5.37 KB
/
CMakeLists.txt
File metadata and controls
executable file
·153 lines (128 loc) · 5.37 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
if(APPLE)
cmake_minimum_required(VERSION 3.9.6)
else()
cmake_minimum_required(VERSION 3.6)
endif()
# Name of the project
project(lab)
# Use glob to get the list of all source files.
file(GLOB_RECURSE SOURCES "src/*.cpp" "ext/glad/src/*.c")
# We don't really need to include header and resource files to build, but it's
# nice to have them show up in IDEs.
file(GLOB_RECURSE HEADERS "src/*.h" "ext/glad/*/*.h")
file(GLOB_RECURSE GLSL "resources/*.glsl" "resources/*.vert" "resources/*.frag" "resources/*.geom" "resources/*.comp")
include_directories("ext/glad/include")
# Set the executable.
add_executable(${CMAKE_PROJECT_NAME} ${SOURCES} ${HEADERS} ${GLSL})
# Set the default target for VS and Xcode
if(APPLE)
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
else()
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT lab)
endif()
# Add GLFW
# Get the GLFW environment variable.
# There should be a CMakeLists.txt in the specified directory.
set(GLFW_DIR "$ENV{GLFW_DIR}")
# If there is no environment variable, search locally
if(NOT GLFW_DIR)
set(GLFW_DIR "ext/glfw-3.3-prerelease")
endif()
if(GLFW_DIR)
message(STATUS "GLFW environment variable found")
option(GLFW_BUILD_EXAMPLES "GLFW_BUILD_EXAMPLES" OFF)
option(GLFW_BUILD_TESTS "GLFW_BUILD_TESTS" OFF)
option(GLFW_BUILD_DOCS "GLFW_BUILD_DOCS" OFF)
if(CMAKE_BUILD_TYPE MATCHES Release)
add_subdirectory(${GLFW_DIR} ${GLFW_DIR}/release)
else()
add_subdirectory(${GLFW_DIR} ${GLFW_DIR}/debug)
endif()
include_directories(${GLFW_DIR}/include)
target_link_libraries(${CMAKE_PROJECT_NAME} glfw ${GLFW_LIBRARIES})
else()
message(STATUS "GLFW environment variable `GLFW_DIR` not found, GLFW3 must be installed with the system")
find_package(PkgConfig)
if (PKGCONFIG_FOUND)
message(STATUS "PkgConfig found")
pkg_search_module(GLFW REQUIRED glfw3)
include_directories(${GLFW_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} ${GLFW_LIBRARIES})
else()
message(STATUS "No PkgConfig found")
find_package(glfw3 REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})
target_link_libraries(${CMAKE_PROJECT_NAME} glfw)
endif()
endif()
# Add GLM
# Get the GLM environment variable. Since GLM is a header-only library, we
# just need to add it to the include directory.
set(GLM_INCLUDE_DIR "$ENV{GLM_INCLUDE_DIR}")
# If there is no environment variable, search locally
if(NOT GLM_INCLUDE_DIR)
set(GLM_INCLUDE_DIR "ext/glm-0.9.8.3")
endif()
if(GLM_INCLUDE_DIR)
include_directories(${GLM_INCLUDE_DIR})
message(STATUS "GLM environment variable found")
else()
# If the GLM_INCLUDE_DIR environment variable is not set, we assume
# the user has installed GLM properly on their system
message(STATUS "GLM environment variable `GLM_INCLUDE_DIR` not found, GLM must be installed with the system")
endif()
# OS specific options and libraries
if(WIN32)
# c++0x is enabled by default.
# -Wall produces way too many warnings.
# -pedantic is not supported.
target_link_libraries(${CMAKE_PROJECT_NAME} opengl32.lib)
# Add FBX
# If there is no environment variable, search locally
if(NOT FBX_INCLUDE_DIR)
set(FBX_INCLUDE_DIR "C:/Program\ Files/Autodesk/FBX/FBX\ SDK/2019.0/include")
endif()
set(FBX_LIBRARY_DIR "C:/Program\ Files/Autodesk/FBX/FBX\ SDK/2019.0/lib/vs2015/x86/debug")
if(FBX_INCLUDE_DIR)
include_directories(${FBX_INCLUDE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} ${FBX_LIBRARY_DIR}/libfbxsdk.lib)
message(STATUS "FBX environment variable `FBX_INCLUDE_DIR` not found, FBX must be installed with the system")
else()
message(STATUS "FBX environment variable `FBX_INCLUDE_DIR` not found, FBX must be installed with the system")
endif()
set(dllLoc ${FBX_LIBRARY_DIR}/libfbxsdk.dll)
set(dest ${CMAKE_CURRENT_BINARY_DIR}/libfbxsdk.dll)
add_custom_command(
TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${dllLoc} ${dest}
DEPENDS ${dest}
COMMENT "copies over dll for fbx sdk to build directory so it can be used during execution"
)
else()
# Enable all pedantic warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic")
if(APPLE)
# Add required frameworks for GLFW.
target_link_libraries(${CMAKE_PROJECT_NAME} "-framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo")
else()
#Link the Linux OpenGL library
target_link_libraries(${CMAKE_PROJECT_NAME} "GL" "dl")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} Threads::Threads)
# If there is no environment variable, search locally
if(NOT FBX_INCLUDE_DIR)
set(FBX_INCLUDE_DIR "/usr/include/fbxsdk")
endif()
set(FBX_LIBRARY "/usr/lib/gcc4/x64/release/libfbxsdk.a")
if(FBX_INCLUDE_DIR)
include_directories(${FBX_INCLUDE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} ${FBX_LIBRARY} ${CMAKE_DL_LIBS})
message(STATUS "FBX environment variable found")
else()
# If the FBX_INCLUDE_DIR environment variable is not set, we assume
# the user has installed FBX properly on their system
message(STATUS "FBX environment variable `FBX_INCLUDE_DIR` not found, FBX must be installed with the system")
endif()
endif()
endif()