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.
#
cmake_minimum_required ( VERSION 2.6 FATAL_ERROR )
# Default to release builds
set ( CMAKE_BUILD_TYPE, Release )
2012-08-09 21:58:21 +00:00
include ( JNIFlags.cmake NO_POLICY_SCOPE )
2012-06-11 18:34:40 +00:00
# Compile a library with both shared and static variants
function ( add_dual_library LIBNAME )
add_library ( ${ LIBNAME } SHARED ${ ARGN } )
add_library ( ${ LIBNAME } _static STATIC ${ ARGN } )
set_target_properties ( ${ LIBNAME } _static PROPERTIES OUTPUT_NAME ${ LIBNAME } )
endfunction ( add_dual_library )
# Link both a static and a dynamic target against some libraries
function ( target_link_dual_libraries LIBNAME )
target_link_libraries ( ${ LIBNAME } ${ ARGN } )
target_link_libraries ( ${ LIBNAME } _static ${ ARGN } )
endfunction ( target_link_dual_libraries )
function ( output_directory TGT DIR )
SET_TARGET_PROPERTIES ( ${ TGT } PROPERTIES
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / $ { D I R } " )
SET_TARGET_PROPERTIES ( ${ TGT } PROPERTIES
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / $ { D I R } " )
SET_TARGET_PROPERTIES ( ${ TGT } PROPERTIES
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / $ { D I R } " )
endfunction ( output_directory TGT DIR )
function ( dual_output_directory TGT DIR )
output_directory ( ${ TGT } "${DIR}" )
output_directory ( ${ TGT } _static "${DIR}" )
endfunction ( dual_output_directory TGT DIR )
if ( NOT GENERATED_JAVAH )
# Must identify where the generated headers have been placed
MESSAGE ( FATAL_ERROR "You must set the cmake variable GENERATED_JAVAH" )
endif ( NOT GENERATED_JAVAH )
find_package ( JNI REQUIRED )
find_package ( ZLIB REQUIRED )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O2" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_FILE_OFFSET_BITS=64" )
set ( D main/native/src/org/apache/hadoop )
2012-09-05 22:19:40 +00:00
set ( T main/native/src/test/org/apache/hadoop )
2012-06-11 18:34:40 +00:00
GET_FILENAME_COMPONENT ( HADOOP_ZLIB_LIBRARY ${ ZLIB_LIBRARIES } NAME )
INCLUDE ( CheckFunctionExists )
INCLUDE ( CheckCSourceCompiles )
CHECK_FUNCTION_EXISTS ( sync_file_range HAVE_SYNC_FILE_RANGE )
CHECK_FUNCTION_EXISTS ( posix_fadvise HAVE_POSIX_FADVISE )
2012-08-01 21:23:10 +00:00
find_library ( SNAPPY_LIBRARY
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 } )
find_path ( SNAPPY_INCLUDE_DIR
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 } )
if ( SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR )
2012-06-11 18:34:40 +00:00
GET_FILENAME_COMPONENT ( HADOOP_SNAPPY_LIBRARY ${ SNAPPY_LIBRARY } NAME )
set ( SNAPPY_SOURCE_FILES
" $ { D } / 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 "
" $ { D } / 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 " )
2012-08-01 21:23:10 +00:00
else ( SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR )
2012-06-11 18:34:40 +00:00
set ( SNAPPY_INCLUDE_DIR "" )
set ( SNAPPY_SOURCE_FILES "" )
2012-08-01 21:23:10 +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 ( REQUIRE_SNAPPY )
endif ( SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR )
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 }
$ { S N A P P Y _ I N C L U D E _ D I R }
2012-09-05 22:19:40 +00:00
$ { D } / u t i l
2012-06-11 18:34:40 +00:00
)
CONFIGURE_FILE ( ${ CMAKE_SOURCE_DIR } /config.h.cmake ${ CMAKE_BINARY_DIR } /config.h )
2012-09-05 22:19:40 +00:00
add_executable ( test_bulk_crc32
$ { D } / u t i l / b u l k _ c r c 3 2 . c
$ { T } / u t i l / t e s t _ b u l k _ c r c 3 2 . c
)
set_property ( SOURCE main.cpp PROPERTY INCLUDE_DIRECTORIES "\" -Werror\ " \" -Wall\ "" )
2012-09-17 19:30:07 +00:00
SET ( CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
2012-06-11 18:34:40 +00:00
add_dual_library ( hadoop
$ { D } / 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
$ { D } / 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
$ { D } / i o / c o m p r e s s / l z 4 / l z 4 . c
$ { S N A P P Y _ S O U R C E _ F I L E S }
$ { D } / 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
$ { D } / 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
$ { D } / i o / n a t i v e i o / N a t i v e I O . c
$ { D } / i o / n a t i v e i o / e r r n o _ e n u m . c
$ { D } / 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
$ { D } / 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
$ { D } / 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
$ { D } / s e c u r i t y / g e t G r o u p . c
2012-10-03 00:06:39 +00:00
$ { D } / u t i l / N a t i v e C o d e L o a d e r . c
2012-06-11 18:34:40 +00:00
$ { D } / u t i l / N a t i v e C r c 3 2 . c
$ { D } / u t i l / b u l k _ c r c 3 2 . c
)
2012-09-17 19:30:07 +00:00
IF ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux" )
#
# 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.
#
SET_TARGET_PROPERTIES ( hadoop
P R O P E R T I E S I N S T A L L _ R P A T H " \ $ O R I G I N / " )
ENDIF ( )
2012-06-11 18:34:40 +00:00
target_link_dual_libraries ( hadoop
d l
$ { J A V A _ J V M _ L I B R A R Y }
)
SET ( LIBHADOOP_VERSION "1.0.0" )
SET_TARGET_PROPERTIES ( hadoop PROPERTIES
S O V E R S I O N $ { L I B H A D O O P _ V E R S I O N } )
dual_output_directory ( hadoop target/usr/local/lib )