hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmcc...@apache.org
Subject hadoop git commit: HDFS-7574. Make cmake work in Windows Visual Studio 2010 (Thanh Do via Colin P. McCabe)
Date Fri, 09 Jan 2015 19:21:04 GMT
Repository: hadoop
Updated Branches:
  refs/heads/HDFS-6994 411c31fab -> 2e42564ad


HDFS-7574. Make cmake work in Windows Visual Studio 2010 (Thanh Do via Colin P. McCabe)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2e42564a
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2e42564a
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2e42564a

Branch: refs/heads/HDFS-6994
Commit: 2e42564ad3bad751f0e8b82c55bfdfd07d615d27
Parents: 411c31f
Author: Colin Patrick Mccabe <cmccabe@cloudera.com>
Authored: Fri Jan 9 11:17:33 2015 -0800
Committer: Colin Patrick Mccabe <cmccabe@cloudera.com>
Committed: Fri Jan 9 11:17:33 2015 -0800

----------------------------------------------------------------------
 .../libhdfs3/CMake/CMakeTestCompileStrerror.cpp |  3 ++
 .../src/contrib/libhdfs3/CMake/Options.cmake    | 36 +++++++++++++++++---
 .../src/contrib/libhdfs3/CMake/Platform.cmake   |  7 ++++
 .../src/contrib/libhdfs3/src/CMakeLists.txt     | 36 +++++++++++++-------
 .../src/contrib/libhdfs3/test/CMakeLists.txt    | 10 +++++-
 5 files changed, 73 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/2e42564a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/CMakeTestCompileStrerror.cpp
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/CMakeTestCompileStrerror.cpp
b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/CMakeTestCompileStrerror.cpp
index 62d082b..ab92314 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/CMakeTestCompileStrerror.cpp
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/CMakeTestCompileStrerror.cpp
@@ -17,6 +17,9 @@
  */
 
 #include <string.h>
+#ifdef _WIN32
+#define strerror_r(errnum, buf, buflen) strerror_s((buf), (buflen), (errnum))
+#endif
 
 int main()
 {

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2e42564a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Options.cmake
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Options.cmake b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Options.cmake
index eb74bd8..b957c40 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Options.cmake
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Options.cmake
@@ -28,6 +28,7 @@ CHECK_FUNCTION_EXISTS(dladdr HAVE_DLADDR)
 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
 
 IF(ENABLE_DEBUG STREQUAL ON)
+    # TODO: set platform debug flag (/Z7) for Windows.
     SET(CMAKE_BUILD_TYPE Debug CACHE 
         STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo
MinSizeRel." FORCE)
     SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0" CACHE STRING "compiler flags for debug" FORCE)
@@ -39,19 +40,32 @@ ELSE(ENABLE_DEBUG STREQUAL ON)
     SET(CMAKE_C_FLAGS_DEBUG "-g -O2" CACHE STRING "compiler flags for debug" FORCE)
 ENDIF(ENABLE_DEBUG STREQUAL ON)
 
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
+IF(NOT MSVC)
+    # Ignore no-strict-aliasing in windows.
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
+    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing")
+ENDIF(NOT MSVC)
 
 IF(ENABLE_COVERAGE STREQUAL ON)
     INCLUDE(CodeCoverage)
 ENDIF(ENABLE_COVERAGE STREQUAL ON)
 
 IF(ENABLE_FRAME_POINTER STREQUAL ON)
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
+    IF(MSVC)
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Oy-")
+    ELSE(MSVC)
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
+    ENDIF(MSVC)
 ENDIF(ENABLE_FRAME_POINTER STREQUAL ON) 
 
 IF(ENABLE_SSE STREQUAL ON)
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
+    IF(MSVC)
+        # In Visual Studio 2013, this option will use SS4.2 instructions
+        # if available. Not sure about the behaviour in Visual Studio 2010.
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
+    ELSE(MSVC)
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
+    ENDIF(MSVC)
 ENDIF(ENABLE_SSE STREQUAL ON) 
 
 IF(NOT TEST_HDFS_PREFIX)
@@ -74,7 +88,17 @@ 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.53 REQUIRED)
+    IF(MSVC)
+        # Find boost libraries with flavor: mt-sgd (multi-thread, static, and debug)
+        SET(Boost_USE_STATIC_LIBS ON)
+        SET(Boost_USE_MULTITHREADED ON)
+        SET(Boost_USE_STATIC_RUNTIME ON)
+        FIND_PACKAGE(Boost 1.53 COMPONENTS thread chrono system atomic iostreams REQUIRED)
		
+        INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}")
+        LINK_DIRECTORIES("${Boost_LIBRARY_DIRS}")
+    ELSE(MSVC)
+        FIND_PACKAGE(Boost 1.53 REQUIRED)
+    ENDIF(MSVC)
     SET(NEED_BOOST true CACHE INTERNAL "boost is required")
 ELSE(ENABLE_BOOST STREQUAL ON)
     SET(NEED_BOOST false CACHE INTERNAL "boost is required")
