You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/04/06 19:20:05 UTC
arrow git commit: ARROW-756: [C++] MSVC build fixes and cleanup,
remove -fPIC flag from EP builds on Windows, Dev docs
Repository: arrow
Updated Branches:
refs/heads/master 58fa4c2fc -> e371ebd7e
ARROW-756: [C++] MSVC build fixes and cleanup, remove -fPIC flag from EP builds on Windows, Dev docs
Includes existing patch for ARROW-757 and closes #492
With this patch I'm able to build with
```
cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..
nmake
```
Author: Wes McKinney <we...@twosigma.com>
Author: Max Risuhin <ri...@gmail.com>
Closes #500 from wesm/ARROW-757-2 and squashes the following commits:
106e454 [Wes McKinney] Notes about MSVC solution file
f34adf2 [Wes McKinney] Windows developer guide
43e5f3f [Wes McKinney] More MSVC cleaning / fixes. Remove -fPIC flags from builds
ec7805e [Max Risuhin] ARROW-757: [C++] Resolve nmake build issues on Windows
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/e371ebd7
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/e371ebd7
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/e371ebd7
Branch: refs/heads/master
Commit: e371ebd7e16e5e5f4b14f0f578049d9246714e77
Parents: 58fa4c2
Author: Wes McKinney <we...@twosigma.com>
Authored: Thu Apr 6 15:19:59 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Thu Apr 6 15:19:59 2017 -0400
----------------------------------------------------------------------
cpp/CMakeLists.txt | 40 +++++++-------
cpp/README.md | 5 +-
cpp/cmake_modules/SetupCxxFlags.cmake | 25 +++++++--
cpp/doc/Windows.md | 83 ++++++++++++++++++++++++++++++
4 files changed, 129 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/e371ebd7/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index d26c847..9947a34 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -146,9 +146,11 @@ include(BuildUtils)
include(SetupCxxFlags)
# Add common flags
-set(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_COMMON_FLAGS}")
set(EP_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-set(CMAKE_CXX_FLAGS "${ARROW_CXXFLAGS} ${CMAKE_CXX_FLAGS}")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARROW_CXXFLAGS}")
+
+message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
# Determine compiler version
include(CompilerInfo)
@@ -446,7 +448,7 @@ if(ARROW_BUILD_TESTS)
if("$ENV{GTEST_HOME}" STREQUAL "")
if(APPLE)
set(GTEST_CMAKE_CXX_FLAGS "-fPIC -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-value -Wno-ignored-attributes")
- else()
+ elseif(NOT MSVC)
set(GTEST_CMAKE_CXX_FLAGS "-fPIC")
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
@@ -456,12 +458,15 @@ if(ARROW_BUILD_TESTS)
set(GTEST_INCLUDE_DIR "${GTEST_PREFIX}/include")
set(GTEST_STATIC_LIB "${GTEST_PREFIX}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(GTEST_VENDORED 1)
+ set(GTEST_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -Dgtest_force_shared_crt=ON
+ -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS})
if (CMAKE_VERSION VERSION_GREATER "3.2")
# BUILD_BYPRODUCTS is a 3.2+ feature
ExternalProject_Add(googletest_ep
URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz"
- CMAKE_ARGS -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS} -Dgtest_force_shared_crt=ON
+ CMAKE_ARGS ${GTEST_CMAKE_ARGS}
# googletest doesn't define install rules, so just build in the
# source dir and don't try to install. See its README for
# details.
@@ -471,7 +476,7 @@ if(ARROW_BUILD_TESTS)
else()
ExternalProject_Add(googletest_ep
URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz"
- CMAKE_ARGS -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS} -Dgtest_force_shared_crt=ON
+ CMAKE_ARGS ${GTEST_CMAKE_ARGS}
# googletest doesn't define install rules, so just build in the
# source dir and don't try to install. See its README for
# details.
@@ -556,9 +561,9 @@ if(ARROW_BUILD_BENCHMARKS)
if("$ENV{GBENCHMARK_HOME}" STREQUAL "")
if(APPLE)
- set(GBENCHMARK_CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++")
- else()
- set(GBENCHMARK_CMAKE_CXX_FLAGS "--std=c++11")
+ set(GBENCHMARK_CMAKE_CXX_FLAGS "-fPIC -std=c++11 -stdlib=libc++")
+ elseif(NOT MSVC)
+ set(GBENCHMARK_CMAKE_CXX_FLAGS "-fPIC --std=c++11")
endif()
set(GBENCHMARK_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/gbenchmark_ep/src/gbenchmark_ep-install")
@@ -569,7 +574,7 @@ if(ARROW_BUILD_BENCHMARKS)
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_INSTALL_PREFIX:PATH=${GBENCHMARK_PREFIX}"
"-DBENCHMARK_ENABLE_TESTING=OFF"
- "-DCMAKE_CXX_FLAGS=-fPIC ${GBENCHMARK_CMAKE_CXX_FLAGS}")
+ "-DCMAKE_CXX_FLAGS=${GBENCHMARK_CMAKE_CXX_FLAGS}")
if (APPLE)
set(GBENCHMARK_CMAKE_ARGS ${GBENCHMARK_CMAKE_ARGS} "-DBENCHMARK_USE_LIBCXX=ON")
endif()
@@ -621,6 +626,13 @@ endif()
message(STATUS "RapidJSON include dir: ${RAPIDJSON_INCLUDE_DIR}")
include_directories(SYSTEM ${RAPIDJSON_INCLUDE_DIR})
+#----------------------------------------------------------------------
+
+if (MSVC)
+ # jemalloc is not supported on Windows
+ set(ARROW_JEMALLOC off)
+endif()
+
if (ARROW_JEMALLOC)
find_package(jemalloc)
@@ -840,12 +852,10 @@ if(ARROW_IPC)
ExternalProject_Add(flatbuffers_ep
URL "https://github.com/google/flatbuffers/archive/v${FLATBUFFERS_VERSION}.tar.gz"
CMAKE_ARGS
- "-DCMAKE_CXX_FLAGS=-fPIC"
"-DCMAKE_INSTALL_PREFIX:PATH=${FLATBUFFERS_PREFIX}"
"-DFLATBUFFERS_BUILD_TESTS=OFF")
set(FLATBUFFERS_INCLUDE_DIR "${FLATBUFFERS_PREFIX}/include")
- set(FLATBUFFERS_STATIC_LIB "${FLATBUFFERS_PREFIX}/libflatbuffers.a")
set(FLATBUFFERS_COMPILER "${FLATBUFFERS_PREFIX}/bin/flatc")
set(FLATBUFFERS_VENDORED 1)
else()
@@ -854,16 +864,8 @@ if(ARROW_IPC)
endif()
message(STATUS "Flatbuffers include dir: ${FLATBUFFERS_INCLUDE_DIR}")
- message(STATUS "Flatbuffers static library: ${FLATBUFFERS_STATIC_LIB}")
message(STATUS "Flatbuffers compiler: ${FLATBUFFERS_COMPILER}")
include_directories(SYSTEM ${FLATBUFFERS_INCLUDE_DIR})
- ADD_THIRDPARTY_LIB(flatbuffers
- STATIC_LIB ${FLATBUFFERS_STATIC_LIB})
-
- if(FLATBUFFERS_VENDORED)
- add_dependencies(flatbuffers flatbuffers_ep)
- endif()
-
add_subdirectory(src/arrow/ipc)
endif()
http://git-wip-us.apache.org/repos/asf/arrow/blob/e371ebd7/cpp/README.md
----------------------------------------------------------------------
diff --git a/cpp/README.md b/cpp/README.md
index b6f0fa0..b19fa00 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -40,6 +40,8 @@ On OS X, you can use [Homebrew][1]:
brew install boost cmake
```
+If you are developing on Windows, see the [Windows developer guide][2].
+
## Building Arrow
Simple debug build:
@@ -123,4 +125,5 @@ both of these options would be used rarely. Current known uses-cases whent hey
* Parameterized tests in google test.
-[1]: https://brew.sh/
\ No newline at end of file
+[1]: https://brew.sh/
+[2]: https://github.com/apache/arrow/blob/master/cpp/doc/Windows.md
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/arrow/blob/e371ebd7/cpp/cmake_modules/SetupCxxFlags.cmake
----------------------------------------------------------------------
diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake
index ee672bd..09a662e 100644
--- a/cpp/cmake_modules/SetupCxxFlags.cmake
+++ b/cpp/cmake_modules/SetupCxxFlags.cmake
@@ -24,15 +24,32 @@ CHECK_CXX_COMPILER_FLAG("-msse3" CXX_SUPPORTS_SSE3)
CHECK_CXX_COMPILER_FLAG("-maltivec" CXX_SUPPORTS_ALTIVEC)
# compiler flags that are common across debug/release builds
-# - Wall: Enable all warnings.
-set(CXX_COMMON_FLAGS "-std=c++11 -Wall")
+
+if (MSVC)
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # clang-cl
+ set(CXX_COMMON_FLAGS "-EHsc")
+ elseif(${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 19)
+ message(FATAL_ERROR "Only MSVC 2015 (Version 19.0) and later are supported
+ by Arrow. Found version ${CMAKE_CXX_COMPILER_VERSION}.")
+ else()
+ # Fix annoying D9025 warning
+ string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+
+ # Set desired warning level (e.g. set /W4 for more warnings)
+ set(CXX_COMMON_FLAGS "/W3")
+ endif()
+else()
+ set(CXX_COMMON_FLAGS "-Wall -std=c++11")
+endif()
# Only enable additional instruction sets if they are supported
if (CXX_SUPPORTS_SSE3 AND ARROW_SSE3)
- set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -msse3")
+ set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -msse3")
endif()
+
if (CXX_SUPPORTS_ALTIVEC AND ARROW_ALTIVEC)
- set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -maltivec")
+ set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -maltivec")
endif()
if (APPLE)
http://git-wip-us.apache.org/repos/asf/arrow/blob/e371ebd7/cpp/doc/Windows.md
----------------------------------------------------------------------
diff --git a/cpp/doc/Windows.md b/cpp/doc/Windows.md
new file mode 100644
index 0000000..64f6a1b
--- /dev/null
+++ b/cpp/doc/Windows.md
@@ -0,0 +1,83 @@
+<!---
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. See accompanying LICENSE file.
+-->
+
+# Developing Arrow C++ on Windows
+
+## System setup, conda, and conda-forge
+
+Since some of the Arrow developers work in the Python ecosystem, we are
+investing time in maintaining the thirdparty build dependencies for Arrow and
+related C++ libraries using the conda package manager. Others are free to add
+other development instructions for Windows here.
+
+### Visual Studio
+
+Microsoft provides the free Visual Studio 2017 Community edition. When doing
+development, you must launch the developer command prompt using
+
+```"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64```
+
+It's easiest to configure a console emulator like [cmder][3] to automatically
+launch this when starting a new development console.
+
+### conda and package toolchain
+
+[Miniconda][1] is a minimal Python distribution including the conda package
+manager. To get started, download and install a 64-bit distribution.
+
+We recommend using packages from [conda-forge][2]
+
+```shell
+conda config --add channels conda-forge
+```
+
+Now, you can bootstrap a build environment
+
+```shell
+conda create -n arrow-dev cmake git boost
+```
+
+## Building with NMake
+
+Activate your conda build environment:
+
+```
+activate arrow-dev
+```
+
+Now, do an out of source build using `nmake`:
+
+```
+cd cpp
+mkdir build
+cd build
+cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release ..
+nmake
+```
+
+When using conda, only release builds are currently supported.
+
+## Build using Visual Studio (MSVC) Solution Files
+
+To build on the command line by instead generating a MSVC solution, instead
+run:
+
+```
+cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release ..
+cmake --build . --config Release
+```
+
+[1]: https://conda.io/miniconda.html
+[2]: https://conda-forge.github.io/
+[3]: http://cmder.net/
\ No newline at end of file