init project
This commit is contained in:
commit
4efddda8c2
18 files changed
+395
No files matched your search
@@ -0,0 +1,6 @@
|
||||
---
|
||||
BasedOnStyle: Microsoft
|
||||
IndentWidth: 4
|
||||
|
||||
SortIncludes: false
|
||||
ColumnLimit: 300
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
CompileFlags:
|
||||
Add: [
|
||||
-DUNICODE,
|
||||
-D_UNICODE,
|
||||
"-std=c++17", # needed when using MSVC
|
||||
"-IC:/Users/sonnycalcr/EDisk/CppCodes/IMECodes/MetasequoiaImeLog/build/vcpkg_installed/x64-windows/include",
|
||||
-Wno-microsoft-goto,
|
||||
-Wno-nonportable-include-path,
|
||||
-Wno-microsoft-extra-qualification,
|
||||
-Wunused-variable,
|
||||
# -Wno-unused-value,
|
||||
] # ignore some specific warnings
|
||||
CompilationDatabase: build/ # Search build/ directory for compile_commands.json
|
||||
# Diagnostics:
|
||||
# UnusedIncludes: None # ignore unused includes
|
||||
@@ -0,0 +1 @@
|
||||
build/
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"Debug snippets": {
|
||||
"scope": "c,cpp",
|
||||
"prefix": "dbug",
|
||||
"body": [
|
||||
"#ifdef FANY_DEBUG",
|
||||
"#endif",
|
||||
],
|
||||
"description": "Add debug macro"
|
||||
},
|
||||
"Win32 log": {
|
||||
"scope": "c,cpp",
|
||||
"prefix": "dlog",
|
||||
"body": [
|
||||
"OutputDebugString(L\"$0\");",
|
||||
],
|
||||
"description": "Debugview log"
|
||||
},
|
||||
"Win32 log with fmt": {
|
||||
"scope": "c,cpp",
|
||||
"prefix": "flog",
|
||||
"body": [
|
||||
"OutputDebugString(fmt::format(L\"$0\").c_str());",
|
||||
],
|
||||
"description": "Debugview log with fmt"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
cmake_minimum_required(VERSION 3.25.0)
|
||||
project(MetasequoiaImeLog VERSION 1.0)
|
||||
|
||||
# Specify the C++ standard
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
add_definitions(
|
||||
/D_UNICODE=1
|
||||
/DUNICODE=1
|
||||
)
|
||||
|
||||
# fmt
|
||||
find_package(fmt REQUIRED)
|
||||
|
||||
set(MY_EXECUTABLE_NAME "MetasequoiaImeLog")
|
||||
set(
|
||||
SOURCE_FILES
|
||||
"./src/main.cpp"
|
||||
)
|
||||
|
||||
add_executable(${MY_EXECUTABLE_NAME} ${SOURCE_FILES})
|
||||
|
||||
target_link_libraries(${MY_EXECUTABLE_NAME} PRIVATE fmt::fmt)
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "vcpkg",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"environment": {
|
||||
"VCPKG_ROOT": "C:/Users/SonnyCalcr/scoop/apps/vcpkg/current"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "C:/Users/SonnyCalcr/scoop/apps/vcpkg/current/scripts/buildsystems/vcpkg.cmake",
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "default",
|
||||
"inherits": "vcpkg",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# MetasequoiaImeLog
|
||||
|
||||
Capture logs for Metasequoia IME modules.
|
||||
@@ -0,0 +1,18 @@
|
||||
CompileFlags:
|
||||
Add: [
|
||||
-DUNICODE,
|
||||
-D_UNICODE,
|
||||
-DFANY_DEBUG,
|
||||
"-std=c++17",
|
||||
"-IC:/Users/SonnyCalcr/EDisk/CppCodes/Win32Codes/Win32WebviewTemplate/src",
|
||||
"-IC:/Users/SonnyCalcr/EDisk/CppCodes/Win32Codes/Win32WebviewTemplate/build/vcpkg_installed/x64-windows/include",
|
||||
"-IC:/Users/SonnyCalcr/.nuget/packages/microsoft.web.webview2/1.0.3240.44/build/native/include",
|
||||
"-IC:/Users/SonnyCalcr/.nuget/packages/microsoft.windows.implementationlibrary/1.0.240803.1/include",
|
||||
-Wno-microsoft-goto,
|
||||
-Wno-nonportable-include-path,
|
||||
-Wno-microsoft-extra-qualification,
|
||||
# -Wno-unused-value,
|
||||
] # ignore some specific warnings
|
||||
# CompilationDatabase: build/ # Search build/ directory for compile_commands.json
|
||||
# Diagnostics:
|
||||
# UnusedIncludes: None # ignore unused includes
|
||||
@@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.25.0)
|
||||
project(WinCppTemplateWithVcpkg VERSION 1.0)
|
||||
|
||||
# Specify the C++ standard
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
add_definitions(
|
||||
/D_UNICODE=1
|
||||
/DUNICODE=1
|
||||
)
|
||||
|
||||
# fmt and spdlog
|
||||
find_package(fmt REQUIRED)
|
||||
|
||||
set(MY_EXECUTABLE_NAME "WinCppTemplateWithVcpkg")
|
||||
set(
|
||||
SOURCE_FILES
|
||||
"./src/main.cpp"
|
||||
)
|
||||
|
||||
add_executable(${MY_EXECUTABLE_NAME} ${SOURCE_FILES})
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "vcpkg",
|
||||
"generator": "Visual Studio 17 2022",
|
||||
"binaryDir": "${sourceDir}/build",
|
||||
"environment": {
|
||||
"VCPKG_ROOT": "C:/Users/sonnycalcr/scoop/apps/vcpkg/current/"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "C:/Users/sonnycalcr/scoop/apps/vcpkg/current/scripts/buildsystems/vcpkg.cmake",
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# generate, compile and run exe files
|
||||
#
|
||||
function getExePathFromCMakeLists() {
|
||||
$content = Get-Content -Raw -Path "./CMakeLists.txt"
|
||||
$exePath = ""
|
||||
foreach ($line in $content -split "`n") {
|
||||
if ($line -match 'set\(MY_EXECUTABLE_NAME[^\"]*\"([^\"]+)\"') {
|
||||
$exeName = $matches[1]
|
||||
$exePath = "./build/bin/Debug/$exeName" + ".exe"
|
||||
break
|
||||
}
|
||||
}
|
||||
return $exePath
|
||||
}
|
||||
|
||||
$currentDirectory = Get-Location
|
||||
$cmakeListsPath = Join-Path -Path $currentDirectory -ChildPath "CMakeLists.txt"
|
||||
|
||||
if (-not (Test-Path $cmakeListsPath)) {
|
||||
Write-Host("No CMakeLists.txt in current directory, please check.")
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Start generating and compiling..."
|
||||
|
||||
$buildFolderPath = ".\build"
|
||||
|
||||
if (-not (Test-Path $buildFolderPath)) {
|
||||
New-Item -ItemType Directory -Path $buildFolderPath | Out-Null
|
||||
Write-Host "build folder created."
|
||||
}
|
||||
|
||||
# cmake -G "Visual Studio 17 2022" -A x64 -S . -B ./build/
|
||||
cmake --preset=default
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
cmake --build build
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# generate, compile and run exe files
|
||||
#
|
||||
function getExePathFromCMakeLists() {
|
||||
$content = Get-Content -Raw -Path "./CMakeLists.txt"
|
||||
$exePath = ""
|
||||
foreach ($line in $content -split "`n") {
|
||||
if ($line -match 'set\(MY_EXECUTABLE_NAME[^\"]*\"([^\"]+)\"') {
|
||||
$exeName = $matches[1]
|
||||
$exePath = "./build/bin/Debug/$exeName" + ".exe"
|
||||
break
|
||||
}
|
||||
}
|
||||
return $exePath
|
||||
}
|
||||
|
||||
$currentDirectory = Get-Location
|
||||
$cmakeListsPath = Join-Path -Path $currentDirectory -ChildPath "CMakeLists.txt"
|
||||
|
||||
if (-not (Test-Path $cmakeListsPath)) {
|
||||
Write-Host("No CMakeLists.txt in current directory, please check.")
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Start generating and compiling..."
|
||||
|
||||
$buildFolderPath = ".\build"
|
||||
|
||||
if (-not (Test-Path $buildFolderPath)) {
|
||||
New-Item -ItemType Directory -Path $buildFolderPath | Out-Null
|
||||
Write-Host "build folder created."
|
||||
}
|
||||
|
||||
# cmake -G "Visual Studio 17 2022" -A x64 -S . -B ./build/
|
||||
cmake --preset=default
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
cmake --build build
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$exePath = getExePathFromCMakeLists
|
||||
Write-Host "start running as follows..."
|
||||
Write-Host "=================================================="
|
||||
Invoke-Expression $exePath
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# run exe file that has already been compiled before
|
||||
#
|
||||
function getExePathFromCMakeLists() {
|
||||
$content = Get-Content -Raw -Path "./CMakeLists.txt"
|
||||
$exePath = ""
|
||||
foreach ($line in $content -split "`n") {
|
||||
if ($line -match 'set\(MY_EXECUTABLE_NAME[^\"]*\"([^\"]+)\"') {
|
||||
$exeName = $matches[1]
|
||||
$exePath = "./build/bin/Debug/$exeName" + ".exe"
|
||||
break
|
||||
}
|
||||
}
|
||||
return $exePath
|
||||
}
|
||||
|
||||
$exePath = getExePathFromCMakeLists
|
||||
#Write-Host "start running as follows..."
|
||||
#Write-Host "=================================================="
|
||||
Invoke-Expression $exePath
|
||||
@@ -0,0 +1,111 @@
|
||||
import os
|
||||
|
||||
|
||||
def normpath(path):
|
||||
return path.replace("\\", "/")
|
||||
|
||||
|
||||
local_app_data_dir = os.environ.get("LOCALAPPDATA")
|
||||
home_dir = os.path.expanduser("~")
|
||||
|
||||
cur_file_path = os.path.dirname(os.path.abspath(__file__))
|
||||
project_root_path = os.path.dirname(cur_file_path)
|
||||
|
||||
user_home = os.path.expanduser("~")
|
||||
|
||||
Win32WebviewTemplate_root_path = normpath(project_root_path)
|
||||
Win32WebviewTemplate_src_path = normpath(
|
||||
os.path.join(Win32WebviewTemplate_root_path, "src")
|
||||
)
|
||||
vcpkg_include_path = normpath(
|
||||
os.path.join(
|
||||
Win32WebviewTemplate_root_path,
|
||||
"build",
|
||||
"vcpkg_installed",
|
||||
"x64-windows",
|
||||
"include",
|
||||
)
|
||||
)
|
||||
utfcpp_path = normpath(os.path.join(Win32WebviewTemplate_root_path, "utfcpp", "source"))
|
||||
webview2_path = normpath(
|
||||
os.path.join(
|
||||
user_home,
|
||||
".nuget",
|
||||
"packages",
|
||||
"microsoft.web.webview2",
|
||||
"1.0.3240.44",
|
||||
"build",
|
||||
"native",
|
||||
"include",
|
||||
)
|
||||
)
|
||||
wim_path = normpath(
|
||||
os.path.join(
|
||||
user_home,
|
||||
".nuget",
|
||||
"packages",
|
||||
"microsoft.windows.implementationlibrary",
|
||||
"1.0.240803.1",
|
||||
"include",
|
||||
)
|
||||
)
|
||||
boost_path = normpath(os.path.join(user_home, "scoop", "apps", "boost", "current"))
|
||||
vcpkg_root_path = normpath(os.path.join(user_home, "scoop", "apps", "vcpkg", "current"))
|
||||
cmake_toolchain_file_path = normpath(
|
||||
os.path.join(
|
||||
user_home,
|
||||
"scoop",
|
||||
"apps",
|
||||
"vcpkg",
|
||||
"current",
|
||||
"scripts",
|
||||
"buildsystems",
|
||||
"vcpkg.cmake",
|
||||
)
|
||||
)
|
||||
|
||||
#
|
||||
# project_root/.clangd
|
||||
# line 7, 8, 9, 10
|
||||
#
|
||||
dot_clangd_file = os.path.join(
|
||||
Win32WebviewTemplate_root_path, "scripts", "config_files", ".clangd"
|
||||
)
|
||||
dot_clangd_output_file = os.path.join(Win32WebviewTemplate_root_path, ".clangd")
|
||||
with open(dot_clangd_file, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
lines[6] = f' "-I{Win32WebviewTemplate_src_path}",\n'
|
||||
lines[7] = f' "-I{vcpkg_include_path}",\n'
|
||||
lines[8] = f' "-I{webview2_path}",\n'
|
||||
lines[9] = f' "-I{wim_path}",\n'
|
||||
with open(dot_clangd_output_file, "w", encoding="utf-8") as f:
|
||||
f.writelines(lines)
|
||||
|
||||
#
|
||||
# project_root/CMakeLists.txt
|
||||
#
|
||||
CMakeLists_file = os.path.join(
|
||||
Win32WebviewTemplate_root_path, "scripts", "config_files", "CMakeLists.txt"
|
||||
)
|
||||
CMakeLists_output_file = os.path.join(Win32WebviewTemplate_root_path, "CMakeLists.txt")
|
||||
with open(CMakeLists_file, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
with open(CMakeLists_output_file, "w", encoding="utf-8") as f:
|
||||
f.writelines(lines)
|
||||
|
||||
#
|
||||
# CMakePresets.json
|
||||
# lines 9 12
|
||||
#
|
||||
CMakePresets_file = os.path.join(
|
||||
Win32WebviewTemplate_root_path, "scripts", "config_files", "CMakePresets.json"
|
||||
)
|
||||
CMakePresets_file_output_file = os.path.join(
|
||||
Win32WebviewTemplate_root_path, "CMakePresets.json"
|
||||
)
|
||||
with open(CMakePresets_file, "r", encoding="utf-8") as f:
|
||||
lines = f.readlines()
|
||||
lines[8] = f' "VCPKG_ROOT": "{vcpkg_root_path}"\n'
|
||||
lines[11] = f' "CMAKE_TOOLCHAIN_FILE": "{cmake_toolchain_file_path}",\n'
|
||||
with open(CMakePresets_file_output_file, "w", encoding="utf-8") as f:
|
||||
f.writelines(lines)
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Hello, World!" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"default-triplet": "x64-windows"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": [
|
||||
"fmt"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user