-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
90 lines (72 loc) · 2.7 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
cmake_minimum_required(VERSION 3.0)
project(demo)
# ------------------------------------------------------------------------------
# Initial settings for our project
# ------------------------------------------------------------------------------
# Generate compile_commands.json for use by YCM
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Check mandatory env variables
if (NOT DEFINED ENV{Qt5_android})
message(FATAL_ERROR "Configure the env variable Qt5_android to point to your android Qt5 installation.")
else()
message(STATUS "Qt5 android installation dir: $ENV{Qt5_android}")
endif()
if (NOT DEFINED ENV{Qt5_host})
message(FATAL_ERROR "Configure the env variable Qt5_host to point to your host Qt5 installation.")
else()
message(STATUS "Qt5 host installation dir: $ENV{Qt5_host}")
endif()
# Minimum Qt version
set(QT_REQUIRED_VERSION 5.5.0)
# Set application version
set(DEMO_MAJOR_VERSION 0)
set(DEMO_MINOR_VERSION 1)
set(DEMO_PATCH_VERSION 0)
set(DEMO_VERSION ${DEMO_MAJOR_VERSION}.${DEMO_MINOR_VERSION})
# An integer value that represents the version of the application
# Increase it at each release
set(DEMO_VERSION_CODE ${DEMO_MINOR_VERSION})
# Cmake modules setup
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
# Tell Cmake to run moc when necessary
set(CMAKE_AUTOMOC ON)
# Since moc files are generated in the build dir, tell cmake to always look for
# includes there
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Set c++11 support
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (COMPILER_SUPPORTS_CXX11)
set(my_cxx_flags "-std=c++11")
elseif (COMPILER_SUPPORTS_CXX0X)
set(my_cxx_flags "-std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${my_cxx_flags}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${my_cxx_flags}")
# OS Configurations
if (ANDROID)
set(CMAKE_PREFIX_PATH "$ENV{Qt5_android}/lib/cmake/Qt5")
set(_dest_dir android/assets)
# Android .so output
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/android/libs/${ARM_TARGET}/)
else()
set(CMAKE_PREFIX_PATH "$ENV{Qt5_host}/lib/cmake/Qt5")
if (CMAKE_HOST_APPLE)
set(_bundle_bin Demo.app/Contents/MacOS)
set(_dest_dir bin/${_bundle_bin})
else()
set(_dest_dir bin)
endif()
# Desktop build
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()
# Each Qt5 package finds its own dependencies
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Qml Quick Gui)
# Add other subdirectories containing CMakeLists.txt file
add_subdirectory(src)
if (ANDROID)
add_subdirectory(android)
endif()