diff --git a/CMakeLists.txt b/CMakeLists.txt index a07c3fe79b6f..24ffbffda27f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ OPTION(USE_HDFS "Enable HDFS support (EXPERIMENTAL)" OFF) OPTION(USE_R35 "Set to ON if your R version is not earlier than 3.5" OFF) OPTION(USE_TIMETAG "Set to ON to output time costs" OFF) OPTION(USE_DEBUG "Set to ON for Debug mode" OFF) +option(BUILD_STATIC_LIB "Build static library" OFF) OPTION(BUILD_FOR_R "Set to ON if building lib_lightgbm for use with the R package" OFF) if(APPLE) @@ -243,7 +244,11 @@ if(BUILD_FOR_R) list(APPEND SOURCES "src/lightgbm_R.cpp") endif(BUILD_FOR_R) -add_library(_lightgbm SHARED ${SOURCES}) +if (BUILD_STATIC_LIB) + add_library(_lightgbm STATIC ${SOURCES}) +else() + add_library(_lightgbm SHARED ${SOURCES}) +endif(BUILD_STATIC_LIB) if(MSVC) set_target_properties(_lightgbm PROPERTIES OUTPUT_NAME "lib_lightgbm")