2012-06-11 18:34:40 +00:00
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#
2015-06-26 19:32:31 +00:00
#
# CMake configuration.
#
2012-06-11 18:34:40 +00:00
2015-06-26 19:32:31 +00:00
cmake_minimum_required ( VERSION 2.6 FATAL_ERROR )
2012-06-11 18:34:40 +00:00
2015-06-26 19:32:31 +00:00
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /.. )
include ( HadoopCommon )
2012-06-11 18:34:40 +00:00
2015-06-26 19:32:31 +00:00
# Source and test locations.
set ( SRC main/native/src/org/apache/hadoop )
set ( TST main/native/src/test/org/apache/hadoop )
2012-06-11 18:34:40 +00:00
2012-10-15 17:44:02 +00:00
#
2015-06-26 19:32:31 +00:00
# Main configuration.
2012-10-15 17:44:02 +00:00
#
2015-06-26 19:32:31 +00:00
# The caller must specify where the generated headers have been placed.
if ( NOT GENERATED_JAVAH )
message ( FATAL_ERROR "You must set the CMake variable GENERATED_JAVAH" )
endif ( )
2014-10-30 02:35:14 +00:00
2015-06-26 19:32:31 +00:00
# Configure JNI.
include ( HadoopJNI )
2012-10-15 17:44:02 +00:00
2015-06-26 19:32:31 +00:00
# Require zlib.
set ( STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${ CMAKE_FIND_LIBRARY_SUFFIXES } )
hadoop_set_find_shared_library_version ( "1" )
2012-06-11 18:34:40 +00:00
find_package ( ZLIB REQUIRED )
2015-06-26 19:32:31 +00:00
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${ STORED_CMAKE_FIND_LIBRARY_SUFFIXES } )
get_filename_component ( HADOOP_ZLIB_LIBRARY ${ ZLIB_LIBRARIES } NAME )
2012-06-11 18:34:40 +00:00
2015-06-26 19:32:31 +00:00
# Look for bzip2.
set ( STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${ CMAKE_FIND_LIBRARY_SUFFIXES } )
hadoop_set_find_shared_library_version ( "1" )
2013-03-06 23:10:12 +00:00
find_package ( BZip2 QUIET )
2015-06-26 19:32:31 +00:00
if ( BZIP2_INCLUDE_DIR AND BZIP2_LIBRARIES )
get_filename_component ( HADOOP_BZIP2_LIBRARY ${ BZIP2_LIBRARIES } NAME )
2013-03-06 23:10:12 +00:00
set ( BZIP2_SOURCE_FILES
2015-06-26 19:32:31 +00:00
" $ { S R C } / i o / c o m p r e s s / b z i p 2 / B z i p 2 C o m p r e s s o r . c "
" $ { S R C } / i o / c o m p r e s s / b z i p 2 / B z i p 2 D e c o m p r e s s o r . c " )
set ( REQUIRE_BZIP2 ${ REQUIRE_BZIP2 } ) # Stop warning about unused variable.
else ( )
2013-03-06 23:10:12 +00:00
set ( BZIP2_SOURCE_FILES "" )
set ( BZIP2_INCLUDE_DIR "" )
2015-06-26 19:32:31 +00:00
if ( REQUIRE_BZIP2 )
message ( FATAL_ERROR "Required bzip2 library and/or header files could not be found." )
endif ( )
endif ( )
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${ STORED_CMAKE_FIND_LIBRARY_SUFFIXES } )
# Require snappy.
set ( STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${ CMAKE_FIND_LIBRARY_SUFFIXES } )
hadoop_set_find_shared_library_version ( "1" )
find_library ( SNAPPY_LIBRARY
2012-08-01 21:23:10 +00:00
N A M E S s n a p p y
P A T H S $ { C U S T O M _ S N A P P Y _ P R E F I X } $ { C U S T O M _ S N A P P Y _ P R E F I X } / l i b
$ { C U S T O M _ S N A P P Y _ P R E F I X } / l i b 6 4 $ { C U S T O M _ S N A P P Y _ L I B } )
2015-06-26 19:32:31 +00:00
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${ STORED_CMAKE_FIND_LIBRARY_SUFFIXES } )
find_path ( SNAPPY_INCLUDE_DIR
2012-08-01 21:23:10 +00:00
N A M E S s n a p p y . h
P A T H S $ { C U S T O M _ S N A P P Y _ P R E F I X } $ { C U S T O M _ S N A P P Y _ P R E F I X } / i n c l u d e
$ { C U S T O M _ S N A P P Y _ I N C L U D E } )
2015-06-26 19:32:31 +00:00
if ( SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR )
get_filename_component ( HADOOP_SNAPPY_LIBRARY ${ SNAPPY_LIBRARY } NAME )
2012-06-11 18:34:40 +00:00
set ( SNAPPY_SOURCE_FILES
2015-06-26 19:32:31 +00:00
" $ { S R C } / i o / c o m p r e s s / s n a p p y / S n a p p y C o m p r e s s o r . c "
" $ { S R C } / i o / c o m p r e s s / s n a p p y / S n a p p y D e c o m p r e s s o r . c " )
set ( REQUIRE_SNAPPY ${ REQUIRE_SNAPPY } ) # Stop warning about unused variable.
message ( STATUS "Found Snappy: ${SNAPPY_LIBRARY}" )
else ( )
2012-06-11 18:34:40 +00:00
set ( SNAPPY_INCLUDE_DIR "" )
set ( SNAPPY_SOURCE_FILES "" )
2015-06-26 19:32:31 +00:00
if ( REQUIRE_SNAPPY )
message ( FATAL_ERROR "Required snappy library could not be found. SNAPPY_LIBRARY=${SNAPPY_LIBRARY}, SNAPPY_INCLUDE_DIR=${SNAPPY_INCLUDE_DIR}, CUSTOM_SNAPPY_INCLUDE_DIR=${CUSTOM_SNAPPY_INCLUDE_DIR}, CUSTOM_SNAPPY_PREFIX=${CUSTOM_SNAPPY_PREFIX}, CUSTOM_SNAPPY_INCLUDE=${CUSTOM_SNAPPY_INCLUDE}" )
endif ( )
endif ( )
2015-11-05 18:31:01 +00:00
set ( STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${ CMAKE_FIND_LIBRARY_SUFFIXES } )
hadoop_set_find_shared_library_version ( "2" )
find_library ( ISAL_LIBRARY
N A M E S i s a l
P A T H S $ { C U S T O M _ I S A L _ P R E F I X } $ { C U S T O M _ I S A L _ P R E F I X } / l i b
2016-01-15 22:05:21 +00:00
$ { C U S T O M _ I S A L _ P R E F I X } / l i b 6 4 $ { C U S T O M _ I S A L _ L I B } / u s r / l i b )
2015-11-05 18:31:01 +00:00
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${ STORED_CMAKE_FIND_LIBRARY_SUFFIXES } )
if ( ISAL_LIBRARY )
GET_FILENAME_COMPONENT ( HADOOP_ISAL_LIBRARY ${ ISAL_LIBRARY } NAME )
2016-03-11 20:56:12 +00:00
set ( ISAL_INCLUDE_DIR ${ SRC } /io/erasurecode )
2015-11-05 18:31:01 +00:00
set ( ISAL_SOURCE_FILES
2016-03-11 20:56:12 +00:00
$ { S R C } / i o / e r a s u r e c o d e / i s a l _ l o a d . c
$ { S R C } / i o / e r a s u r e c o d e / e r a s u r e _ c o d e . c
$ { S R C } / i o / e r a s u r e c o d e / g f _ u t i l . c
$ { S R C } / i o / e r a s u r e c o d e / d u m p . c
$ { S R C } / i o / e r a s u r e c o d e / e r a s u r e _ c o d e r . c
$ { S R C } / i o / e r a s u r e c o d e / j n i _ e r a s u r e _ c o d e _ n a t i v e . c
$ { S R C } / i o / e r a s u r e c o d e / j n i _ c o m m o n . c
$ { S R C } / i o / e r a s u r e c o d e / j n i _ r s _ e n c o d e r . c
$ { S R C } / i o / e r a s u r e c o d e / j n i _ r s _ d e c o d e r . c )
2015-11-05 18:31:01 +00:00
add_executable ( erasure_code_test
2016-03-11 20:56:12 +00:00
$ { S R C } / i o / e r a s u r e c o d e / i s a l _ l o a d . c
$ { S R C } / i o / e r a s u r e c o d e / e r a s u r e _ c o d e . c
$ { S R C } / i o / e r a s u r e c o d e / g f _ u t i l . c
$ { S R C } / i o / e r a s u r e c o d e / d u m p . c
$ { S R C } / i o / e r a s u r e c o d e / e r a s u r e _ c o d e r . c
$ { T S T } / i o / e r a s u r e c o d e / e r a s u r e _ c o d e _ t e s t . c
2015-11-05 18:31:01 +00:00
)
target_link_libraries ( erasure_code_test ${ CMAKE_DL_LIBS } )
else ( ISAL_LIBRARY )
IF ( REQUIRE_ISAL )
MESSAGE ( FATAL_ERROR "Required ISA-L library could not be found. ISAL_LIBRARY=${ISAL_LIBRARY}, CUSTOM_ISAL_PREFIX=${CUSTOM_ISAL_PREFIX}" )
ENDIF ( REQUIRE_ISAL )
endif ( ISAL_LIBRARY )
2015-06-26 19:32:31 +00:00
# Build hardware CRC32 acceleration, if supported on the platform.
if ( CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64" )
set ( BULK_CRC_ARCH_SOURCE_FIlE "${SRC}/util/bulk_crc32_x86.c" )
elseif ( CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" )
set ( BULK_CRC_ARCH_SOURCE_FIlE "${SRC}/util/bulk_crc32_aarch64.c" )
else ( )
message ( "No HW CRC acceleration for ${CMAKE_SYSTEM_PROCESSOR}, falling back to SW" )
endif ( )
# Find the no-suffix version of libcrypto/openssl. See HADOOP-11216 for details.
set ( STORED_CMAKE_FIND_LIBRARY_SUFFIXES ${ CMAKE_FIND_LIBRARY_SUFFIXES } )
hadoop_set_find_shared_library_without_version ( )
set ( OPENSSL_NAME "crypto" )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Windows" )
2014-07-03 23:40:31 +00:00
SET ( OPENSSL_NAME "eay32" )
2015-06-26 19:32:31 +00:00
endif ( )
message ( "CUSTOM_OPENSSL_PREFIX = ${CUSTOM_OPENSSL_PREFIX}" )
2014-07-03 23:40:31 +00:00
find_library ( OPENSSL_LIBRARY
N A M E S $ { O P E N S S L _ N A M E }
P A T H S $ { C U S T O M _ O P E N S S L _ P R E F I X } $ { C U S T O M _ O P E N S S L _ P R E F I X } / l i b
$ { C U S T O M _ O P E N S S L _ P R E F I X } / l i b 6 4 $ { C U S T O M _ O P E N S S L _ L I B } N O _ D E F A U L T _ P A T H )
2014-10-30 02:35:14 +00:00
find_library ( OPENSSL_LIBRARY NAMES ${ OPENSSL_NAME } )
2015-06-26 19:32:31 +00:00
find_path ( OPENSSL_INCLUDE_DIR
2014-07-03 23:40:31 +00:00
N A M E S o p e n s s l / e v p . h
P A T H S $ { C U S T O M _ O P E N S S L _ P R E F I X } $ { C U S T O M _ O P E N S S L _ P R E F I X } / i n c l u d e
$ { C U S T O M _ O P E N S S L _ I N C L U D E } N O _ D E F A U L T _ P A T H )
2014-10-30 02:35:14 +00:00
find_path ( OPENSSL_INCLUDE_DIR NAMES openssl/evp.h )
2015-06-26 19:32:31 +00:00
set ( CMAKE_FIND_LIBRARY_SUFFIXES ${ STORED_CMAKE_FIND_LIBRARY_SUFFIXES } )
set ( USABLE_OPENSSL 0 )
if ( OPENSSL_LIBRARY AND OPENSSL_INCLUDE_DIR )
include ( CheckCSourceCompiles )
set ( OLD_CMAKE_REQUIRED_INCLUDES ${ CMAKE_REQUIRED_INCLUDES } )
set ( CMAKE_REQUIRED_INCLUDES ${ OPENSSL_INCLUDE_DIR } )
check_c_source_compiles ( "#include \" ${ OPENSSL_INCLUDE_DIR } /openssl/evp.h\ "\nint main(int argc, char **argv) { return !EVP_aes_256_ctr; }" HAS_NEW_ENOUGH_OPENSSL )
set ( CMAKE_REQUIRED_INCLUDES ${ OLD_CMAKE_REQUIRED_INCLUDES } )
2014-10-30 02:35:14 +00:00
if ( NOT HAS_NEW_ENOUGH_OPENSSL )
2015-06-26 19:32:31 +00:00
message ( "The OpenSSL library installed at ${OPENSSL_LIBRARY} is too old. You need a version at least new enough to have EVP_aes_256_ctr." )
else ( )
2014-10-30 02:35:14 +00:00
SET ( USABLE_OPENSSL 1 )
2015-06-26 19:32:31 +00:00
endif ( )
endif ( )
if ( USABLE_OPENSSL )
get_filename_component ( HADOOP_OPENSSL_LIBRARY ${ OPENSSL_LIBRARY } NAME )
set ( OPENSSL_SOURCE_FILES
" $ { S R C } / c r y p t o / O p e n s s l C i p h e r . c "
" $ { S R C } / c r y p t o / r a n d o m / O p e n s s l S e c u r e R a n d o m . c " )
set ( REQUIRE_OPENSSL ${ REQUIRE_OPENSSL } ) # Stop warning about unused variable.
else ( )
message ( "Cannot find a usable OpenSSL library. OPENSSL_LIBRARY=${OPENSSL_LIBRARY}, OPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}, CUSTOM_OPENSSL_LIB=${CUSTOM_OPENSSL_LIB}, CUSTOM_OPENSSL_PREFIX=${CUSTOM_OPENSSL_PREFIX}, CUSTOM_OPENSSL_INCLUDE=${CUSTOM_OPENSSL_INCLUDE}" )
if ( REQUIRE_OPENSSL )
message ( FATAL_ERROR "Terminating build because require.openssl was specified." )
endif ( )
set ( OPENSSL_LIBRARY "" )
set ( OPENSSL_INCLUDE_DIR "" )
set ( OPENSSL_SOURCE_FILES "" )
endif ( )
# Check for platform-specific functions and libraries.
include ( CheckFunctionExists )
include ( CheckLibraryExists )
check_function_exists ( sync_file_range HAVE_SYNC_FILE_RANGE )
check_function_exists ( posix_fadvise HAVE_POSIX_FADVISE )
check_library_exists ( dl dlopen "" NEED_LINK_DL )
# Configure the build.
2012-06-11 18:34:40 +00:00
include_directories (
$ { G E N E R A T E D _ J A V A H }
m a i n / n a t i v e / s r c
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c
$ { C M A K E _ B I N A R Y _ D I R }
$ { J N I _ I N C L U D E _ D I R S }
$ { Z L I B _ I N C L U D E _ D I R S }
2013-03-06 23:10:12 +00:00
$ { B Z I P 2 _ I N C L U D E _ D I R }
2012-06-11 18:34:40 +00:00
$ { S N A P P Y _ I N C L U D E _ D I R }
2015-11-05 18:31:01 +00:00
$ { I S A L _ I N C L U D E _ D I R }
2014-07-03 23:40:31 +00:00
$ { O P E N S S L _ I N C L U D E _ D I R }
2015-06-26 19:32:31 +00:00
$ { S R C } / u t i l
2012-09-05 22:19:40 +00:00
)
2015-06-26 19:32:31 +00:00
configure_file ( ${ CMAKE_SOURCE_DIR } /config.h.cmake ${ CMAKE_BINARY_DIR } /config.h )
2012-09-05 22:19:40 +00:00
2015-06-26 19:32:31 +00:00
set ( CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
hadoop_add_dual_library ( hadoop
2013-01-09 21:37:34 +00:00
m a i n / n a t i v e / s r c / e x c e p t i o n . c
2015-06-26 19:32:31 +00:00
$ { S R C } / i o / c o m p r e s s / l z 4 / L z 4 C o m p r e s s o r . c
$ { S R C } / i o / c o m p r e s s / l z 4 / L z 4 D e c o m p r e s s o r . c
$ { S R C } / i o / c o m p r e s s / l z 4 / l z 4 . c
$ { S R C } / i o / c o m p r e s s / l z 4 / l z 4 h c . c
2015-11-05 18:31:01 +00:00
$ { I S A L _ S O U R C E _ F I L E S }
2012-06-11 18:34:40 +00:00
$ { S N A P P Y _ S O U R C E _ F I L E S }
2014-07-03 23:40:31 +00:00
$ { O P E N S S L _ S O U R C E _ F I L E S }
2015-06-26 19:32:31 +00:00
$ { S R C } / i o / c o m p r e s s / z l i b / Z l i b C o m p r e s s o r . c
$ { S R C } / i o / c o m p r e s s / z l i b / Z l i b D e c o m p r e s s o r . c
2013-03-06 23:10:12 +00:00
$ { B Z I P 2 _ S O U R C E _ F I L E S }
2015-06-26 19:32:31 +00:00
$ { S R C } / i o / n a t i v e i o / N a t i v e I O . c
$ { S R C } / i o / n a t i v e i o / e r r n o _ e n u m . c
$ { S R C } / i o / n a t i v e i o / f i l e _ d e s c r i p t o r . c
$ { S R C } / i o / n a t i v e i o / S h a r e d F i l e D e s c r i p t o r F a c t o r y . c
$ { S R C } / n e t / u n i x / D o m a i n S o c k e t . c
$ { S R C } / n e t / u n i x / D o m a i n S o c k e t W a t c h e r . c
$ { S R C } / s e c u r i t y / J n i B a s e d U n i x G r o u p s M a p p i n g . c
$ { S R C } / s e c u r i t y / J n i B a s e d U n i x G r o u p s N e t g r o u p M a p p i n g . c
$ { S R C } / s e c u r i t y / h a d o o p _ g r o u p _ i n f o . c
$ { S R C } / s e c u r i t y / h a d o o p _ u s e r _ i n f o . c
$ { S R C } / u t i l / N a t i v e C o d e L o a d e r . c
$ { S R C } / u t i l / N a t i v e C r c 3 2 . c
$ { S R C } / u t i l / b u l k _ c r c 3 2 . c
2015-03-30 20:55:02 +00:00
$ { B U L K _ C R C _ A R C H _ S O U R C E _ F I l E }
2012-06-11 18:34:40 +00:00
)
2015-06-26 19:32:31 +00:00
if ( NEED_LINK_DL )
2012-10-23 15:32:25 +00:00
set ( LIB_DL dl )
2015-06-26 19:32:31 +00:00
endif ( )
2012-09-17 19:30:07 +00:00
2015-06-26 19:32:31 +00:00
hadoop_target_link_dual_libraries ( hadoop ${ LIB_DL } ${ JAVA_JVM_LIBRARY } )
set ( LIBHADOOP_VERSION "1.0.0" )
set_target_properties ( hadoop PROPERTIES SOVERSION ${ LIBHADOOP_VERSION } )
hadoop_dual_output_directory ( hadoop target/usr/local/lib )
# By embedding '$ORIGIN' into the RPATH of libhadoop.so, dlopen will look in
# the directory containing libhadoop.so. However, $ORIGIN is not supported by
# all operating systems.
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux|SunOS" )
2014-12-16 00:16:02 +00:00
set ( RPATH "\$ORIGIN/" )
2015-06-26 19:32:31 +00:00
if ( EXTRA_LIBHADOOP_RPATH )
2014-12-16 00:16:02 +00:00
set ( RPATH "${RPATH}:${EXTRA_LIBHADOOP_RPATH}/" )
2015-06-26 19:32:31 +00:00
endif ( )
set_target_properties ( hadoop PROPERTIES INSTALL_RPATH "${RPATH}" )
endif ( )
2012-09-17 19:30:07 +00:00
2015-06-26 19:32:31 +00:00
# Build the CRC32 test executable.
add_executable ( test_bulk_crc32
$ { S R C } / u t i l / b u l k _ c r c 3 2 . c
$ { B U L K _ C R C _ A R C H _ S O U R C E _ F I l E }
$ { T S T } / u t i l / t e s t _ b u l k _ c r c 3 2 . c
2012-06-11 18:34:40 +00:00
)