-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
89 lines (74 loc) · 3.53 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.1.1)
project(Project)
set(CMAKE_BUILD_TYPE Release)
add_executable(Project main.cpp argparser.cpp argparser.h meshdata.cpp meshdata.h vertex.h vectors.h matrix.cpp matrix.h mesh.cpp mesh.h OpenGLRenderer.cpp OpenGLRenderer.h OpenGLCanvas.cpp OpenGLCanvas.h OpenGLCamera.cpp OpenGLCamera.h boundingbox.h triangle.h triangulator.h fracture.cpp fracture.h)
set(my_executable Project)
set(OpenGL_GL_PREFERENCE GLVND)
# http://glm.g-truc.net/0.9.5/updates.html
add_definitions(-DGLM_FORCE_RADIANS)
# We've placed a few FindXXX.cmake files in the the source directory
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
# Following the instructions for Windows here:
# http://www.cs.rpi.edu/~cutler/classes/advancedgraphics/S19/opengl_install_notes.php
# the graphics librarys files are placed in this directory
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "C:\\GraphicsLibraries")
# make sure all of the necessary graphics libraries are available
find_package(CGAL REQUIRED)
if(CGAL_FOUND)
include_directories(${CGAL_INCLUDE_DIRS})
target_link_libraries(${my_executable} ${CGAL_LIBRARIES} )
endif(CGAL_FOUND)
find_package(OpenGL REQUIRED)
if(OPENGL_FOUND)
include_directories(${OPENGL_INCLUDE_DIRS})
target_link_libraries(${my_executable} ${OPENGL_LIBRARIES} )
endif(OPENGL_FOUND)
find_package(GLEW REQUIRED)
if(GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
target_link_libraries(${my_executable} ${GLEW_LIBRARIES})
endif(GLEW_FOUND)
find_package(GLM REQUIRED)
if(GLM_FOUND)
include_directories(${GLM_INCLUDE_DIRS})
endif()
# find all the dependencies of GLFW
set(ENV{PKG_CONFIG_PATH} /usr/local/lib/pkgconfig:/usr/lib/pkgconfig:$ENV{PKG_CONFIG_PATH})
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_search_module(GLFW REQUIRED glfw3)
include_directories(${GLFW_INCLUDE_DIRS})
else(PKG_CONFIG_FOUND)
message("Did not find pkg-config, trying FindGLFW.cmake")
find_package(GLFW REQUIRED)
if(GLFW_FOUND)
include_directories(${GLFW_INCLUDE_DIR})
else(GLFW_FOUND)
endif(GLFW_FOUND)
endif(PKG_CONFIG_FOUND)
message(STATUS "CGAL_LIBRARIES: ${CGAL_LIBRARIES}")
message(STATUS "OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}")
message(STATUS "GLEW_LIBRARIES: ${GLEW_LIBRARIES}")
message(STATUS "GLFW_LIBRARIES: ${GLFW_LIBRARIES}")
message(STATUS "GLFW_STATIC_LIBRARIES: ${GLFW_STATIC_LIBRARIES}")
message(STATUS "GLFW_LDFLAGS: ${GLFW_LDFLAGS}")
message(STATUS "GLFW_STATIC_LDFLAGS: ${GLFW_STATIC_LDFLAGS}")
# some linux compilations require this hack to get the libraries in the right order
if (UNIX)
set(MISSING_FLAGS "-lX11 -lXxf86vm -lXrandr -lpthread -lXi -lXinerama -lXcursor -lrt -ldl")
target_link_libraries(${my_executable} "${OPENGL_gl_LIBRARY}" "${GLEW_LIBRARIES}" "${GLFW_LIBRARIES}" "${MISSING_FLAGS}")
endif()
target_link_libraries(${my_executable} "${OPENGL_gl_LIBRARY}" "${GLEW_LIBRARIES}" "${GLFW_LIBRARIES}")
## this will hopefully work whether you have the static or the dynamic GLFW libraries
# string replace hack to fix a bug in the pkg_config information
string(REPLACE ";" " " flags_static "${GLFW_STATIC_LDFLAGS}")
string(REPLACE ";" " " flags_dynamic "${GLFW_LDFLAGS}")
set_property(TARGET ${my_executable} APPEND_STRING PROPERTY LINK_FLAGS "${flags_static} ${flags_dynamic}")
if (UNIX)
# LINUX
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20")
set_target_properties (${my_executable} PROPERTIES COMPILE_FLAGS "-g -Wall -Wextra -pedantic ${BUILD_32}")
else()
# WINDOWS
set_target_properties (${my_executable} PROPERTIES COMPILE_FLAGS "/W4")
endif()