2014-07-17 17:44:55 +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 )
2015-06-30 23:06:46 +00:00
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /../../../../hadoop-common-project/hadoop-common/ )
include ( HadoopCommon )
# Add extra compiler and linker flags.
# -Wno-sign-compare
hadoop_add_compiler_flags ( "-DNDEBUG -DSIMPLE_MEMCPY -fno-strict-aliasing" )
# Source location.
set ( SRC main/native )
# 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 ( )
# Configure JNI.
include ( HadoopJNI )
# Probe for headers and functions.
include ( CheckFunctionExists )
include ( CheckIncludeFiles )
check_include_files ( fcntl.h HAVE_FCNTL_H )
check_include_files ( malloc.h HAVE_MALLOC_H )
check_include_files ( mach/mach.h HAVE_MACH_MACH_H )
check_include_files ( memory.h HAVE_MEMORY_H )
check_include_files ( stddef.h HAVE_STDDEF_H )
check_include_files ( stdint.h HAVE_STDINT_H )
check_include_files ( stdlib.h HAVE_STDLIB_H )
Check_include_files ( string.h HAVE_STRING_H )
check_include_files ( unistd.h HAVE_UNITSTD_H )
check_function_exists ( clock_gettime HAVE_CLOCK_GETTIME )
check_function_exists ( localtime_r HAVE_LOCALTIME_R )
check_function_exists ( memset HAVE_MEMSET )
check_function_exists ( strchr HAVE_STRCHR )
check_function_exists ( strtoul HAVE_STRTOUL )
# Require snappy.
set ( STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES )
hadoop_set_find_shared_library_version ( "1" )
2014-07-22 19:55:03 +00:00
find_library ( SNAPPY_LIBRARY
2014-07-17 17:44:55 +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-30 23:06:46 +00:00
set ( CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES )
2014-07-22 19:55:03 +00:00
find_path ( SNAPPY_INCLUDE_DIR
2014-07-17 17:44:55 +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-30 23:06:46 +00:00
if ( SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR )
2014-07-17 17:44:55 +00:00
GET_FILENAME_COMPONENT ( HADOOP_SNAPPY_LIBRARY ${ SNAPPY_LIBRARY } NAME )
set ( SNAPPY_SOURCE_FILES
2015-06-30 23:06:46 +00:00
" $ { S R C } / s r c / c o d e c / S n a p p y C o d e c . c c " )
set ( REQUIRE_SNAPPY ${ REQUIRE_SNAPPY } ) # Stop warning about unused variable.
message ( STATUS "Found Snappy: ${SNAPPY_LIBRARY}" )
else ( )
2014-08-06 07:32:49 +00:00
set ( SNAPPY_LIBRARY "" )
2014-07-17 17:44:55 +00:00
set ( SNAPPY_INCLUDE_DIR "" )
set ( SNAPPY_SOURCE_FILES "" )
2015-06-30 23:06:46 +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 ( )
2014-07-17 17:44:55 +00:00
2015-06-30 23:06:46 +00:00
configure_file ( ${ CMAKE_SOURCE_DIR } /config.h.cmake ${ CMAKE_BINARY_DIR } /config.h )
2014-08-06 07:32:49 +00:00
2014-07-17 17:44:55 +00:00
include_directories (
2014-07-22 19:55:03 +00:00
$ { G E N E R A T E D _ J A V A H }
2015-06-30 23:06:46 +00:00
$ { S R C } / s r c
$ { S R C } / s r c / u t i l
$ { S R C } / s r c / l i b
$ { S R C } / t e s t
2014-07-17 17:44:55 +00:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
2014-08-06 06:01:12 +00:00
$ { C M A K E _ B I N A R Y _ D I R }
2014-07-17 17:44:55 +00:00
$ { J N I _ 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 }
)
2014-08-27 19:23:03 +00:00
# add gtest as system library to suppress gcc warnings
2015-06-30 23:06:46 +00:00
include_directories ( SYSTEM ${ SRC } /gtest/include )
2014-07-17 17:44:55 +00:00
2016-11-28 23:24:44 +00:00
set ( CMAKE_MACOSX_RPATH TRUE )
2015-06-30 23:06:46 +00:00
set ( CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
2016-11-28 23:24:44 +00:00
set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
2014-07-17 17:44:55 +00:00
2015-06-30 23:06:46 +00:00
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
2014-07-22 19:55:03 +00:00
# macosx does not have -lrt
set ( NT_DEPEND_LIBRARY dl pthread z ${ SNAPPY_LIBRARY } ${ JAVA_JVM_LIBRARY } )
2014-08-14 04:47:20 +00:00
set ( SYSTEM_MAC TRUE )
2015-06-30 23:06:46 +00:00
else ( )
2014-07-22 19:55:03 +00:00
set ( NT_DEPEND_LIBRARY dl rt pthread z ${ SNAPPY_LIBRARY } ${ JAVA_JVM_LIBRARY } )
2014-08-14 04:47:20 +00:00
set ( SYSTEM_MAC FALSE )
2015-06-30 23:06:46 +00:00
endif ( )
2014-07-22 19:55:03 +00:00
2014-08-14 04:47:20 +00:00
configure_file ( main/native/test.sh test/test.sh )
2015-06-30 23:06:46 +00:00
hadoop_add_dual_library ( nativetask
2014-08-06 06:01:12 +00:00
$ { C M A K E _ B I N A R Y _ D I R } / l z 4 . c
2015-06-30 23:06:46 +00:00
$ { S R C } / s r c / c o d e c / B l o c k C o d e c . c c
$ { S R C } / s r c / c o d e c / G z i p C o d e c . c c
$ { S R C } / s r c / c o d e c / L z 4 C o d e c . c c
2014-07-17 17:44:55 +00:00
$ { S N A P P Y _ S O U R C E _ F I L E S }
2015-06-30 23:06:46 +00:00
$ { S R C } / s r c / h a n d l e r / B a t c h H a n d l e r . c c
$ { S R C } / s r c / h a n d l e r / M C o l l e c t o r O u t p u t H a n d l e r . c c
$ { S R C } / s r c / h a n d l e r / A b s t r a c t M a p H a n d l e r . c c
$ { S R C } / s r c / h a n d l e r / C o m b i n e H a n d l e r . c c
$ { S R C } / s r c / l i b / B u f f e r s . c c
$ { S R C } / s r c / l i b / B u f f e r S t r e a m . c c
$ { S R C } / s r c / l i b / C o m p r e s s i o n s . c c
$ { S R C } / s r c / l i b / P a r t i t i o n B u c k e t . c c
$ { S R C } / s r c / l i b / P a r t i t i o n B u c k e t I t e r a t o r . c c
$ { S R C } / s r c / l i b / F i l e S y s t e m . c c
$ { S R C } / s r c / l i b / I F i l e . c c
$ { S R C } / s r c / l i b / j n i u t i l s . c c
$ { S R C } / s r c / l i b / L o g . c c
$ { S R C } / s r c / l i b / M a p O u t p u t C o l l e c t o r . c c
$ { S R C } / s r c / l i b / M a p O u t p u t S p e c . c c
$ { S R C } / s r c / l i b / M e m o r y B l o c k . c c
$ { S R C } / s r c / l i b / M e r g e . c c
$ { S R C } / s r c / l i b / N a t i v e L i b r a r y . c c
$ { S R C } / s r c / l i b / I t e r a t o r . c c
$ { S R C } / s r c / l i b / N a t i v e O b j e c t F a c t o r y . c c
$ { S R C } / s r c / l i b / N a t i v e R u n t i m e J n i I m p l . c c
$ { S R C } / s r c / l i b / N a t i v e T a s k . c c
$ { S R C } / s r c / l i b / S p i l l I n f o . c c
$ { S R C } / s r c / l i b / P a t h . c c
$ { S R C } / s r c / l i b / S t r e a m s . c c
$ { S R C } / s r c / l i b / T a s k C o u n t e r s . c c
$ { S R C } / s r c / u t i l / C h e c k s u m . c c
$ { S R C } / s r c / u t i l / R a n d o m . c c
$ { S R C } / s r c / u t i l / S t r i n g U t i l . c c
$ { S R C } / s r c / u t i l / S y n c U t i l s . c c
$ { S R C } / s r c / u t i l / T i m e r . c c
$ { S R C } / s r c / u t i l / W r i t a b l e U t i l s . c c
2014-07-17 17:44:55 +00:00
)
2014-07-22 19:55:03 +00:00
target_link_libraries ( nativetask ${ NT_DEPEND_LIBRARY } )
2015-06-30 23:06:46 +00:00
add_library ( gtest ${ SRC } /gtest/gtest-all.cc )
2014-08-27 19:23:03 +00:00
set_target_properties ( gtest PROPERTIES COMPILE_FLAGS "-w" )
2014-07-22 19:55:03 +00:00
add_executable ( nttest
2015-06-30 23:06:46 +00:00
$ { S R C } / t e s t / l i b / T e s t B y t e A r r a y . c c
$ { S R C } / t e s t / l i b / T e s t B y t e B u f f e r . c c
$ { S R C } / t e s t / l i b / T e s t C o m p a r a t o r F o r D u a l P i v o t Q u i c k S o r t . c c
$ { S R C } / t e s t / l i b / T e s t C o m p a r a t o r F o r S t d S o r t . c c
$ { S R C } / t e s t / l i b / T e s t F i x S i z e C o n t a i n e r . c c
$ { S R C } / t e s t / l i b / T e s t M e m o r y P o o l . c c
$ { S R C } / t e s t / l i b / T e s t I t e r a t o r . c c
$ { S R C } / t e s t / l i b / T e s t K V B u f f e r . c c
$ { S R C } / t e s t / l i b / T e s t M e m B l o c k I t e r a t o r . c c
$ { S R C } / t e s t / l i b / T e s t M e m o r y B l o c k . c c
$ { S R C } / t e s t / l i b / T e s t P a r t i t i o n B u c k e t . c c
$ { S R C } / t e s t / l i b / T e s t R e a d B u f f e r . c c
$ { S R C } / t e s t / l i b / T e s t R e a d W r i t e B u f f e r . c c
$ { S R C } / t e s t / u t i l / T e s t C h e c k s u m . c c
$ { S R C } / t e s t / u t i l / T e s t S t r i n g U t i l . c c
$ { S R C } / t e s t / u t i l / T e s t W r i t a b l e U t i l s . c c
$ { S R C } / t e s t / T e s t C o m m a n d . c c
$ { S R C } / t e s t / T e s t C o n f i g . c c
$ { S R C } / t e s t / T e s t C o u n t e r . c c
$ { S R C } / t e s t / T e s t C o m p r e s s i o n s . c c
$ { S R C } / t e s t / T e s t F i l e S y s t e m . c c
$ { S R C } / t e s t / T e s t I F i l e . c c
$ { S R C } / t e s t / T e s t P r i m i t i v e s . c c
$ { S R C } / t e s t / T e s t S o r t . c c
$ { S R C } / t e s t / T e s t M a i n . c c
$ { S R C } / t e s t / t e s t _ c o m m o n s . c c )
2014-07-22 19:55:03 +00:00
target_link_libraries ( nttest
n a t i v e t a s k _ s t a t i c
2014-08-27 19:23:03 +00:00
g t e s t
2014-07-22 19:55:03 +00:00
$ { N T _ D E P E N D _ L I B R A R Y }
2014-07-17 17:44:55 +00:00
)
2015-06-30 23:06:46 +00:00
# By embedding '$ORIGIN' into the RPATH of libnativetask.so, dlopen will look in
# the directory containing libnativetask.so. However, $ORIGIN is not supported by
# all operating systems.
if ( CMAKE_SYSTEM_NAME MATCHES "Linux|SunOS" )
set_target_properties ( nativetask PROPERTIES INSTALL_RPATH "\$ORIGIN/" )
endif ( )
set ( LIBNATIVETASK_VERSION "1.0.0" )
set_target_properties ( nativetask PROPERTIES SOVERSION ${ LIBNATIVETASK_VERSION } )
hadoop_dual_output_directory ( nativetask target/usr/local/lib )
hadoop_output_directory ( nttest test )