-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
118 lines (95 loc) · 3.31 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
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
cmake_minimum_required(VERSION 3.7)
project(Flatlands)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} CMakeFiles/)
# let YCM do cool stuff for us
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(Executable Flatlands)
set(SourceDir src) # Change src/ to your source directory
set(IncludeDir include/) # Change include/ to your include directory
include_directories(${IncludeDir})
file(GLOB_RECURSE SourceFiles
${SourceDir}/*.cpp
)
set(THREADS_PREFER_PTHREAD_FLAD ON)
find_package(Threads REQUIRED)
find_package(OpenGL REQUIRED)
if (UNIX)
find_package(X11 REQUIRED)
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
endif (UNIX)
if (WIN32)
include_directories(${WinSDK})
endif (WIN32)
add_executable(${Executable}
${SourceFiles})
if (${APPLE})
#########################################################
# FIND CARBON
#########################################################
FIND_LIBRARY(CARBON_LIBRARY Carbon)
target_link_libraries(${Executable} ${CARBON_LIBRARY})
#########################################################
# FIND PNG
#########################################################
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIRS})
link_directories(${PNG_LIBRARY_DIRS})
add_definitions(${PNG_DEFINITIONS})
if(NOT PNG_FOUND)
message(ERROR " PNG not found!")
endif(NOT PNG_FOUND)
target_link_libraries(${Executable} ${PNG_LIBRARIES})
#########################################################
# FIND GLUT
#########################################################
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIRS})
link_directories(${GLUT_LIBRARY_DIRS})
add_definitions(${GLUT_DEFINITIONS})
if(NOT GLUT_FOUND)
message(ERROR " GLUT not found!")
endif(NOT GLUT_FOUND)
target_link_libraries(${Executable} ${GLUT_LIBRARIES})
#########################################################
# FIND OPENGL
#########################################################
find_package(OpenGL REQUIRED)
include_directories(${OpenGL_INCLUDE_DIRS})
link_directories(${OpenGL_LIBRARY_DIRS})
add_definitions(${OpenGL_DEFINITIONS})
if(NOT OPENGL_FOUND)
message(ERROR " OPENGL not found!")
endif(NOT OPENGL_FOUND)
target_link_libraries(${Executable} ${OPENGL_LIBRARIES})
add_definitions(-std=c++17)
else()
link_libraries(${Executable}
Threads::Threads
OpenGL::OpenGL
OpenGL::GL
OpenGL::GLX
)
if (UNIX)
target_link_libraries(${Executable} stdc++fs)
target_link_libraries(${Executable} GL)
target_link_libraries(${Executable} png)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(SFML_STATIC_LIBRARIES FALSE)
target_link_libraries(${Executable}
${X11_LIBRARIES}
PNG::PNG
)
endif (UNIX)
if (WIN32)
target_link_libraries(${Executable}
${WinSDK}
)
endif (WIN32)
endif()