From 95fa410e4525ab4419d1cb2624572d574615ed0f Mon Sep 17 00:00:00 2001 From: Mikael CAPELLE Date: Wed, 30 Aug 2023 15:52:35 +0200 Subject: [PATCH 1/3] Use CMake to build. --- CMakeLists.txt | 4 ++++ bootstrap.ps1 | 35 +++++------------------------------ src/CMakeLists.txt | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 30 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..18e51e2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.16) + +project(mob) +add_subdirectory(src) diff --git a/bootstrap.ps1 b/bootstrap.ps1 index 9e797d7..f50820f 100644 --- a/bootstrap.ps1 +++ b/bootstrap.ps1 @@ -1,40 +1,15 @@ $root = $PSScriptRoot if (!$root) { - $root = "." + $root = "." } -$installationPath = & $root\third-party\bin\vswhere.exe -products * -nologo -prerelease -latest -property installationPath -if (! $?) { - Write-Error "vswhere returned $LastExitCode" - exit $LastExitCode -} - -if (! $installationPath) { - Write-Error "Empty installation path" - exit 1 -} - -$opts = "" -$opts += " $root\vs\mob.sln" -$opts += " -m" -$opts += " -p:Configuration=Release" -$opts += " -noLogo" -$opts += " -p:UseMultiToolTask=true" -$opts += " -p:EnforceProcessCountAcrossBuilds=true" -$opts += " -clp:ErrorsOnly;Verbosity=minimal" - -$vsDevCmd = "$installationPath\Common7\Tools\VsDevCmd.bat" -if (!(Test-Path "$vsDevCmd")) { - Write-Error "VdDevCmd.bat not found at $vsDevCmd" - exit 1 -} - -& "${env:COMSPEC}" /c "`"$vsDevCmd`" -no_logo -arch=amd64 -host_arch=amd64 && msbuild $opts" +cmake -B build . | Out-Null +cmake --build build --config Release -- "-p:UseMultiToolTask=true" "-noLogo" "-p:EnforceProcessCountAcrossBuilds=true" "-clp:ErrorsOnly;Verbosity=minimal" if (! $?) { Write-Error "Build failed" exit $LastExitCode } -Copy-Item "$root\build\Release\x64\mob.exe" "$root\mob.exe" -echo "run ``.\mob -d prefix/path build`` to start building" \ No newline at end of file +Copy-Item "$root\build\src\Release\mob.exe" "$root\mob.exe" +Write-Output "run ``.\mob -d prefix/path build`` to start building" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..7c15d53 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.16) + +file(GLOB_RECURSE src_files *.cpp) + +add_executable(mob ${src_files}) +set_target_properties(mob PROPERTIES CXX_STANDARD 20) + +target_compile_definitions(mob PUBLIC NOMINMAX) +target_compile_options(mob PUBLIC "/MT") +target_include_directories(mob PUBLIC ${CMAKE_SOURCE_DIR}/third-party/include) +target_link_libraries(mob PUBLIC + wsock32 ws2_32 crypt32 wldap32 dbghelp shlwapi version + optimized ${CMAKE_SOURCE_DIR}/third-party/lib/libcurl.lib + debug ${CMAKE_SOURCE_DIR}/third-party/lib/libcurl-d.lib + optimized ${CMAKE_SOURCE_DIR}/third-party/lib/zlib.lib + debug ${CMAKE_SOURCE_DIR}/third-party/lib/zlibd.lib) From 45508c3d9931965e9135eb00af6329e3d3f4c613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Wed, 6 Sep 2023 18:05:57 +0200 Subject: [PATCH 2/3] Organize files as trees in the generated VS solution. --- CMakeLists.txt | 2 + src/CMakeLists.txt | 10 +- vs/debug.props | 15 --- vs/mob.sln | 25 ---- vs/mob.vcxproj | 162 ----------------------- vs/mob.vcxproj.filters | 291 ----------------------------------------- vs/props.props | 32 ----- vs/release.props | 25 ---- 8 files changed, 10 insertions(+), 552 deletions(-) delete mode 100644 vs/debug.props delete mode 100644 vs/mob.sln delete mode 100644 vs/mob.vcxproj delete mode 100644 vs/mob.vcxproj.filters delete mode 100644 vs/props.props delete mode 100644 vs/release.props diff --git a/CMakeLists.txt b/CMakeLists.txt index 18e51e2..f015637 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,3 +2,5 @@ cmake_minimum_required(VERSION 3.16) project(mob) add_subdirectory(src) + +set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT mob) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c15d53..f52246c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,9 @@ cmake_minimum_required(VERSION 3.16) -file(GLOB_RECURSE src_files *.cpp) +file(GLOB_RECURSE source_files *.cpp) +file(GLOB RECURSE header_files *.h) -add_executable(mob ${src_files}) +add_executable(mob ${source_files}) set_target_properties(mob PROPERTIES CXX_STANDARD 20) target_compile_definitions(mob PUBLIC NOMINMAX) @@ -14,3 +15,8 @@ target_link_libraries(mob PUBLIC debug ${CMAKE_SOURCE_DIR}/third-party/lib/libcurl-d.lib optimized ${CMAKE_SOURCE_DIR}/third-party/lib/zlib.lib debug ${CMAKE_SOURCE_DIR}/third-party/lib/zlibd.lib) + +source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} + PREFIX src + FILES ${source_files} ${header_files}) +set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT mob) diff --git a/vs/debug.props b/vs/debug.props deleted file mode 100644 index 745efbe..0000000 --- a/vs/debug.props +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - libcurl-d.lib;zlibd.lib;%(AdditionalDependencies) - - - MultiThreadedDebug - - - - \ No newline at end of file diff --git a/vs/mob.sln b/vs/mob.sln deleted file mode 100644 index fe6f3cf..0000000 --- a/vs/mob.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30014.187 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mob", "mob.vcxproj", "{CB2CB683-78DA-44B9-B762-D195041F234E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CB2CB683-78DA-44B9-B762-D195041F234E}.Debug|x64.ActiveCfg = Debug|x64 - {CB2CB683-78DA-44B9-B762-D195041F234E}.Debug|x64.Build.0 = Debug|x64 - {CB2CB683-78DA-44B9-B762-D195041F234E}.Release|x64.ActiveCfg = Release|x64 - {CB2CB683-78DA-44B9-B762-D195041F234E}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {84F7C190-1CD8-46DF-9349-05A62C5B02B5} - EndGlobalSection -EndGlobal diff --git a/vs/mob.vcxproj b/vs/mob.vcxproj deleted file mode 100644 index cafed2a..0000000 --- a/vs/mob.vcxproj +++ /dev/null @@ -1,162 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {cb2cb683-78da-44b9-b762-d195041f234e} - mob - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - Unicode - true - - - - - - - - - - - - - - - - - - - - - - - false - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/vs/mob.vcxproj.filters b/vs/mob.vcxproj.filters deleted file mode 100644 index de212c4..0000000 --- a/vs/mob.vcxproj.filters +++ /dev/null @@ -1,291 +0,0 @@ - - - - - {23ea265d-5536-4626-b27a-5403447aec6e} - - - {892d19b8-e898-4c80-be14-e1ee1fb13209} - - - {b0afbfc3-9b49-4768-9077-a8284ced4416} - - - {6e4d31d5-100c-4a4d-8e7d-4c48939819bd} - - - {78dd6066-d407-4450-b520-649454c15ee9} - - - {b9307be3-9ccb-4449-8aed-d9b69f0beda9} - - - - - src - - - src - - - src - - - src - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tools - - - src\tools - - - src\tools - - - src\tools - - - src\tools - - - src\tools - - - src\tools - - - src\tools - - - src\tools - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\tasks - - - src\core - - - src\core - - - src\core - - - src\core - - - src\core - - - src\utility - - - src\utility - - - src\utility - - - src\utility - - - src\utility - - - src\cmd - - - src\cmd - - - src\cmd - - - src\cmd - - - src\cmd - - - src\cmd - - - src\cmd - - - src\cmd - - - src\core - - - src\core - - - src\core - - - src\tools - - - src\tasks - - - src\tasks - - - src\tools - - - - - src - - - src - - - src - - - src\tasks - - - src\tasks - - - src\tools - - - src\core - - - src\core - - - src\core - - - src\core - - - src\core - - - src\utility - - - src\utility - - - src\utility - - - src\utility - - - src\utility - - - src\utility - - - src\cmd - - - src\utility - - - src\core - - - src\core - - - src\core - - - src\tools - - - src\tools - - - src\tools - - - src\tasks - - - \ No newline at end of file diff --git a/vs/props.props b/vs/props.props deleted file mode 100644 index 046c06c..0000000 --- a/vs/props.props +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - $(SolutionDir)..\build\$(Configuration)\$(PlatformTarget)\ - $(ProjectDir)obj\$(ProjectName)\$(Configuration)\$(PlatformTarget)\ - - - - EnableAllWarnings - - - - - Caret - true - stdcpplatest - Use - pch.h - $(IntDir)fake\%(RelativeDir) - _CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;CURL_STATICLIB;NOMINMAX;%(PreprocessorDefinitions) - ..\third-party\include;%(AdditionalIncludeDirectories) - 4566 - - - ..\third-party\lib;%(AdditionalLibraryDirectories) - Ws2_32.lib;Crypt32.lib;Wldap32.lib;Shlwapi.lib;DbgHelp.lib;Version.lib;%(AdditionalDependencies) - - - - \ No newline at end of file diff --git a/vs/release.props b/vs/release.props deleted file mode 100644 index 451936a..0000000 --- a/vs/release.props +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - libcurl.lib;zlib.lib;%(AdditionalDependencies) - true - true - UseLinkTimeCodeGeneration - - - AnySuitable - - - true - NDEBUG;%(PreprocessorDefinitions) - true - true - true - - - - \ No newline at end of file From 42aef59f9ef6082633b5f8dddbe9c0265a68eb37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Wed, 6 Sep 2023 18:30:01 +0200 Subject: [PATCH 3/3] Allow running bootstrap.ps1 from a different folder. --- bootstrap.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bootstrap.ps1 b/bootstrap.ps1 index f50820f..69ce93a 100644 --- a/bootstrap.ps1 +++ b/bootstrap.ps1 @@ -3,8 +3,12 @@ if (!$root) { $root = "." } -cmake -B build . | Out-Null -cmake --build build --config Release -- "-p:UseMultiToolTask=true" "-noLogo" "-p:EnforceProcessCountAcrossBuilds=true" "-clp:ErrorsOnly;Verbosity=minimal" +cmake -B $root/build $root | Out-Null +cmake --build $root/build --config Release -- ` + "-p:UseMultiToolTask=true" ` + "-noLogo" ` + "-p:EnforceProcessCountAcrossBuilds=true" ` + "-clp:ErrorsOnly;Verbosity=minimal" if (! $?) { Write-Error "Build failed"