티스토리 뷰

개발/오픈소스

RE2 WINDOWS 빌드 방법

-=HaeJuK=- 2024. 9. 2. 19:23
728x90
param(
    [string]$vsVersion,
    [string]$buildType = "Release",
    [string]$arch = "x64",
    [string]$AbslBasePath = "2024_01_16"
)

# Confirm input
$validVsVersions = @("2015","2017", "2019", "2022")
$validBuildTypes = @("Debug", "Release", "Release-MD", "MinSizeRel")
$validArchs = @("x64", "Win32")

if ($vsVersion -notin $validVsVersions -or $buildType -notin $validBuildTypes -or $arch -notin $validArchs) {
    Write-Host "Invalid input. Please enter the correct Visual Studio version, build type, and architecture."
    exit
}

# Setup paths
#$sourcePath = "G:\ThirdParty\Source\re2\2023-03-01" #vs2017
$sourcePath = "G:\ThirdParty\Source\re2\2024-03-01" #vs2019, 2022
#$sourcePath = "G:\ThirdParty\Source\re2\2024-05-01" #vs2019, 2022

$buildDir = "install\build_${vsVersion}_${buildType}_${arch}"
$buildPath = Join-Path $sourcePath "builds"
$installPath = Join-Path $sourcePath $buildDir

# Create build and install directories
New-Item -Path $buildPath -ItemType Directory -Force
New-Item -Path $installPath -ItemType Directory -Force

# Change to build directory
Set-Location -Path $buildPath

# Visual Studio generator 및 Platform Toolset 설정
$generator = ""
$toolset = ""
$toolsetVersion = ""
switch ($vsVersion) {
    "2022" {
        $generator = "`"Visual Studio 17 2022`""
        $toolsetVersion = "v143"
		$AbslBasePath = "2024_01_16"
    }
    "2019" {
        $generator = "`"Visual Studio 16 2019`""
        $toolsetVersion = "v142"
		$AbslBasePath = "2024_01_16"
    }
    "2017" {
        $generator = "`"Visual Studio 15 2017`""
        $toolset = "-T v141_xp"
        $toolsetVersion = "v141"
		$AbslBasePath = "2023_01_25"
    }
    "2015" {
        $generator = "`"Visual Studio 14 2015`""
        $toolset = "-T v140_xp"
        $toolsetVersion = "v140"
		$AbslBasePath = "2022_06_23"	
    }
}

$AbslArch = $arch;
if($arch -eq "Win32" ){
	 $AbslArch = "x86"
}

# OpenSSL 경로 설정

$AbslPath = "G:\ThirdParty\Source\AbSeil\$AbslBasePath\install\build_${vsVersion}_${buildType}_${arch}\lib\cmake\absl\"
#"$AbslBasePath\$toolsetVersion\AbSeil\lib\$AbslArch\$buildType\cmake\absl\"
#-Dabsl_DIR="G:\ThirdParty\Windows\v143\AbSeil\lib\x64\Debug\cmake\absl"

Write-Host "=== AbslPath:$AbslPath"

# CMake에 전달할 OpenSSL 변수 설정
$cmakeArgs = @(
    "-G", $generator,
    $toolset,
    "-A", $arch,
    "..",
    "-Dabsl_DIR=$AbslPath",
    "-DENABLE_SSL_SUPPORT=ON",
    "-DCMAKE_INSTALL_PREFIX=$installPath",
    "-DBUILD_SHARED_LIBS=OFF"
)

# CMAKE_CXX_FLAGS 설정
$cmakeCXXFlagsDebug = "/MTd"
$cmakeCXXFlagsRelease = "/MT"
$cmakeCXXFlagsReleaseMD = "/MD"
$cmakeCXXFlagsMinSizeRel = "/MD"

# 사용자에게 현재 설정을 보여주고 확인 받음
Write-Host "====================================================================" -ForegroundColor Cyan
Write-Host "=== You have selected the following configuration:"
Write-Host "=== INFORMATION" -ForegroundColor Yellow
Write-Host "=== [VS Version]: $vsVersion" -ForegroundColor Green
Write-Host "=== [BUILD Type]: $buildType" -ForegroundColor Green
Write-Host "=== [ARCH]: $arch" -ForegroundColor Green
Write-Host "=== [Source Path]: $sourcePath" -ForegroundColor Green
Write-Host "=== [OpenSSL Path]: $AbslPath" -ForegroundColor Green
Write-Host "=== [CMAKE_CXX_FLAGS_DEBUG]: $cmakeCXXFlagsDebug" -ForegroundColor Green
Write-Host "=== [CMAKE_CXX_FLAGS_RELEASE]: $cmakeCXXFlagsRelease" -ForegroundColor Green
Write-Host "=== [CMAKE_CXX_FLAGS_RELEASE_MD]: $cmakeCXXFlagsReleaseMD" -ForegroundColor Green
Write-Host "=== [CMAKE_CXX_FLAGS_MINSIZEREL]: $cmakeCXXFlagsMinSizeRel" -ForegroundColor Green
Write-Host "=== [cmakeArgs]: $cmakeArgs" -ForegroundColor Green
Write-Host "====================================================================" -ForegroundColor Cyan

$response = Read-Host "Is this information correct? (y/n)"
if ($response -ne 'y') {
    Write-Host "Configuration aborted by user." -ForegroundColor Red
    exit
}

# Run CMake to configure
$cmakeArgs += "-DCMAKE_CXX_FLAGS_DEBUG=$cmakeCXXFlagsDebug"
$cmakeArgs += "-DCMAKE_CXX_FLAGS_RELEASE=$cmakeCXXFlagsRelease"
$cmakeArgs += "-DCMAKE_CXX_FLAGS_MINSIZEREL=$cmakeCXXFlagsMinSizeRel"
$cmakeArgs += "-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=$cmakeCXXFlagsRelease"

if ($buildType -eq "Release-MD") {
    $cmakeArgs += "-DCMAKE_CXX_FLAGS=$cmakeCXXFlagsReleaseMD"
}

& cmake $cmakeArgs

# Build and install
& cmake --build . --config $buildType
& cmake --build . --target install --config $buildType

# Return to original path
Set-Location -Path $sourcePath

# Cleanup: Remove build directory
Remove-Item -Path $buildPath -Recurse -Force

Write-Host "Build and installation completed and cleaned up for Visual Studio $vsVersion, $buildType, $arch, installed at $installPath" -ForegroundColor Green
반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함
250x250