HDFS-16464. Create only libhdfspp static libraries for Windows (#4571)
* Added the appropriate CMake flags and commands to enable only statically linked libraries and executables to be built on Windows.
This commit is contained in:
parent
21b8952125
commit
4fb799e6c5
|
@ -18,12 +18,33 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
|
||||
|
||||
# Need this CMake policy for using the MultiThreaded MSVC runtime library.
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
|
||||
# Need this CMake policy for invoking target_link_libraries on a target in any directory.
|
||||
cmake_policy(SET CMP0079 NEW)
|
||||
|
||||
project(hadoop_hdfs_native_client)
|
||||
|
||||
enable_testing()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
if (MSVC)
|
||||
# Instructs MSVC to use the static version of the runtime library.
|
||||
# More info - https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-170
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
|
||||
|
||||
# This indicates that Windows 10 and above are supported.
|
||||
# More info - https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
|
||||
set(NT_REQUIRED_VERSION 0x0A00)
|
||||
add_definitions(-D_WIN32_WINNT=${NT_REQUIRED_VERSION})
|
||||
|
||||
# Windows.h defines the "min" and "max" macros which conflicts with the std::min and std::max from C++ STL.
|
||||
# Adding the below definition will disable this macro.
|
||||
add_definitions(-DNOMINMAX)
|
||||
endif (MSVC)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../../hadoop-common-project/hadoop-common)
|
||||
include(HadoopCommon)
|
||||
|
||||
|
|
|
@ -274,7 +274,8 @@ endif()
|
|||
|
||||
set(LIBHDFSPP_VERSION "0.1.0")
|
||||
set(LIBHDFSPP_ALL_OBJECTS $<TARGET_OBJECTS:x_platform_obj> $<TARGET_OBJECTS:bindings_c_obj> $<TARGET_OBJECTS:fs_obj> $<TARGET_OBJECTS:rpc_obj> $<TARGET_OBJECTS:reader_obj> $<TARGET_OBJECTS:proto_obj> $<TARGET_OBJECTS:connection_obj> $<TARGET_OBJECTS:common_obj> $<TARGET_OBJECTS:uriparser2_obj>)
|
||||
if (HADOOP_BUILD)
|
||||
# HDFS-16464: We don't support building Hadoop DLL for Windows yet.
|
||||
if (HADOOP_BUILD AND NOT MSVC)
|
||||
hadoop_add_dual_library(hdfspp ${EMPTY_FILE_CC} ${LIBHDFSPP_ALL_OBJECTS})
|
||||
hadoop_target_link_dual_libraries(hdfspp
|
||||
${LIB_DL}
|
||||
|
@ -285,20 +286,19 @@ if (HADOOP_BUILD)
|
|||
)
|
||||
set_target_properties(hdfspp PROPERTIES SOVERSION ${LIBHDFSPP_VERSION})
|
||||
hadoop_dual_output_directory(hdfspp ${OUT_DIR})
|
||||
else (HADOOP_BUILD)
|
||||
else (HADOOP_BUILD AND NOT MSVC)
|
||||
add_library(hdfspp_static STATIC ${EMPTY_FILE_CC} ${LIBHDFSPP_ALL_OBJECTS})
|
||||
target_link_libraries(hdfspp_static
|
||||
target_link_libraries(hdfspp_static PUBLIC
|
||||
${LIB_DL}
|
||||
${PROTOBUF_LIBRARY}
|
||||
${OPENSSL_LIBRARIES}
|
||||
${SASL_LIBRARIES}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
)
|
||||
${CMAKE_THREAD_LIBS_INIT})
|
||||
if(BUILD_SHARED_HDFSPP)
|
||||
add_library(hdfspp SHARED ${EMPTY_FILE_CC} ${LIBHDFSPP_ALL_OBJECTS})
|
||||
set_target_properties(hdfspp PROPERTIES SOVERSION ${LIBHDFSPP_VERSION})
|
||||
endif(BUILD_SHARED_HDFSPP)
|
||||
endif (HADOOP_BUILD)
|
||||
endif (HADOOP_BUILD AND NOT MSVC)
|
||||
|
||||
# Set up make install targets
|
||||
# Can be installed to a particular location via "make DESTDIR=... install"
|
||||
|
|
Loading…
Reference in New Issue