forked from aevum/libgdx-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
122 lines (94 loc) · 3.72 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
project(gdx-cpp)
cmake_minimum_required(VERSION 2.8)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
include(cmake/gdx.cmake)
include_directories(src)
link_directories(${LIBRARY_OUTPUT_PATH})
set(ANDROID_NDK $ENV{ANDROID_NDK})
option(BUILD_BOX2D "Builds Box2D" TRUE)
option(BUILD_AS_SHARED_LIBRARIES "Build libraries as shared libraries instead of static" FALSE)
option(GDX_LOG_DEBUG "Enables the output of debug logs" TRUE)
option(GDX_LOG_INFO "Enables the output of debug logs" FALSE)
option(GDX_LOG_ERROR "Enables the output of debug logs" FALSE)
if (GDX_LOG_DEBUG)
set(GDX_LOG_LEVEL_DEBUG TRUE)
set(GDX_LOG_LEVEL_INFO TRUE)
set(GDX_LOG_LEVEL_ERROR TRUE)
elseif(GDX_LOG_INFO)
set(GDX_LOG_LEVEL_INFO TRUE)
set(GDX_LOG_LEVEL_ERROR TRUE)
elseif(GDX_LOG_ERROR)
set(GDX_LOG_LEVEL_ERROR TRUE)
endif()
if(APPLE)
message("MacOSX (iOS) found. Setting the backend to IOS")
SET(GDX_BACKEND_IOS ON)
SET(GDX_BACKEND_LIB gdx-cpp-backend-ios)
set(BOX2D_BUILD_STATIC TRUE)
set(BOX2D_BUILD_SHARED FALSE)
elseif (UNIX)
if (ANDROID_NDK)
message("ANDROID_NDK Found. Setting the backend to ANDROID")
SET(GDX_BACKEND_ANDROID ON)
SET(GDX_BACKEND_LIB gdx-cpp-backend-android)
set(BOX2D_BUILD_STATIC FALSE)
set(BOX2D_BUILD_SHARED TRUE)
else()
message("Linux found. Setting the backend to LINUX")
add_definitions(-DLIBGDX_CPP_BUILD_OPENGL_INSTEAD_GLES)
SET(GDX_BACKEND_LINUX ON)
SET(GDX_BACKEND_LIB gdx-cpp-backend-linux)
if (BUILD_AS_SHARED_LIBRARIES)
set(BOX2D_BUILD_STATIC FALSE)
set(BOX2D_BUILD_SHARED TRUE)
else()
set(BOX2D_BUILD_STATIC TRUE)
set(BOX2D_BUILD_SHARED FALSE)
endif()
endif()
elseif(WIN32)
message("Win32 found. Setting the backend to WIN32")
SET(GDX_BACKEND_WIN32 ON)
SET(GDX_BACKEND_LIB gdx-cpp-backend-win32)
endif()
CONFIGURE_FILE(src/gdx-cpp/gl.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/src/gdx-cpp/gl.hpp )
CONFIGURE_FILE(src/gdx-cpp/config.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/src/gdx-cpp/config.hpp )
if (BUILD_BOX2D)
set(BOX2D_INSTALL TRUE)
add_subdirectory(src/Box2D)
add_subdirectory(src/gdx-cpp/physics/box2d)
endif()
if (GDX_BACKEND_IOS)
add_subdirectory(src/backends/gdx-cpp-backend-ios)
SET(BUILD_AGG TRUE)
elseif(GDX_BACKEND_ANDROID)
add_subdirectory(src/backends/gdx-cpp-backend-android)
# SET(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} --allow-shlib-undefined")
SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--allow-shlib-undefined)
SET(BUILD_AGG TRUE)
elseif(GDX_BACKEND_WIN32)
add_subdirectory(src/backends/windows)
elseif(GDX_BACKEND_LINUX)
if(CMAKE_COMPILER_IS_GNUCXX)
# get gnu compiler version number
exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info)
string (REGEX MATCH " [34]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}")
string(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+.*" "\\1" gcc_major_vers "${_gcc_version}")
string(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+).*" "\\1" gcc_minor_vers "${_gcc_version}")
# g++' -Wdouble-promotion needs at least version 4.6
if(${gcc_major_vers} GREATER 3 AND ${gcc_minor_vers} GREATER 5)
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wdouble-promotion")
endif()
endif()
SET(BUILD_AGG TRUE)
add_subdirectory(src/backends/gdx-cpp-backend-linux)
endif()
if (BUILD_AGG)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/agg/include ${CMAKE_CURRENT_SOURCE_DIR}/src/agg/svg)
add_subdirectory(src/agg)
endif()
add_subdirectory(src/gdx-cpp)
install(FILES cmake/finders/FindGdxCpp.cmake
DESTINATION share/gdx/cmake)
install(FILES cmake/gdx.cmake
DESTINATION share/gdx/cmake)