diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 5a4d8263a1..64b04ccc18 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -115,6 +115,9 @@ Trunk (Unreleased) MAPREDUCE-2632. Avoid calling the partitioner when the numReduceTasks is 1. (Ravi Teja Ch N V and Sunil G via kasha) + MAPREDUCE-6407. Migrate MAPREDUCE nativetask build to new CMake framework + (Alan Burlison via Colin P. McCabe) + BUG FIXES MAPREDUCE-6191. Improve clearing stale state of Java serialization diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/CMakeLists.txt b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/CMakeLists.txt index 80036e8d13..f878a949f0 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/CMakeLists.txt +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/CMakeLists.txt @@ -18,236 +18,170 @@ cmake_minimum_required(VERSION 2.6 FATAL_ERROR) -# Default to release builds -set(CMAKE_BUILD_TYPE, Release) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../../../hadoop-common-project/hadoop-common/) +include(HadoopCommon) -include(JNIFlags.cmake NO_POLICY_SCOPE) +# Add extra compiler and linker flags. +# -Wno-sign-compare +hadoop_add_compiler_flags("-DNDEBUG -DSIMPLE_MEMCPY -fno-strict-aliasing") -# 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) +# Source location. +set(SRC main/native) -# 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) +# 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() -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) +# Configure JNI. +include(HadoopJNI) -function(dual_output_directory TGT DIR) - output_directory(${TGT} "${DIR}") - output_directory(${TGT}_static "${DIR}") -endfunction(dual_output_directory TGT DIR) +# Probe for headers and functions. +include(CheckFunctionExists) +include(CheckIncludeFiles) -# -# This macro alters the behavior of find_package and find_library. -# It does this by setting the CMAKE_FIND_LIBRARY_SUFFIXES global variable. -# You should save that variable before calling this function and restore it -# after you have accomplished your goal. -# -# The behavior is altered in two ways: -# 1. We always find shared libraries, never static; -# 2. We find shared libraries with the given version number. -# -# On Windows this function is a no-op. Windows does not encode -# version number information information into library path names. -# -macro(set_find_shared_library_version LVERS) - IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - # Mac OS uses .dylib - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".${LVERS}.dylib") - ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") - # FreeBSD has always .so installed. - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so") - ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - # Windows doesn't support finding shared libraries by version. - ELSE() - # Most UNIX variants use .so - SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so.${LVERS}") - ENDIF() -endmacro(set_find_shared_library_version LVERS) +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) -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) - -SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES) -set_find_shared_library_version("1") -SET(CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES) - -# primitive configs -set(PRFLAGS "-DSIMPLE_MEMCPY") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PRFLAGS} -fno-strict-aliasing -Wall -Wno-sign-compare") -set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -no-undefined -version-info 0:1:0 - -L${_JAVA_HOME}/jre/lib/amd64/server -ljvm") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -g -O2 -DNDEBUG -fPIC") -set(D main/native/) - -SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES) -set_find_shared_library_version("1") -SET(CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES) - -INCLUDE(CheckFunctionExists) -INCLUDE(CheckCSourceCompiles) -#INCLUDE(CheckLibraryExists) -INCLUDE(CheckIncludeFiles) -#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) -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) - -SET(STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES) -set_find_shared_library_version("1") +# Require snappy. +set(STORED_CMAKE_FIND_LIBRARY_SUFFIXES CMAKE_FIND_LIBRARY_SUFFIXES) +hadoop_set_find_shared_library_version("1") find_library(SNAPPY_LIBRARY NAMES snappy PATHS ${CUSTOM_SNAPPY_PREFIX} ${CUSTOM_SNAPPY_PREFIX}/lib ${CUSTOM_SNAPPY_PREFIX}/lib64 ${CUSTOM_SNAPPY_LIB}) -SET(CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES) +set(CMAKE_FIND_LIBRARY_SUFFIXES STORED_CMAKE_FIND_LIBRARY_SUFFIXES) find_path(SNAPPY_INCLUDE_DIR NAMES snappy.h PATHS ${CUSTOM_SNAPPY_PREFIX} ${CUSTOM_SNAPPY_PREFIX}/include ${CUSTOM_SNAPPY_INCLUDE}) -if (SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR) +if(SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR) GET_FILENAME_COMPONENT(HADOOP_SNAPPY_LIBRARY ${SNAPPY_LIBRARY} NAME) set(SNAPPY_SOURCE_FILES - "${D}/src/codec/SnappyCodec.cc") -else (SNAPPY_LIBRARY AND SNAPPY_INCLUDE_DIR) + "${SRC}/src/codec/SnappyCodec.cc") + set(REQUIRE_SNAPPY ${REQUIRE_SNAPPY}) # Stop warning about unused variable. + message(STATUS "Found Snappy: ${SNAPPY_LIBRARY}") +else() set(SNAPPY_LIBRARY "") set(SNAPPY_INCLUDE_DIR "") set(SNAPPY_SOURCE_FILES "") - 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) + 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() -CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h) +configure_file(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h) include_directories( ${GENERATED_JAVAH} - ${D}/src - ${D}/src/util - ${D}/src/lib - ${D}/test + ${SRC}/src + ${SRC}/src/util + ${SRC}/src/lib + ${SRC}/test ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${JNI_INCLUDE_DIRS} ${SNAPPY_INCLUDE_DIR} ) # add gtest as system library to suppress gcc warnings -include_directories(SYSTEM ${D}/gtest/include) +include_directories(SYSTEM ${SRC}/gtest/include) +set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) - -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +if(CMAKE_SYSTEM_NAME MATCHES "Darwin") # macosx does not have -lrt set(NT_DEPEND_LIBRARY dl pthread z ${SNAPPY_LIBRARY} ${JAVA_JVM_LIBRARY}) set(SYSTEM_MAC TRUE) -else (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +else() set(NT_DEPEND_LIBRARY dl rt pthread z ${SNAPPY_LIBRARY} ${JAVA_JVM_LIBRARY}) set(SYSTEM_MAC FALSE) -endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +endif() configure_file(main/native/test.sh test/test.sh) -add_dual_library(nativetask +hadoop_add_dual_library(nativetask ${CMAKE_BINARY_DIR}/lz4.c - ${D}/src/codec/BlockCodec.cc - ${D}/src/codec/GzipCodec.cc - ${D}/src/codec/Lz4Codec.cc + ${SRC}/src/codec/BlockCodec.cc + ${SRC}/src/codec/GzipCodec.cc + ${SRC}/src/codec/Lz4Codec.cc ${SNAPPY_SOURCE_FILES} - ${D}/src/handler/BatchHandler.cc - ${D}/src/handler/MCollectorOutputHandler.cc - ${D}/src/handler/AbstractMapHandler.cc - ${D}/src/handler/CombineHandler.cc - ${D}/src/lib/Buffers.cc - ${D}/src/lib/BufferStream.cc - ${D}/src/lib/Compressions.cc - ${D}/src/lib/PartitionBucket.cc - ${D}/src/lib/PartitionBucketIterator.cc - ${D}/src/lib/FileSystem.cc - ${D}/src/lib/IFile.cc - ${D}/src/lib/jniutils.cc - ${D}/src/lib/Log.cc - ${D}/src/lib/MapOutputCollector.cc - ${D}/src/lib/MapOutputSpec.cc - ${D}/src/lib/MemoryBlock.cc - ${D}/src/lib/Merge.cc - ${D}/src/lib/NativeLibrary.cc - ${D}/src/lib/Iterator.cc - ${D}/src/lib/NativeObjectFactory.cc - ${D}/src/lib/NativeRuntimeJniImpl.cc - ${D}/src/lib/NativeTask.cc - ${D}/src/lib/SpillInfo.cc - ${D}/src/lib/Path.cc - ${D}/src/lib/Streams.cc - ${D}/src/lib/TaskCounters.cc - ${D}/src/util/Checksum.cc - ${D}/src/util/Random.cc - ${D}/src/util/StringUtil.cc - ${D}/src/util/SyncUtils.cc - ${D}/src/util/Timer.cc - ${D}/src/util/WritableUtils.cc + ${SRC}/src/handler/BatchHandler.cc + ${SRC}/src/handler/MCollectorOutputHandler.cc + ${SRC}/src/handler/AbstractMapHandler.cc + ${SRC}/src/handler/CombineHandler.cc + ${SRC}/src/lib/Buffers.cc + ${SRC}/src/lib/BufferStream.cc + ${SRC}/src/lib/Compressions.cc + ${SRC}/src/lib/PartitionBucket.cc + ${SRC}/src/lib/PartitionBucketIterator.cc + ${SRC}/src/lib/FileSystem.cc + ${SRC}/src/lib/IFile.cc + ${SRC}/src/lib/jniutils.cc + ${SRC}/src/lib/Log.cc + ${SRC}/src/lib/MapOutputCollector.cc + ${SRC}/src/lib/MapOutputSpec.cc + ${SRC}/src/lib/MemoryBlock.cc + ${SRC}/src/lib/Merge.cc + ${SRC}/src/lib/NativeLibrary.cc + ${SRC}/src/lib/Iterator.cc + ${SRC}/src/lib/NativeObjectFactory.cc + ${SRC}/src/lib/NativeRuntimeJniImpl.cc + ${SRC}/src/lib/NativeTask.cc + ${SRC}/src/lib/SpillInfo.cc + ${SRC}/src/lib/Path.cc + ${SRC}/src/lib/Streams.cc + ${SRC}/src/lib/TaskCounters.cc + ${SRC}/src/util/Checksum.cc + ${SRC}/src/util/Random.cc + ${SRC}/src/util/StringUtil.cc + ${SRC}/src/util/SyncUtils.cc + ${SRC}/src/util/Timer.cc + ${SRC}/src/util/WritableUtils.cc ) target_link_libraries(nativetask ${NT_DEPEND_LIBRARY}) -add_library(gtest ${D}/gtest/gtest-all.cc) +add_library(gtest ${SRC}/gtest/gtest-all.cc) set_target_properties(gtest PROPERTIES COMPILE_FLAGS "-w") add_executable(nttest - ${D}/test/lib/TestByteArray.cc - ${D}/test/lib/TestByteBuffer.cc - ${D}/test/lib/TestComparatorForDualPivotQuickSort.cc - ${D}/test/lib/TestComparatorForStdSort.cc - ${D}/test/lib/TestFixSizeContainer.cc - ${D}/test/lib/TestMemoryPool.cc - ${D}/test/lib/TestIterator.cc - ${D}/test/lib/TestKVBuffer.cc - ${D}/test/lib/TestMemBlockIterator.cc - ${D}/test/lib/TestMemoryBlock.cc - ${D}/test/lib/TestPartitionBucket.cc - ${D}/test/lib/TestReadBuffer.cc - ${D}/test/lib/TestReadWriteBuffer.cc - ${D}/test/util/TestChecksum.cc - ${D}/test/util/TestStringUtil.cc - ${D}/test/util/TestWritableUtils.cc - ${D}/test/TestCommand.cc - ${D}/test/TestConfig.cc - ${D}/test/TestCounter.cc - ${D}/test/TestCompressions.cc - ${D}/test/TestFileSystem.cc - ${D}/test/TestIFile.cc - ${D}/test/TestPrimitives.cc - ${D}/test/TestSort.cc - ${D}/test/TestMain.cc - ${D}/test/test_commons.cc) - + ${SRC}/test/lib/TestByteArray.cc + ${SRC}/test/lib/TestByteBuffer.cc + ${SRC}/test/lib/TestComparatorForDualPivotQuickSort.cc + ${SRC}/test/lib/TestComparatorForStdSort.cc + ${SRC}/test/lib/TestFixSizeContainer.cc + ${SRC}/test/lib/TestMemoryPool.cc + ${SRC}/test/lib/TestIterator.cc + ${SRC}/test/lib/TestKVBuffer.cc + ${SRC}/test/lib/TestMemBlockIterator.cc + ${SRC}/test/lib/TestMemoryBlock.cc + ${SRC}/test/lib/TestPartitionBucket.cc + ${SRC}/test/lib/TestReadBuffer.cc + ${SRC}/test/lib/TestReadWriteBuffer.cc + ${SRC}/test/util/TestChecksum.cc + ${SRC}/test/util/TestStringUtil.cc + ${SRC}/test/util/TestWritableUtils.cc + ${SRC}/test/TestCommand.cc + ${SRC}/test/TestConfig.cc + ${SRC}/test/TestCounter.cc + ${SRC}/test/TestCompressions.cc + ${SRC}/test/TestFileSystem.cc + ${SRC}/test/TestIFile.cc + ${SRC}/test/TestPrimitives.cc + ${SRC}/test/TestSort.cc + ${SRC}/test/TestMain.cc + ${SRC}/test/test_commons.cc) target_link_libraries(nttest nativetask_static @@ -255,17 +189,14 @@ target_link_libraries(nttest ${NT_DEPEND_LIBRARY} ) -IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - # - # 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. - # - SET_TARGET_PROPERTIES(nativetask - PROPERTIES INSTALL_RPATH "\$ORIGIN/") -ENDIF() +# 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}) -dual_output_directory(nativetask target/usr/local/lib) -output_directory(nttest test) +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) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/JNIFlags.cmake b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/JNIFlags.cmake deleted file mode 100644 index 0100b06312..0000000000 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/JNIFlags.cmake +++ /dev/null @@ -1,118 +0,0 @@ -# -# 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) - -# If JVM_ARCH_DATA_MODEL is 32, compile all binaries as 32-bit. -# This variable is set by maven. -if (JVM_ARCH_DATA_MODEL EQUAL 32) - # Force 32-bit code generation on amd64/x86_64, ppc64, sparc64 - if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_SYSTEM_PROCESSOR MATCHES ".*64") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -m32") - endif () - if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") - # Set CMAKE_SYSTEM_PROCESSOR to ensure that find_package(JNI) will use - # the 32-bit version of libjvm.so. - set(CMAKE_SYSTEM_PROCESSOR "i686") - endif () -endif (JVM_ARCH_DATA_MODEL EQUAL 32) - -# Determine float ABI of JVM on ARM Linux -if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") - find_program(READELF readelf) - if (READELF MATCHES "NOTFOUND") - message(WARNING "readelf not found; JVM float ABI detection disabled") - else (READELF MATCHES "NOTFOUND") - execute_process( - COMMAND ${READELF} -A ${JAVA_JVM_LIBRARY} - OUTPUT_VARIABLE JVM_ELF_ARCH - ERROR_QUIET) - if (NOT JVM_ELF_ARCH MATCHES "Tag_ABI_VFP_args: VFP registers") - message("Soft-float JVM detected") - - # Test compilation with -mfloat-abi=softfp using an arbitrary libc function - # (typically fails with "fatal error: bits/predefs.h: No such file or directory" - # if soft-float dev libraries are not installed) - include(CMakePushCheckState) - cmake_push_check_state() - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mfloat-abi=softfp") - include(CheckSymbolExists) - check_symbol_exists(exit stdlib.h SOFTFP_AVAILABLE) - if (NOT SOFTFP_AVAILABLE) - message(FATAL_ERROR "Soft-float dev libraries required (e.g. 'apt-get install libc6-dev-armel' on Debian/Ubuntu)") - endif (NOT SOFTFP_AVAILABLE) - cmake_pop_check_state() - - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=softfp") - endif () - endif (READELF MATCHES "NOTFOUND") -endif (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND CMAKE_SYSTEM_NAME STREQUAL "Linux") - -IF("${CMAKE_SYSTEM}" MATCHES "Linux") - # - # Locate JNI_INCLUDE_DIRS and JNI_LIBRARIES. - # Since we were invoked from Maven, we know that the JAVA_HOME environment - # variable is valid. So we ignore system paths here and just use JAVA_HOME. - # - FILE(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _JAVA_HOME) - IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") - SET(_java_libarch "i386") - ELSEIF (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") - SET(_java_libarch "amd64") - ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") - SET(_java_libarch "arm") - ELSE() - SET(_java_libarch ${CMAKE_SYSTEM_PROCESSOR}) - ENDIF() - SET(_JDK_DIRS "${_JAVA_HOME}/jre/lib/${_java_libarch}/*" - "${_JAVA_HOME}/jre/lib/${_java_libarch}" - "${_JAVA_HOME}/jre/lib/*" - "${_JAVA_HOME}/jre/lib" - "${_JAVA_HOME}/lib/*" - "${_JAVA_HOME}/lib" - "${_JAVA_HOME}/include/*" - "${_JAVA_HOME}/include" - "${_JAVA_HOME}" - ) - FIND_PATH(JAVA_INCLUDE_PATH - NAMES jni.h - PATHS ${_JDK_DIRS} - NO_DEFAULT_PATH) - #In IBM java, it's jniport.h instead of jni_md.h - FIND_PATH(JAVA_INCLUDE_PATH2 - NAMES jni_md.h jniport.h - PATHS ${_JDK_DIRS} - NO_DEFAULT_PATH) - SET(JNI_INCLUDE_DIRS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2}) - FIND_LIBRARY(JAVA_JVM_LIBRARY - NAMES rt jvm - PATHS ${_JDK_DIRS} - NO_DEFAULT_PATH) - SET(JNI_LIBRARIES ${JAVA_JVM_LIBRARY}) - MESSAGE("JAVA_HOME=${JAVA_HOME}, JAVA_JVM_LIBRARY=${JAVA_JVM_LIBRARY}") - MESSAGE("JAVA_INCLUDE_PATH=${JAVA_INCLUDE_PATH}, JAVA_INCLUDE_PATH2=${JAVA_INCLUDE_PATH2}") - IF(JAVA_JVM_LIBRARY AND JAVA_INCLUDE_PATH AND JAVA_INCLUDE_PATH2) - MESSAGE("Located all JNI components successfully.") - ELSE() - MESSAGE(FATAL_ERROR "Failed to find a viable JVM installation under JAVA_HOME.") - ENDIF() -ELSE() - find_package(JNI REQUIRED) -ENDIF()