@@ -131,6 +155,8 @@ ELSEIF(CMAKE_COMPILER_IS_CLANG)
         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
         SET(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
     ENDIF(ENABLE_LIBCPP STREQUAL ON)
+ELSEIF(MSVC)
+    SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
 ENDIF(CMAKE_COMPILER_IS_GNUCXX)
 
 TRY_COMPILE(STRERROR_R_RETURN_INT

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2e42564a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Platform.cmake
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Platform.cmake b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Platform.cmake
index f5f18e6..0388493 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Platform.cmake
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/CMake/Platform.cmake
@@ -20,6 +20,8 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     SET(OS_LINUX true CACHE INTERNAL "Linux operating system")
 ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     SET(OS_MACOSX true CACHE INTERNAL "Mac Darwin operating system")
+ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+    SET(OS_WINDOWS true CACHE INTERNAL "Windows operation system")
 ELSE(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     MESSAGE(FATAL_ERROR "Unsupported OS: \"${CMAKE_SYSTEM_NAME}\"")
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@@ -44,6 +46,11 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
     SET(GCC_COMPILER_VERSION_PATCH ${GCC_COMPILER_VERSION_PATCH} CACHE INTERNAL "gcc patch
version")
     
     MESSAGE(STATUS "checking compiler: GCC (${GCC_COMPILER_VERSION_MAJOR}.${GCC_COMPILER_VERSION_MINOR}.${GCC_COMPILER_VERSION_PATCH})")
+ELSEIF(MSVC)
+    IF (NOT(${MSVC_VERSION} EQUAL 1600))
+        MESSAGE(FATAL_ERROR "Only supports Visual Studio 2010. Unsupported MSVC_VERSION:
${MSVC_VERSION}")
+    ENDIF(NOT(${MSVC_VERSION} EQUAL 1600))
+    MESSAGE(STATUS "checking compiler: MSVC version ${MSVC_VERSION}")
 ELSE(CMAKE_COMPILER_IS_GNUCXX)
     EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} --version  OUTPUT_VARIABLE COMPILER_OUTPUT)
     IF(COMPILER_OUTPUT MATCHES "clang")

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2e42564a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/CMakeLists.txt
index aa6ce01..b203379 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/CMakeLists.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/CMakeLists.txt
@@ -71,21 +71,31 @@ ADD_CUSTOM_COMMAND(
 	WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
 )
 
-TARGET_LINK_LIBRARIES(libhdfs3-static pthread)
-TARGET_LINK_LIBRARIES(libhdfs3-shared pthread)
+IF(NOT MSVC)
+    # pthread is not available in Windows.
+    TARGET_LINK_LIBRARIES(libhdfs3-static pthread)
+    TARGET_LINK_LIBRARIES(libhdfs3-shared pthread)
+ENDIF(NOT MSVC)
        
 IF(NEED_BOOST)
-    INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_thread)
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_chrono)
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_system)
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_atomic)
-    TARGET_LINK_LIBRARIES(libhdfs3-static boost_iostreams)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_thread)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_chrono)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_system)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_atomic)
-    TARGET_LINK_LIBRARIES(libhdfs3-shared boost_iostreams)
+    IF(MSVC)
+        # We already find boost libraries in options.cmake
+        # therefore just need to link here.
+        TARGET_LINK_LIBRARIES(libhdfs3-static ${Boost_LIBRARIES})
+        TARGET_LINK_LIBRARIES(libhdfs3-shared ${Boost_LIBRARIES})
+    ELSE(MSVC)
+        INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_thread)
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_chrono)
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_system)
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_atomic)
+        TARGET_LINK_LIBRARIES(libhdfs3-static boost_iostreams)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_thread)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_chrono)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_system)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_atomic)
+        TARGET_LINK_LIBRARIES(libhdfs3-shared boost_iostreams)
+    ENDIF(MSVC)
 ENDIF(NEED_BOOST)
 
 IF(NEED_GCCEH)

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2e42564a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/test/CMakeLists.txt b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/test/CMakeLists.txt
index b8cca0b..2838f4a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/test/CMakeLists.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/test/CMakeLists.txt
@@ -19,7 +19,15 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
 
 SET(TEST_WORKING_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data/)
-ADD_DEFINITIONS(-DGTEST_LANG_CXX11=0 -Dprivate=public -Dprotected=public -DDATA_DIR="${TEST_WORKING_DIR}/")
+
+IF(MSVC)
+    # in Windows, redefine private = public, protected = public cause
+    # a serious linking curse. Hence this preprocessor symbol.
+    # In the future, we may want to get rid of this definition even for MacOS and Linux.
+    ADD_DEFINITIONS(-DGTEST_LANG_CXX11=0 -D_WIN_TEST_ -DDATA_DIR="${TEST_WORKING_DIR}/")
+ELSE(MSVC)
+    ADD_DEFINITIONS(-DGTEST_LANG_CXX11=0 -Dprivate=public -Dprotected=public -DDATA_DIR="${TEST_WORKING_DIR}/")
+ENDIF(MSVC)
 
 ADD_SUBDIRECTORY(function)
 ADD_SUBDIRECTORY(unit)


Mime
View raw message