-
Project Properties -> General:
- Top dropdowns = "All configurations" and "All platforms",
- C++ Language Standard = C++ 20
- Output and Temp Directories (default location is at .sln level)
- Set Output Directory to
$(ProjectDir)$(Platform)\$(Configuration)
- Set Temp Directory to
$(ProjectDir)$(Platform)\Temp-$(Configuration)
- Set Output Directory to
-
Headers:
- Project Properties -> C\C++ -> General -> Additional Include Directories = add relative path to where those header files are.
-
Libs:
- Project Properties -> Linker -> General -> Additional Library Directories = add a relative path to .lib files,
- Project Properties -> Linker -> Input -> Additional Dependencies = add .lib names (separated by
;
)
-
Source Code:
- Add C/C++ files to the project, then:
- Solution Explorer -> Show Hidden Files -> Right click on the newly added source files -> Include In Project.
-
DLLs:
-
Project Properties -> Build Events -> Post-Build-Event, you have two options:
5.1. Trigger powershell to execute a .ps1 script that copies the dlls to output directory (recommended)
- Example post build event that triggers .ps1 script that does the post-build setup (MAKE SURE PWSH added to PATH)
pwsh -file .\automation\post-build.ps1 "$(ProjectDir.TrimEnd('\'))" "$(outputPath.TrimEnd('\'))"
- Sample
post-build.ps1
script (ex. resides inautomation
directory inside project folder)
param([string]$projectDir, [string]$outputPath); # some logging Write-Host "ProjectDir = $projectDir" Write-Host "OutputPath = $outputPath" # 1. Copy dlls to output directory Write-Host "Copying dlls to output dir..." Copy-Item -Path "$projectDir\dlls\*" -Destination "$outputPath" -Force -Recurse # this\* will make the .dll files, not the folder. # 2. Copy resources to output directory Write-Host "Copying resources to output dir..." Copy-Item -Path "$projectDir\resources" -Destination "$outputPath" -Force -Recurse # copies resources folder Write-Host "DONE."
5.2. Or: add
xcopy
command to copy .dll files to output directory- Example post build events to copy the needed files/folders to output directory
REM copy res directory to output xcopy "$(ProjectDir)res" "$(OutputPath)res" /Y /I /E REM copy .dll files directory to output (todo test) xcopy "$(ProjectDir)dlls\*" "$(OutputPath)" /Y /I /E
Take a look at this project as an example.