blender/intern/cycles/app/CMakeLists.txt
Jonas Holzman 57f767f109 Build: Cycles: Migrate Cycles Standalone from SDL2 to SDL3
Currently, Cycles Standalone links against a system SDL2 for creating
its window. This is due to our previous SDL2 pre-compiled dependency
not providing the video module required for windowing due to it only
being used for audio. With the recent SDL3 migration (!157521), the
video submodule was enabled, allowing it to now be also used for Cycles
Standalone windowing.

Changes:
- Remove SDL2 external library find_package from `external_libs.cmake`
- Link against Blender's own `bf::dependencies::optional::sdl` target
- Make the internal `WITH_SDL` uncached CMake variable depend on
  `WITH_CYCLES_STANDALONE_GUI`
- Migrate SDL2 code in `window.cpp` to SDL3, based off Campbell's
  original SDL3 patch[^1]

[^1]: 02ce2baf0e (diff-3e6be82789041df3098be544352007094f890b94)

Pull Request: https://projects.blender.org/blender/blender/pulls/158498
2026-05-13 14:42:42 +02:00

174 lines
3.7 KiB
CMake

# SPDX-FileCopyrightText: 2011-2022 Blender Foundation
#
# SPDX-License-Identifier: Apache-2.0
#####################################################################
# Cycles standalone executable
#####################################################################
set(INC
..
)
set(INC_SYS
)
set(LIB
cycles_device
cycles_kernel
cycles_scene
cycles_session
cycles_bvh
cycles_subd
cycles_graph
cycles_util
)
if(WITH_CYCLES_OSL)
list(APPEND LIB cycles_kernel_osl)
endif()
if(CYCLES_STANDALONE_REPOSITORY)
list(APPEND LIB extern_sky)
else()
list(APPEND LIB bf_intern_sky)
endif()
if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
list(APPEND LIB
bf::dependencies::epoxy
bf::dependencies::optional::sdl
)
endif()
if(WITH_USD)
# Silence warning from USD headers using deprecated TBB header.
add_definitions(
-D__TBB_show_deprecation_message_atomic_H
-D__TBB_show_deprecation_message_task_H
)
list(APPEND LIB
cycles_hydra
bf::dependencies::optional::usd
)
endif()
cycles_external_libraries_append(LIB)
# Common configuration.
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})
if(APPLE AND NOT CYCLES_STANDALONE_REPOSITORY)
set(app_output_dir Blender.app/Contents/MacOS)
set(app_install_dir Blender.app/Contents/MacOS)
else()
set(app_install_dir ${CMAKE_INSTALL_PREFIX})
endif()
# Application build targets
if(WITH_CYCLES_STANDALONE)
set(SRC
cycles_standalone.cpp
cycles_xml.cpp
cycles_xml.h
oiio_output_driver.cpp
oiio_output_driver.h
)
if(WITH_CYCLES_STANDALONE_GUI)
list(APPEND SRC
opengl/display_driver.cpp
opengl/display_driver.h
opengl/shader.cpp
opengl/shader.h
opengl/window.cpp
opengl/window.h
)
endif()
add_executable(cycles ${SRC} ${INC} ${INC_SYS})
unset(SRC)
target_link_libraries(cycles PRIVATE ${LIB})
if(APPLE)
if(WITH_CYCLES_STANDALONE_GUI)
# Frameworks used by SDL.
string(CONCAT _cycles_sdl_frameworks
" -framework AudioToolbox"
" -framework AudioUnit"
" -framework Cocoa"
" -framework CoreAudio"
" -framework CoreHaptics"
" -framework CoreVideo"
" -framework ForceFeedback"
" -framework GameController"
)
set_property(
TARGET cycles
APPEND PROPERTY LINK_FLAGS
"${_cycles_sdl_frameworks}"
)
endif()
endif()
if(CYCLES_STANDALONE_REPOSITORY)
cycles_install_libraries(cycles)
if(WITH_USD AND USD_LIBRARY_DIR)
install(DIRECTORY
${USD_LIBRARY_DIR}/usd
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install(DIRECTORY
${USD_LIBRARY_DIR}/../plugin/usd
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
endif()
endif()
install(
TARGETS cycles
DESTINATION ${app_install_dir})
if(DEFINED app_output_dir)
set_target_properties(cycles
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${app_output_dir}")
endif()
add_test(
NAME cycles_version
COMMAND $<TARGET_FILE:cycles> --version)
endif()
if(WITH_CYCLES_PRECOMPUTE)
set(SRC
cycles_precompute.cpp
)
add_executable(cycles_precompute ${SRC} ${INC} ${INC_SYS})
unset(SRC)
target_link_libraries(cycles_precompute
PRIVATE cycles_util
PRIVATE bf::dependencies::openimageio
PRIVATE bf::dependencies::optional::tbb
PRIVATE bf::dependencies::optional::osl)
if(NOT CYCLES_STANDALONE_REPOSITORY)
target_link_libraries(cycles_precompute
PRIVATE bf::intern::guardedalloc)
endif()
if(DEFINED app_output_dir)
set_target_properties(cycles_precompute
PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${app_output_dir}")
endif()
install(
TARGETS cycles_precompute
DESTINATION ${app_install_dir})
endif()