diff --git a/.github/workflows/desktop.yml b/.github/workflows/desktop.yml new file mode 100644 index 00000000..3c4ddeb1 --- /dev/null +++ b/.github/workflows/desktop.yml @@ -0,0 +1,167 @@ +name: Desktop builds + +on: + push: + + workflow_dispatch: + inputs: + downloadPublicVersion: + description: 'public version # to test against' + apis: + description: 'CSV of apis whose quickstart examples we should build' + default: 'admob,analytics,auth,database,dynamic_links,firestore,functions,messaging,remote_config,storage' + required: true + +jobs: + build: + name: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.architecture }}-${{ matrix.msvc_runtime}} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + build_type: ["Release", "Debug"] + architecture: ["x64", "x86"] + msvc_runtime: ["static", "dynamic"] + python_version: [3.7] + + include: + - os: windows-latest + vcpkg_triplet_suffix: "windows-static" + - os: windows-latest + msvc_runtime: "dynamic" + vcpkg_triplet_suffix: "windows-static-md" + - os: ubuntu-latest + vcpkg_triplet_suffix: "linux" + - os: macos-latest + vcpkg_triplet_suffix: "osx" + + exclude: + - os: macos-latest + architecture: "x86" + - os: macos-latest + msvc_runtime: "dynamic" + - os: ubuntu-latest + msvc_runtime: "dynamic" + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - uses: actions/checkout@v2 + with: + repository: 'firebase/firebase-cpp-sdk' + ref : 'dev' + submodules: true + path: 'firebase-cpp-sdk-source' + + - name: download public SDK package from web + if: ${{ github.event.inputs.downloadPublicVersion != '' }} + shell: bash + run: | + if [[ ! "${{ github.event.inputs.downloadPublicVersion }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo Invalid version number: "${{ github.event.inputs.downloadPublicVersion }}" + exit 1 + fi + set +e + # Retry up to 10 times because Curl has a tendency to timeout on + # Github runners. + for retry in {1..10} error; do + if [[ $retry == "error" ]]; then exit 5; fi + curl -L https://dl.google.com/firebase/sdk/cpp/firebase_cpp_sdk_${{ github.event.inputs.downloadPublicVersion }}.zip --output firebase_cpp_sdk.zip && break + sleep 300 + done + set -e + + - name: Unzip Firebase C++ SDK + shell: bash + if: ${{ github.event.inputs.downloadPublicVersion != '' }} + run: | + ls + if [ "$RUNNER_OS" == "Windows" ]; then + 7z x firebase_cpp_sdk.zip + else + unzip -q firebase_cpp_sdk.zip + fi + + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version }} + architecture: 'x64' + + - name: Build apps against Firebase C++ source + shell: bash + if: ${{ github.event.inputs.downloadPublicVersion == '' }} + env: + APIS: ${{ github.event.inputs.apis}} + run: | + OLDIFS=$IFS + IFS=',' + set -f + apilist="${APIS:-auth,messaging}" + for api in $apilist; do + set +f + echo "Building quickstart for: $api" + python firebase-cpp-sdk-source/scripts/build_desktop_app_with_firebase.py --sdk_dir firebase-cpp-sdk-source --app_dir $api/testapp --build_dir build --msvc_runtime_library ${{ matrix.msvc_runtime }} --arch ${{ matrix.architecture }} + done + set +f + IFS=$OLDIFS + + - name: Build apps against Firebase C++ prebuilt libraries + shell: bash + if: ${{ github.event.inputs.downloadPublicVersion != '' }} + env: + APIS: ${{ github.event.inputs.apis}} + run: | + OLDIFS=$IFS + IFS=',' + set -f + apilist="${APIS:-auth,messaging}" + for api in $apilist; do + set +f + echo "$api" + python firebase-cpp-sdk-source/scripts/build_desktop_app_with_firebase.py --sdk_dir firebase_cpp_sdk --app_dir $api/testapp --build_dir build --msvc_runtime_library ${{ matrix.msvc_runtime }} + done + set +f + IFS=$OLDIFS + + - name: Print built libraries + shell: bash + env: + APIS: ${{ github.event.inputs.apis}} + run: | + OLDIFS=$IFS + IFS=',' + set -f + apilist="${APIS:-auth,messaging}" + for api in $apilist; do + set +f + find $api/testapp/build -name "*.lib" + find $api/testapp/build -name "*.dll" + find $api/testapp/build -name "*.dylib" + find $api/testapp/build -name "*.a" + find $api/testapp/build -name "*.so" + find $api/testapp/build -name "*.framework" + find $api/testapp/build -name "desktop_testapp*" -type f + done + set +f + IFS=$OLDIFS + + - name: Inspect firebase libraries for cpu arch and msvc runtime. + shell: bash + env: + APIS: ${{ github.event.inputs.apis}} + run: | + OLDIFS=$IFS + IFS=',' + set -f + apilist="${APIS:-auth,messaging}" + for api in $apilist; do + set +f + python firebase-cpp-sdk-source/scripts/gha/inspect_built_libraries.py $api/testapp/build + done + set +f + IFS=$OLDIF + continue-on-error: true diff --git a/admob/testapp/CMakeLists.txt b/admob/testapp/CMakeLists.txt index 3a7d02dd..436203c4 100644 --- a/admob/testapp/CMakeLists.txt +++ b/admob/testapp/CMakeLists.txt @@ -62,10 +62,27 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/analytics/testapp/CMakeLists.txt b/analytics/testapp/CMakeLists.txt index cd156ba0..9b832448 100644 --- a/analytics/testapp/CMakeLists.txt +++ b/analytics/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -69,10 +86,27 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/auth/testapp/CMakeLists.txt b/auth/testapp/CMakeLists.txt index f5aa704f..a3fe07fa 100644 --- a/auth/testapp/CMakeLists.txt +++ b/auth/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -69,10 +86,27 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/database/testapp/CMakeLists.txt b/database/testapp/CMakeLists.txt index d505b0c9..4bebf1ef 100644 --- a/database/testapp/CMakeLists.txt +++ b/database/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -69,10 +86,27 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/dynamic_links/testapp/CMakeLists.txt b/dynamic_links/testapp/CMakeLists.txt index 5574b351..f9a65a99 100644 --- a/dynamic_links/testapp/CMakeLists.txt +++ b/dynamic_links/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -69,10 +86,27 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/firestore/testapp/CMakeLists.txt b/firestore/testapp/CMakeLists.txt index a4dd2727..37decaa3 100644 --- a/firestore/testapp/CMakeLists.txt +++ b/firestore/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -78,11 +95,27 @@ if(ANDROID) set(ADDITIONAL_LIBS) else() # Build a desktop application. - - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/functions/testapp/CMakeLists.txt b/functions/testapp/CMakeLists.txt index c6eb6903..a8cb4a12 100644 --- a/functions/testapp/CMakeLists.txt +++ b/functions/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -69,10 +86,27 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/messaging/testapp/CMakeLists.txt b/messaging/testapp/CMakeLists.txt index 03bd733e..396606c1 100644 --- a/messaging/testapp/CMakeLists.txt +++ b/messaging/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -69,10 +86,28 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() + # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/remote_config/testapp/CMakeLists.txt b/remote_config/testapp/CMakeLists.txt index b83676fe..ba23cacf 100644 --- a/remote_config/testapp/CMakeLists.txt +++ b/remote_config/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -69,10 +86,27 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS diff --git a/storage/testapp/CMakeLists.txt b/storage/testapp/CMakeLists.txt index f885aa89..651f8e44 100644 --- a/storage/testapp/CMakeLists.txt +++ b/storage/testapp/CMakeLists.txt @@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") endif() -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) +if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() +endif() project(firebase_testapp) @@ -69,10 +86,27 @@ if(ANDROID) else() # Build a desktop application. - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) + if (MSVC) + if (MSVC_RUNTIME_LIBRARY_STATIC) + add_compile_options( + $<$:/MT> + $<$:/MTd> + $<$:/MT> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MT vs MTd) but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MT) + else() + add_compile_options( + $<$:/MD> + $<$:/MDd> + $<$:/MD> + ) + # Ideally we should be setting this variable as per the Debug/Release config + # (MDd vs MD)but our prebuilt libraries don't ship with Debug builds. + set(MSVC_RUNTIME_MODE MD) + endif() + endif() # Platform abstraction layer for the desktop sample. set(FIREBASE_SAMPLE_DESKTOP_SRCS