-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
140 lines (114 loc) · 5.06 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
cmake_minimum_required(VERSION 2.6)
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
project("TextEngine" C CXX) # This project uses C and C++
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wextra -g -Wno-unused-parameter -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x -Wall -g")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules)
# use color messages
#include(${CMAKE_SOURCE_DIR}/CMakeModules/colorMessage.cmake)
# Get the list of programs to build
include(BuildList.cmake)
# Get custom Windows library installation paths
if (WIN32)
include(Windows.cmake)
# GLUT installation
set(GLUT_ROOT_PATH "${WINDOWS_LIBRARY_PATH}${WINDOWS_GLUT_FOLDER}/" ${GLUT_ROOT_PATH})
# GLEW installation
set(GLEW_ROOT_PATH "${WINDOWS_LIBRARY_PATH}${WINDOWS_GLEW_FOLDER}/")
set(CMAKE_LIBRARY_PATH "${GLEW_ROOT_PATH}lib" ${CMAKE_LIBRARY_PATH})
set(CMAKE_INCLUDE_PATH "${GLEW_ROOT_PATH}include" ${CMAKE_INCLUDE_PATH})
# FreeType installation
set(FREETYPE_ROOT_PATH "${WINDOWS_LIBRARY_PATH}${WINDOWS_FREETYPE_FOLDER}/")
set(CMAKE_LIBRARY_PATH "${FREETYPE_ROOT_PATH}" ${CMAKE_LIBRARY_PATH})
set(CMAKE_INCLUDE_PATH "${FREETYPE_ROOT_PATH}include" ${CMAKE_INCLUDE_PATH})
endif()
# Use glxinfo or glewinfo to determine OpenGL version if they are
# available. Fail if a high enough version of OpenGL is not supported.
find_file(GLXINFO glxinfo)
find_file(GLEWINFO glewinfo)
if(UNIX AND NOT APPLE AND (GLXINFO OR GLEWINFO))
execute_process(COMMAND ${GLXINFO} COMMAND grep "OpenGL core profile version string" COMMAND cut -d " " -f 6 OUTPUT_VARIABLE openglversion OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(NOT openglversion AND GLEWINFO)
execute_process(COMMAND ${GLEWINFO} COMMAND grep "OpenGL version " COMMAND cut -d " " -f 3 OUTPUT_VARIABLE openglversion OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
endif()
if(openglversion)
message("OpenGL core profile version - ${openglversion}")
if(openglversion VERSION_LESS "3.2")
message(FATAL_ERROR "OpenGL version 3.2 or higher is required.")
endif()
endif()
endif()
# SITE_NAME sets the HOSTNAME variable to the name of this computer.
SITE_NAME(HOSTNAME)
# Doxygen documentation
# option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" ON)
# if(BUILD_DOCUMENTATION)
# find_package(Doxygen)
# if(DOXYGEN_FOUND)
# #-- Add a custom target to run Doxygen when ever the project is built
# add_custom_target (docs
# COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
# SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
# # Add or remove 'ALL' after 'docs' above to enable/disable doxygen generation when running "make"
# else()
# message(WARNING "Not creating Doxygen documents because doxygen was not found on this system.")
# endif()
# endif()
# === Libraries that we use ===
# --- math library ---
if(NOT WIN32)
find_library(M_LIBRARY
NAMES m
PATHS /usr/lib /usr/local/lib
)
if(NOT M_LIBRARY)
message(STATUS
"math library 'libm' not found - floating point support disabled")
endif()
else()
# not needed on windows
set(M_LIBRARY "")
endif()
# --- OpenGL ---
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})
# --- Freeglut (version 2.6 or higher) ---
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIR})
# Make sure freeglut installation is new enough!
include(CheckSymbolExists)
if(UNIX AND NOT APPLE)
CHECK_SYMBOL_EXISTS(GLUT_CORE_PROFILE "${GLUT_INCLUDE_DIR}/GL/freeglut.h;${GLUT_INCLUDE_DIR}/GL/freeglut_ext.h" FREEGLUT_NEW_ENOUGH)
if(NOT FREEGLUT_NEW_ENOUGH)
message(FATAL_ERROR "freeglut version 2.6 or higher is required.")
endif()
endif()
# --- GLEW ---
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIR})
# Check for an newer extension that we use for glGetProgram(). If GLEW
# is too old, it might not know about the extension and we could get
# compile errors.
include(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(GL_ARB_get_program_binary "${GLEW_INCLUDE_DIRS}/GL/glew.h" GLEW_NEW_ENOUGH)
if(NOT GLEW_NEW_ENOUGH)
message(FATAL_ERROR "glew version 1.5.6 or higher is required.")
endif()
# --- FreeType ---
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
# Collect libraries that all programs use together into one cmake variable
set(COMMON_LIBRARIES ${GLEW_LIBRARIES} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES} ${FREETYPE_LIBRARIES} ${M_LIB} -lpthread)
# Create a static library containing all files that we regularly use.
include_directories("include")
set(FILES_IN_ENGINE src/SFont.cpp src/CCharacter.cpp src/CTextBuffer.cpp src/CCanvas.cpp src/CGame.cpp)
add_library(TextEngine STATIC ${FILES_IN_ENGINE})
set_target_properties(TextEngine PROPERTIES COMPILE_DEFINITIONS "${PREPROC_DEFINE}")
# Make compilation rule for all programs that don't need ImageMagick or ASSIMIP
foreach(arg ${BUILD_LIST})
add_executable(${arg} ${arg}.cpp)
target_link_libraries(${arg} TextEngine ${COMMON_LIBRARIES})
message(${COMMON_LIBRARIES})
set_target_properties(${arg} PROPERTIES COMPILE_DEFINITIONS "${PREPROC_DEFINE}")
endforeach()