You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2019/08/16 08:24:45 UTC
[arrow] branch master updated: ARROW-5638: [C++][CMake] Fixes for
xcode project builds
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 34e2fd6 ARROW-5638: [C++][CMake] Fixes for xcode project builds
34e2fd6 is described below
commit 34e2fd658a848dfc81d7a72aa2b435d158315af5
Author: Hatem Helal <hh...@mathworks.com>
AuthorDate: Fri Aug 16 17:24:28 2019 +0900
ARROW-5638: [C++][CMake] Fixes for xcode project builds
This patch fixes the following build failures with Xcode projects generated with the `-G Xcode` option for Cmake:
* Link failure with google test
* Cmake error with `ARROW_GANDIVA_JAVA`
* Build failure for lz4_ep
This patch effectively disables the ability to do multi-configuration builds with the generated Xcode project and makes them behave more like a single-configuration Makefile driven build. I see no problem with this as supporting it would add a lot of extra complexity to the rest of the build system and one can always generate multiple projects with different configurations as needed.
Closes #5046 from hatemhelal/arrow-5638 and squashes the following commits:
86de87920 <Sutou Kouhei> Close CMAKE_BUILD_TYPE related codes
b9417f7f9 <Hatem Helal> Move UPPERCASE_BUILD_TYPE definition and also rebase w/ master
ad7f8826a <Hatem Helal> Code review feedback
afd5d032b <Hatem Helal> cmake-format changes
04485e127 <Hatem Helal> update xcode example to include CMAKE_BUILD_TYPE
6576e970a <Hatem Helal> Pass CMAKE_SYSTEM_NAME when building lz4 for xcode project support
35e771164 <Hatem Helal> Fixes for xcode project builds
Lead-authored-by: Hatem Helal <hh...@mathworks.com>
Co-authored-by: Hatem Helal <ha...@gmail.com>
Co-authored-by: Sutou Kouhei <ko...@clear-code.com>
Signed-off-by: Sutou Kouhei <ko...@clear-code.com>
---
cpp/CMakeLists.txt | 12 ++++++++++++
cpp/cmake_modules/ThirdpartyToolchain.cmake | 18 ++++++++++++------
cpp/src/gandiva/jni/CMakeLists.txt | 2 +-
docs/source/developers/cpp.rst | 2 +-
4 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 0367e3f..ed3e91f 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -27,6 +27,7 @@ get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG
if(NOT GENERATOR_IS_MULTI_CONFIG AND NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build.")
endif()
+string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
project(arrow VERSION "${ARROW_BASE_VERSION}")
@@ -395,6 +396,17 @@ set(LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
# where to put generated binaries
set(EXECUTABLE_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}")
+if(CMAKE_GENERATOR STREQUAL Xcode)
+ # Xcode projects support multi-configuration builds. This forces a single output directory
+ # when building with Xcode that is consistent with single-configuration Makefile driven build.
+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${UPPERCASE_BUILD_TYPE}
+ "${BUILD_OUTPUT_ROOT_DIRECTORY}")
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${UPPERCASE_BUILD_TYPE}
+ "${BUILD_OUTPUT_ROOT_DIRECTORY}")
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${UPPERCASE_BUILD_TYPE}
+ "${BUILD_OUTPUT_ROOT_DIRECTORY}")
+endif()
+
#
# Dependencies
#
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 5515338..a21f0aa 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -417,8 +417,6 @@ endif()
# ----------------------------------------------------------------------
# ExternalProject options
-string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
-
set(EP_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}}")
set(EP_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${UPPERCASE_BUILD_TYPE}}")
@@ -1469,6 +1467,14 @@ macro(build_gtest)
set(GTEST_CMAKE_ARGS ${GTEST_CMAKE_ARGS} "-DCMAKE_MACOSX_RPATH:BOOL=ON")
endif()
+ if(CMAKE_GENERATOR STREQUAL "Xcode")
+ # Xcode projects support multi-configuration builds. This forces the gtest build
+ # to use the same output directory as a single-configuration Makefile driven build.
+ list(
+ APPEND GTEST_CMAKE_ARGS "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${_GTEST_LIBRARY_DIR}"
+ "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE}=${_GTEST_RUNTIME_DIR}")
+ endif()
+
if(MSVC)
if(NOT ("${CMAKE_GENERATOR}" STREQUAL "Ninja"))
set(_GTEST_RUNTIME_DIR ${_GTEST_RUNTIME_DIR}/${CMAKE_BUILD_TYPE})
@@ -1477,9 +1483,9 @@ macro(build_gtest)
${GTEST_CMAKE_ARGS} "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${_GTEST_RUNTIME_DIR}"
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE}=${_GTEST_RUNTIME_DIR}")
else()
- set(GTEST_CMAKE_ARGS
- ${GTEST_CMAKE_ARGS} "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${_GTEST_RUNTIME_DIR}"
- "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE}=${_GTEST_RUNTIME_DIR}")
+ list(
+ APPEND GTEST_CMAKE_ARGS "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${_GTEST_RUNTIME_DIR}"
+ "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_${CMAKE_BUILD_TYPE}=${_GTEST_RUNTIME_DIR}")
endif()
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1)
@@ -1845,7 +1851,7 @@ macro(build_lz4)
else()
set(LZ4_STATIC_LIB "${LZ4_BUILD_DIR}/lib/liblz4.a")
set(LZ4_BUILD_COMMAND BUILD_COMMAND ${CMAKE_SOURCE_DIR}/build-support/build-lz4-lib.sh
- "AR=${CMAKE_AR}")
+ "AR=${CMAKE_AR}" "OS=${CMAKE_SYSTEM_NAME}")
endif()
# We need to copy the header in lib to directory outside of the build
diff --git a/cpp/src/gandiva/jni/CMakeLists.txt b/cpp/src/gandiva/jni/CMakeLists.txt
index 482a6b4..7d1ca32 100644
--- a/cpp/src/gandiva/jni/CMakeLists.txt
+++ b/cpp/src/gandiva/jni/CMakeLists.txt
@@ -84,7 +84,7 @@ add_arrow_lib(gandiva_jni
EXTRA_INCLUDES
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
- ${JNI_HEADERS_DIR}
+ $<BUILD_INTERFACE:${JNI_HEADERS_DIR}>
PRIVATE_INCLUDES
${JNI_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR})
diff --git a/docs/source/developers/cpp.rst b/docs/source/developers/cpp.rst
index b44b0d6..62bbec8 100644
--- a/docs/source/developers/cpp.rst
+++ b/docs/source/developers/cpp.rst
@@ -649,7 +649,7 @@ by generating an Xcode project:
cd cpp
mkdir xcode-build
cd xcode-build
- cmake .. -G Xcode -DARROW_BUILD_TESTS=ON
+ cmake .. -G Xcode -DARROW_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=DEBUG
open arrow.xcodeproj
This will generate a project and open it in the Xcode app. As an alternative,