cmake(dotnet): Be able to disable a Target Framework Moniker
This commit is contained in:
@@ -228,6 +228,12 @@ message(STATUS "XPRESS support: ${USE_XPRESS}")
|
||||
if(BUILD_DOTNET)
|
||||
option(UNIVERSAL_DOTNET_PACKAGE "Build a .Net multi OS Package" OFF)
|
||||
message(STATUS ".Net: Create multiple os package: ${UNIVERSAL_DOTNET_PACKAGE}")
|
||||
|
||||
option(USE_DOTNET_TFM_31 "Use .Net Core 3.1 LTS support" ON)
|
||||
message(STATUS ".Net: Use .Net Core 3.1 LTS support: ${USE_DOTNET_TFM_31}")
|
||||
|
||||
option(USE_DOTNET_TFM_60 "Use .Net 6.0 LTS support" ON)
|
||||
message(STATUS ".Net: Use .Net 6.0 LTS support: ${USE_DOTNET_TFM_60}")
|
||||
endif()
|
||||
|
||||
if(BUILD_JAVA)
|
||||
|
||||
@@ -30,6 +30,8 @@ endif()
|
||||
# Needed by dotnet/CMakeLists.txt
|
||||
set(DOTNET_PACKAGE Google.OrTools)
|
||||
set(DOTNET_PACKAGES_DIR "${PROJECT_BINARY_DIR}/dotnet/packages")
|
||||
|
||||
# see: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
|
||||
if(APPLE)
|
||||
set(RUNTIME_IDENTIFIER osx-x64)
|
||||
elseif(UNIX)
|
||||
@@ -44,6 +46,17 @@ message(STATUS ".Net runtime project: ${DOTNET_NATIVE_PROJECT}")
|
||||
set(DOTNET_NATIVE_PROJECT_DIR ${PROJECT_BINARY_DIR}/dotnet/${DOTNET_NATIVE_PROJECT})
|
||||
message(STATUS ".Net runtime project build path: ${DOTNET_NATIVE_PROJECT_DIR}")
|
||||
|
||||
# see: https://docs.microsoft.com/en-us/dotnet/standard/frameworks
|
||||
if(USE_DOTNET_TFM_31 AND USE_DOTNET_TFM_60)
|
||||
set(DOTNET_TFM "<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>")
|
||||
elseif(USE_DOTNET_TFM_60)
|
||||
set(DOTNET_TFM "<TargetFramework>net6.0</TargetFramework>")
|
||||
elseif(USE_DOTNET_TFM_31)
|
||||
set(DOTNET_TFM "<TargetFramework>netcoreapp3.1</TargetFramework>")
|
||||
else()
|
||||
message(FATAL_ERROR "No .Net SDK selected !")
|
||||
endif()
|
||||
|
||||
set(DOTNET_PROJECT ${DOTNET_PACKAGE})
|
||||
message(STATUS ".Net project: ${DOTNET_PROJECT}")
|
||||
set(DOTNET_PROJECT_DIR ${PROJECT_BINARY_DIR}/dotnet/${DOTNET_PROJECT})
|
||||
@@ -368,10 +381,18 @@ function(add_dotnet_sample FILE_NAME)
|
||||
WORKING_DIRECTORY ${DOTNET_SAMPLE_DIR})
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_test(
|
||||
NAME dotnet_${COMPONENT_NAME}_${SAMPLE_NAME}
|
||||
COMMAND ${DOTNET_EXECUTABLE} run --no-build --framework net6.0 -c Release
|
||||
WORKING_DIRECTORY ${DOTNET_SAMPLE_DIR})
|
||||
if(USE_DOTNET_TFM_31)
|
||||
add_test(
|
||||
NAME dotnet_${COMPONENT_NAME}_${SAMPLE_NAME}
|
||||
COMMAND ${DOTNET_EXECUTABLE} run --no-build --framework netcoreapp3.1 -c Release
|
||||
WORKING_DIRECTORY ${DOTNET_SAMPLE_DIR})
|
||||
endif()
|
||||
if(USE_DOTNET_TFM_60)
|
||||
add_test(
|
||||
NAME dotnet_${COMPONENT_NAME}_${SAMPLE_NAME}
|
||||
COMMAND ${DOTNET_EXECUTABLE} run --no-build --framework net6.0 -c Release
|
||||
WORKING_DIRECTORY ${DOTNET_SAMPLE_DIR})
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Configuring sample ${FILE_NAME} done")
|
||||
endfunction()
|
||||
@@ -431,10 +452,18 @@ function(add_dotnet_example FILE_NAME)
|
||||
WORKING_DIRECTORY ${DOTNET_EXAMPLE_DIR})
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_test(
|
||||
NAME dotnet_${COMPONENT_NAME}_${EXAMPLE_NAME}
|
||||
COMMAND ${DOTNET_EXECUTABLE} run --no-build --framework net6.0 -c Release
|
||||
WORKING_DIRECTORY ${DOTNET_EXAMPLE_DIR})
|
||||
if(USE_DOTNET_TFM_31)
|
||||
add_test(
|
||||
NAME dotnet_${COMPONENT_NAME}_${EXAMPLE_NAME}
|
||||
COMMAND ${DOTNET_EXECUTABLE} run --no-build --framework netcoreapp3.1 -c Release
|
||||
WORKING_DIRECTORY ${DOTNET_EXAMPLE_DIR})
|
||||
endif()
|
||||
if(USE_DOTNET_TFM_60)
|
||||
add_test(
|
||||
NAME dotnet_${COMPONENT_NAME}_${EXAMPLE_NAME}
|
||||
COMMAND ${DOTNET_EXECUTABLE} run --no-build --framework net6.0 -c Release
|
||||
WORKING_DIRECTORY ${DOTNET_EXAMPLE_DIR})
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Configuring example ${FILE_NAME} done")
|
||||
endfunction()
|
||||
|
||||
@@ -87,6 +87,8 @@ $$(TEMP_DOTNET_DIR)/$1/%/%.csproj: \
|
||||
$$(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \
|
||||
ortools$$Sdotnet$$SSample.csproj.in \
|
||||
> $$(TEMP_DOTNET_DIR)$$S$1$$S$$*$$S$$*.csproj
|
||||
$$(SED) -i -e 's/@DOTNET_TFM@/<TargetFrameworks>netcoreapp3.1;net6.0<\/TargetFrameworks>/' \
|
||||
$$(TEMP_DOTNET_DIR)$$S$1$$S$$*$$S$$*.csproj
|
||||
$$(SED) -i -e 's/@DOTNET_PROJECT@/$$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \
|
||||
$$(TEMP_DOTNET_DIR)$$S$1$$S$$*$$S$$*.csproj
|
||||
$$(SED) -i -e 's/@SAMPLE_NAME@/$$*/' \
|
||||
@@ -136,6 +138,8 @@ $$(TEMP_DOTNET_DIR)/$1/%/%.csproj: \
|
||||
$$(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \
|
||||
ortools$$Sdotnet$$SSample.csproj.in \
|
||||
> $$(TEMP_DOTNET_DIR)$$S$1$$S$$*$$S$$*.csproj
|
||||
$$(SED) -i -e 's/@DOTNET_TFM@/<TargetFrameworks>netcoreapp3.1;net6.0<\/TargetFrameworks>/' \
|
||||
$$(TEMP_DOTNET_DIR)$$S$1$$S$$*$$S$$*.csproj
|
||||
$$(SED) -i -e 's/@DOTNET_PROJECT@/$$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \
|
||||
$$(TEMP_DOTNET_DIR)$$S$1$$S$$*$$S$$*.csproj
|
||||
$$(SED) -i -e 's/@SAMPLE_NAME@/$$*/' \
|
||||
@@ -184,6 +188,8 @@ $(TEMP_DOTNET_DIR)/tests/%/%.csproj: \
|
||||
$(SED) -e "s/@DOTNET_PACKAGES_DIR@/..\/..\/..\/$(BUILD_DIR)\/dotnet\/packages/" \
|
||||
ortools$Sdotnet$STest.csproj.in \
|
||||
> $(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj
|
||||
$(SED) -i -e 's/@DOTNET_TFM@/<TargetFrameworks>netcoreapp3.1;net6.0<\/TargetFrameworks>/' \
|
||||
$(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj
|
||||
$(SED) -i -e 's/@DOTNET_PROJECT@/$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \
|
||||
$(TEMP_DOTNET_DIR)$Stests$S$*$S$*.csproj
|
||||
$(SED) -i -e 's/@TEST_NAME@/$*/' \
|
||||
@@ -483,6 +489,8 @@ $$(TEMP_DOTNET_DIR)/ortools_examples/examples/dotnet/%.csproj: \
|
||||
$$(SED) -i -e 's/@PROJECT_VERSION_PATCH@/$$(GIT_REVISION)/' \
|
||||
$$(TEMP_DOTNET_DIR)$$Sortools_examples$$Sexamples$$Sdotnet$$S$$*.csproj
|
||||
$(SED) -i -e 's/@DOTNET_PACKAGES_DIR@/./' \
|
||||
$$(TEMP_DOTNET_DIR)$$Sortools_examples$$Sexamples$$Sdotnet$$S$$*.csproj
|
||||
$(SED) -i -e 's/@DOTNET_TFM@/<TargetFrameworks>netcoreapp3.1;net6.0<\/TargetFrameworks>/' \
|
||||
$$(TEMP_DOTNET_DIR)$$Sortools_examples$$Sexamples$$Sdotnet$$S$$*.csproj
|
||||
$(SED) -i -e 's/@DOTNET_PROJECT@/$$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \
|
||||
$$(TEMP_DOTNET_DIR)$$Sortools_examples$$Sexamples$$Sdotnet$$S$$*.csproj
|
||||
@@ -512,6 +520,8 @@ $$(TEMP_DOTNET_DIR)/ortools_examples/examples/dotnet/%.csproj: \
|
||||
$$(SED) -i -e 's/@PROJECT_VERSION_PATCH@/$$(GIT_REVISION)/' \
|
||||
$$(TEMP_DOTNET_DIR)$$Sortools_examples$$Sexamples$$Sdotnet$$S$$*.csproj
|
||||
$(SED) -i -e 's/@DOTNET_PACKAGES_DIR@/./' \
|
||||
$$(TEMP_DOTNET_DIR)$$Sortools_examples$$Sexamples$$Sdotnet$$S$$*.csproj
|
||||
$(SED) -i -e 's/@DOTNET_TFM@/<TargetFrameworks>netcoreapp3.1;net6.0<\/TargetFrameworks>/' \
|
||||
$$(TEMP_DOTNET_DIR)$$Sortools_examples$$Sexamples$$Sdotnet$$S$$*.csproj
|
||||
$(SED) -i -e 's/@DOTNET_PROJECT@/$$(DOTNET_ORTOOLS_ASSEMBLY_NAME)/' \
|
||||
$$(TEMP_DOTNET_DIR)$$Sortools_examples$$Sexamples$$Sdotnet$$S$$*.csproj
|
||||
@@ -570,7 +580,7 @@ nuget_archive: dotnet | $(TEMP_DOTNET_DIR)
|
||||
|
||||
.PHONY: nuget_upload # Upload Nuget Package
|
||||
nuget_upload: nuget_archive
|
||||
@echo Uploading Nuget package for "net6.0".
|
||||
@echo Uploading Nuget package for "netcoreapp3.1;net6.0".
|
||||
$(warning Not Implemented)
|
||||
|
||||
endif # HAS_DOTNET=ON
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
@DOTNET_TFM@
|
||||
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AssemblyName>@DOTNET_PROJECT@</AssemblyName>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<LangVersion>9.0</LangVersion>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
@DOTNET_TFM@
|
||||
<RuntimeIdentifier>@RUNTIME_IDENTIFIER@</RuntimeIdentifier>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AssemblyName>@DOTNET_PROJECT@</AssemblyName>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
@DOTNET_TFM@
|
||||
<RuntimeIdentifier>@RUNTIME_IDENTIFIER@</RuntimeIdentifier>
|
||||
<AssemblyName>google-ortools-native</AssemblyName>
|
||||
<Version>@PROJECT_VERSION@</Version>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<TargetFrameworks>net6.0</TargetFrameworks>
|
||||
@DOTNET_TFM@
|
||||
<EnableDefaultItems>false</EnableDefaultItems>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<!-- see https://github.com/dotnet/docs/issues/12237 -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<TargetFrameworks>netcoreapp3.1;net6.0</TargetFrameworks>
|
||||
@DOTNET_TFM@
|
||||
<EnableDefaultItems>false</EnableDefaultItems>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<!-- see https://github.com/dotnet/docs/issues/12237 -->
|
||||
|
||||
Reference in New Issue
Block a user