diff --git a/CMakeLists.txt b/CMakeLists.txt index 2add83c5856782cc2819b88ff74a8b8503865a7c..8befc05b280693b8a539f7ccf676855abf69c73d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,10 @@ if(NOT DEFINED CMAKE_MACOSX_RPATH) set(CMAKE_MACOSX_RPATH 0) endif() +if(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_VERSION VERSION_LESS 3.7) + message(FATAL_ERROR "CMake 3.7 or above is required to build for Android") +endif() + project(VTK) if (NOT CMAKE_VERSION VERSION_LESS "3.1") @@ -152,20 +156,20 @@ if (ANDROID OR APPLE_IOS) CACHE STRING "Output from TRY_RUN" FORCE) # need int version for CPP - if (${OPENGL_ES_VERSION} MATCHES 2.0) + if (OPENGL_ES_VERSION STREQUAL "2.0") set(OPENGL_ES_VERSION_INT 20) endif() - if (${OPENGL_ES_VERSION} MATCHES 3.0) + if (OPENGL_ES_VERSION STREQUAL "3.0") set(OPENGL_ES_VERSION_INT 30) endif() if (APPLE_IOS) unset(OPENGL_INCLUDE_DIR CACHE) - if (${OPENGL_ES_VERSION} MATCHES 2.0) + if (OPENGL_ES_VERSION STREQUAL "2.0") find_path(OPENGL_INCLUDE_DIR ES2/gl.h ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenGLES.framework/Headers ${_OPENGL_INCLUDE_DIR}) - elseif (${OPENGL_ES_VERSION} MATCHES 3.0) + elseif (OPENGL_ES_VERSION STREQUAL "3.0") find_path(OPENGL_INCLUDE_DIR ES3/gl.h ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/OpenGLES.framework/Headers ${_OPENGL_INCLUDE_DIR}) @@ -181,36 +185,14 @@ if (ANDROID OR APPLE_IOS) unset(OPENGL_gl_LIBRARY CACHE) unset(OPENGL_egl_LIBRARY CACHE) - if (${OPENGL_ES_VERSION} MATCHES 2.0) - find_path(OPENGL_INCLUDE_DIR GLES2/gl2.h - ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include - ${_OPENGL_INCLUDE_PATH} - NO_DEFAULT_PATH - ) - find_library(OPENGL_gl_LIBRARY - NAMES GLESv2 - PATHS - ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/lib - ${_OPENGL_LIB_PATH} - ) - elseif (${OPENGL_ES_VERSION} MATCHES 3.0) - find_path(OPENGL_INCLUDE_DIR GLES3/gl3.h - ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include - ${_OPENGL_INCLUDE_PATH} - ) - find_library(OPENGL_gl_LIBRARY - NAMES GLESv3 - PATHS - ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/lib - ${_OPENGL_LIB_PATH} - ) + if (OPENGL_ES_VERSION STREQUAL "2.0") + find_path(OPENGL_INCLUDE_DIR GLES2/gl2.h) + find_library(OPENGL_gl_LIBRARY NAMES GLESv2) + elseif (OPENGL_ES_VERSION STREQUAL "3.0") + find_path(OPENGL_INCLUDE_DIR GLES3/gl3.h) + find_library(OPENGL_gl_LIBRARY NAMES GLESv3) endif() - find_library(OPENGL_egl_LIBRARY - NAMES EGL - PATHS - ${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/lib - ${_OPENGL_LIB_PATH} - ) + find_library(OPENGL_egl_LIBRARY NAMES EGL) endif() else() # Choose static or shared libraries. diff --git a/Common/Core/CMakeLists.txt b/Common/Core/CMakeLists.txt index 56c94624f9b859ee4cc53cedf778d1e75c3a3103..59a568a33634e05272d7e93ad964a143dac9a7b4 100644 --- a/Common/Core/CMakeLists.txt +++ b/Common/Core/CMakeLists.txt @@ -720,3 +720,7 @@ endif() vtk_module_library(vtkCommonCore ${Module_SRCS}) vtk_module_link_libraries(vtkCommonCore LINK_PRIVATE ${CMAKE_THREAD_LIBS} LINK_PUBLIC ${VTK_SMP_IMPLEMENTATION_LIBRARIES}) + +if(ANDROID) + target_link_libraries(vtkCommonCore LINK_PRIVATE log) +endif() diff --git a/Examples/Android/JavaVTK/CMakeLists.txt b/Examples/Android/JavaVTK/CMakeLists.txt index ab7f0d36627e304590df7eee00a4a0021ba31a95..9c83d0b92855b400964960d4f819bf9384549d13 100644 --- a/Examples/Android/JavaVTK/CMakeLists.txt +++ b/Examples/Android/JavaVTK/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.7) project(JavaVTK) if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) @@ -12,7 +12,7 @@ find_package(VTK COMPONENTS ) include(${VTK_USE_FILE}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_NDK_ABI_NAME}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}) message(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) add_subdirectory(jni) @@ -39,7 +39,7 @@ add_custom_target(JavaVTK-ant-configure ALL update project --name JavaVTK --path "${CMAKE_CURRENT_SOURCE_DIR}" - --target "android-${ANDROID_NATIVE_API_LEVEL}" + --target "android-${CMAKE_SYSTEM_VERSION}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/build.xml" "${CMAKE_CURRENT_BINARY_DIR}/build.xml" diff --git a/Examples/Android/JavaVTK/jni/CMakeLists.txt b/Examples/Android/JavaVTK/jni/CMakeLists.txt index 69ec8552ea7e88e2baab0f2bdb74d7077f681ae5..b4a27c5a6e94a069333df9f00e7de3e93bdf337b 100644 --- a/Examples/Android/JavaVTK/jni/CMakeLists.txt +++ b/Examples/Android/JavaVTK/jni/CMakeLists.txt @@ -1,7 +1,3 @@ -include_directories( - "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include" -) - set(sources main.cxx ) diff --git a/Examples/Android/NativeVTK/CMakeLists.txt b/Examples/Android/NativeVTK/CMakeLists.txt index 8451c39991639e6359606f7d998ca879bb4eb565..cc860206de2a222515c0193abcfc3871bd78977e 100644 --- a/Examples/Android/NativeVTK/CMakeLists.txt +++ b/Examples/Android/NativeVTK/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.7) project(NativeVTK) if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) @@ -14,7 +14,7 @@ find_package(VTK COMPONENTS ) include(${VTK_USE_FILE}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_NDK_ABI_NAME}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}) message(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) add_subdirectory(jni) @@ -41,7 +41,7 @@ add_custom_target(NativeVTK-ant-configure ALL update project --name NativeVTK --path "${CMAKE_CURRENT_SOURCE_DIR}" - --target "android-${ANDROID_NATIVE_API_LEVEL}" + --target "android-${CMAKE_SYSTEM_VERSION}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/build.xml" "${CMAKE_CURRENT_BINARY_DIR}/build.xml" diff --git a/Examples/Android/NativeVTK/jni/CMakeLists.txt b/Examples/Android/NativeVTK/jni/CMakeLists.txt index d2ce911306d9e5d15db7623975cc772808ed9c33..0e474d80e51e6ab5200c52df0a452fc096cdb67d 100644 --- a/Examples/Android/NativeVTK/jni/CMakeLists.txt +++ b/Examples/Android/NativeVTK/jni/CMakeLists.txt @@ -1,11 +1,10 @@ include_directories( - "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include" - "${ANDROID_NDK}/sources/android/native_app_glue" + "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue" ) set(sources main.cxx - ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c + ${CMAKE_ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c ) add_library(NativeVTK SHARED ${sources}) diff --git a/Examples/Android/VolumeRender/CMakeLists.txt b/Examples/Android/VolumeRender/CMakeLists.txt index c7ed58c561fd44401d0a096a3d44ed4462503706..6dba111e9c909e2ca2411ce42bc27830195b9694 100644 --- a/Examples/Android/VolumeRender/CMakeLists.txt +++ b/Examples/Android/VolumeRender/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.7) project(VolumeRender) if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) @@ -13,7 +13,7 @@ find_package(VTK COMPONENTS ) include(${VTK_USE_FILE}) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_NDK_ABI_NAME}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}) message(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) add_subdirectory(jni) @@ -40,7 +40,7 @@ add_custom_target(VolumeRender-ant-configure ALL update project --name VolumeRender --path "${CMAKE_CURRENT_SOURCE_DIR}" - --target "android-${ANDROID_NATIVE_API_LEVEL}" + --target "android-${CMAKE_SYSTEM_VERSION}" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/build.xml" "${CMAKE_CURRENT_BINARY_DIR}/build.xml" diff --git a/Examples/Android/VolumeRender/jni/CMakeLists.txt b/Examples/Android/VolumeRender/jni/CMakeLists.txt index 483c6386b1f8a0ba02abe59bec977385f4cb2ffa..75b07f67d6f3f0d7c987f230131d0c6739ea1371 100644 --- a/Examples/Android/VolumeRender/jni/CMakeLists.txt +++ b/Examples/Android/VolumeRender/jni/CMakeLists.txt @@ -1,7 +1,3 @@ -include_directories( - "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include" -) - set(sources main.cxx ) diff --git a/Rendering/OpenGL2/CMakeLists.txt b/Rendering/OpenGL2/CMakeLists.txt index 87e3d00a88b9d643901e04639abe2976937ab840..3494a01affe8012ede8ab77e5c995773515bf2f8 100644 --- a/Rendering/OpenGL2/CMakeLists.txt +++ b/Rendering/OpenGL2/CMakeLists.txt @@ -309,8 +309,7 @@ elseif(ANDROID) vtkEGLRenderWindow.cxx ) include_directories( - "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include" - "${ANDROID_NDK}/sources/android/native_app_glue" + "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue" ) elseif(APPLE_IOS) # Add some custom overrides @@ -360,7 +359,9 @@ endif() if(ANDROID) target_link_libraries(${vtk-module} - LINK_PUBLIC ${OPENGL_egl_LIBRARY}) + LINK_PUBLIC ${OPENGL_egl_LIBRARY} + LINK_PRIVATE android + ) endif() if (APPLE_IOS)