# 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_rest_lib library cmake_minimum_required (VERSION 3.1) # Firebase C++ SDK requires C++14. set (CMAKE_CXX_STANDARD 14) set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version. project(firebase_rest_lib NONE) enable_language(C) enable_language(CXX) set(rest_SRCS controller_curl.cc controller_interface.cc gzipheader.cc request.cc request_binary_gzip.cc request_file.cc response.cc response_binary.cc transport_builder.cc transport_curl.cc transport_interface.cc util.cc www_form_url_encoded.cc zlibwrapper.cc) add_library(firebase_rest_lib STATIC ${rest_SRCS}) target_include_directories(firebase_rest_lib PUBLIC ${FIREBASE_CPP_SDK_ROOT_DIR} ${FLATBUFFERS_SOURCE_DIR}/include ${ZLIB_SOURCE_DIR}/.. ${ZLIB_BINARY_DIR} PRIVATE ${CURL_SOURCE_DIR}/include ) if(MSVC) set(rest_additional_defines -DWIN32_LEAN_AND_MEAN CURL_STATICLIB=1 ) elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(rest_additional_defines -DFIREBASE_SSL_CAPATH="/etc/ssl/certs" ) else() set(rest_additional_defines) endif() target_compile_definitions(firebase_rest_lib PRIVATE -DINTERNAL_EXPERIMENTAL=1 "${rest_additional_defines}" ) set(FIREBASE_CURL_DEPENDENCY libcurl) if (MSVC) # libcurl on Windows depends on internal Windows SSL via its crypt32 library. set(FIREBASE_CURL_DEPENDENCY ${FIREBASE_CURL_DEPENDENCY} crypt32) endif() # firebase_rest_lib has a dependency on flatbuffers, which needs to be included. target_link_libraries(firebase_rest_lib PUBLIC firebase_app PRIVATE flatbuffers ${FIREBASE_CURL_DEPENDENCY} zlibstatic ${CMAKE_DL_LIBS} ) # 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() # Add shared definitions across all platforms, and then platform specific ones. add_definitions( # Use the curl_config.h generated by CMake. -DHAVE_CONFIG_H # Enable ZLIB in curl. -DHAVE_LIBZ # Ensure curl includes ZLIB headers. -DHAVE_ZLIB_H # Enforce stricter curl typechecking. -DCURL_STRICTER # Disable unused protocols/options to reduce vulnerability surface. -DCURL_DISABLE_FTP -DCURL_DISABLE_NTLM -DCURL_DISABLE_LIBCURL_OPTION ) if(WIN32) # Add definitons used for the Windows builds. add_definitions( # Increase curl's default buffer size to increase throughput. -DCURL_MAX_WRITE_SIZE=16384 # Enable SCHANNEL for Windows -DUSE_SCHANNEL -DUSE_WINDOWS_SSPI # Force synchronous DNS # (async DNS does not work with SCHANNEL). -DUSE_SYNC_DNS ) elseif(APPLE) # MacOS does not have any unique definitions. else() # Add definitions used for Linux builds, but not MacOS. add_definitions( # Increase curl's default buffer size to increase throughput. -DCURL_MAX_WRITE_SIZE=65536 ) endif() if(FIREBASE_CPP_BUILD_TESTS) # Add the tests subdirectory add_subdirectory(tests) endif() cpp_pack_library(firebase_rest_lib "deps/app") cpp_pack_library(libcurl "deps/app/external") cpp_pack_library(zlibstatic "deps/app/external") cpp_pack_library_file(${OPENSSL_SSL_LIBRARY} "deps/app/external") cpp_pack_library_file(${OPENSSL_CRYPTO_LIBRARY} "deps/app/external")