pbrt-v4
pbrt-v4 copied to clipboard
Windows release build
I've compiled pbrt v4 GPU in windows with cmake and MSVC. As the Debug version is slow, I've been trying to get the release one. Matt wrote the build yields the release version by default, but this has not been the case in windows, as you obtain the debug one instead, even after manually setting CMAKE_BUILD_TYPE to 'Release'. So the solution I've found is to select the release version at build time, by using:
cmake --build . --config Release
Are you using the built-in CMake support in Visual Studio (which uses the “Ninja” or “Ninja Multi-Config” generator), or did you use CMake to generate a Visual Studio project and open that?
Could you please try editing the main CMakeLists.txt and add the following code between the cmake_minimum_required()
and the project()
command, and re-try to see if you now get the “Release” build by default? You will need to get rid of your existing CMake cache first though.
get_property(PBRT_MULTICONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (PBRT_MULTICONFIG_GENERATOR)
if (NOT CMAKE_CONFIGURATION_TYPES)
message (STATUS "Setting the available builds types with 'Release' as default as none was specified.")
set (CMAKE_CONFIGURATION_TYPES "Release" "Debug" "MinSizeRel" "RelWithDebInfo" CACHE STRING "Choose the types of builds available to multi-config generators." FORCE)
endif ()
else ()
if (NOT CMAKE_BUILD_TYPE)
message (STATUS "Setting build type to 'Release' as none was specified.")
set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug"
"MinSizeRel" "RelWithDebInfo")
endif ()
endif ()
Hi.. instead to modify the CMakeList.txt, I use a small .cmd file to define variables, create the project and launch the compilation from the console
@echo off
@echo.
:: my custom CMake install path
@set PATH=C:/apps/CMake/bin;%PATH%
:: This assume that MSVC Community is installed in the default path
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
:: to create a fresh build
if exist build rmdir build /s /q
mkdir build
cd build
:: Generate project for MSVC 2022
cmake -G "Visual Studio 17 2022" ../ ^
-DPBRT_OPTIX7_PATH=F:/CUDA/OptiXSDK770 ^
-DCMAKE_INSTALL_PREFIX=./pbrt4deploy ^
-DCMAKE_BUILD_TYPE="Release"
:: build and install a Release version
cmake --build . --parallel 8 --config Release --target install
if %ERRORLEVEL% NEQ 0 goto build_error
if %ERRORLEVEL% NEQ 1 goto succes
:build_error
echo "Error building project"
:: to allow look any console messages
pause
goto end
:succes
:: back to sources folder
cd ..
echo "End build file sucessful"
:end
I placed this file in the 'root' folder of my cloned repository. Hope this helps you. Cheers..
Hi.. instead to modify the CMakeList.txt, I use a small .cmd file to define variables, create the project and launch the compilation from the console
My comment regarding modifying the CMakeLists.txt was not meant as a workaround that users should make, but rather as something PBRT should be doing; and since I no longer have a Windows install, I can not test locally that the change fixes it. There is already code in PBRT’s CMakeLists.txt for defaulting to a Release build if nothing was specified, but that code only applies to single-config generators. So the idea would be to extend that code with multi-config generator support.
Yes, of course! I only expose my own solution. :)
Are you using the built-in CMake support in Visual Studio (which uses the “Ninja” or “Ninja Multi-Config” generator), or did you use CMake to generate a Visual Studio project and open that?
I just used CMake from the command line to generate all the build files, then I built also from the command line, I used:
cmake ../pbrt-v4.git -DPBRT_OPTIX7_PATH="C:\ProgramData\NVIDIA Corporation\OptiX SDK 7.7.0" -DCMAKE_BUILD_TYPE="Release"
cmake --build .
allthough I used -DCMAKE_BUILD_TYPE="Release"
, the Debug version was built, so I had to use
cmake --build . --config relase
Could you please try editing the main CMakeLists.txt and add the following code between the
cmake_minimum_required()
and theproject()
command, and re-try to see if you now get the “Release” build by default? You will need to get rid of your existing CMake cache first though.
thanks a lot for the suggestion, I'll try to test this in windows
Hi.. instead to modify the CMakeList.txt, I use a small .cmd file to define variables, create the project and launch the compilation from the console
....
Thanks a lot for the script, it is quite helpful to me, as I'm not so used to scripting in windows