-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
CMakeLists.txt
85 lines (72 loc) · 3.23 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
IF(vw_BUILD_NET_CORE AND vw_BUILD_NET_FRAMEWORK)
MESSAGE(FATAL_ERROR "Cannot build VW bindings for .NET Core and .NET Framework at the same time.")
ENDIF()
if(vw_BUILD_NET_FRAMEWORK AND NOT WIN32)
message(FATAL_ERROR ".NET Framework can only be built on Windows")
endif()
# Generate .nuspec files for creating Nuget packages
if(WIN32)
set(NUGET_RUNTIME_ID "win-x64")
elseif(APPLE)
set(NUGET_RUNTIME_ID "osx-x64")
else()
set(NUGET_RUNTIME_ID "linux-x64")
endif()
if(vw_BUILD_NET_FRAMEWORK)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../nuget/dotnet/dotnet.nuspec.in nuget/dotnet/dotnet.nuspec @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nuget/dotnet/dotnet.nuspec DESTINATION ./)
endif()
if(vw_BUILD_NET_CORE)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../nuget/dotnet/dotnetcore.nuspec.in nuget/dotnet/dotnetcore.nuspec @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nuget/dotnet/dotnetcore.nuspec DESTINATION ./)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../nuget/dotnet/dotnetcore_runtime.nuspec.in nuget/dotnet/dotnetcore_runtime.nuspec @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nuget/dotnet/dotnetcore_runtime.nuspec DESTINATION ./)
configure_file(${CMAKE_CURRENT_LIST_DIR}/../nuget/dotnet/runtime.json.in nuget/dotnet/runtime.json @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/nuget/dotnet/runtime.json DESTINATION ./)
endif()
# Add the appropriate subdirectories depending on if we're build Core or Framework
IF (vw_BUILD_NET_CORE)
message(STATUS "Building .NET Core Bindings")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include(FindDotnet)
add_subdirectory(common/netstandard)
add_subdirectory(vw.net.native)
add_subdirectory(vw.net)
add_subdirectory(cs/netstandard)
add_subdirectory(cs_json/netstandard)
add_subdirectory(cs_parallel/netstandard)
add_subdirectory(cs_console/netcoreapp)
add_subdirectory(examples/simulator/netcoreapp)
if (BUILD_TESTING)
add_subdirectory(testcommon/netstandard)
add_subdirectory(unittest/netstandard)
endif()
ELSEIF (vw_BUILD_NET_FRAMEWORK)
message(STATUS "Building .NET Framework Bindings")
enable_language(CSharp)
# Explicitly set the `PlatformTarget` for C# projects, since AnyCPU can result in
# System.BadImageFormatException throws, when trying to load C++/CLI assemblies.
IF(CMAKE_GENERATOR_PLATFORM STREQUAL "x64")
SET(CMAKE_CSharp_FLAGS "/platform:x64")
ELSEIF(CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")
SET(CMAKE_CSharp_FLAGS "/platform:x86")
ELSE()
MESSAGE(WARNING "Generator platform is set to '${CMAKE_GENERATOR_PLATFORM}', which is not supported by managed projects. Defaulting to 'AnyCPU'...")
SET(CMAKE_CSharp_FLAGS "/platform:AnyCPU")
ENDIF()
# StrongName signing for VW assemblies - stage the keyfile, and set its location
configure_file(vw_key.snk vw_key.snk COPYONLY)
set(vw_DOTNET_SIGNING_KEY ${CMAKE_CURRENT_BINARY_DIR}/vw_key.snk)
add_subdirectory(common)
add_subdirectory(cli)
add_subdirectory(cs)
add_subdirectory(cs_json)
add_subdirectory(cs_parallel)
add_subdirectory(cs_console)
add_subdirectory(examples/simulator)
if (BUILD_TESTING)
add_subdirectory(testcommon)
add_subdirectory(unittest)
add_subdirectory(cs_unittest_nofriend)
endif()
ENDIF()