Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__pycache__/
*.py[cod]
*$py.class
*.pyc

### Gradle ###
.gradle
Expand All @@ -20,3 +21,6 @@ gcs_key_file.json
*_build/
*_unity/
*_unity_seperate/

# Windows ignore
vcpkg
2 changes: 1 addition & 1 deletion build_bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CMAKE_OPTIONS="${CMAKE_OPTIONS} -DFIREBASE_UNITY_BUILD_TESTS=ON"
build_options=(
"unity:-DFIREBASE_INCLUDE_UNITY=ON"
# "mono:-DFIREBASE_INCLUDE_MONO=ON"
"unity_separate:-DFIREBASE_INCLUDE_UNITY=ON -DFIREBASE_UNI_LIBRARY=OFF"
# "unity_separate:-DFIREBASE_INCLUDE_UNITY=ON -DFIREBASE_UNI_LIBRARY=OFF"
# "mono_separate:-DFIREBASE_INCLUDE_MONO=ON -DFIREBASE_UNI_LIBRARY=OFF"
)

Expand Down
2 changes: 1 addition & 1 deletion build_windows_x32.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ IF EXIST ..\firebase-cpp-sdk (
IF EXIST "C:\Program Files (x86)\Mono\bin" (
SET MONO_DIR="C:/Program Files (x86)/Mono/bin"
) ELSE (
ECHO ERROR: Cant find mono
ECHO ERROR: Cant find mono in programs files x86
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are being more specific with the error here, as a user, it will be awesome to see something like this,
"Can't find mono in C:\Program Files (x86)".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried somehow the .bat file doesn't like it....

EXIT /B -1
)

Expand Down
6 changes: 3 additions & 3 deletions build_windows_x64.bat
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ IF EXIST ..\firebase-cpp-sdk (
SET CPP_DIR=-DFIREBASE_CPP_SDK_DIR^=../../firebase-cpp-sdk
)

IF EXIST "C:\Program Files (x86)\Mono\bin" (
SET MONO_DIR="C:/Program Files (x86)/Mono/bin"
IF EXIST "C:\Program Files\Mono\bin" (
SET MONO_DIR="C:/Program Files/Mono/bin"
) ELSE (
ECHO ERROR: Cant find mono
ECHO ERROR: Cant find mono in program files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

EXIT /B -1
)

Expand Down
108 changes: 108 additions & 0 deletions cmake/FindMono.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Copyright 2021 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.

# Locates the Mono launcher and build tool.
#
# Optional variable arguments for this module:
# MONO_DIR: Variable to specify a search path for Mono.
# MONO_DISABLE_VISUAL_STUDIO_FALLBACK: Do not use Visual Studio's msbuild
# as a fallback on Windows when using the Visual Studio project generator.
#
# Cache variables set by this module:
# MONO_EXE: Location of the Mono interpreter executable.
# MONO_VERSION: Version of the detected Mono installation.
# MONO_CSHARP_BUILD_EXE: Location of the tool (e.g msbuild or xbuild) that
# can build .csproj projects.

# If MONO_DIR is specified, only search that path.
set(FIND_MONO_OPTIONS "")
if(EXISTS "${MONO_DIR}")
set(FIND_MONO_OPTIONS
PATHS
"${MONO_DIR}"
"${MONO_DIR}/lib/mono"
PATH_SUFFIXES
bin
NO_DEFAULT_PATH
)
endif()

# Search for Mono tools.
find_program(MONO_EXE mono
${FIND_MONO_OPTIONS}
)
find_program(MONO_CSHARP_BUILD_EXE
NAMES
msbuild
xbuild
${FIND_MONO_OPTIONS}
)

if(CMAKE_HOST_WIN32 AND
NOT MONO_DISABLE_VISUAL_STUDIO_FALLBACK AND
EXISTS "${CMAKE_VS_MSBUILD_COMMAND}")
if(NOT MONO_CSHARP_BUILD_EXE)
# If Mono's build tool isn't found, fallback to Visual Studio.
message(STATUS "Mono installation not found, trying to fallback "
"to Visual Studio's msbuild ${CMAKE_VS_MSBUILD_COMMAND}."
)
set(MONO_CSHARP_BUILD_EXE "${CMAKE_VS_MSBUILD_COMMAND}"
CACHE STRING "" FORCE
)
endif()
if(NOT MONO_EXE)
# Just use cmake to launch the C# executable which should run on Windows if
# the .NET framework is installed.
# NOTE: This does not use cmd as CTest passes a path with / path separators
# to CreateProcess() causing cmd to fail to start.
set(MONO_EXE "${CMAKE_COMMAND};-E;env" CACHE STRING "" FORCE)
endif()
endif()

# If the mono executable is found, and retrieve the version.
if(MONO_EXE)
if(EXISTS "${MONO_EXE}")
execute_process(
COMMAND ${MONO_EXE} -V
OUTPUT_VARIABLE MONO_VERSION_STRING
RESULT_VARIABLE RESULT
)
if(NOT ${RESULT} EQUAL "0")
message(FATAL_ERROR "${MONO_EXE} -V returned ${RESULT}.")
endif()
string(REGEX MATCH "([0-9]*)([.])([0-9]*)([.]*)([0-9]*)"
MONO_VERSION_MATCH "${MONO_VERSION_STRING}")
set(MONO_VERSION "${MONO_VERSION_MATCH}" CACHE STRING "Mono version.")
else()
set(MONO_VERSION "0.0.0" CACHE STRING "Mono version.")
endif()
endif()

if(NOT MONO_EXE OR NOT MONO_CSHARP_BUILD_EXE)
message(FATAL_ERROR "Cannot find mono and msbuild/xbuild executables.")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Mono
DEFAULT_MSG
MONO_EXE
MONO_CSHARP_BUILD_EXE
MONO_VERSION
)
mark_as_advanced(
MONO_EXE
MONO_CSHARP_BUILD_EXE
MONO_VERSION
)
Loading