Skip to content

Commit

Permalink
Add -fPIC for building shared library.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Aug 9, 2021
1 parent 3c723b6 commit ccafdab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ if(MSVC)
endif()
else()
if(NOT USE_DEBUG)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -funroll-loops")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -funroll-loops")
endif()
endif(MSVC)

Expand Down Expand Up @@ -374,6 +374,10 @@ if (BUILD_STATIC_LIB)
add_library(_lightgbm STATIC $<TARGET_OBJECTS:lightgbm_capi_objs> $<TARGET_OBJECTS:lightgbm_objs>)
else()
add_library(_lightgbm SHARED $<TARGET_OBJECTS:lightgbm_capi_objs> $<TARGET_OBJECTS:lightgbm_objs>)
if(NOT MSVC)
target_compile_options(lightgbm_objs PRIVATE -fPIC)
target_compile_options(lightgbm_capi_objs PRIVATE -fPIC)
endif(MSVC)
endif(BUILD_STATIC_LIB)

if(MSVC)
Expand Down

0 comments on commit ccafdab

Please sign in to comment.