Skip to content

Commit

Permalink
Include /usr/local/include for AppleClang.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyfdecyf committed Aug 8, 2021
1 parent cb3f8ff commit 33385b1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ endif(USE_CUDA)
)

add_library(lightgbm_objs OBJECT ${SOURCES})
target_compile_options(lightgbm_objs PRIVATE -D_lightgbm_EXPORTS)

add_executable(lightgbm src/main.cpp src/application/application.cpp $<TARGET_OBJECTS:lightgbm_objs>)
set(API_SOURCES "src/c_api.cpp")
Expand All @@ -369,6 +370,7 @@ if(__BUILD_FOR_R)
endif(__BUILD_FOR_R)

add_library(lightgbm_capi_objs OBJECT ${API_SOURCES})
target_compile_options(lightgbm_capi_objs PRIVATE -D_lightgbm_EXPORTS)

if (BUILD_STATIC_LIB)
add_library(_lightgbm STATIC $<TARGET_OBJECTS:lightgbm_capi_objs> $<TARGET_OBJECTS:lightgbm_objs>)
Expand Down Expand Up @@ -424,6 +426,11 @@ endif(USE_MPI)

if(USE_OPENMP)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# Include directory has to be explicitly speicfied when using CMake object library
# to compile R package. Otherwise, omp.h can't be found.
# OpenMP_CXX_INCLUDE_DIRS is empty so use hard coded path here.
include_directories(SYSTEM /usr/local/include)

TARGET_LINK_LIBRARIES(lightgbm OpenMP::OpenMP_CXX)
TARGET_LINK_LIBRARIES(_lightgbm OpenMP::OpenMP_CXX)
endif()
Expand Down

0 comments on commit 33385b1

Please sign in to comment.