Skip to content

Commit 5d1e970

Browse files
committed
C++: Fix build with nightly Rust
Cargo disallows dashes in library target names (lib.name in Cargo.toml), but when not set it uses the package name. That meant that dashes snuck in and rust-lang/cargo#12783 fixes that. The targets Corrosion creates correspond to the library name, so after that change it's slint_cpp. To make this work with stable cargo, explicitly switch lib.name to slint_cpp.
1 parent f623841 commit 5d1e970

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

api/cpp/CMakeLists.txt

+19-19
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ if (SLINT_BUILD_RUNTIME)
113113

114114
if(BUILD_SHARED_LIBS)
115115
set(rustc_lib_type "cdylib")
116-
set(slint_cpp_impl "slint-cpp-shared")
116+
set(slint_cpp_impl "slint_cpp-shared")
117117
set(cmake_lib_type "SHARED")
118118
else()
119119
set(rustc_lib_type "staticlib")
120-
set(slint_cpp_impl "slint-cpp-static")
120+
set(slint_cpp_impl "slint_cpp-static")
121121
set(cmake_lib_type "STATIC")
122122
endif()
123123

@@ -142,15 +142,15 @@ if (SLINT_BUILD_RUNTIME)
142142
# target property doesn't propagate :(
143143
if (APPLE AND SLINT_IS_TOPLEVEL_BUILD AND BUILD_SHARED_LIBS)
144144
# corrosion could provide the Cargo.toml package version as a CMake target property.
145-
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)
145+
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)
146146
# Set this one to false again explicitely because Corrosion will starting setting this property to true by default.
147-
set_target_properties(slint-cpp-shared PROPERTIES IMPORTED_NO_SONAME 0)
148-
set_target_properties(slint-cpp-shared PROPERTIES IMPORTED_SONAME libslint_cpp.dylib)
147+
set_target_properties(slint_cpp-shared PROPERTIES IMPORTED_NO_SONAME 0)
148+
set_target_properties(slint_cpp-shared PROPERTIES IMPORTED_SONAME libslint_cpp.dylib)
149149
endif()
150150

151151
add_library(Slint INTERFACE)
152152
add_library(Slint::Slint ALIAS Slint)
153-
target_link_libraries(Slint INTERFACE slint-cpp)
153+
target_link_libraries(Slint INTERFACE slint_cpp)
154154
target_compile_features(Slint INTERFACE cxx_std_20)
155155
if (MSVC)
156156
target_compile_options(Slint INTERFACE /bigobj)
@@ -167,25 +167,25 @@ if (SLINT_BUILD_RUNTIME)
167167

168168

169169
set_property(
170-
TARGET slint-cpp
170+
TARGET slint_cpp
171171
APPEND
172172
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
173173
"SLINT_GENERATED_INCLUDE_DIR=${CMAKE_CURRENT_BINARY_DIR}/generated_include/"
174174
)
175175

176176
set_property(
177-
TARGET slint-cpp
177+
TARGET slint_cpp
178178
PROPERTY CORROSION_FEATURES
179179
${features}
180180
)
181181
set_property(
182-
TARGET slint-cpp
182+
TARGET slint_cpp
183183
PROPERTY CORROSION_NO_DEFAULT_FEATURES
184184
ON
185185
)
186186

187187
if(SLINT_LIBRARY_CARGO_FLAGS)
188-
corrosion_set_cargo_flags(slint-cpp ${SLINT_LIBRARY_CARGO_FLAGS})
188+
corrosion_set_cargo_flags(slint_cpp ${SLINT_LIBRARY_CARGO_FLAGS})
189189
endif()
190190

191191
if(SLINT_FEATURE_BACKEND_QT)
@@ -200,14 +200,14 @@ if (SLINT_BUILD_RUNTIME)
200200

201201
if(SLINT_FEATURE_BACKEND_QT AND TARGET Qt::qmake)
202202
set_property(
203-
TARGET slint-cpp
203+
TARGET slint_cpp
204204
APPEND
205205
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
206206
QMAKE=$<TARGET_PROPERTY:Qt::qmake,LOCATION>
207207
)
208208
else()
209209
set_property(
210-
TARGET slint-cpp
210+
TARGET slint_cpp
211211
APPEND
212212
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
213213
SLINT_NO_QT=1
@@ -241,7 +241,7 @@ if (SLINT_BUILD_RUNTIME)
241241
# to build time.
242242
if(DEFINED ENV{PKG_CONFIG_SYSROOT_DIR})
243243
set_property(
244-
TARGET slint-cpp
244+
TARGET slint_cpp
245245
APPEND
246246
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
247247
"PKG_CONFIG_SYSROOT_DIR=$ENV{PKG_CONFIG_SYSROOT_DIR}"
@@ -253,15 +253,15 @@ if (SLINT_BUILD_RUNTIME)
253253
find_program(CLANGCXX clang++)
254254
if(CLANGCC AND NOT DEFINED ENV{CLANGCC})
255255
set_property(
256-
TARGET slint-cpp
256+
TARGET slint_cpp
257257
APPEND
258258
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
259259
CLANGCC=${CLANGCC}
260260
)
261261
endif()
262262
if(CLANGCXX AND NOT DEFINED ENV{CLANGCXX})
263263
set_property(
264-
TARGET slint-cpp
264+
TARGET slint_cpp
265265
APPEND
266266
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
267267
CLANGCXX=${CLANGCXX}
@@ -289,13 +289,13 @@ if (SLINT_BUILD_RUNTIME)
289289
if(host_cc)
290290
string(REPLACE "-" "_" cargo_host_target_underscore "${Rust_CARGO_HOST_TARGET}")
291291
set_property(
292-
TARGET slint-cpp
292+
TARGET slint_cpp
293293
APPEND
294294
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
295295
CC_${cargo_host_target_underscore}=${host_cc}
296296
)
297297
set_property(
298-
TARGET slint-cpp
298+
TARGET slint_cpp
299299
APPEND
300300
PROPERTY CORROSION_ENVIRONMENT_VARIABLES
301301
CFLAGS_${cargo_host_target_underscore}=
@@ -354,10 +354,10 @@ if (SLINT_BUILD_RUNTIME)
354354
include(${CMAKE_CURRENT_LIST_DIR}/cmake/SlintMacro.cmake)
355355
endif()
356356

357-
export(TARGETS Slint slint-cpp
357+
export(TARGETS Slint slint_cpp
358358
NAMESPACE Slint:: FILE "${CMAKE_BINARY_DIR}/lib/cmake/Slint/SlintTargets.cmake")
359359
install(EXPORT SlintTargets NAMESPACE Slint:: DESTINATION lib/cmake/Slint)
360-
install(TARGETS Slint slint-cpp
360+
install(TARGETS Slint slint_cpp
361361
EXPORT SlintTargets LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include/slint)
362362

363363
install(FILES $<TARGET_FILE:${slint_cpp_impl}> TYPE LIB)

api/cpp/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ links = "slint_cpp"
2020
[lib]
2121
path = "lib.rs"
2222
crate-type = ["lib", "cdylib", "staticlib"]
23+
name = "slint_cpp"
2324

2425
# Note, these features need to be kept in sync (along with their defaults) in
2526
# the C++ crate's CMakeLists.txt

0 commit comments

Comments
 (0)