Repository: orc Updated Branches: refs/heads/master 0ee4b1070 -> 7cd67fe29
ORC-266: [C++] Cleanup cmake scripts Fixes #192 Signed-off-by: Deepak Majeti <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/orc/repo Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/7cd67fe2 Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/7cd67fe2 Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/7cd67fe2 Branch: refs/heads/master Commit: 7cd67fe290f229fd3d8d1bae2fc02ad68319585d Parents: 0ee4b10 Author: Jim Crist <[email protected]> Authored: Mon Nov 20 15:15:15 2017 -0600 Committer: Deepak Majeti <[email protected]> Committed: Sun Nov 26 11:07:26 2017 -0500 ---------------------------------------------------------------------- CMakeLists.txt | 52 ++--- c++/CMakeLists.txt | 5 +- c++/src/CMakeLists.txt | 22 +-- c++/test/CMakeLists.txt | 19 +- cmake_modules/FindGTest.cmake | 32 +++- cmake_modules/FindLZ4.cmake | 50 +++-- cmake_modules/FindProtobuf.cmake | 65 ++++--- cmake_modules/FindSnappy.cmake | 48 +++-- cmake_modules/FindZLIB.cmake | 46 +++-- cmake_modules/ThirdpartyToolchain.cmake | 275 +++++++++++++++++---------- tools/CMakeLists.txt | 5 +- tools/src/CMakeLists.txt | 4 +- tools/test/CMakeLists.txt | 14 +- 13 files changed, 398 insertions(+), 239 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0441855..061e27f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,11 +20,6 @@ SET(CPACK_PACKAGE_VERSION_MINOR "5") SET(CPACK_PACKAGE_VERSION_PATCH "0-SNAPSHOT") SET(ORC_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules") -set (LZ4_VERSION "1.7.5") -set (SNAPPY_VERSION "1.1.4") -set (ZLIB_VERSION "1.2.11") -set (GTEST_VERSION "1.8.0") -set (PROTOBUF_VERSION "2.6.0") option (BUILD_JAVA "Include ORC Java library in the build process" @@ -38,6 +33,18 @@ option (BUILD_LIBHDFSPP "Include LIBHDFSPP library in the build process" ON) +option(BUILD_CPP_TESTS + "Build the googletest unit tests" + ON) + +option(BUILD_TOOLS + "Build the tools" + ON) + +option(INSTALL_VENDORED_LIBS + "Install vendored thirdparty libraries along with liborc" + ON) + # Make sure that a build type is selected if (NOT CMAKE_BUILD_TYPE) message(STATUS "No build type selected, default to ReleaseWithDebugInfo") @@ -98,24 +105,25 @@ INCLUDE(ThirdpartyToolchain) set (EXAMPLE_DIRECTORY ${CMAKE_SOURCE_DIR}/examples) add_subdirectory(c++) -add_subdirectory(tools) if (BUILD_JAVA) add_subdirectory(java) endif() -# Add another target called test-out that prints the results on failure -if (CMAKE_CONFIGURATION_TYPES) - add_custom_target (test-out - COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process - --output-on-failure --build-config "$<CONFIGURATION>" - ) -else (CMAKE_CONFIGURATION_TYPES) - add_custom_target (test-out - COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process - --output-on-failure - ) -endif (CMAKE_CONFIGURATION_TYPES) - -install( - FILES LICENSE NOTICE - DESTINATION .) +if (BUILD_TOOLS) + add_subdirectory(tools) +endif () + +if (BUILD_CPP_TESTS) + # Add another target called test-out that prints the results on failure + if (CMAKE_CONFIGURATION_TYPES) + add_custom_target (test-out + COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process + --output-on-failure --build-config "$<CONFIGURATION>" + ) + else () + add_custom_target (test-out + COMMAND ${CMAKE_CTEST_COMMAND} --force-new-ctest-process + --output-on-failure + ) + endif () +endif () http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/c++/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/c++/CMakeLists.txt b/c++/CMakeLists.txt index d197776..cec1582 100644 --- a/c++/CMakeLists.txt +++ b/c++/CMakeLists.txt @@ -17,4 +17,7 @@ include_directories ( add_subdirectory(include) add_subdirectory(src) -add_subdirectory(test) + +if (BUILD_CPP_TESTS) + add_subdirectory(test) +endif () http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/c++/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index b6fe1bf..7a39b4d 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -119,11 +119,11 @@ configure_file ( include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${PROTOBUF_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIRS} - ${SNAPPY_INCLUDE_DIRS} - ${LZ4_INCLUDE_DIRS} - ${LIBHDFSPP_INCLUDE_DIRS} + ${PROTOBUF_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIR} + ${SNAPPY_INCLUDE_DIR} + ${LZ4_INCLUDE_DIR} + ${LIBHDFSPP_INCLUDE_DIR} ) add_custom_command(OUTPUT orc_proto.pb.h orc_proto.pb.cc @@ -168,17 +168,15 @@ endif(ORC_CXX_HAS_THREAD_LOCAL AND BUILD_LIBHDFSPP) add_library (orc STATIC ${SOURCE_FILES}) -install(TARGETS orc DESTINATION lib) - target_link_libraries (orc - ${PROTOBUF_LIBRARIES} - ${ZLIB_LIBRARIES} - ${SNAPPY_LIBRARIES} - ${LZ4_LIBRARIES} + protobuf + zlib + snappy + lz4 ${LIBHDFSPP_LIBRARIES} ) -add_dependencies(orc protobuf) +install(TARGETS orc DESTINATION lib) if(ORC_CXX_HAS_THREAD_LOCAL AND BUILD_LIBHDFSPP) add_definitions(-DBUILD_LIBHDFSPP) http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/c++/test/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index ea7ac6d..83ce8f8 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -14,10 +14,10 @@ include_directories( ${PROJECT_SOURCE_DIR}/c++/src ${PROJECT_BINARY_DIR}/c++/include ${PROJECT_BINARY_DIR}/c++/src - ${PROTOBUF_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIRS} - ${SNAPPY_INCLUDE_DIRS} - ${GTEST_INCLUDE_DIRS} + ${PROTOBUF_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIR} + ${SNAPPY_INCLUDE_DIR} + ${GTEST_INCLUDE_DIR} ) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAGS} ${WARN_FLAGS}") @@ -48,11 +48,11 @@ add_executable (orc-test target_link_libraries (orc-test orc + lz4 + protobuf + snappy + zlib ${GTEST_LIBRARIES} - ${LZ4_LIBRARIES} - ${PROTOBUF_LIBRARIES} - ${SNAPPY_LIBRARIES} - ${ZLIB_LIBRARIES} ) add_executable (create-test-files @@ -61,8 +61,7 @@ add_executable (create-test-files target_link_libraries (create-test-files orc - ${PROTOBUF_LIBRARIES} + protobuf ) add_test (NAME orc-test COMMAND orc-test) - http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/cmake_modules/FindGTest.cmake ---------------------------------------------------------------------- diff --git a/cmake_modules/FindGTest.cmake b/cmake_modules/FindGTest.cmake index fd8fbff..0d58528 100644 --- a/cmake_modules/FindGTest.cmake +++ b/cmake_modules/FindGTest.cmake @@ -12,9 +12,10 @@ # GTEST_HOME environmental variable is used to check for GTest headers and static library +# GTEST_INCLUDE_DIR: directory containing headers +# GTEST_LIBS: directory containing gtest libraries +# GMOCK_STATIC_LIB: is set to gmock.a static library # GTEST_FOUND is set if GTEST is found -# GTEST_INCLUDE_DIRS is set to the header directory -# GTEST_LIBS is set to gmock.a static library if (NOT "${GTEST_HOME}" STREQUAL "") message (STATUS "GTEST_HOME set: ${GTEST_HOME}") @@ -22,7 +23,7 @@ endif () file (TO_CMAKE_PATH "${GTEST_HOME}" _gtest_path ) -find_path (GTEST_INCLUDE_DIRS gmock/gmock.h HINTS +find_path (GTEST_INCLUDE_DIR gmock/gmock.h HINTS ${_gtest_path} NO_DEFAULT_PATH PATH_SUFFIXES "include") @@ -32,11 +33,11 @@ find_library (GTEST_LIBRARIES NAMES gmock PATHS NO_DEFAULT_PATH PATH_SUFFIXES "lib") -if (GTEST_INCLUDE_DIRS AND GTEST_LIBRARIES) +if (GTEST_INCLUDE_DIR AND GTEST_LIBRARIES) set (GTEST_FOUND TRUE) get_filename_component (GTEST_LIBS ${GTEST_LIBRARIES} PATH ) set (GTEST_HEADER_NAME gmock/gmock.h) - set (GTEST_HEADER ${GTEST_INCLUDE_DIRS}/${GTEST_HEADER_NAME}) + set (GTEST_HEADER ${GTEST_INCLUDE_DIR}/${GTEST_HEADER_NAME}) set (GTEST_LIB_NAME gmock) set (GMOCK_STATIC_LIB ${GTEST_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${GTEST_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) else () @@ -46,6 +47,23 @@ endif () if (GTEST_FOUND) message (STATUS "Found the GTest header: ${GTEST_HEADER}") message (STATUS "Found the GTest library: ${GMOCK_STATIC_LIB}") -elseif (NOT "${GTEST_HOME}" STREQUAL "") - message (STATUS "Could not find GTest headers and library") +else () + if (_gtest_path) + set (GTEST_ERR_MSG "Could not find GTest. Looked in ${_gtest_path}.") + else () + set (GTEST_ERR_MSG "Could not find GTest in system search paths.") + endif() + + if (GTest_FIND_REQUIRED) + message (FATAL_ERROR "${GTEST_ERR_MSG}") + else () + message (STATUS "${GTEST_ERR_MSG}") + endif () endif () + +mark_as_advanced ( + GTEST_INCLUDE_DIR + GMOCK_STATIC_LIB + GTEST_LIBS + GTEST_LIBRARIES +) http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/cmake_modules/FindLZ4.cmake ---------------------------------------------------------------------- diff --git a/cmake_modules/FindLZ4.cmake b/cmake_modules/FindLZ4.cmake index 6a3a3a5..6cd905d 100644 --- a/cmake_modules/FindLZ4.cmake +++ b/cmake_modules/FindLZ4.cmake @@ -10,20 +10,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -# LZ4_HOME environmental variable is used to check for LZ4 headers and static library +# LZ4_HOME environment variable is used to check for LZ4 headers and static library -# LZ4_FOUND is set if LZ4 is found -# LZ4_INCLUDE_DIRS is set to the header directory -# LZ4_LIBS is set to lz4.a static library -# LZ4_PREFIX will be LZ4_HOME +# LZ4_INCLUDE_DIR: directory containing headers +# LZ4_LIBS: directory containing LZ4 libraries +# LZ4_STATIC_LIB: path to lz4.a +# LZ4_FOUND: whether LZ4 has been found -if (NOT "${LZ4_HOME}" STREQUAL "") - message (STATUS "LZ4_HOME set: ${LZ4_HOME}") -endif () +if( NOT "${LZ4_HOME}" STREQUAL "") + file (TO_CMAKE_PATH "${LZ4_HOME}" _lz4_path) +endif() -file (TO_CMAKE_PATH "${LZ4_HOME}" _lz4_path ) +message (STATUS "LZ4_HOME: ${LZ4_HOME}") -find_path (LZ4_INCLUDE_DIRS lz4.h HINTS +find_path (LZ4_INCLUDE_DIR lz4.h HINTS ${_lz4_path} NO_DEFAULT_PATH PATH_SUFFIXES "include") @@ -33,12 +33,11 @@ find_library (LZ4_LIBRARIES NAMES lz4 PATHS NO_DEFAULT_PATH PATH_SUFFIXES "lib") -if (LZ4_INCLUDE_DIRS AND LZ4_LIBRARIES) +if (LZ4_INCLUDE_DIR AND LZ4_LIBRARIES) set (LZ4_FOUND TRUE) - set (LZ4_PREFIX ${LZ4_HOME}) - get_filename_component (LZ4_LIBS ${LZ4_LIBRARIES} PATH ) + get_filename_component (LZ4_LIBS ${LZ4_LIBRARIES} PATH) set (LZ4_HEADER_NAME lz4.h) - set (LZ4_HEADER ${LZ4_INCLUDE_DIRS}/${LZ4_HEADER_NAME}) + set (LZ4_HEADER ${LZ4_INCLUDE_DIR}/${LZ4_HEADER_NAME}) set (LZ4_LIB_NAME lz4) set (LZ4_STATIC_LIB ${LZ4_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${LZ4_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) else () @@ -48,6 +47,23 @@ endif () if (LZ4_FOUND) message (STATUS "Found the LZ4 header: ${LZ4_HEADER}") message (STATUS "Found the LZ4 library: ${LZ4_STATIC_LIB}") -elseif (NOT "${LZ4_HOME}" STREQUAL "") - message (STATUS "Could not find LZ4 headers and library") -endif () +else() + if (_lz4_path) + set (LZ4_ERR_MSG "Could not find LZ4. Looked in ${_lz4_path}.") + else () + set (LZ4_ERR_MSG "Could not find LZ4 in system search paths.") + endif () + + if (LZ4_FIND_REQUIRED) + message (FATAL_ERROR "${LZ4_ERR_MSG}") + else () + message (STATUS "${LZ4_ERR_MSG}") + endif () +endif() + +mark_as_advanced ( + LZ4_INCLUDE_DIR + LZ4_STATIC_LIB + LZ4_LIBS + LZ4_LIBRARIES +) http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/cmake_modules/FindProtobuf.cmake ---------------------------------------------------------------------- diff --git a/cmake_modules/FindProtobuf.cmake b/cmake_modules/FindProtobuf.cmake index 5251e5a..9956973 100644 --- a/cmake_modules/FindProtobuf.cmake +++ b/cmake_modules/FindProtobuf.cmake @@ -13,23 +13,25 @@ # PROTOBUF_HOME environmental variable is used to check for Protobuf headers and static library # PROTOBUF_FOUND is set if Protobuf is found -# PROTOBUF_INCLUDE_DIRS is set to the header directory -# PROTOBUF_LIBS is set to protobuf.a protoc.a static libraries -# PROTOBUF_EXECUTABLE is set to protoc -# PROTOBUF_PREFIX will be PROTOBUF_HOME +# PROTOBUF_INCLUDE_DIR: directory containing headers +# PROTOBUF_LIBS: directory containing Protobuf libraries +# PROTOBUF_STATIC_LIB: location of protobuf.a +# PROTOC_STATIC_LIB: location of protoc.a +# PROTOBUF_EXECUTABLE: location of protoc -if (NOT "${PROTOBUF_HOME}" STREQUAL "") - message (STATUS "PROTOBUF_HOME set: ${PROTOBUF_HOME}") -endif () -file (TO_CMAKE_PATH "${PROTOBUF_HOME}" _protobuf_path ) +if( NOT "${PROTOBUF_HOME}" STREQUAL "") + file (TO_CMAKE_PATH "${PROTOBUF_HOME}" _protobuf_path) +endif() + +message (STATUS "PROTOBUF_HOME: ${PROTOBUF_HOME}") -find_path (PROTOBUF_INCLUDE_DIRS google/protobuf/io/zero_copy_stream.h HINTS +find_path (PROTOBUF_INCLUDE_DIR google/protobuf/io/zero_copy_stream.h HINTS ${_protobuf_path} NO_DEFAULT_PATH PATH_SUFFIXES "include") -find_path (PROTOBUF_INCLUDE_DIRS google/protobuf/io/coded_stream.h HINTS +find_path (PROTOBUF_INCLUDE_DIR google/protobuf/io/coded_stream.h HINTS ${_protobuf_path} NO_DEFAULT_PATH PATH_SUFFIXES "include") @@ -49,26 +51,39 @@ find_program(PROTOBUF_EXECUTABLE protoc HINTS NO_DEFAULT_PATH PATH_SUFFIXES "bin") -if (PROTOBUF_INCLUDE_DIRS AND PROTOBUF_LIBRARY AND PROTOC_LIBRARY AND PROTOBUF_EXECUTABLE) +if (PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY AND PROTOC_LIBRARY AND PROTOBUF_EXECUTABLE) set (PROTOBUF_FOUND TRUE) - set (PROTOBUF_PREFIX ${PROTOBUF_HOME}) - set (PROTOBUF_HEADER ${PROTOBUF_INCLUDE_DIRS}/${PROTOBUF_HEADER_NAME}) - get_filename_component (PROTOBUF_LIB ${PROTOBUF_LIBRARY} PATH ) - get_filename_component (PROTOC_LIB ${PROTOC_LIBRARY} PATH ) - set (PROTOBUF_HEADER_NAME protobuf.h) + get_filename_component (PROTOBUF_LIBS ${PROTOBUF_LIBRARY} PATH) set (PROTOBUF_LIB_NAME protobuf) - set (PROTOBUF_STATIC_LIB ${PROTOBUF_LIB}/${CMAKE_STATIC_LIBRARY_PREFIX}${PROTOBUF_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) set (PROTOC_LIB_NAME protoc) - set (PROTOC_STATIC_LIB ${PROTOC_LIB}/${CMAKE_STATIC_LIBRARY_PREFIX}${PROTOC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) + set (PROTOBUF_STATIC_LIB ${PROTOBUF_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${PROTOBUF_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) + set (PROTOC_STATIC_LIB ${PROTOBUF_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${PROTOC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) else () set (PROTOBUF_FOUND FALSE) endif () if (PROTOBUF_FOUND) - message (STATUS "Found the Protobuf headers: ${PROTOBUF_INCLUDE_DIRS}") - message (STATUS "Found the Protobuf library: ${PROTOBUF_LIBRARY}") - message (STATUS "Found the Protobuf library: ${PROTOC_LIBRARY}") - message (STATUS "Found the Protobuf executable: ${PROTOBUF_EXECUTABLE}") -elseif (NOT "${PROTOBUF_HOME}" STREQUAL "") - message (STATUS "Could not find Protobuf headers, library and binary") -endif () + message (STATUS "Found the Protobuf headers: ${PROTOBUF_INCLUDE_DIR}") + message (STATUS "Found the Protobuf library: ${PROTOBUF_STATIC_LIB}") + message (STATUS "Found the Protoc library: ${PROTOC_STATIC_LIB}") + message (STATUS "Found the Protoc executable: ${PROTOBUF_EXECUTABLE}") +else() + if (_protobuf_path) + set (PROTOBUF_ERR_MSG "Could not find Protobuf. Looked in ${_protobuf_path}.") + else () + set (PROTOBUF_ERR_MSG "Could not find Protobuf in system search paths.") + endif() + + if (Protobuf_FIND_REQUIRED) + message (FATAL_ERROR "${PROTOBUF_ERR_MSG}") + else () + message (STATUS "${PROTOBUF_ERR_MSG}") + endif () +endif() + +mark_as_advanced ( + PROTOBUF_INCLUDE_DIR + PROTOBUF_LIBS + PROTOBUF_STATIC_LIB + PROTOC_STATIC_LIB +) http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/cmake_modules/FindSnappy.cmake ---------------------------------------------------------------------- diff --git a/cmake_modules/FindSnappy.cmake b/cmake_modules/FindSnappy.cmake index 4749c28..9275d18 100644 --- a/cmake_modules/FindSnappy.cmake +++ b/cmake_modules/FindSnappy.cmake @@ -12,18 +12,18 @@ # SNAPPY_HOME environmental variable is used to check for Snappy headers and static library -# SNAPPY_FOUND is set if Snappy is found -# SNAPPY_INCLUDE_DIRS is set to the header directory -# SNAPPY_LIBS is set to snappy.a static library -# SNAPPY_PREFIX will be SNAPPY_HOME +# SNAPPY_INCLUDE_DIR: directory containing headers +# SNAPPY_LIBS: directory containing snappy libraries +# SNAPPY_STATIC_LIB: path to libsnappy.a +# SNAPPY_FOUND: whether snappy has been found -if (NOT "${SNAPPY_HOME}" STREQUAL "") - message (STATUS "SNAPPY_HOME set: ${SNAPPY_HOME}") -endif () +if( NOT "${SNAPPY_HOME}" STREQUAL "") + file (TO_CMAKE_PATH "${SNAPPY_HOME}" _snappy_path) +endif() -file (TO_CMAKE_PATH "${SNAPPY_HOME}" _snappy_path ) +message (STATUS "SNAPPY_HOME: ${SNAPPY_HOME}") -find_path (SNAPPY_INCLUDE_DIRS snappy.h HINTS +find_path (SNAPPY_INCLUDE_DIR snappy.h HINTS ${_snappy_path} NO_DEFAULT_PATH PATH_SUFFIXES "include") @@ -33,12 +33,11 @@ find_library (SNAPPY_LIBRARIES NAMES snappy PATHS NO_DEFAULT_PATH PATH_SUFFIXES "lib") -if (SNAPPY_INCLUDE_DIRS AND SNAPPY_LIBRARIES) +if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARIES) set (SNAPPY_FOUND TRUE) - set (SNAPPY_PREFIX ${SNAPPY_HOME}) - get_filename_component (SNAPPY_LIBS ${SNAPPY_LIBRARIES} PATH ) + get_filename_component (SNAPPY_LIBS ${SNAPPY_LIBRARIES} PATH) set (SNAPPY_HEADER_NAME snappy.h) - set (SNAPPY_HEADER ${SNAPPY_INCLUDE_DIRS}/${SNAPPY_HEADER_NAME}) + set (SNAPPY_HEADER ${SNAPPY_INCLUDE_DIR}/${SNAPPY_HEADER_NAME}) set (SNAPPY_LIB_NAME snappy) set (SNAPPY_STATIC_LIB ${SNAPPY_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${SNAPPY_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) else () @@ -48,6 +47,23 @@ endif () if (SNAPPY_FOUND) message (STATUS "Found the Snappy header: ${SNAPPY_HEADER}") message (STATUS "Found the Snappy library: ${SNAPPY_STATIC_LIB}") -elseif (NOT "${SNAPPY_HOME}" STREQUAL "") - message (STATUS "Could not find Snappy headers and library") -endif () +else() + if (_snappy_path) + set (SNAPPY_ERR_MSG "Could not find Snappy. Looked in ${_snappy_path}.") + else () + set (SNAPPY_ERR_MSG "Could not find Snappy in system search paths.") + endif() + + if (Snappy_FIND_REQUIRED) + message (FATAL_ERROR "${SNAPPY_ERR_MSG}") + else () + message (STATUS "${SNAPPY_ERR_MSG}") + endif () +endif() + +mark_as_advanced ( + SNAPPY_INCLUDE_DIR + SNAPPY_STATIC_LIB + SNAPPY_LIBS + SNAPPY_LIBRARIES +) http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/cmake_modules/FindZLIB.cmake ---------------------------------------------------------------------- diff --git a/cmake_modules/FindZLIB.cmake b/cmake_modules/FindZLIB.cmake index d498bbe..9be11b1 100644 --- a/cmake_modules/FindZLIB.cmake +++ b/cmake_modules/FindZLIB.cmake @@ -12,18 +12,18 @@ # ZLIB_HOME environmental variable is used to check for ZLIB headers and static library -# ZLIB_FOUND is set if ZLIB is found -# ZLIB_INCLUDE_DIRS is set to the header directory -# ZLIB_LIBS is set to zlib.a static library -# ZLIB_PREFIX will be ZLIB_HOME +# ZLIB_INCLUDE_DIR: directory containing headers +# ZLIB_LIBS: directory containing ZLIB libraries +# ZLIB_STATIC_LIB: path to zlib.a +# ZLIB_FOUND: whether ZLIB has been found -if (NOT "${ZLIB_HOME}" STREQUAL "") - message (STATUS "ZLIB_HOME set: ${ZLIB_HOME}") -endif () +if( NOT "${ZLIB_HOME}" STREQUAL "") + file (TO_CMAKE_PATH "${ZLIB_HOME}" _zlib_path) +endif() -file (TO_CMAKE_PATH "${ZLIB_HOME}" _zlib_path ) +message (STATUS "ZLIB_HOME: ${ZLIB_HOME}") -find_path (ZLIB_INCLUDE_DIRS zlib.h HINTS +find_path (ZLIB_INCLUDE_DIR zlib.h HINTS ${_zlib_path} NO_DEFAULT_PATH PATH_SUFFIXES "include") @@ -33,12 +33,11 @@ find_library (ZLIB_LIBRARIES NAMES z PATHS NO_DEFAULT_PATH PATH_SUFFIXES "lib") -if (ZLIB_INCLUDE_DIRS AND ZLIB_LIBRARIES) +if (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARIES) set (ZLIB_FOUND TRUE) - set (ZLIB_PREFIX ${ZLIB_HOME}) get_filename_component (ZLIB_LIBS ${ZLIB_LIBRARIES} PATH ) set (ZLIB_HEADER_NAME zlib.h) - set (ZLIB_HEADER ${ZLIB_INCLUDE_DIRS}/${ZLIB_HEADER_NAME}) + set (ZLIB_HEADER ${ZLIB_INCLUDE_DIR}/${ZLIB_HEADER_NAME}) set (ZLIB_LIB_NAME z) set (ZLIB_STATIC_LIB ${ZLIB_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}) else () @@ -48,6 +47,23 @@ endif () if (ZLIB_FOUND) message (STATUS "Found the ZLIB header: ${ZLIB_HEADER}") message (STATUS "Found the ZLIB library: ${ZLIB_STATIC_LIB}") -elseif (NOT "${ZLIB_HOME}" STREQUAL "") - message (STATUS "Could not find ZLIB headers and library") -endif () +else() + if (_zlib_path) + set (ZLIB_ERR_MSG "Could not find ZLIB. Looked in ${_zlib_path}.") + else () + set (ZLIB_ERR_MSG "Could not find ZLIB in system search paths.") + endif() + + if (ZLIB_FIND_REQUIRED) + message (FATAL_ERROR "${ZLIB_ERR_MSG}") + else () + message (STATUS "${ZLIB_ERR_MSG}") + endif () +endif() + +mark_as_advanced ( + ZLIB_INCLUDE_DIR + ZLIB_STATIC_LIB + ZLIB_LIBS + ZLIB_LIBRARIES +) http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/cmake_modules/ThirdpartyToolchain.cmake ---------------------------------------------------------------------- diff --git a/cmake_modules/ThirdpartyToolchain.cmake b/cmake_modules/ThirdpartyToolchain.cmake index 5b1068a..5255992 100644 --- a/cmake_modules/ThirdpartyToolchain.cmake +++ b/cmake_modules/ThirdpartyToolchain.cmake @@ -10,19 +10,46 @@ # See the License for the specific language governing permissions and # limitations under the License. +set (LZ4_VERSION "1.7.5") +set (SNAPPY_VERSION "1.1.4") +set (ZLIB_VERSION "1.2.11") +set (GTEST_VERSION "1.8.0") +set (PROTOBUF_VERSION "2.6.0") + set (THIRDPARTY_DIR "${CMAKE_BINARY_DIR}/c++/libs/thirdparty") string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE) +if (DEFINED ENV{SNAPPY_HOME}) + set (SNAPPY_HOME "$ENV{SNAPPY_HOME}") +endif () + +if (DEFINED ENV{ZLIB_HOME}) + set (ZLIB_HOME "$ENV{ZLIB_HOME}") +endif () + +if (DEFINED ENV{LZ4_HOME}) + set (LZ4_HOME "$ENV{LZ4_HOME}") +endif () + +if (DEFINED ENV{PROTOBUF_HOME}) + set (PROTOBUF_HOME "$ENV{PROTOBUF_HOME}") +endif () + +if (DEFINED ENV{GTEST_HOME}) + set (GTEST_HOME "$ENV{GTEST_HOME}") +endif () + # ---------------------------------------------------------------------- # Snappy -set (SNAPPY_HOME "$ENV{SNAPPY_HOME}") -find_package (Snappy) -if (NOT SNAPPY_FOUND) +if (NOT "${SNAPPY_HOME}" STREQUAL "") + find_package (Snappy REQUIRED) + set(SNAPPY_VENDORED FALSE) +else () set (SNAPPY_PREFIX "${THIRDPARTY_DIR}/snappy_ep-install") set (SNAPPY_HOME "${SNAPPY_PREFIX}") - set (SNAPPY_INCLUDE_DIRS "${SNAPPY_PREFIX}/include") + set (SNAPPY_INCLUDE_DIR "${SNAPPY_PREFIX}/include") set (SNAPPY_STATIC_LIB_NAME snappy) set (SNAPPY_STATIC_LIB "${SNAPPY_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${SNAPPY_STATIC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") set (SNAPPY_SRC_URL "https://github.com/google/snappy/releases/download/${SNAPPY_VERSION}/snappy-${SNAPPY_VERSION}.tar.gz") @@ -41,32 +68,39 @@ if (NOT SNAPPY_FOUND) LOG_BUILD 1 LOG_INSTALL 1 BUILD_BYPRODUCTS "${SNAPPY_STATIC_LIB}") + + set (SNAPPY_VENDORED TRUE) endif () -include_directories (SYSTEM ${SNAPPY_INCLUDE_DIRS}) + +include_directories (SYSTEM ${SNAPPY_INCLUDE_DIR}) add_library (snappy STATIC IMPORTED) set_target_properties (snappy PROPERTIES IMPORTED_LOCATION ${SNAPPY_STATIC_LIB}) -set (SNAPPY_LIBRARIES snappy) -add_dependencies (snappy snappy_ep) -install(DIRECTORY ${SNAPPY_PREFIX}/lib DESTINATION . - PATTERN "pkgconfig" EXCLUDE - PATTERN "*.so*" EXCLUDE - PATTERN "*.dylib" EXCLUDE) + +if (SNAPPY_VENDORED) + add_dependencies (snappy snappy_ep) + if (INSTALL_VENDORED_LIBS) + install(FILES "${SNAPPY_STATIC_LIB}" + DESTINATION "lib") + endif () +endif () + # ---------------------------------------------------------------------- # ZLIB -set (ZLIB_HOME "$ENV{ZLIB_HOME}") -find_package (ZLIB) -if (NOT ZLIB_FOUND) +if (NOT "${ZLIB_HOME}" STREQUAL "") + find_package (ZLIB REQUIRED) + set (ZLIB_VENDORED FALSE) +else () set (ZLIB_PREFIX "${THIRDPARTY_DIR}/zlib_ep-install") set (ZLIB_HOME "${ZLIB_PREFIX}") - set (ZLIB_INCLUDE_DIRS "${ZLIB_PREFIX}/include") + set (ZLIB_INCLUDE_DIR "${ZLIB_PREFIX}/include") set (ZLIB_STATIC_LIB_NAME z) set (ZLIB_STATIC_LIB "${ZLIB_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") set (ZLIB_SRC_URL "http://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz") set (ZLIB_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX=${ZLIB_PREFIX} - -DCMAKE_C_FLAGS=${EP_C_FLAGS} - -DBUILD_SHARED_LIBS=OFF) + -DCMAKE_INSTALL_PREFIX=${ZLIB_PREFIX} + -DCMAKE_C_FLAGS=${EP_C_FLAGS} + -DBUILD_SHARED_LIBS=OFF) ExternalProject_Add (zlib_ep URL ${ZLIB_SRC_URL} @@ -76,26 +110,32 @@ if (NOT ZLIB_FOUND) LOG_INSTALL 1 BUILD_BYPRODUCTS "${ZLIB_STATIC_LIB}" CMAKE_ARGS ${ZLIB_CMAKE_ARGS}) + + set (ZLIB_VENDORED TRUE) endif () -include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS}) + +include_directories (SYSTEM ${ZLIB_INCLUDE_DIR}) add_library (zlib STATIC IMPORTED) set_target_properties (zlib PROPERTIES IMPORTED_LOCATION ${ZLIB_STATIC_LIB}) -set (ZLIB_LIBRARIES zlib) -add_dependencies (zlib zlib_ep) -install(DIRECTORY ${ZLIB_PREFIX}/lib DESTINATION . - PATTERN "pkgconfig" EXCLUDE - PATTERN "*.so*" EXCLUDE - PATTERN "*.dylib" EXCLUDE) + +if (ZLIB_VENDORED) + add_dependencies (zlib zlib_ep) + if (INSTALL_VENDORED_LIBS) + install(FILES "${ZLIB_STATIC_LIB}" + DESTINATION "lib") + endif () +endif () # ---------------------------------------------------------------------- # LZ4 -set (LZ4_HOME "$ENV{LZ4_HOME}") -find_package (LZ4) -if (NOT LZ4_FOUND) +if (NOT "${LZ4_HOME}" STREQUAL "") + find_package (LZ4 REQUIRED) + set (LZ4_VENDORED FALSE) +else () set (LZ4_PREFIX "${THIRDPARTY_DIR}/lz4_ep-install") set (LZ4_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/lz4_ep-prefix/src/lz4_ep") - set (LZ4_INCLUDE_DIRS "${LZ4_PREFIX}/include") + set (LZ4_INCLUDE_DIR "${LZ4_PREFIX}/include") set (LZ4_STATIC_LIB_NAME lz4) set (LZ4_STATIC_LIB "${LZ4_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${LZ4_STATIC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") set (LZ4_SRC_URL "https://github.com/lz4/lz4/archive/v${LZ4_VERSION}.tar.gz") @@ -111,69 +151,85 @@ if (NOT LZ4_FOUND) LOG_INSTALL 1 BUILD_BYPRODUCTS ${LZ4_STATIC_LIB} ) + + set (LZ4_VENDORED TRUE) endif () -include_directories (SYSTEM ${LZ4_INCLUDE_DIRS}) + +include_directories (SYSTEM ${LZ4_INCLUDE_DIR}) add_library (lz4 STATIC IMPORTED) set_target_properties (lz4 PROPERTIES IMPORTED_LOCATION ${LZ4_STATIC_LIB}) -set (LZ4_LIBRARIES lz4) -add_dependencies (lz4 lz4_ep) -install(DIRECTORY ${LZ4_PREFIX}/lib DESTINATION . - PATTERN "pkgconfig" EXCLUDE - PATTERN "*.so*" EXCLUDE - PATTERN "*.dylib" EXCLUDE) + +if (LZ4_VENDORED) + add_dependencies (lz4 lz4_ep) + if (INSTALL_VENDORED_LIBS) + install(FILES "${LZ4_STATIC_LIB}" + DESTINATION "lib") + endif () +endif () # ---------------------------------------------------------------------- # GoogleTest (gtest now includes gmock) -set (GTEST_HOME "$ENV{GTEST_HOME}") -find_package (GTest) -if (NOT GTEST_FOUND) - set (GTEST_PREFIX "${THIRDPARTY_DIR}/googletest_ep-install") - set (GTEST_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest_ep-prefix/src/googletest_ep") - set (GTEST_INCLUDE_DIRS "${GTEST_PREFIX}/include") - set (GMOCK_STATIC_LIB "${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}") - set (GTEST_SRC_URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz") - if(APPLE) - set(GTEST_CMAKE_CXX_FLAGS " -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-value -Wno-ignored-attributes") - else() - set(GTEST_CMAKE_CXX_FLAGS "") - endif() - - set(GTEST_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX=${GTEST_PREFIX} - -Dgtest_force_shared_crt=ON - -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS}) - - ExternalProject_Add(googletest_ep - BUILD_IN_SOURCE 1 - URL ${GTEST_SRC_URL} - LOG_DOWNLOAD 1 - LOG_CONFIGURE 1 - LOG_BUILD 1 - LOG_INSTALL 1 - BUILD_BYPRODUCTS "${GMOCK_STATIC_LIB}" - CMAKE_ARGS ${GTEST_CMAKE_ARGS} - ) -endif () -include_directories (SYSTEM ${GTEST_INCLUDE_DIRS}) -add_library (gmock STATIC IMPORTED) -set_target_properties (gmock PROPERTIES IMPORTED_LOCATION ${GMOCK_STATIC_LIB}) -add_dependencies (gmock googletest_ep) +if (BUILD_CPP_TESTS) + if (NOT "${GTEST_HOME}" STREQUAL "") + find_package (GTest REQUIRED) + set (GTEST_VENDORED FALSE) + else () + set (GTEST_PREFIX "${THIRDPARTY_DIR}/googletest_ep-install") + set (GTEST_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest_ep-prefix/src/googletest_ep") + set (GTEST_INCLUDE_DIR "${GTEST_PREFIX}/include") + set (GMOCK_STATIC_LIB "${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}") + set (GTEST_SRC_URL "https://github.com/google/googletest/archive/release-${GTEST_VERSION}.tar.gz") + if(APPLE) + set(GTEST_CMAKE_CXX_FLAGS " -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-value -Wno-ignored-attributes") + else() + set(GTEST_CMAKE_CXX_FLAGS "") + endif() + + set(GTEST_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=${GTEST_PREFIX} + -Dgtest_force_shared_crt=ON + -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS}) + + ExternalProject_Add(googletest_ep + BUILD_IN_SOURCE 1 + URL ${GTEST_SRC_URL} + LOG_DOWNLOAD 1 + LOG_CONFIGURE 1 + LOG_BUILD 1 + LOG_INSTALL 1 + BUILD_BYPRODUCTS "${GMOCK_STATIC_LIB}" + CMAKE_ARGS ${GTEST_CMAKE_ARGS} + ) + + set (GTEST_VENDORED TRUE) + endif () + + include_directories (SYSTEM ${GTEST_INCLUDE_DIR}) + + add_library (gmock STATIC IMPORTED) + set_target_properties (gmock PROPERTIES IMPORTED_LOCATION ${GMOCK_STATIC_LIB}) -set (GTEST_LIBRARIES gmock) -if(NOT APPLE AND NOT MSVC) - list (APPEND GTEST_LIBRARIES pthread) -endif(NOT APPLE AND NOT MSVC) + if (GTEST_VENDORED) + add_dependencies (gmock googletest_ep) + endif () + + set (GTEST_LIBRARIES gmock) + if (NOT APPLE AND NOT MSVC) + list (APPEND GTEST_LIBRARIES pthread) + endif () +endif () # ---------------------------------------------------------------------- # Protobuf -set (PROTOBUF_HOME "$ENV{PROTOBUF_HOME}") -find_package (Protobuf) -if (NOT PROTOBUF_FOUND) +if (NOT "${PROTOBUF_HOME}" STREQUAL "") + find_package (Protobuf REQUIRED) + set (PROTOBUF_VENDORED FALSE) +else () set (PROTOBUF_PREFIX "${THIRDPARTY_DIR}/protobuf_ep-install") set (PROTOBUF_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/protobuf_ep-prefix/src/protobuf_ep") - set (PROTOBUF_INCLUDE_DIRS "${PROTOBUF_PREFIX}/include") + set (PROTOBUF_INCLUDE_DIR "${PROTOBUF_PREFIX}/include") set (PROTOBUF_STATIC_LIB "${PROTOBUF_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}") set (PROTOC_STATIC_LIB "${PROTOBUF_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}protoc${CMAKE_STATIC_LIBRARY_SUFFIX}") set (PROTOBUF_EXECUTABLE "${PROTOBUF_PREFIX}/bin/protoc") @@ -189,22 +245,26 @@ if (NOT PROTOBUF_FOUND) LOG_INSTALL 1 BUILD_BYPRODUCTS "${PROTOBUF_STATIC_LIB}" "${PROTOC_STATIC_LIB}" ) + + set (PROTOBUF_VENDORED TRUE) endif () -include_directories (SYSTEM ${PROTOBUF_INCLUDE_DIRS}) + +include_directories (SYSTEM ${PROTOBUF_INCLUDE_DIR}) + add_library (protobuf STATIC IMPORTED) set_target_properties (protobuf PROPERTIES IMPORTED_LOCATION ${PROTOBUF_STATIC_LIB}) -add_dependencies (protobuf protobuf_ep) add_library (protoc STATIC IMPORTED) set_target_properties (protoc PROPERTIES IMPORTED_LOCATION ${PROTOC_STATIC_LIB}) -add_dependencies (protoc protobuf_ep) -set (PROTOBUF_LIBRARIES protobuf protoc) - -install(DIRECTORY ${PROTOBUF_PREFIX}/lib DESTINATION . - PATTERN "pkgconfig" EXCLUDE - PATTERN "*.so*" EXCLUDE - PATTERN "*.dylib" EXCLUDE) +if (PROTOBUF_VENDORED) + add_dependencies (protoc protobuf_ep) + add_dependencies (protobuf protobuf_ep) + if (INSTALL_VENDORED_LIBS) + install(FILES "${PROTOBUF_STATIC_LIB}" "${PROTOC_STATIC_LIB}" + DESTINATION "lib") + endif () +endif () # ---------------------------------------------------------------------- # LIBHDFSPP @@ -216,21 +276,21 @@ if(BUILD_LIBHDFSPP) find_package(Threads) set (LIBHDFSPP_PREFIX "${THIRDPARTY_DIR}/libhdfspp_ep-install") - set (LIBHDFSPP_INCLUDE_DIRS "${LIBHDFSPP_PREFIX}/include") + set (LIBHDFSPP_INCLUDE_DIR "${LIBHDFSPP_PREFIX}/include") set (LIBHDFSPP_STATIC_LIB_NAME hdfspp_static) set (LIBHDFSPP_STATIC_LIB "${LIBHDFSPP_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${LIBHDFSPP_STATIC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}") set (LIBHDFSPP_SRC_URL "${CMAKE_SOURCE_DIR}/c++/libs/libhdfspp/libhdfspp.tar.gz") set (LIBHDFSPP_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX=${LIBHDFSPP_PREFIX} - -DPROTOBUF_INCLUDE_DIR=${PROTOBUF_INCLUDE_DIRS} - -DPROTOBUF_LIBRARY=${PROTOBUF_STATIC_LIB} - -DPROTOBUF_PROTOC_LIBRARY=${PROTOC_STATIC_LIB} - -DPROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_EXECUTABLE} - -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} - -DCMAKE_C_FLAGS=${EP_C_FLAGS} - -DBUILD_SHARED_LIBS=OFF - -DHDFSPP_LIBRARY_ONLY=TRUE - -DBUILD_SHARED_HDFSPP=FALSE) + -DCMAKE_INSTALL_PREFIX=${LIBHDFSPP_PREFIX} + -DPROTOBUF_INCLUDE_DIR=${PROTOBUF_INCLUDE_DIR} + -DPROTOBUF_LIBRARY=${PROTOBUF_STATIC_LIB} + -DPROTOBUF_PROTOC_LIBRARY=${PROTOC_STATIC_LIB} + -DPROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_EXECUTABLE} + -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} + -DCMAKE_C_FLAGS=${EP_C_FLAGS} + -DBUILD_SHARED_LIBS=OFF + -DHDFSPP_LIBRARY_ONLY=TRUE + -DBUILD_SHARED_HDFSPP=FALSE) ExternalProject_Add (libhdfspp_ep DEPENDS protobuf_ep @@ -242,15 +302,22 @@ if(BUILD_LIBHDFSPP) BUILD_BYPRODUCTS "${LIBHDFSPP_STATIC_LIB}" CMAKE_ARGS ${LIBHDFSPP_CMAKE_ARGS}) - include_directories (SYSTEM ${LIBHDFSPP_INCLUDE_DIRS}) + include_directories (SYSTEM ${LIBHDFSPP_INCLUDE_DIR}) + add_library (libhdfspp STATIC IMPORTED) set_target_properties (libhdfspp PROPERTIES IMPORTED_LOCATION ${LIBHDFSPP_STATIC_LIB}) - set (LIBHDFSPP_LIBRARIES libhdfspp ${CYRUS_SASL_SHARED_LIB} ${OPENSSL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) add_dependencies (libhdfspp libhdfspp_ep) - install(DIRECTORY ${LIBHDFSPP_PREFIX}/lib DESTINATION . - PATTERN "pkgconfig" EXCLUDE - PATTERN "*.so*" EXCLUDE - PATTERN "*.dylib" EXCLUDE) + if (INSTALL_VENDORED_LIBS) + install(FILES "${LIBHDFSPP_STATIC_LIB}" + DESTINATION "lib") + endif () + + set (LIBHDFSPP_LIBRARIES + libhdfspp + ${CYRUS_SASL_SHARED_LIB} + ${OPENSSL_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT}) + else(ORC_CXX_HAS_THREAD_LOCAL) message(STATUS "WARNING: Libhdfs++ library was not built because the required feature http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/tools/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9606d3b..02b3347 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -11,4 +11,7 @@ # limitations under the License. add_subdirectory(src) -add_subdirectory(test) + +if (BUILD_CPP_TESTS) + add_subdirectory(test) +endif () http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/tools/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/tools/src/CMakeLists.txt b/tools/src/CMakeLists.txt index e5126a3..435a3e3 100644 --- a/tools/src/CMakeLists.txt +++ b/tools/src/CMakeLists.txt @@ -22,7 +22,7 @@ include_directories ( ${PROJECT_BINARY_DIR}/c++/include ${PROJECT_SOURCE_DIR}/c++/src ${PROJECT_BINARY_DIR}/c++/src - ${PROTOBUF_INCLUDE_DIRS} + ${PROTOBUF_INCLUDE_DIR} ) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g ${CXX11_FLAGS} ${WARN_FLAGS}") @@ -49,7 +49,7 @@ add_executable (orc-metadata target_link_libraries (orc-metadata orc - ${PROTOBUF_LIBRARIES} + protobuf ) add_executable (orc-statistics http://git-wip-us.apache.org/repos/asf/orc/blob/7cd67fe2/tools/test/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/tools/test/CMakeLists.txt b/tools/test/CMakeLists.txt index a94c8fb..d5d5dbc 100644 --- a/tools/test/CMakeLists.txt +++ b/tools/test/CMakeLists.txt @@ -16,9 +16,9 @@ include_directories( ${PROJECT_SOURCE_DIR}/tools-c++/src ${PROJECT_BINARY_DIR}/c++/include ${PROJECT_BINARY_DIR}/c++/src - ${PROTOBUF_INCLUDE_DIRS} - ${ZLIB_INCLUDE_DIRS} - ${GTEST_INCLUDE_DIRS} + ${PROTOBUF_INCLUDE_DIR} + ${ZLIB_INCLUDE_DIR} + ${GTEST_INCLUDE_DIR} ) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAGS} ${WARN_FLAGS}") @@ -33,10 +33,10 @@ add_executable (tool-test target_link_libraries (tool-test orc - ${PROTOBUF_LIBRARIES} - ${GTEST_LIBRARIES} - ${ZLIB_LIBRARIES} - ${SNAPPY_LIBRARIES} + protobuf + gmock + zlib + snappy ) add_test (tool-test tool-test ${EXAMPLE_DIRECTORY} ${PROJECT_BINARY_DIR})
