Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dotnet & Mono build warnings #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
60 changes: 30 additions & 30 deletions cmake/Modules/FindCSBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ list(INSERT CMAKE_MODULE_PATH 0 "${dotnet_cmake_module_DIR}/Modules/dotnet")
include(FindPackageHandleStandardArgs)

if(CSBUILD_TOOL MATCHES "Mono|DotNetCore")
set(MONO_FOUND FALSE)
set(DOTNET_CORE_FOUND FALSE)
set(Mono_FOUND FALSE)
set(DotNetCore_FOUND FALSE)
find_package(${CSBUILD_TOOL} REQUIRED)
endif()
if(NOT DOTNET_CORE_FOUND AND NOT MONO_FOUND)
if(NOT DotNetCore_FOUND AND NOT Mono_FOUND)
if(CSBUILD_TOOL)
message(WARNING "Ignored -DCSBUILD_TOOL=${CSBUILD_TOOL} it does not match Mono|DotNetCore")
endif()
find_package(DotNetCore)
if(NOT DOTNET_CORE_FOUND)
if(NOT DotNetCore_FOUND)
find_package(Mono)
endif()

Expand All @@ -35,52 +35,52 @@ if(NOT CSHARP_TARGET_FRAMEWORK)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(DOTNET_CORE_PLATFORM "linux")
set(DotNetCore_PLATFORM "linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(DOTNET_CORE_PLATFORM "osx")
set(DotNetCore_PLATFORM "osx")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(DOTNET_CORE_PLATFORM "win")
set(DotNetCore_PLATFORM "win")
else()
message(FATAL_ERROR "Unknown value for CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
endif()

if(MSVC)
string(FIND ${CMAKE_GENERATOR} "ARM" IS_ARM)
if(IS_ARM GREATER -1)
set(DOTNET_CORE_ARCH "arm")
set(DotNetCore_ARCH "arm")
endif()
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")
set(DOTNET_CORE_ARCH "arm")
set(DotNetCore_ARCH "arm")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(DOTNET_CORE_ARCH "arm64")
set(DotNetCore_ARCH "arm64")
endif()

if(NOT DOTNET_CORE_ARCH)
if(NOT DotNetCore_ARCH)
if(CMAKE_SIZEOF_VOID_P EQUAL "4" OR FORCE_X86)
set(CSHARP_PLATFORM "x86" CACHE STRING "C# target platform: x86, x64, anycpu, or itanium")
set(DOTNET_CORE_ARCH "x86")
set(DotNetCore_ARCH "x86")
elseif(CMAKE_SIZEOF_VOID_P EQUAL "8")
if(MONO_FOUND AND "${MONO_VERSION}" VERSION_LESS "2.10.10")
if(Mono_FOUND AND "${Mono_VERSION}" VERSION_LESS "2.10.10")
set(CSHARP_PLATFORM "anycpu" CACHE STRING "C# target platform: x86, x64, anycpu, or itanium")
else()
set(CSHARP_PLATFORM "x64" CACHE STRING "C# target platform: x86, x64, anycpu, or itanium")
set(DOTNET_CORE_ARCH "x64")
set(DotNetCore_ARCH "x64")
endif()
else()
message(FATAL_ERROR "Only 32-bit and 64-bit are supported: ${CMAKE_SIZEOF_VOID_P}")
endif()
endif()

if(DOTNET_CORE_FOUND)
if(NOT DOTNET_CORE_PLATFORM)
if(DotNetCore_FOUND)
if(NOT DotNetCore_PLATFORM)
message(FATAL_ERROR "Missing .NET Core platform")
endif()

if(NOT DOTNET_CORE_ARCH)
if(NOT DotNetCore_ARCH)
message(FATAL_ERROR "Missing .NET Core arch")
endif()

set(DOTNET_CORE_RUNTIME "${DOTNET_CORE_PLATFORM}-${DOTNET_CORE_ARCH}")
set(DotNetCore_RUNTIME "${DotNetCore_PLATFORM}-${DotNetCore_ARCH}")
endif()

if(MSVC)
Expand All @@ -97,27 +97,27 @@ string(REPLACE "." "" _version "${CSHARP_TARGET_FRAMEWORK_VERSION}")
set(CSBUILD_FOUND TRUE)
set(CSBUILD_RESTORE_FLAGS "/version")
set(CSBUILD_BUILD_FLAGS "")
if(DOTNET_CORE_FOUND)
message(STATUS "Found .NET Core: ${DOTNET_CORE_VERSION}")
set(CSBUILD_EXECUTABLE "${DOTNET_CORE_EXECUTABLE}")
if(DotNetCore_FOUND)
message(STATUS "Found .NET Core: ${DotNetCore_VERSION}")
set(CSBUILD_EXECUTABLE "${DotNetCore_EXECUTABLE}")
set(CSBUILD_CSPROJ "dotnetcore.csproj")
set(CSBUILD_BUILD_FLAGS "publish;-r;${DOTNET_CORE_RUNTIME}")
set(CSBUILD_BUILD_FLAGS "publish;-r;${DotNetCore_RUNTIME}")
set(CSBUILD_OUPUT_PREFIX "${CSHARP_TARGET_FRAMEWORK}/publish/")
set(CSHARP_INTERPRETER "${DOTNET_CORE_EXECUTABLE}")
set(CSBUILD_RESTORE_FLAGS "restore;-r;${DOTNET_CORE_RUNTIME}")
set(CSHARP_INTERPRETER "${DotNetCore_EXECUTABLE}")
set(CSBUILD_RESTORE_FLAGS "restore;-r;${DotNetCore_RUNTIME}")
set(CSHARP_TYPE "${CSHARP_TARGET_FRAMEWORK}")
elseif(MONO_FOUND)
message(STATUS "Found Mono: ${MONO_VERSION}")
elseif(Mono_FOUND)
message(STATUS "Found Mono: ${Mono_VERSION}")
set(CSBUILD_EXECUTABLE "${XBUILD_EXECUTABLE}")
set(CSBUILD_CSPROJ "msbuild.csproj")
set(CSBUILD_OUPUT_PREFIX "")
set(CSHARP_INTERPRETER "${MONO_EXECUTABLE}")
set(CSHARP_INTERPRETER "${Mono_EXECUTABLE}")
set(CSHARP_TYPE "net${_version}")
else()
set(CSBUILD_FOUND FALSE)
endif()

if(NOT CSHARP_PLATFORM AND NOT DOTNET_CORE_FOUND)
if(NOT CSHARP_PLATFORM AND NOT DotNetCore_FOUND)
message(FATAL_ERROR "CSHARP_PLATFORM not set")
endif()

Expand All @@ -127,9 +127,9 @@ endif()

if(CSBUILD_FOUND)
message(STATUS "Using Framework: ${CSHARP_TARGET_FRAMEWORK}")
if(DOTNET_CORE_FOUND)
if(DotNetCore_FOUND)
message(STATUS "Using Framework: ${CSHARP_TARGET_FRAMEWORK}")
message(STATUS "Using Runtime: ${DOTNET_CORE_RUNTIME}")
message(STATUS "Using Runtime: ${DotNetCore_RUNTIME}")
else()
find_program(NUGET_EXE nuget)
set(RESTORE_EXE ${NUGET_EXE})
Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/FindDotNETExtra.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function(install_dotnet _TARGET_NAME)
get_target_property(_target_executable ${_TARGET_NAME} EXECUTABLE)
get_target_property(_target_path ${_TARGET_NAME} OUTPUT_PATH)
get_target_property(_target_name ${_TARGET_NAME} OUTPUT_NAME)
get_target_property(_target_dotnet_core ${_TARGET_NAME} DOTNET_CORE)
get_target_property(_target_DotNetCore ${_TARGET_NAME} DotNetCore)

if (ARGC EQUAL 2)
set (_DESTINATION ${ARGV1})
Expand Down
32 changes: 16 additions & 16 deletions cmake/Modules/dotnet/FindDotNetCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
#
# Find the msbuild tool
#
# DOTNET_CORE_FOUND System has msbuild
# DOTNET_CORE_EXECUTABLE Where to find csc
# DOTNET_CORE_VERSION The version number of the DotNet framework
# DotNetCore_FOUND System has msbuild
# DotNetCore_EXECUTABLE Where to find csc
# DotNetCore_VERSION The version number of the DotNet framework

set(DOTNET_CORE_ROOT "" CACHE PATH "Set the location of the .NET root directory")
set(DOTNET_CORE_VERSION "" CACHE STRING "C# .NET compiler version")
set(DotNetCore_ROOT "" CACHE PATH "Set the location of the .NET root directory")
set(DotNetCore_VERSION "" CACHE STRING "C# .NET compiler version")

if(DOTNET_CORE_ROOT AND EXISTS "${DOTNET_CORE_ROOT}")
find_program(DOTNET_CORE_EXECUTABLE dotnet dotnet.exe
PATHS ${DOTNET_CORE_ROOT}
if(DotNetCore_ROOT AND EXISTS "${DotNetCore_ROOT}")
find_program(DotNetCore_EXECUTABLE dotnet dotnet.exe
PATHS ${DotNetCore_ROOT}
PATH_SUFFIXES . bin
NO_DEFAULT_PATH)
endif()


find_program(DOTNET_CORE_EXECUTABLE dotnet dotnet.exe)
find_program(DotNetCore_EXECUTABLE dotnet dotnet.exe)

if(EXISTS "${DOTNET_CORE_EXECUTABLE}")
if(EXISTS "${DotNetCore_EXECUTABLE}")
execute_process(
COMMAND ${DOTNET_CORE_EXECUTABLE} --version
OUTPUT_VARIABLE dotnet_core_version_string
COMMAND ${DotNetCore_EXECUTABLE} --version
OUTPUT_VARIABLE DotNetCore_version_string
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX MATCH "([0-9]*)([.])([0-9]*)([.]*)([0-9]*)" dotnet_core_version_string "${dotnet_core_version_string}")
set(DOTNET_CORE_VERSION ${dotnet_core_version_string} CACHE STRING ".NET coreclr version" FORCE)
string(REGEX MATCH "([0-9]*)([.])([0-9]*)([.]*)([0-9]*)" DotNetCore_version_string "${DotNetCore_version_string}")
set(DotNetCore_VERSION ${DotNetCore_version_string} CACHE STRING ".NET coreclr version" FORCE)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DOTNET_CORE DEFAULT_MSG DOTNET_CORE_EXECUTABLE)
mark_as_advanced(DOTNET_CORE_EXECUTABLE DOTNET_CORE_VERSION)
find_package_handle_standard_args(DotNetCore DEFAULT_MSG DotNetCore_EXECUTABLE)
mark_as_advanced(DotNetCore_EXECUTABLE DotNetCore_VERSION)

56 changes: 28 additions & 28 deletions cmake/Modules/dotnet/FindMono.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,69 @@
# Based on
# https://github.com/Illumina/interop/tree/master/cmake/Modules
#
# Find the xbuild tool and mono interpreter
# Find the xbuild tool and Mono interpreter
#
# MONO_FOUND System has Mono dev files, as well as mono, mcs, gmcs and gacutil if not MONO_ONLY_LIBRARIES_REQUIRED
# MONO_EXECUTABLE Where to find 'mono'
# Mono_FOUND System has Mono dev files, as well as Mono, mcs, gmcs and gacutil if not Mono_ONLY_LIBRARIES_REQUIRED
# Mono_EXECUTABLE Where to find 'Mono'
# XBUILD_EXECUTABLE Where to find 'xbuild'
# MONO_VERSION The version number of the Mono interpreter
# Mono_VERSION The version number of the Mono interpreter

set(MONO_ROOT "" CACHE PATH "Set the location of the Mono root directory")
set(Mono_ROOT "" CACHE PATH "Set the location of the Mono root directory")

if(MONO_ROOT AND EXISTS "${MONO_ROOT}")
find_program(MONO_EXECUTABLE mono
PATHS ${MONO_ROOT} ${MONO_ROOT}/lib/mono/1.0
if(Mono_ROOT AND EXISTS "${Mono_ROOT}")
find_program(Mono_EXECUTABLE Mono
PATHS ${Mono_ROOT} ${Mono_ROOT}/lib/Mono/1.0
PATH_SUFFIXES bin
NO_DEFAULT_PATH)
find_program(XBUILD_EXECUTABLE xbuild
PATHS ${MONO_ROOT} ${MONO_ROOT}/lib/mono/1.0
PATHS ${Mono_ROOT} ${Mono_ROOT}/lib/Mono/1.0
PATH_SUFFIXES bin
NO_DEFAULT_PATH)
endif()

find_program(MONO_EXECUTABLE mono)
find_program(Mono_EXECUTABLE Mono)
find_program(XBUILD_EXECUTABLE xbuild)

if(WIN32)
set(MONO_CLR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono;DefaultCLR]")
get_filename_component(csharp_mono_bin_hints "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\${MONO_CLR};SdkInstallRoot]/bin" ABSOLUTE)
set(Mono_CLR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono;DefaultCLR]")
get_filename_component(csharp_Mono_bin_hints "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Novell\\Mono\\${Mono_CLR};SdkInstallRoot]/bin" ABSOLUTE)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(csharp_mono_bin_hints
set(csharp_Mono_bin_hints
"/Library/Frameworks/Mono.framework/Commands"
"/usr"
"/usr/local"
"/usr/lib/mono/2.0"
"/opt/novell/mono")
"/usr/lib/Mono/2.0"
"/opt/novell/Mono")
else()
set(csharp_mono_bin_hints
set(csharp_Mono_bin_hints
"/usr/bin/"
"/usr/local/bin/"
"/usr/lib/mono/2.0"
"/opt/novell/mono/bin")
"/usr/lib/Mono/2.0"
"/opt/novell/Mono/bin")
endif()

find_program(MONO_EXECUTABLE mono mono.exe
HINTS ${csharp_mono_bin_hints}
find_program(Mono_EXECUTABLE Mono Mono.exe
HINTS ${csharp_Mono_bin_hints}
PATH_SUFFIXES bin
NO_DEFAULT_PATH
)

find_program(XBUILD_EXECUTABLE xbuild xbuild.exe
HINTS ${csharp_mono_bin_hints}
HINTS ${csharp_Mono_bin_hints}
PATH_SUFFIXES bin
NO_DEFAULT_PATH
)

if(EXISTS "${MONO_EXECUTABLE}")
if(EXISTS "${Mono_EXECUTABLE}")
execute_process(
COMMAND ${MONO_EXECUTABLE} -V
OUTPUT_VARIABLE csharp_mono_version_string
COMMAND ${Mono_EXECUTABLE} -V
OUTPUT_VARIABLE csharp_Mono_version_string
)
string(REGEX MATCH "([0-9]*)([.])([0-9]*)([.]*)([0-9]*)" csharp_mono_version_temp "${csharp_mono_version_string}")
set(MONO_VERSION ${csharp_mono_version_temp} CACHE STRING "C# Mono interpreter version")
string(REGEX MATCH "([0-9]*)([.])([0-9]*)([.]*)([0-9]*)" csharp_Mono_version_temp "${csharp_Mono_version_string}")
set(Mono_VERSION ${csharp_Mono_version_temp} CACHE STRING "C# Mono interpreter version")
endif()


include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MONO DEFAULT_MSG XBUILD_EXECUTABLE MONO_EXECUTABLE)
mark_as_advanced(MONO_EXECUTABLE XBUILD_EXECUTABLE MONO_VERSION)
find_package_handle_standard_args(Mono DEFAULT_MSG XBUILD_EXECUTABLE Mono_EXECUTABLE)
mark_as_advanced(Mono_EXECUTABLE XBUILD_EXECUTABLE Mono_VERSION)
8 changes: 4 additions & 4 deletions cmake/Modules/dotnet/UseCSharpProjectBuilder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function(csharp_add_project name)
set(CSHARP_IMPORTS "")
endif()

if(${_csharp_add_project_EXECUTABLE} AND NOT DOTNET_CORE_FOUND)
if(${_csharp_add_project_EXECUTABLE} AND NOT DotNetCore_FOUND)
set(ext "exe")
else()
set(ext "dll")
Expand Down Expand Up @@ -178,7 +178,7 @@ function(csharp_add_project name)
DEPENDS ${sources_dep}
)

set(DOTNET_OUTPUT_PATH ${CSHARP_BUILDER_OUTPUT_PATH}/${CSHARP_TARGET_FRAMEWORK}/${DOTNET_CORE_RUNTIME}/publish/)
set(DOTNET_OUTPUT_PATH ${CSHARP_BUILDER_OUTPUT_PATH}/${CSHARP_TARGET_FRAMEWORK}/${DotNetCore_RUNTIME}/publish/)

set_target_properties(${name}
PROPERTIES
Expand All @@ -188,7 +188,7 @@ function(csharp_add_project name)
${DOTNET_OUTPUT_PATH}
OUTPUT_NAME
${name}${CSBUILD_OUTPUT_SUFFIX}.${ext}
DOTNET_CORE
${DOTNET_CORE_FOUND}
DotNetCore
${DotNetCore_FOUND}
)
endfunction()