【初始提交】
This commit is contained in:
47
.vscode/tasks.json
vendored
Normal file
47
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"type": "process",
|
||||||
|
"command": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
|
||||||
|
"args": [
|
||||||
|
"-File",
|
||||||
|
"${workspaceFolder}\\build-win-app.ps1",
|
||||||
|
"-build_type",
|
||||||
|
"Release",
|
||||||
|
"-build_and_run",
|
||||||
|
"false"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": false
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "silent"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "run",
|
||||||
|
"type": "process",
|
||||||
|
"command": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
|
||||||
|
"args": [
|
||||||
|
"-File",
|
||||||
|
"${workspaceFolder}\\build.ps1",
|
||||||
|
"-build_type",
|
||||||
|
"Debug",
|
||||||
|
"-build_and_run",
|
||||||
|
"true"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "silent"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
26
CMakeLists.txt
Normal file
26
CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(Demo)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
if(WIN32)
|
||||||
|
set(CMAKE_CXX_COMPILER "MSVC")
|
||||||
|
elseif(UNIX)
|
||||||
|
set(CMAKE_CXX_COMPILER "g++")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# 指定库链接目录
|
||||||
|
link_directories(3rd/lib)
|
||||||
|
|
||||||
|
include_directories(3rd/include)
|
||||||
|
include_directories(src)
|
||||||
|
|
||||||
|
aux_source_directory(./src DIR_SRCS)
|
||||||
|
aux_source_directory(./app DIR_SRCS)
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(Demo ${DIR_SRCS})
|
||||||
|
|
||||||
|
# if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
# target_link_libraries(${PROJECT_NAME} spdlogd-mt-x64.lib)
|
||||||
|
# else()
|
||||||
|
# target_link_libraries(${PROJECT_NAME} spdlog-mt-x64)
|
||||||
|
# endif()
|
||||||
6
app/main.cpp
Normal file
6
app/main.cpp
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int32_t main(int32_t argc, char** argv) {
|
||||||
|
std::cout << "Hello, World!" << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
39
build-win-app.ps1
Normal file
39
build-win-app.ps1
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$build_type,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[string]$build_and_run
|
||||||
|
)
|
||||||
|
|
||||||
|
# 定义项目和构建目录的变量
|
||||||
|
$projectDir = "$PSScriptRoot"
|
||||||
|
echo $projectDir
|
||||||
|
$buildDir = "$projectDir\build"
|
||||||
|
|
||||||
|
# 创建构建目录
|
||||||
|
if (-Not (Test-Path -Path $buildDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $buildDir
|
||||||
|
}
|
||||||
|
|
||||||
|
# 进入构建目录
|
||||||
|
Set-Location -Path $buildDir
|
||||||
|
|
||||||
|
# 运行CMake生成构建系统
|
||||||
|
# 这里假设CMakeLists.txt在项目根目录下
|
||||||
|
cmake -G "Visual Studio 17 2022" -T host=x64 -DCMAKE_BUILD_TYPE=$build_type ..
|
||||||
|
# 编译项目
|
||||||
|
cmake --build . --config $build_type
|
||||||
|
|
||||||
|
# 返回项目目录
|
||||||
|
Set-Location -Path $projectDir
|
||||||
|
|
||||||
|
# 打印构建完成的消息
|
||||||
|
Write-Host "build done." -ForegroundColor Darkgreen
|
||||||
|
|
||||||
|
if($build_and_run -eq "true"){
|
||||||
|
Write-Host "################## APP Run ##################" -ForegroundColor Blue
|
||||||
|
Start-Process -FilePath "build\\${build_type}\\TestCode.exe"
|
||||||
|
# & "build\\$build_type\\TestCode.exe"
|
||||||
|
|
||||||
|
}
|
||||||
20
src/TimeCount.cpp
Normal file
20
src/TimeCount.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "TimeCount.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
USE_TIME::USE_TIME(std::string str) :
|
||||||
|
strTmp(str)
|
||||||
|
{
|
||||||
|
start = std::chrono::system_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
USE_TIME::~USE_TIME()
|
||||||
|
{
|
||||||
|
end = std::chrono::system_clock::now();
|
||||||
|
|
||||||
|
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
|
||||||
|
std::cout << strTmp << "\t" << float(duration.count()*1.0) * std::chrono::milliseconds::period::num << "ms \t\n";
|
||||||
|
|
||||||
|
//auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
|
||||||
|
//std::cout << strTmp << "\t" << float(duration.count()*1.0) * std::chrono::microseconds::period::num << "ms \t\n";
|
||||||
|
}
|
||||||
|
|
||||||
18
src/TimeCount.h
Normal file
18
src/TimeCount.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef TIME_COUNT_H
|
||||||
|
#define TIME_COUNT_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
class USE_TIME{
|
||||||
|
public:
|
||||||
|
USE_TIME(std::string str = "");
|
||||||
|
~USE_TIME();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string strTmp;
|
||||||
|
std::chrono::system_clock::time_point start;
|
||||||
|
std::chrono::system_clock::time_point end;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user