From 5726c81fdbfbdd40d496f278a84f328b45c240c0 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Wed, 29 May 2024 23:11:52 +0800 Subject: [PATCH] chore: switch to CMake build system. - switch to CMake build system and delete original project files because Visual Studio supports CMake project debugging. - there is a UTF-8 bug for library after switching, but I don't know why it happends. maybe fixed in future. --- .gitignore | 50 +++++++- CMakeLists.txt | 8 ++ YYCCommonplace.sln | 44 ------- src/CMakeLists.txt | 39 ++++++ src/YYCCommonplace.vcxproj | 182 ---------------------------- src/YYCCommonplace.vcxproj.filters | 75 ------------ testbench/CMakeLists.txt | 25 ++++ testbench/Testbench.vcxproj | 175 -------------------------- testbench/Testbench.vcxproj.filters | 22 ---- 9 files changed, 119 insertions(+), 501 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 YYCCommonplace.sln create mode 100644 src/CMakeLists.txt delete mode 100644 src/YYCCommonplace.vcxproj delete mode 100644 src/YYCCommonplace.vcxproj.filters create mode 100644 testbench/CMakeLists.txt delete mode 100644 testbench/Testbench.vcxproj delete mode 100644 testbench/Testbench.vcxproj.filters diff --git a/.gitignore b/.gitignore index c64b424..33cb249 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# -------------------- Output -------------------- +out/ +CMakeSettings.json + # -------------------- VSCode -------------------- .vscode/ @@ -18,7 +22,7 @@ _deps ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore # User-specific files *.rsuser @@ -48,7 +52,6 @@ bld/ [Oo]bj/ [Ll]og/ [Ll]ogs/ -Temp/ # Visual Studio 2015/2017 cache/options directory .vs/ @@ -108,6 +111,7 @@ StyleCopReport.xml *.tmp_proj *_wpftmp.csproj *.log +*.tlog *.vspscc *.vssscc .builds @@ -160,7 +164,9 @@ _TeamCity* !.axoCover/settings.json # Coverlet is a free, cross platform Code Coverage Tool -coverage*[.json, .xml, .info] +coverage*.json +coverage*.xml +coverage*.info # Visual Studio code coverage results *.coverage @@ -309,6 +315,17 @@ node_modules/ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) *.vbw +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts @@ -365,6 +382,9 @@ ASALocalRun/ # Local History for Visual Studio .localhistory/ +# Visual Studio History (VSHistory) files +.vshistory/ + # BeatPulse healthcheck temp database healthchecksdb @@ -373,3 +393,27 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b087bb4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) +project(YYCCommonplace LANGUAGES CXX) + +# Add core static library in build +add_subdirectory(src) +# Add testbench code in build +add_subdirectory(testbench) + diff --git a/YYCCommonplace.sln b/YYCCommonplace.sln deleted file mode 100644 index 35a752f..0000000 --- a/YYCCommonplace.sln +++ /dev/null @@ -1,44 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.33529.622 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "YYCCommonplace", "src\YYCCommonplace.vcxproj", "{FA5E5834-54DF-4CA1-8F49-9533BE13467A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Testbench", "testbench\Testbench.vcxproj", "{3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}" - ProjectSection(ProjectDependencies) = postProject - {FA5E5834-54DF-4CA1-8F49-9533BE13467A} = {FA5E5834-54DF-4CA1-8F49-9533BE13467A} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FA5E5834-54DF-4CA1-8F49-9533BE13467A}.Debug|x64.ActiveCfg = Debug|x64 - {FA5E5834-54DF-4CA1-8F49-9533BE13467A}.Debug|x64.Build.0 = Debug|x64 - {FA5E5834-54DF-4CA1-8F49-9533BE13467A}.Debug|x86.ActiveCfg = Debug|Win32 - {FA5E5834-54DF-4CA1-8F49-9533BE13467A}.Debug|x86.Build.0 = Debug|Win32 - {FA5E5834-54DF-4CA1-8F49-9533BE13467A}.Release|x64.ActiveCfg = Release|x64 - {FA5E5834-54DF-4CA1-8F49-9533BE13467A}.Release|x64.Build.0 = Release|x64 - {FA5E5834-54DF-4CA1-8F49-9533BE13467A}.Release|x86.ActiveCfg = Release|Win32 - {FA5E5834-54DF-4CA1-8F49-9533BE13467A}.Release|x86.Build.0 = Release|Win32 - {3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}.Debug|x64.ActiveCfg = Debug|x64 - {3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}.Debug|x64.Build.0 = Debug|x64 - {3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}.Debug|x86.ActiveCfg = Debug|Win32 - {3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}.Debug|x86.Build.0 = Debug|Win32 - {3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}.Release|x64.ActiveCfg = Release|x64 - {3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}.Release|x64.Build.0 = Release|x64 - {3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}.Release|x86.ActiveCfg = Release|Win32 - {3A6F9D19-5DF0-4EB9-A227-DCC9A7B25A31}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A05D6B8D-5374-41E9-9010-8ACB16391AE2} - EndGlobalSection -EndGlobal diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..9801ed2 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,39 @@ +# Setup file lists up +set(YYCC_HEADER ${CMAKE_CURRENT_LIST_DIR}) +set(YYCC_SRC + DialogHelper.cpp + EncodingHelper.cpp + ExceptionHelper.cpp + IOHelper.cpp + ParserHelper.cpp + StringHelper.cpp + TerminalHelper.cpp +) + +# Create static library +add_library(YYCCommonplace + ${YYCC_SRC} +) +# Setup header infomations +target_include_directories(YYCCommonplace +PUBLIC + ${YYCC_HEADER} +) +# Setup C++ standard +set_target_properties(YYCCommonplace +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED 17 + CXX_EXTENSION OFF +) +# Disable MSVC standard library warnings +target_compile_definitions(YYCCommonplace +PUBLIC + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:_CRT_NONSTDC_NO_DEPRECATE> +) +# Order build as UTF-8 in MSVC +target_compile_options(YYCCommonplace +PRIVATE + $<$:/utf-8> +) diff --git a/src/YYCCommonplace.vcxproj b/src/YYCCommonplace.vcxproj deleted file mode 100644 index 294c40a..0000000 --- a/src/YYCCommonplace.vcxproj +++ /dev/null @@ -1,182 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {fa5e5834-54df-4ca1-8f49-9533be13467a} - YYCCommonplace - 10.0 - - - - StaticLibrary - true - v142 - Unicode - - - StaticLibrary - false - v142 - true - Unicode - - - StaticLibrary - true - v142 - Unicode - - - StaticLibrary - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(ProjectDir)bin\$(Platform)\$(Configuration)\ - $(ProjectDir)obj\$(Platform)\$(Configuration)\ - - - false - $(ProjectDir)bin\$(Platform)\$(Configuration)\ - $(ProjectDir)obj\$(Platform)\$(Configuration)\ - - - true - $(ProjectDir)bin\$(Platform)\$(Configuration)\ - $(ProjectDir)obj\$(Platform)\$(Configuration)\ - - - false - $(ProjectDir)bin\$(Platform)\$(Configuration)\ - $(ProjectDir)obj\$(Platform)\$(Configuration)\ - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - /utf-8 %(AdditionalOptions) - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - /utf-8 %(AdditionalOptions) - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - /utf-8 %(AdditionalOptions) - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - /utf-8 %(AdditionalOptions) - - - Console - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/YYCCommonplace.vcxproj.filters b/src/YYCCommonplace.vcxproj.filters deleted file mode 100644 index bce9462..0000000 --- a/src/YYCCommonplace.vcxproj.filters +++ /dev/null @@ -1,75 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - Headers - - - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - Sources - - - \ No newline at end of file diff --git a/testbench/CMakeLists.txt b/testbench/CMakeLists.txt new file mode 100644 index 0000000..2d5fa65 --- /dev/null +++ b/testbench/CMakeLists.txt @@ -0,0 +1,25 @@ +# Create executable testbench +add_executable(Testbench + main.cpp +) +# Add YYCC as its library +target_include_directories(Testbench +PRIVATE + +) +target_link_libraries(Testbench +PRIVATE + YYCCommonplace +) +# Setup C++ standard +set_target_properties(Testbench +PROPERTIES + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED 17 + CXX_EXTENSION OFF +) +# Order build as UTF-8 in MSVC +target_compile_options(YYCCommonplace +PRIVATE + $<$:/utf-8> +) diff --git a/testbench/Testbench.vcxproj b/testbench/Testbench.vcxproj deleted file mode 100644 index d82f088..0000000 --- a/testbench/Testbench.vcxproj +++ /dev/null @@ -1,175 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {3a6f9d19-5df0-4eb9-a227-dcc9a7b25a31} - Testbench - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(ProjectDir)bin\$(Platform)\$(Configuration)\ - $(ProjectDir)obj\$(Platform)\$(Configuration)\ - - - false - $(ProjectDir)bin\$(Platform)\$(Configuration)\ - $(ProjectDir)obj\$(Platform)\$(Configuration)\ - - - true - $(ProjectDir)bin\$(Platform)\$(Configuration)\ - $(ProjectDir)obj\$(Platform)\$(Configuration)\ - - - false - $(ProjectDir)bin\$(Platform)\$(Configuration)\ - $(ProjectDir)obj\$(Platform)\$(Configuration)\ - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - /utf-8 %(AdditionalOptions) - $(SolutionDir)src\;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)src\bin\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - YYCCommonplace.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - /utf-8 %(AdditionalOptions) - $(SolutionDir)src\;%(AdditionalIncludeDirectories) - - - Console - true - true - true - $(SolutionDir)src\bin\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - YYCCommonplace.lib;%(AdditionalDependencies) - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - /utf-8 %(AdditionalOptions) - $(SolutionDir)src\;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)src\bin\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - YYCCommonplace.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - /utf-8 %(AdditionalOptions) - $(SolutionDir)src\;%(AdditionalIncludeDirectories) - - - Console - true - true - true - $(SolutionDir)src\bin\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) - YYCCommonplace.lib;%(AdditionalDependencies) - - - - - - - - - \ No newline at end of file diff --git a/testbench/Testbench.vcxproj.filters b/testbench/Testbench.vcxproj.filters deleted file mode 100644 index efff4b3..0000000 --- a/testbench/Testbench.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Sources - - - \ No newline at end of file