Skip to content

Commit

Permalink
Fix builds of applications using Slint via FetchContent (part 2)
Browse files Browse the repository at this point in the history
Amend 8406e10 by fixing the condition
to apply the install_name when the cache variable used to detect package
builds is defined, not _not_ defined.

cc slint-ui#2075
  • Loading branch information
tronical committed Apr 3, 2023
1 parent ba793a8 commit 13a5d3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ if (WIN32)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin/debug)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin/release)
elseif(APPLE)
# On macOS, the slint_cpp.dylib's install_name uses @rpath. CMake doesn't set BUILD_RPATH for
# imported targets though, so include the directory here by hand in the rpath used to build binaries
# in the build tree (such as our examples or tests).
set(CMAKE_BUILD_RPATH ${CMAKE_BINARY_DIR}/api/cpp)
endif()

add_subdirectory(api/cpp/)
Expand Down
2 changes: 1 addition & 1 deletion api/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ corrosion_import_crate(MANIFEST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../Cargo.to
# include the binary dir and thus our examples would have the correct rpath set, binaries
# outside (i.e. applications using Slint via FetchContent) would not and the BUILD_RPATH
# target property doesn't propagate :(
if (APPLE AND NOT DEFINED CACHE{SLINT_BUILD_TESTING})
if (APPLE AND DEFINED CACHE{SLINT_BUILD_TESTING})
# corrosion could provide the Cargo.toml package version as a CMake target property.
corrosion_add_target_local_rustflags(slint-cpp -Clink-arg=-Wl,-install_name,@rpath/libslint_cpp.dylib,-current_version,${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR},-compatibility_version,${PROJECT_VERSION_MAJOR}.0)
# Set this one to false again explicitely because Corrosion will starting setting this property to true by default.
Expand Down

0 comments on commit 13a5d3c

Please sign in to comment.