forked from tangrams/tangram-es
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
110 lines (82 loc) · 3.22 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
cmake_minimum_required(VERSION 3.0)
project(tangram)
# Options
option(TANGRAM_USE_SYSTEM_FONT_LIBS "Use system libraries Freetype, ICU and Harfbuzz via pkgconfig" OFF)
option(TANGRAM_USE_SYSTEM_GLFW_LIBS "Use system libraries for GLFW3 via pkgconfig" OFF)
if(NOT ${CMAKE_BUILD_TYPE} STREQUAL "")
message(STATUS "Build type configuration " ${CMAKE_BUILD_TYPE})
else()
set(CMAKE_BUILD_TYPE Release)
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/core/deps/harfbuzz-icu-freetype/harfbuzz/README")
message(SEND_ERROR "Missing submodules - Please run:\n 'git submodule update --init'")
return()
endif()
set(TANGRAM_APPLICATION ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
include(${PROJECT_SOURCE_DIR}/toolchains/utils.cmake)
# platform lookup
set(SUPPORTED_TARGETS darwin ios android raspberrypi linux tizen ios.framework)
if(NOT PLATFORM_TARGET)
string(TOLOWER "${CMAKE_SYSTEM_NAME}" varplatform)
string(TOUPPER "${CMAKE_SYSTEM_NAME}" VARPLATFORM)
message(STATUS "No target defined (give as parameter -DPLATFORM_TARGET=platform_name).")
message(STATUS "Targets available: ${SUPPORTED_TARGETS}.")
message(STATUS "Will use your OS: ${varplatform}.")
set(PLATFORM_TARGET ${varplatform})
else()
string(TOLOWER "${PLATFORM_TARGET}" varplatform)
string(TOUPPER "${PLATFORM_TARGET}" VARPLATFORM)
message(STATUS "Platform chosen : ${VARPLATFORM}")
endif()
list(FIND SUPPORTED_TARGETS ${varplatform} target_in_list)
if(target_in_list EQUAL -1)
message(SEND_ERROR "${varplatform} not in supported targets: ${SUPPORTED_TARGETS}")
return()
endif()
# setting up cache variable platform
set(PLATFORM ${varplatform} CACHE INTERNAL "platform" FORCE)
# cmake output configuration
if(NOT ${PLATFORM_TARGET} STREQUAL android)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()
if (CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG)
add_definitions(-DLOG_LEVEL=3)
else()
add_definitions(-DLOG_LEVEL=2)
endif()
# cmake inclusions and definitions
set(CMAKE_TARGET_FILE ${PROJECT_SOURCE_DIR}/toolchains/${PLATFORM_TARGET}.cmake)
message(STATUS "Including ${varplatform} dependent cmake file : ${CMAKE_TARGET_FILE}")
set(EXTERNAL_LIBS_DIR ${CMAKE_SOURCE_DIR}/external/exports/${PLATFORM_TARGET}
CACHE INTERNAL "external-libs" FORCE)
## set platform configuration, build library and application.
# adds targets:
# - core
# - tangram
# - copy_resources
include(${CMAKE_TARGET_FILE})
if(BENCHMARK OR UNIT_TESTS)
add_library(platform_mock
${PROJECT_SOURCE_DIR}/tests/src/mockPlatform.cpp
${PROJECT_SOURCE_DIR}/tests/src/gl_mock.cpp)
target_include_directories(platform_mock
PUBLIC ${CORE_LIBRARIES_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/tests/src)
target_compile_definitions(platform_mock
PUBLIC -DUNIT_TESTS)
target_link_libraries(platform_mock
PUBLIC tangramcore)
endif()
if(UNIT_TESTS)
message(STATUS "Build with tests")
add_subdirectory(${PROJECT_SOURCE_DIR}/tests)
endif()
if(BENCHMARK)
message(STATUS "Build with benchmarks")
add_subdirectory(${PROJECT_SOURCE_DIR}/bench)
endif()