Skip to content

Commit fa50fd2

Browse files
committed
static linking flag logic fix
1 parent 164b01a commit fa50fd2

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

projectm-sys/build.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ fn enable_playlist() -> &'static str {
1212
"OFF"
1313
}
1414
}
15-
16-
fn enable_static_link() -> &'static str {
15+
// Are we linking to shared or static libraries?
16+
fn build_shared_libs_flag() -> &'static str {
1717
if cfg!(feature = "static") {
18-
"ON"
18+
"OFF" // Disable shared libs to enable static linking
1919
} else {
20-
"OFF"
20+
"ON" // Enable shared libs
2121
}
2222
}
2323

@@ -37,7 +37,7 @@ fn main() {
3737

3838
// Determine feature flags
3939
let enable_playlist_flag = enable_playlist();
40-
let enable_static_flag = enable_static_link();
40+
let build_shared_libs = build_shared_libs_flag();
4141

4242
let dst;
4343

@@ -90,7 +90,7 @@ fn main() {
9090
.define("CMAKE_VERBOSE_MAKEFILE", "ON")
9191
.define("BUILD_TESTING", "OFF")
9292
.define("BUILD_EXAMPLES", "OFF")
93-
.define("BUILD_SHARED_LIBS", enable_static_flag); // Integrated static linking option
93+
.define("BUILD_SHARED_LIBS", build_shared_libs); // static/dynamic
9494

9595
dst = cmake_config.build();
9696
} else if cfg!(target_os = "emscripten") {
@@ -100,15 +100,15 @@ fn main() {
100100
.define("BUILD_TESTING", "OFF")
101101
.define("BUILD_EXAMPLES", "OFF")
102102
.define("ENABLE_EMSCRIPTEN", "ON")
103-
.define("BUILD_SHARED_LIBS", enable_static_flag) // Integrated static linking option
103+
.define("BUILD_SHARED_LIBS", build_shared_libs) // static/dynamic
104104
.build();
105105
} else {
106106
// Configure and build libprojectM using CMake for other platforms (Linux, macOS)
107107
dst = cmake::Config::new(&projectm_path)
108108
.define("ENABLE_PLAYLIST", enable_playlist_flag)
109109
.define("BUILD_TESTING", "OFF")
110110
.define("BUILD_EXAMPLES", "OFF")
111-
.define("BUILD_SHARED_LIBS", enable_static_flag) // Integrated static linking option
111+
.define("BUILD_SHARED_LIBS", build_shared_libs) // static/dynamic
112112
.build();
113113
}
114114

@@ -120,7 +120,7 @@ fn main() {
120120

121121
// Platform and feature-specific library linking
122122
if cfg!(target_os = "windows") || cfg!(target_os = "emscripten") {
123-
// Static linking for Windows and Emscripten if the 'static' feature is enabled
123+
// Static or Dynamic linking based on 'static' feature
124124
if cfg!(feature = "static") {
125125
if profile == "release" {
126126
println!("cargo:rustc-link-lib=static=projectM-4");
@@ -134,7 +134,6 @@ fn main() {
134134
}
135135
}
136136
} else {
137-
// Dynamic linking if 'static' feature is not enabled
138137
if profile == "release" {
139138
println!("cargo:rustc-link-lib=dylib=projectM-4");
140139
if cfg!(feature = "playlist") {

0 commit comments

Comments
 (0)