1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
cmake_minimum_required (VERSION 2.8)
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)
include(${CMAKE_CURRENT_SOURCE_DIR}/Modules/CMakeUtilityFunctions.cmake)
project (AdiosJava CXX Java)
include_directories (${CMAKE_CURRENT_BINARY_DIR})
find_package (Java REQUIRED)
include_directories (${JNI_INCLUDE_DIRS})
find_package (JNI REQUIRED)
include_directories (${JNI_INCLUDE_DIRS})
option (ADIOS_USE_MPI "Use parallel ADIOS" ON)
find_package (ADIOS REQUIRED)
add_definitions (${ADIOS_COMPILE_FLAGS})
add_definitions (-DADIOS_USE_READ_API_1)
include_directories (${ADIOS_INCLUDE_PATH})
if (ADIOS_USE_MPI)
find_package (MPI REQUIRED)
include_directories (${MPI_CXX_INCLUDE_PATH})
add_definitions (-DADIOS_USE_MPI)
else ()
find_package (MPI REQUIRED)
endif()
set (SRC
gov_ornl_ccs_AdiosDatatype.cxx
gov_ornl_ccs_AdiosFlag.cxx
gov_ornl_ccs_AdiosStatisticsFlag.cxx
gov_ornl_ccs_AdiosBufferAllocWhen.cxx
gov_ornl_ccs_Adios.cxx
gov_ornl_ccs_AdiosFile.cxx
gov_ornl_ccs_AdiosGroup.cxx
gov_ornl_ccs_AdiosVarinfo.cxx
)
foreach (FILE ${SRC})
string (REGEX REPLACE ".cxx" ".h" FILE ${FILE})
list (APPEND HEADERS ${FILE})
endforeach ()
add_library (AdiosJava SHARED
${HEADERS}
${SRC}
)
set (CMAKE_JNI_TARGET TRUE)
set (CMAKE_JAVA_TARGET_VERSION 1.2.0)
target_link_libraries (AdiosJava
${ADIOS_LIBRARIES}
${MPI_CXX_LIBRARIES}
)
foreach (FILE ${HEADERS})
string (REGEX REPLACE "_" "/" JAVA_FILE ${FILE})
string (REGEX REPLACE "\\.h" ".java" JAVA_FILE ${JAVA_FILE})
string (REGEX REPLACE "_" "." JAVA_OBJ ${FILE})
string (REGEX REPLACE "\\.h" "" JAVA_OBJ ${JAVA_OBJ})
add_custom_command (
OUTPUT ${FILE}
COMMAND ${Java_JAVAC_EXECUTABLE} -d ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${JAVA_FILE}
COMMAND ${Java_JAVAH_EXECUTABLE} -jni -d ${CMAKE_CURRENT_BINARY_DIR} ${JAVA_OBJ}
DEPENDS ${JAVA_FILE} ${PREV}
)
list (APPEND PREV ${FILE})
endforeach ()
foreach (FILE ${SRC})
string (REGEX REPLACE "_" "/" FILE ${FILE})
string (REGEX REPLACE "\\.cxx" ".java" FILE ${FILE})
list (APPEND JAVA_SRC ${FILE})
endforeach ()
add_custom_command (TARGET AdiosJava
POST_BUILD
COMMAND cmake -E echo "Creating jar file..."
COMMAND jar cvf AdiosJava.jar gov
)
install (TARGETS AdiosJava
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/AdiosJava.jar DESTINATION lib)
ENABLE_TESTING()
add_test (test1 ${CMAKE_CURRENT_SOURCE_DIR}/test/test1.sh ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/test AdiosTest)
add_test (test2 ${CMAKE_CURRENT_SOURCE_DIR}/test/test2.sh ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/test AdiosNoxmlTest)
|