Skip to content

Commit f2661d2

Browse files
committed
support md/mt properly on windows
Using a top level CMake option to drive /mt vs /md.
1 parent aba3091 commit f2661d2

File tree

3 files changed

+86
-17
lines changed

3 files changed

+86
-17
lines changed

.github/workflows/desktop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
for api in $apilist; do
103103
set +f
104104
echo "$api"
105-
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
105+
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 }}
106106
done
107107
set +f
108108
IFS=$OLDIFS

auth/testapp/CMakeLists.txt

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR})
1515
message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information")
1616
endif()
1717

18-
# Windows runtime mode, either MD or MT depending on whether you are using
19-
# /MD or /MT. For more information see:
20-
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
21-
set(MSVC_RUNTIME_MODE MD)
18+
if (MSVC)
19+
if (MSVC_RUNTIME_LIBRARY_STATIC)
20+
add_compile_options(
21+
$<$<CONFIG:>:/MT>
22+
$<$<CONFIG:Debug>:/MTd>
23+
$<$<CONFIG:Release>:/MT>
24+
)
25+
# Ideally we should be setting this variable as per the Debug/Release config
26+
# (MT vs MTd) but our prebuilt libraries don't ship with Debug builds.
27+
set(MSVC_RUNTIME_MODE MT)
28+
else()
29+
add_compile_options(
30+
$<$<CONFIG:>:/MD>
31+
$<$<CONFIG:Debug>:/MDd>
32+
$<$<CONFIG:Release>:/MD>
33+
)
34+
# Ideally we should be setting this variable as per the Debug/Release config
35+
# (MDd vs MD)but our prebuilt libraries don't ship with Debug builds.
36+
set(MSVC_RUNTIME_MODE MD)
37+
endif()
38+
endif()
2239

2340
project(firebase_testapp)
2441

@@ -69,10 +86,27 @@ if(ANDROID)
6986
else()
7087
# Build a desktop application.
7188

72-
# Windows runtime mode, either MD or MT depending on whether you are using
73-
# /MD or /MT. For more information see:
74-
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
75-
set(MSVC_RUNTIME_MODE MD)
89+
if (MSVC)
90+
if (MSVC_RUNTIME_LIBRARY_STATIC)
91+
add_compile_options(
92+
$<$<CONFIG:>:/MT>
93+
$<$<CONFIG:Debug>:/MTd>
94+
$<$<CONFIG:Release>:/MT>
95+
)
96+
# Ideally we should be setting this variable as per the Debug/Release config
97+
# (MT vs MTd) but our prebuilt libraries don't ship with Debug builds.
98+
set(MSVC_RUNTIME_MODE MT)
99+
else()
100+
add_compile_options(
101+
$<$<CONFIG:>:/MD>
102+
$<$<CONFIG:Debug>:/MDd>
103+
$<$<CONFIG:Release>:/MD>
104+
)
105+
# Ideally we should be setting this variable as per the Debug/Release config
106+
# (MDd vs MD)but our prebuilt libraries don't ship with Debug builds.
107+
set(MSVC_RUNTIME_MODE MD)
108+
endif()
109+
endif()
76110

77111
# Platform abstraction layer for the desktop sample.
78112
set(FIREBASE_SAMPLE_DESKTOP_SRCS

messaging/testapp/CMakeLists.txt

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,27 @@ if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR})
1515
message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information")
1616
endif()
1717

18-
# Windows runtime mode, either MD or MT depending on whether you are using
19-
# /MD or /MT. For more information see:
20-
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
21-
set(MSVC_RUNTIME_MODE MD)
18+
if (MSVC)
19+
if (MSVC_RUNTIME_LIBRARY_STATIC)
20+
add_compile_options(
21+
$<$<CONFIG:>:/MT>
22+
$<$<CONFIG:Debug>:/MTd>
23+
$<$<CONFIG:Release>:/MT>
24+
)
25+
# Ideally we should be setting this variable as per the Debug/Release config
26+
# (MT vs MTd) but our prebuilt libraries don't ship with Debug builds.
27+
set(MSVC_RUNTIME_MODE MT)
28+
else()
29+
add_compile_options(
30+
$<$<CONFIG:>:/MD>
31+
$<$<CONFIG:Debug>:/MDd>
32+
$<$<CONFIG:Release>:/MD>
33+
)
34+
# Ideally we should be setting this variable as per the Debug/Release config
35+
# (MDd vs MD)but our prebuilt libraries don't ship with Debug builds.
36+
set(MSVC_RUNTIME_MODE MD)
37+
endif()
38+
endif()
2239

2340
project(firebase_testapp)
2441

@@ -69,10 +86,28 @@ if(ANDROID)
6986
else()
7087
# Build a desktop application.
7188

72-
# Windows runtime mode, either MD or MT depending on whether you are using
73-
# /MD or /MT. For more information see:
74-
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
75-
set(MSVC_RUNTIME_MODE MD)
89+
if (MSVC)
90+
if (MSVC_RUNTIME_LIBRARY_STATIC)
91+
add_compile_options(
92+
$<$<CONFIG:>:/MT>
93+
$<$<CONFIG:Debug>:/MTd>
94+
$<$<CONFIG:Release>:/MT>
95+
)
96+
# Ideally we should be setting this variable as per the Debug/Release config
97+
# (MT vs MTd) but our prebuilt libraries don't ship with Debug builds.
98+
set(MSVC_RUNTIME_MODE MT)
99+
else()
100+
add_compile_options(
101+
$<$<CONFIG:>:/MD>
102+
$<$<CONFIG:Debug>:/MDd>
103+
$<$<CONFIG:Release>:/MD>
104+
)
105+
# Ideally we should be setting this variable as per the Debug/Release config
106+
# (MDd vs MD)but our prebuilt libraries don't ship with Debug builds.
107+
set(MSVC_RUNTIME_MODE MD)
108+
endif()
109+
endif()
110+
76111

77112
# Platform abstraction layer for the desktop sample.
78113
set(FIREBASE_SAMPLE_DESKTOP_SRCS

0 commit comments

Comments
 (0)