forked from firebase/firebase-cpp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
150 lines (133 loc) · 4.49 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
# Copyright 2019 Google
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# CMake file for the firebase_analytics library
# Analytics generates header files for default events, parameters, and
# properties based on the iOS SDK, that are used across all platforms.
set(analytics_generated_headers_dir
"${FIREBASE_GEN_FILE_DIR}/analytics/src/include/firebase/analytics")
set(event_names_header "${analytics_generated_headers_dir}/event_names.h")
set(parameter_names_header
"${analytics_generated_headers_dir}/parameter_names.h")
set(user_property_names_header
"${analytics_generated_headers_dir}/user_property_names.h")
file(MAKE_DIRECTORY ${analytics_generated_headers_dir})
# Generate the header file by invoking the generate_constants python script.
function(generate_analytics_header OBJC_FILE CPP_FILE)
add_custom_command(
OUTPUT ${CPP_FILE}
COMMAND ${FIREBASE_PYTHON_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/generate_constants.py"
"--objc_header=${OBJC_FILE}"
"--cpp_header=${CPP_FILE}"
DEPENDS ${OBJC_FILE}
COMMENT "Generating ${CPP_FILE}"
)
endfunction()
# Call the above function for all of the header files to generate.
generate_analytics_header(
"${CMAKE_CURRENT_LIST_DIR}/ios_headers/FIREventNames.h"
"${event_names_header}"
)
generate_analytics_header(
"${CMAKE_CURRENT_LIST_DIR}/ios_headers/FIRParameterNames.h"
"${parameter_names_header}"
)
generate_analytics_header(
"${CMAKE_CURRENT_LIST_DIR}/ios_headers/FIRUserPropertyNames.h"
"${user_property_names_header}"
)
add_custom_target(FIREBASE_ANALYTICS_GENERATED_HEADERS
DEPENDS
"${user_property_names_header}"
"${parameter_names_header}"
"${event_names_header}"
)
# Common source files used by all platforms
set(common_SRCS
src/analytics_common.cc
# List the generated files, so that they are generated for the build.
${event_names_header}
${parameter_names_header}
${user_property_names_header})
# Source files used by the Android implementation.
set(android_SRCS
src/analytics_android.cc)
# Source files used by the iOS implementation.
set(ios_SRCS
src/analytics_ios.mm)
# Source files used by the stub implementation.
set(stub_SRCS
src/analytics_stub.cc)
if(ANDROID)
set(analytics_platform_SRCS
"${android_SRCS}")
elseif(IOS)
set(analytics_platform_SRCS
"${ios_SRCS}")
else()
set(analytics_platform_SRCS
"${stub_SRCS}")
endif()
add_library(firebase_analytics STATIC
${common_SRCS}
${analytics_platform_SRCS})
set_property(TARGET firebase_analytics PROPERTY FOLDER "Firebase Cpp")
# Set up the dependency on Firebase App.
target_link_libraries(firebase_analytics
PUBLIC firebase_app)
# Public headers all refer to each other relative to the src/include directory,
# while private headers are relative to the entire C++ SDK directory.
target_include_directories(firebase_analytics
PUBLIC
${CMAKE_CURRENT_LIST_DIR}/src/include
${FIREBASE_GEN_FILE_DIR}/analytics/src/include
PRIVATE
${FIREBASE_CPP_SDK_ROOT_DIR}
${FIREBASE_GEN_FILE_DIR}
)
target_compile_definitions(firebase_analytics
PRIVATE
-DINTERNAL_EXPERIMENTAL=1
)
# Automatically include headers that might not be declared.
if(MSVC)
add_definitions(/FI"assert.h" /FI"string.h" /FI"stdint.h")
else()
add_definitions(-include assert.h -include string.h)
endif()
if(ANDROID)
firebase_cpp_proguard_file(analytics)
elseif(IOS)
# Enable Automatic Reference Counting (ARC) and Bitcode.
target_compile_options(firebase_analytics
PUBLIC "-fobjc-arc" "-fembed-bitcode")
target_link_libraries(firebase_analytics
PUBLIC "-fembed-bitcode")
setup_pod_headers(
firebase_analytics
POD_NAMES
FirebaseCore
FirebaseAnalytics
)
if (FIREBASE_XCODE_TARGET_FORMAT STREQUAL "frameworks")
set_target_properties(firebase_analytics PROPERTIES
FRAMEWORK TRUE
)
endif()
endif()
if(FIREBASE_CPP_BUILD_TESTS)
# Add the tests subdirectory
add_subdirectory(tests)
endif()
cpp_pack_library(firebase_analytics "")
cpp_pack_public_headers()