Skip to content

Commit

Permalink
ARROW-18256: [C++][Windows] Use IMPORTED_IMPLIB for external shared T…
Browse files Browse the repository at this point in the history
…hrift
  • Loading branch information
kou committed Nov 6, 2022
1 parent 7f067f9 commit aad9065
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions cpp/cmake_modules/FindThrift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,22 @@ endif()
set(THRIFT_LIB_NAME_BASE "thrift${THRIFT_MSVC_LIB_SUFFIX}")

if(ARROW_THRIFT_USE_SHARED)
set(THRIFT_LIB_NAMES thrift)
if(CMAKE_IMPORT_LIBRARY_SUFFIX)
list(APPEND
THRIFT_LIB_NAMES
"${CMAKE_IMPORT_LIBRARY_PREFIX}${THRIFT_LIB_NAME_BASE}${CMAKE_IMPORT_LIBRARY_SUFFIX}"
)
set(THRIFT_LIB_NAME
"${CMAKE_IMPORT_LIBRARY_PREFIX}${THRIFT_LIB_NAME_BASE}${CMAKE_IMPORT_LIBRARY_SUFFIX}")
else()
set(THRIFT_LIB_NAME
"${CMAKE_SHARED_LIBRARY_PREFIX}${THRIFT_LIB_NAME_BASE}${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
list(APPEND
THRIFT_LIB_NAMES
"${CMAKE_SHARED_LIBRARY_PREFIX}${THRIFT_LIB_NAME_BASE}${CMAKE_SHARED_LIBRARY_SUFFIX}"
)
else()
set(THRIFT_LIB_NAMES
set(THRIFT_LIB_NAME
"${CMAKE_STATIC_LIBRARY_PREFIX}${THRIFT_LIB_NAME_BASE}${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
endif()

if(Thrift_ROOT)
find_library(THRIFT_LIB
NAMES ${THRIFT_LIB_NAMES}
NAMES ${THRIFT_LIB_NAME}
PATHS ${Thrift_ROOT}
PATH_SUFFIXES "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib")
find_path(THRIFT_INCLUDE_DIR thrift/Thrift.h
Expand All @@ -108,7 +104,7 @@ else()
list(APPEND THRIFT_PC_LIBRARY_DIRS "${THRIFT_PC_LIBDIR}")

find_library(THRIFT_LIB
NAMES ${THRIFT_LIB_NAMES}
NAMES ${THRIFT_LIB_NAME}
PATHS ${THRIFT_PC_LIBRARY_DIRS}
NO_DEFAULT_PATH)
find_program(THRIFT_COMPILER thrift
Expand All @@ -118,7 +114,7 @@ else()
set(Thrift_VERSION ${THRIFT_PC_VERSION})
else()
find_library(THRIFT_LIB
NAMES ${THRIFT_LIB_NAMES}
NAMES ${THRIFT_LIB_NAME}
PATH_SUFFIXES "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib")
find_path(THRIFT_INCLUDE_DIR thrift/Thrift.h PATH_SUFFIXES "include")
find_program(THRIFT_COMPILER thrift PATH_SUFFIXES "bin")
Expand All @@ -139,13 +135,17 @@ find_package_handle_standard_args(
HANDLE_COMPONENTS)

if(Thrift_FOUND)
set(Thrift_IMPORTED_PROPERTY_NAME IMPORTED_LOCATION)
if(ARROW_THRIFT_USE_SHARED)
add_library(thrift::thrift SHARED IMPORTED)
if(CMAKE_IMPORT_LIBRARY_SUFFIX)
set(Thrift_IMPORTED_PROPERTY_NAME IMPORTED_IMPLIB)
endif()
else()
add_library(thrift::thrift STATIC IMPORTED)
endif()
set_target_properties(thrift::thrift
PROPERTIES IMPORTED_LOCATION "${THRIFT_LIB}"
PROPERTIES ${Thrift_IMPORTED_PROPERTY_NAME} "${THRIFT_LIB}"
INTERFACE_INCLUDE_DIRECTORIES "${THRIFT_INCLUDE_DIR}")
if(WIN32 AND NOT MSVC_TOOLCHAIN)
# We don't need this for Visual C++ because Thrift uses
Expand Down

0 comments on commit aad9065

Please sign in to comment.