when it comes to quotes, cmake is quite like bash... cherry-picked from: qt-wgpu-skel:1c28c636b7cc9497e3e8ba6718b1e4eecab5298e
34 lines
903 B
CMake
34 lines
903 B
CMake
# build the Rust side as a static library
|
|
set(impl_basename "${CARGO_TARGET_DIR}/release/libphoton_light_impl")
|
|
|
|
set(cargo_cmake_args)
|
|
|
|
if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.27")
|
|
list(APPEND cargo_cmake_args DEPENDS_EXPLICIT_ONLY)
|
|
endif()
|
|
|
|
if("${CMAKE_VERSION}" VERSION_GREATER_EQUAL "3.28")
|
|
list(APPEND cargo_cmake_args JOB_SERVER_AWARE TRUE)
|
|
endif()
|
|
|
|
add_custom_command(
|
|
OUTPUT "${impl_basename}.a"
|
|
COMMAND env "CARGO_TARGET_DIR=${CARGO_TARGET_DIR}" ${CARGO} build --release --package photon-light-impl
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
DEPFILE "${impl_basename}.d"
|
|
USES_TERMINAL
|
|
VERBATIM
|
|
${cargo_cmake_args}
|
|
)
|
|
|
|
# HACK ensure CMake *actually adds* the command above
|
|
add_custom_target(build_impl
|
|
DEPENDS "${impl_basename}.a"
|
|
)
|
|
|
|
add_library(photon_light_impl STATIC IMPORTED)
|
|
|
|
set_target_properties(photon_light_impl PROPERTIES
|
|
IMPORTED_LOCATION "${impl_basename}.a"
|
|
)
|