-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
277 lines (224 loc) · 9.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
cmake_minimum_required(VERSION 2.6.4)
include (CheckIncludeFile)
include (CheckFunctionExists)
# let's use & require C++11 - note these are only functional with CMake 3.1
# we do manual fallbacks for CMake 3.0 in the compilers section
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
project(fgrun)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
if(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
# use official include provided by latest CMake
include(GNUInstallDirs)
else(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
# backward compatibility: use our own module for older cmake versions
include(OldGNUInstallDirs)
endif(${CMAKE_VERSION} VERSION_GREATER 2.8.4)
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
file(READ version versionFile)
string(STRIP ${versionFile} FGRUN_VERSION)
#packaging
SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING")
SET(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "FlightGear Launcher")
SET(CPACK_PACKAGE_VENDOR "The FlightGear project")
SET(CPACK_GENERATOR "TBZ2")
SET(CPACK_INSTALL_CMAKE_PROJECTS ${CMAKE_CURRENT_BINARY_DIR};FGRun;ALL;/)
# split version string into components, note CMAKE_MATCH_0 is the entire regexp match
string(REGEX MATCH "([0-9]+)\\.([0-9]+)" CPACK_PACKAGE_VERSION ${FGRUN_VERSION} )
set(CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
set(CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
message(STATUS "version is ${CPACK_PACKAGE_VERSION_MAJOR} dot ${CPACK_PACKAGE_VERSION_MINOR}")
set(CPACK_SOURCE_GENERATOR TBZ2)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "fgrun-${FGRUN_VERSION}" CACHE INTERNAL "tarball basename")
set(CPACK_SOURCE_IGNORE_FILES
"\\\\.svn;Makefile.am;~$;${CPACK_SOURCE_IGNORE_FILES}")
message(STATUS "ignoring: ${CPACK_SOURCE_IGNORE_FILES}")
include (CPack)
option(ENABLE_NLS "Set to ON to build fgrun with NLS support" ON)
option(SIMGEAR_SHARED "Set to ON to dynamically link SimGear" OFF)
option(SHARED_FLTK "Set to ON to dynamically link FLTK (requires that SimGear also be dynamically linked)" OFF)
if (SHARED_FLTK AND NOT SIMGEAR_SHARED)
message(FATAL_ERROR "Please do not use SHARED_FLTK without SIMGEAR_SHARED, as it will probably fail to compile")
endif (SHARED_FLTK AND NOT SIMGEAR_SHARED)
if (MSVC)
GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH)
if (CMAKE_CL_64)
SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty.x64")
else (CMAKE_CL_64)
SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty")
endif (CMAKE_CL_64)
if (EXISTS ${TEST_3RDPARTY_DIR})
set(MSVC_3RDPARTY_ROOT ${PARENT_DIR} CACHE PATH "Location where the third-party dependencies are extracted")
else (EXISTS ${TEST_3RDPARTY_DIR})
set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
endif (EXISTS ${TEST_3RDPARTY_DIR})
list(APPEND PLATFORM_LIBS "winmm.lib" "Shlwapi.lib")
else (MSVC)
set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted")
endif (MSVC)
if (MSVC AND MSVC_3RDPARTY_ROOT)
message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}")
set( OSG_MSVC "msvc" )
if (${MSVC_VERSION} EQUAL 1900)
set( OSG_MSVC ${OSG_MSVC}140 )
elseif (${MSVC_VERSION} EQUAL 1800)
set( OSG_MSVC ${OSG_MSVC}120 )
elseif (${MSVC_VERSION} EQUAL 1700)
set( OSG_MSVC ${OSG_MSVC}110 )
elseif (${MSVC_VERSION} EQUAL 1600)
set( OSG_MSVC ${OSG_MSVC}100 )
endif ()
if (CMAKE_CL_64)
set( OSG_MSVC ${OSG_MSVC}-64 )
set( MSVC_3RDPARTY_DIR 3rdParty.x64 )
else (CMAKE_CL_64)
set( MSVC_3RDPARTY_DIR 3rdParty )
endif (CMAKE_CL_64)
find_path(FLTK_DIR include/FL/Fl.H
${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/fltk
${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/fltk-1.3
${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}
)
list (APPEND CMAKE_PROGRAM_PATH ${FLTK_DIR}/bin)
set (CMAKE_LIBRARY_PATH ${FLTK_DIR}/lib ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/lib )
set (CMAKE_INCLUDE_PATH ${FLTK_DIR}/include ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/include)
GET_FILENAME_COMPONENT(MSVC_ROOT_PARENT_DIR ${MSVC_3RDPARTY_ROOT} PATH)
find_path(BOOST_ROOT boost/version.hpp
${MSVC_ROOT_PARENT_DIR}
${MSVC_3RDPARTY_ROOT}/boost
${MSVC_3RDPARTY_ROOT}/boost_1_51_0
${MSVC_3RDPARTY_ROOT}/boost_1_50_0
${MSVC_3RDPARTY_ROOT}/boost_1_49_0
${MSVC_3RDPARTY_ROOT}/boost_1_48_0
${MSVC_3RDPARTY_ROOT}/boost_1_47_0
${MSVC_3RDPARTY_ROOT}/boost_1_46_1
${MSVC_3RDPARTY_ROOT}/boost_1_46_0
${MSVC_3RDPARTY_ROOT}/boost_1_45_0
${MSVC_3RDPARTY_ROOT}/boost_1_44_0
)
message(STATUS "BOOST_ROOT is ${BOOST_ROOT}")
endif (MSVC AND MSVC_3RDPARTY_ROOT)
if(WIN32)
if(MSVC)
set(MSVC_FLAGS "-DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
if (${MSVC_VERSION} GREATER 1599)
set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
endif (${MSVC_VERSION} GREATER 1599)
endif(MSVC)
set(NOMINMAX 1)
set( WINSOCK_LIBRARY "ws2_32.lib" )
endif(WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
find_package(Boost REQUIRED)
find_package(ZLIB REQUIRED)
if (SHARED_FLTK)
#see http://sources.debian.net/src/fltk1.3/1.3.2-4/README.CMake.txt lines 200-240
find_package(FLTK REQUIRED NO_MODULE)
include(${FLTK_USE_FILE})
set(FLTK_LIBRARIES "fltk_forms_SHARED;fltk_gl_SHARED;fltk_images_SHARED;fltk_SHARED")
else (SHARED_FLTK)
find_package(FLTK REQUIRED)
endif (SHARED_FLTK)
find_package(OpenSceneGraph 2.8.1 REQUIRED osgText osgDB osgParticle osgUtil osgViewer osgGA)
find_package(SimGear ${FGRUN_VERSION} REQUIRED)
if (ENABLE_NLS)
find_package(Gettext)
endif (ENABLE_NLS)
if (ENABLE_NLS AND GETTEXT_FOUND)
if (MSVC)
FIND_LIBRARY(INTL_LIBRARY
NAMES intl
HINTS
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/opt
)
if (NOT INTL_LIBRARY)
set( ENABLE_NLS 0 )
endif (NOT INTL_LIBRARY)
endif (MSVC)
if (ENABLE_NLS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_NLS")
endif (ENABLE_NLS)
else (ENABLE_NLS AND GETTEXT_FOUND)
set( INTL_LIBRARY "" )
endif (ENABLE_NLS AND GETTEXT_FOUND)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
check_include_file(termios.h HAVE_TERMIOS_H)
check_include_file(pty.h HAVE_PTY_H)
check_include_file(utmp.h HAVE_UTMP_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(string.h HAVE_STRING_H)
check_function_exists(openpty HAVE_OPENPTY)
if (NOT HAVE_OPENPTY)
unset( HAVE_OPENPTY CACHE )
set( CMAKE_REQUIRED_LIBRARIES util )
check_function_exists(openpty HAVE_OPENPTY)
if (HAVE_OPENPTY)
set( OPENPTY_LIBRARY util CACHE INTERNAL "" )
else (HAVE_OPENPTY)
set( CMAKE_REQUIRED_LIBRARIES )
endif (HAVE_OPENPTY)
endif (NOT HAVE_OPENPTY)
check_function_exists(login_tty HAVE_LOGIN_TTY)
check_function_exists(_getpty HAVE__GETPTY)
if ( NOT ( HAVE_OPENPTY OR HAVE__GETPTY ) )
if (EXISTS /dev/ptmx)
set(HAVE_DEV_PTMX)
endif (EXISTS /dev/ptmx)
if (EXISTS /dev/pts)
set(HAVE_DEV_PTS)
endif (EXISTS /dev/pts)
endif ( NOT ( HAVE_OPENPTY OR HAVE__GETPTY ) )
if ( FLTK_FOUND )
if ( X11_Xinerama_FOUND )
message(STATUS "Found X11_Xinerama...")
list(APPEND FLTK_LIBRARIES ${X11_Xinerama_LIB})
endif()
if ( X11_Xft_FOUND )
message(STATUS "Found X11_Xft...")
list(APPEND FLTK_LIBRARIES ${X11_Xft_LIB})
endif()
if ( CMAKE_DL_LIBS )
list(APPEND FLTK_LIBRARIES ${CMAKE_DL_LIBS})
endif()
set( CMAKE_REQUIRED_INCLUDES ${FLTK_INCLUDE_DIR} )
set( CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES} )
message(STATUS "Using FLTK_LIBRARIES for fgrun: ${FLTK_LIBRARIES}")
check_cxx_source_runs(
"#include <FL/Fl.H>
int main() {
return Fl::version() >= 1.03 ? 0 : -1;
}
"
HAVE_FLTK_1_3)
if ( NOT HAVE_FLTK_1_3 )
message( SEND_ERROR "FLTK 1.3 is required" )
endif ( NOT HAVE_FLTK_1_3 )
endif ( FLTK_FOUND )
add_definitions(-DHAVE_CONFIG_H)
include_directories(${PROJECT_BINARY_DIR}/src)
include_directories(${CMAKE_HOME_DIRECTORY}/src)
configure_file (
"${PROJECT_SOURCE_DIR}/src/config_cmake.h.in"
"${PROJECT_BINARY_DIR}/src/config.h"
)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${SIMGEAR_INCLUDE_DIR}
${FLTK_INCLUDE_DIR})
add_subdirectory( src )
add_subdirectory( po )