Skip to content

Commit b14dfda

Browse files
committed
vs 编译
1 parent cab9758 commit b14dfda

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

c#/base/CMakeLists.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
3+
project("BaseApp" CSharp)
4+
5+
set(BASE_SRC_DIR ${PROJECT_SOURCE_DIR} CACHE STRING "BASE_SRC_DIR.")
6+
7+
#set(NET_VER_DIR "net35" CACHE STRING "BASE_SRC_DIR.")
8+
set(NET_VER_DIR "net40" CACHE STRING "BASE_SRC_DIR.")
9+
#set(NET_VER_DIR "net45" CACHE STRING "BASE_SRC_DIR.")
10+
#set(NET_VER_DIR "netstandard2.0" CACHE STRING "BASE_SRC_DIR.")
11+
12+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDYZ_DBG")
13+
14+
include(CSharpUtilities)
15+
16+
file(GLOB BASE_DLL_SRC "MyDll.cs")
17+
file(GLOB BASE_APP_SRC "MyApp.cs")
18+
19+
add_library(libMyDll STATIC ${BASE_DLL_SRC})
20+
add_executable(BaseApp ${BASE_APP_SRC} ${BASE_DLL_SRC})
21+
22+
# Set the .NET Framework version for the executable.
23+
# set_property(TARGET BaseApp PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1")
24+
25+
# Set the executable to be 32-bit.
26+
# set_property(TARGET libMyDll PROPERTY WIN32_EXECUTABLE TRUE)
27+
set_property(TARGET BaseApp PROPERTY WIN32_EXECUTABLE TRUE)
28+
29+
# Set the C# language version (defaults to 3.0).
30+
set(CMAKE_CSharp_FLAGS "/langversion:latest")
31+
32+
#csharp_set_windows_forms_properties()
33+
34+
# target_link_libraries(BaseApp MyDll)
35+
36+
# If necessary, link in other library/DLL references, such as 3rd party libraries.
37+
# set_property(TARGET BaseApp PROPERTY VS_DOTNET_REFERENCE_my lib/${NET_VER_DIR}/my.dll)
38+
39+
# Add in the .NET reference libraries.
40+
set_property(TARGET libMyDll PROPERTY VS_DOTNET_REFERENCES
41+
"Microsoft.CSharp"
42+
"System"
43+
"System.Core"
44+
"System.Data"
45+
"System.Drawing"
46+
"System.Windows.Forms"
47+
)
48+
49+
set_property(TARGET BaseApp PROPERTY VS_DOTNET_REFERENCES
50+
"Microsoft.CSharp"
51+
"System"
52+
"System.Core"
53+
"System.Data"
54+
"System.Drawing"
55+
"System.Windows.Forms"
56+
)
57+
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/Release")

c#/base/build_vs.bat

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
rem call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
2+
call "E:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
3+
4+
mkdir dyzbuild
5+
pushd dyzbuild
6+
rem cmake ..
7+
cmake -G "Visual Studio 16 2019" -A x64 ..
8+
MSBuild libMyDll.csproj /p:Configuration=Release /p:Platform=x64
9+
MSBuild BaseApp.csproj /p:Configuration=Release /p:Platform=x64
10+
popd
11+
12+
for /f %%i in ('dir /s /b "*.dll"') do (copy %%i .\)
13+
for /f %%i in ('dir /s /b "*.exe"') do (copy %%i .\)
14+
pause

0 commit comments

Comments
 (0)