2012-06-11 14:34:40 -04: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 17:58:21 -04:00
|
|
|
include(../../../hadoop-common-project/hadoop-common/src/JNIFlags.cmake NO_POLICY_SCOPE)
|
2012-06-11 14:34:40 -04: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
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DIR}")
|
|
|
|
SET_TARGET_PROPERTIES(${TGT} PROPERTIES
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DIR}")
|
|
|
|
SET_TARGET_PROPERTIES(${TGT} PROPERTIES
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DIR}")
|
|
|
|
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)
|
|
|
|
|
|
|
|
# Flatten a list into a string.
|
|
|
|
function(FLATTEN_LIST INPUT SEPARATOR OUTPUT)
|
|
|
|
string (REPLACE ";" "${SEPARATOR}" _TMPS "${INPUT}")
|
|
|
|
set (${OUTPUT} "${_TMPS}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
2012-07-12 20:10:04 -04:00
|
|
|
# Check to see if our compiler and linker support the __thread attribute.
|
|
|
|
# On Linux and some other operating systems, this is a more efficient
|
|
|
|
# alternative to POSIX thread local storage.
|
|
|
|
INCLUDE(CheckCSourceCompiles)
|
|
|
|
CHECK_C_SOURCE_COMPILES("int main(void) { static __thread int i = 0; return 0; }" HAVE_BETTER_TLS)
|
|
|
|
|
2012-06-11 14:34:40 -04:00
|
|
|
find_package(JNI REQUIRED)
|
|
|
|
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)
|
|
|
|
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O2 -D_GNU_SOURCE")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_FILE_OFFSET_BITS=64")
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${GENERATED_JAVAH}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_BINARY_DIR}
|
|
|
|
${JNI_INCLUDE_DIRS}
|
2012-07-20 15:15:52 -04:00
|
|
|
main/native
|
2012-07-16 12:42:53 -04:00
|
|
|
main/native/libhdfs
|
2012-06-11 14:34:40 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
set(_FUSE_DFS_VERSION 0.1.0)
|
|
|
|
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
|
|
|
|
|
|
|
|
add_dual_library(hdfs
|
2012-08-06 17:02:30 -04:00
|
|
|
main/native/libhdfs/exception.c
|
2012-07-16 12:42:53 -04:00
|
|
|
main/native/libhdfs/jni_helper.c
|
2012-10-03 22:53:28 -04:00
|
|
|
main/native/libhdfs/hdfs.c
|
2012-06-11 14:34:40 -04:00
|
|
|
)
|
|
|
|
target_link_dual_libraries(hdfs
|
|
|
|
${JAVA_JVM_LIBRARY}
|
|
|
|
)
|
|
|
|
dual_output_directory(hdfs target/usr/local/lib)
|
|
|
|
set(LIBHDFS_VERSION "0.0.0")
|
|
|
|
set_target_properties(hdfs PROPERTIES
|
|
|
|
SOVERSION ${LIBHDFS_VERSION})
|
|
|
|
|
2012-08-09 10:44:05 -04:00
|
|
|
add_library(posix_util
|
|
|
|
main/native/util/posix_util.c
|
|
|
|
)
|
|
|
|
|
2012-07-16 12:42:53 -04:00
|
|
|
add_executable(test_libhdfs_ops
|
|
|
|
main/native/libhdfs/test/test_libhdfs_ops.c
|
2012-06-11 14:34:40 -04:00
|
|
|
)
|
2012-07-16 12:42:53 -04:00
|
|
|
target_link_libraries(test_libhdfs_ops
|
2012-06-11 14:34:40 -04:00
|
|
|
hdfs
|
|
|
|
${JAVA_JVM_LIBRARY}
|
|
|
|
)
|
|
|
|
|
2012-07-16 12:42:53 -04:00
|
|
|
add_executable(test_libhdfs_read
|
|
|
|
main/native/libhdfs/test/test_libhdfs_read.c
|
2012-06-11 14:34:40 -04:00
|
|
|
)
|
2012-07-16 12:42:53 -04:00
|
|
|
target_link_libraries(test_libhdfs_read
|
2012-06-11 14:34:40 -04:00
|
|
|
hdfs
|
|
|
|
${JAVA_JVM_LIBRARY}
|
|
|
|
)
|
|
|
|
|
2012-07-16 12:42:53 -04:00
|
|
|
add_executable(test_libhdfs_write
|
|
|
|
main/native/libhdfs/test/test_libhdfs_write.c
|
2012-06-11 14:34:40 -04:00
|
|
|
)
|
2012-07-16 12:42:53 -04:00
|
|
|
target_link_libraries(test_libhdfs_write
|
2012-06-11 14:34:40 -04:00
|
|
|
hdfs
|
|
|
|
${JAVA_JVM_LIBRARY}
|
|
|
|
)
|
|
|
|
|
2012-07-13 19:28:03 -04:00
|
|
|
add_library(native_mini_dfs
|
2012-07-16 12:42:53 -04:00
|
|
|
main/native/libhdfs/native_mini_dfs.c
|
2012-07-13 19:28:03 -04:00
|
|
|
)
|
|
|
|
target_link_libraries(native_mini_dfs
|
|
|
|
hdfs
|
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(test_native_mini_dfs
|
2012-07-16 12:42:53 -04:00
|
|
|
main/native/libhdfs/test_native_mini_dfs.c
|
2012-07-13 19:28:03 -04:00
|
|
|
)
|
|
|
|
target_link_libraries(test_native_mini_dfs
|
|
|
|
native_mini_dfs
|
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(test_libhdfs_threaded
|
2012-07-16 12:42:53 -04:00
|
|
|
main/native/libhdfs/test_libhdfs_threaded.c
|
2012-07-13 19:28:03 -04:00
|
|
|
)
|
|
|
|
target_link_libraries(test_libhdfs_threaded
|
|
|
|
hdfs
|
|
|
|
native_mini_dfs
|
|
|
|
pthread
|
|
|
|
)
|
|
|
|
|
2012-09-10 09:43:28 -04:00
|
|
|
IF(REQUIRE_LIBWEBHDFS)
|
|
|
|
add_subdirectory(contrib/libwebhdfs)
|
|
|
|
ENDIF(REQUIRE_LIBWEBHDFS)
|
2012-07-16 12:42:53 -04:00
|
|
|
add_subdirectory(main/native/fuse-dfs)
|