From 95fa410e4525ab4419d1cb2624572d574615ed0f Mon Sep 17 00:00:00 2001 From: Mikael CAPELLE Date: Wed, 30 Aug 2023 15:52:35 +0200 Subject: [PATCH] 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)