Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjseagull committed Nov 29, 2024
1 parent f672094 commit 15cb928
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
6 changes: 3 additions & 3 deletions CMake/FindGsasl.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
find_path(GSASL_INCLUDE_DIRS NAMES gsasl.h PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" NO_DEFAULT_PATH)
if (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
find_library(GSASL_LIBRARIES NAMES gsasl z PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH)
find_library(GSASL_LIBRARIES NAMES gsasl PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH)
else()
find_library(GSASL_LIBRARIES NAMES gsasld z PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH)
find_library(GSASL_LIBRARIES NAMES gsasld PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH)
endif()
if(NOT GSASL_INCLUDE_DIR OR NOT GSASL_LIBRARIES)
if(NOT GSASL_INCLUDE_DIRS OR NOT GSASL_LIBRARIES)
message(FATAL_ERROR "Broken installation of vcpkg port gsasl")
endif()
INCLUDE(FindPackageHandleStandardArgs)
Expand Down
33 changes: 32 additions & 1 deletion CMake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ IF(OS_LINUX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--export-dynamic")
ENDIF(OS_LINUX)

SET(BOOST_ROOT ${CMAKE_PREFIX_PATH})
IF(ENABLE_BOOST STREQUAL ON)
MESSAGE(STATUS "using boost instead of native compiler c++0x support.")
FIND_PACKAGE(Boost 1.50 REQUIRED)
SET(NEED_BOOST true CACHE INTERNAL "boost is required")
ELSE(ENABLE_BOOST STREQUAL ON)
SET(NEED_BOOST false CACHE INTERNAL "boost is required")
ENDIF(ENABLE_BOOST STREQUAL ON)

IF(CMAKE_COMPILER_IS_GNUCXX)
IF(ENABLE_LIBCPP STREQUAL ON)
MESSAGE(FATAL_ERROR "Unsupport using GCC compiler with libc++")
Expand All @@ -62,13 +71,35 @@ IF(CMAKE_COMPILER_IS_GNUCXX)

IF((GCC_COMPILER_VERSION_MAJOR LESS 4) OR ((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR LESS 4)))
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
IF(NOT ENABLE_BOOST STREQUAL ON)
MESSAGE(STATUS "gcc version is older than 4.6.0, boost is required.")
FIND_PACKAGE(Boost 1.50 REQUIRED)
SET(NEED_BOOST true CACHE INTERNAL "boost is required")
ENDIF(NOT ENABLE_BOOST STREQUAL ON)
ELSEIF((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR LESS 7))
IF(NOT ENABLE_BOOST STREQUAL ON)
MESSAGE(STATUS "gcc version is older than 4.6.0, boost is required.")
FIND_PACKAGE(Boost 1.50 REQUIRED)
SET(NEED_BOOST true CACHE INTERNAL "boost is required")
ENDIF(NOT ENABLE_BOOST STREQUAL ON)
MESSAGE(STATUS "adding c++0x support for gcc compiler")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ELSE((GCC_COMPILER_VERSION_MAJOR LESS 4) OR ((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR LESS 4)))
MESSAGE(STATUS "adding c++0x support for gcc compiler")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ENDIF((GCC_COMPILER_VERSION_MAJOR LESS 4) OR ((GCC_COMPILER_VERSION_MAJOR EQUAL 4) AND (GCC_COMPILER_VERSION_MINOR LESS 4)))

IF(NEED_BOOST)
IF((Boost_MAJOR_VERSION LESS 1) OR ((Boost_MAJOR_VERSION EQUAL 1) AND (Boost_MINOR_VERSION LESS 50)))
MESSAGE(FATAL_ERROR "boost 1.50+ is required")
ENDIF()
ELSE(NEED_BOOST)
IF(HAVE_NANOSLEEP)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_NANOSLEEP")
ELSE(HAVE_NANOSLEEP)
MESSAGE(FATAL_ERROR "nanosleep() is required")
ENDIF(HAVE_NANOSLEEP)
ENDIF(NEED_BOOST)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
ELSEIF(CMAKE_COMPILER_IS_CLANG)
MESSAGE(STATUS "adding c++0x support for clang compiler")
Expand Down Expand Up @@ -135,4 +166,4 @@ TRY_COMPILE(HAVE_STD_ATOMIC
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/test.cpp
CMAKE_FLAGS "-DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'"
OUTPUT_VARIABLE OUTPUT)
OUTPUT_VARIABLE OUTPUT)
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ endif()

include(FindGsasl)
include (FindKrb5)
find_package(Boost COMPONENTS atomic chrono iostreams thread system)

ADD_SUBDIRECTORY(mock)
ADD_SUBDIRECTORY(src)
Expand Down
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ ADD_CUSTOM_COMMAND(
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

if(NEED_BOOST)
find_package(Boost COMPONENTS atomic chrono iostreams thread system)
TARGET_LINK_LIBRARIES(libhdfs3-static pthread Boost::thread Boost::chrono Boost::system Boost::iostreams Boost::thread)
TARGET_LINK_LIBRARIES(libhdfs3-shared pthread Boost::thread Boost::chrono Boost::system Boost::iostreams Boost::thread)
endif()

IF(NEED_GCCEH)
TARGET_LINK_LIBRARIES(libhdfs3-static gcc_eh)
Expand All @@ -93,7 +96,7 @@ INCLUDE_DIRECTORIES(${KERBEROS_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${GSASL_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/mock)

TARGET_LINK_LIBRARIES(libhdfs3-static PRIVATE protobuf::libprotobuf LibXml2::LibXml2 ${GSASL_LIBRARIES} ${KERBEROS_LIBRARIES})
TARGET_LINK_LIBRARIES(libhdfs3-static PRIVATE protobuf::libprotobuf LibXml2::LibXml2 ${GSASL_LIBRARIES} ${KERBEROS_LIBRARIES})

TARGET_LINK_LIBRARIES(libhdfs3-shared protobuf::libprotobuf LibXml2::LibXml2 ${GSASL_LIBRARIES} ${KERBEROS_LIBRARIES})

Expand Down

0 comments on commit 15cb928

Please sign in to comment.