1
+ # Copyright 2019 Google
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ set (FUTURE_LIB_SRC_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE INTERNAL "" )
16
+
17
+ # Defines a Future library for the given namespace
18
+ function (define_future_lib CPP_NAMESPACE)
19
+ set (library_name "${CPP_NAMESPACE} _future" )
20
+
21
+ # Modify the public Future header with the new namespace
22
+ file (READ
23
+ ${FUTURE_LIB_SRC_DIR} /../app/src/include /firebase/future.h
24
+ old_future_header)
25
+ string (TOUPPER ${CPP_NAMESPACE} upper_namespace)
26
+ set (new_header_guard "FUTURE_INCLUDE_${upper_namespace} _FUTURE_H_" )
27
+ string (REPLACE
28
+ FIREBASE_APP_CLIENT_CPP_SRC_INCLUDE_FIREBASE_FUTURE_H_
29
+ ${new_header_guard}
30
+ future_header_guard_changed
31
+ "${old_future_header} " )
32
+ string (REPLACE
33
+ "namespace FIREBASE_NAMESPACE {"
34
+ "namespace ${CPP_NAMESPACE} {"
35
+ future_header_namespace_changed
36
+ "${future_header_guard_changed} " )
37
+ file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR} /future_include/${CPP_NAMESPACE} )
38
+ set (generated_future_header_path
39
+ "${PROJECT_BINARY_DIR} /future_include/${CPP_NAMESPACE} /future.h" )
40
+ #TODO Change to use a configure_file, will need to change future.h, and the
41
+ # Firebase library to use it as well.
42
+ file (WRITE
43
+ ${generated_future_header_path}
44
+ "${future_header_namespace_changed} " )
45
+
46
+ if (ANDROID OR DEFINED ANDROID_NDK)
47
+ set (log_SRCS
48
+ ${FUTURE_LIB_SRC_DIR} /../app/src/log .cc
49
+ ${FUTURE_LIB_SRC_DIR} /../app/src/log_android.cc)
50
+ elseif (IOS OR "${CMAKE_OSX_SYSROOT} " MATCHES "iphoneos" )
51
+ set (log_SRCS
52
+ ${FUTURE_LIB_SRC_DIR} /../app/src/log .cc
53
+ ${FUTURE_LIB_SRC_DIR} /../app/src/log_ios.mm)
54
+ else ()
55
+ set (log_SRCS
56
+ ${FUTURE_LIB_SRC_DIR} /../app/src/log .cc
57
+ ${FUTURE_LIB_SRC_DIR} /../app/src/log_stdio.cc)
58
+ endif ()
59
+
60
+ add_library ("${library_name} " STATIC
61
+ ${FUTURE_LIB_SRC_DIR} /../app/src/cleanup_notifier.cc
62
+ ${FUTURE_LIB_SRC_DIR} /../app/src/future_manager.cc
63
+ ${FUTURE_LIB_SRC_DIR} /../app/src/reference_counted_future_impl.cc
64
+ ${generated_future_header_path}
65
+ ${log_SRCS} )
66
+
67
+ target_compile_definitions ("${library_name} "
68
+ PRIVATE
69
+ -DFIREBASE_NAMESPACE=${CPP_NAMESPACE}
70
+ )
71
+ if ("${CPP_NAMESPACE} " STREQUAL "playbillingclient" )
72
+ target_compile_definitions ("${library_name} "
73
+ PRIVATE
74
+ -DUSE_PLAYBILLING_FUTURE=1
75
+ )
76
+ endif ()
77
+ target_include_directories ("${library_name} "
78
+ PUBLIC
79
+ ${PROJECT_BINARY_DIR} /future_include
80
+ PRIVATE
81
+ ${FUTURE_LIB_SRC_DIR} /..
82
+ ${FUTURE_LIB_SRC_DIR} /../app/src/include
83
+ )
84
+ endfunction ()
0 commit comments