Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand Down Expand Up @@ -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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can always set these variables.

We should use UPPERCASE_BUILD_TYPE instead of CMAKE_BUILD_TYPE because users may specify Debug as CMAKE_BUILD_TYPE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can always set these variables.

I'm a bit worried about settings these variables unconditionally and possibly breaking multi-configuration generators (MSVC?).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor build will answer this... Oh, we don't have a job that uses "Visual Studio XXX" generator.

OK. We can set them only for Xcode for now.


#
# Dependencies
#
Expand Down
18 changes: 12 additions & 6 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}}")

Expand Down Expand Up @@ -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})
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/gandiva/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion docs/source/developers/cpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down