Skip to content

Commit

Permalink
build: Prefer system libcaesium if present
Browse files Browse the repository at this point in the history
`ExternalProject_Add` does not work in build sandboxes without network access Linux distros like NixOS use.
Let’s skip it and use `libcaesium` from package manager when available, since that is the preferred way on Linux.
  • Loading branch information
jtojnar committed May 25, 2023
1 parent 123830b commit 63761ac
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ else ()
project(${TARGET} LANGUAGES CXX)
endif ()

find_program(CARGO "cargo" REQUIRED)
find_library(LIBCAESIUM libcaesium)
if(NOT LIBCAESIUM)
find_program(CARGO "cargo" REQUIRED)
endif ()

add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x050F00)

Expand Down Expand Up @@ -159,20 +162,23 @@ if (WIN32)
set(CARGO_TARGET "--target=x86_64-pc-windows-gnu")
endif ()

ExternalProject_Add(
libcaesium
GIT_REPOSITORY https://github.com/Lymphatus/libcaesium
GIT_TAG ${LIBCAESIUM_VERSION}
CONFIGURE_COMMAND ""
BUILD_COMMAND ${CARGO} build ${CARGO_BUILD_FLAGS} ${CARGO_TARGET}
INSTALL_COMMAND ""
BINARY_DIR ${LIBCAESIUM_SOURCE_DIR}
LOG_OUTPUT_ON_FAILURE ON
LOG_BUILD ON
BUILD_BYPRODUCTS ${LIBCAESIUM_SOURCE_DIR}/target/x86_64-pc-windows-gnu/${LIBCAESIUM_BUILD_TYPE}/caesium.dll
)

add_dependencies(caesium_image_compressor libcaesium)
if (LIBCAESIUM)
add_dependencies(caesium_image_compressor ${LIBCAESIUM})
else ()
ExternalProject_Add(
libcaesium
GIT_REPOSITORY https://github.com/Lymphatus/libcaesium
GIT_TAG ${LIBCAESIUM_VERSION}
CONFIGURE_COMMAND ""
BUILD_COMMAND ${CARGO} build ${CARGO_BUILD_FLAGS} ${CARGO_TARGET}
INSTALL_COMMAND ""
BINARY_DIR ${LIBCAESIUM_SOURCE_DIR}
LOG_OUTPUT_ON_FAILURE ON
LOG_BUILD ON
BUILD_BYPRODUCTS ${LIBCAESIUM_SOURCE_DIR}/target/x86_64-pc-windows-gnu/${LIBCAESIUM_BUILD_TYPE}/caesium.dll
)
add_dependencies(caesium_image_compressor libcaesium)
endif ()

# --- WinSparkle ---
if (WIN32)
Expand Down

0 comments on commit 63761ac

Please sign in to comment.