Skip to content

Commit e02fc64

Browse files
author
Montana Low
committed
handle old os x
1 parent b1b714b commit e02fc64

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lightgbm-sys/build.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,25 @@ fn main() {
3737

3838
// CMake
3939
let mut dst = Config::new(&lgbm_root);
40-
let dst = dst
40+
let mut dst = dst
4141
.profile("Release")
4242
.define("BUILD_STATIC_LIB", "ON")
4343
.define("CMAKE_POSITION_INDEPENDENT_CODE", "ON");
4444

4545
#[cfg(feature = "cuda")]
46-
let dst = dst.define("USE_CUDA", "1").define("USE_CUDA_EXP", "1");
46+
let mut dst = dst.define("USE_CUDA", "1").define("USE_CUDA_EXP", "1");
4747

4848
#[cfg(target_os = "macos")]
49-
let dst = dst
50-
.define("CMAKE_C_COMPILER", "/opt/homebrew/opt/llvm/bin/clang")
51-
.define("CMAKE_CXX_COMPILER", "/opt/homebrew/opt/llvm/bin/clang++")
52-
.define("OPENMP_LIBRARIES", "/opt/homebrew/opt/llvm/lib")
53-
.define("OPENMP_INCLUDES", "/opt/homebrew/opt/llvm/include");
49+
{
50+
let path = PathBuf::from("/opt/homebrew/"); // check for m1 vs intel config
51+
if let Ok(_dir) = std::fs::read_dir(&path) {
52+
dst = dst
53+
.define("CMAKE_C_COMPILER", "/opt/homebrew/opt/llvm/bin/clang")
54+
.define("CMAKE_CXX_COMPILER", "/opt/homebrew/opt/llvm/bin/clang++")
55+
.define("OPENMP_LIBRARIES", "/opt/homebrew/opt/llvm/lib")
56+
.define("OPENMP_INCLUDES", "/opt/homebrew/opt/llvm/include");
57+
};
58+
}
5459

5560
let dst = dst.build();
5661

0 commit comments

Comments
 (0)