[CMake] Generator for Android.mk
Doug
douglas.linder at gmail.com
Tue Aug 14 22:53:15 EDT 2012
No.
...but you can do it manually, like:
cmake/Android.mk.in:
LOCAL_PATH :=
include $(CLEAR_VARS)
# Build include list
LOCAL_C_INCLUDES := @PROJECT_ANDROID_INCLUDES@
# Build source list
LOCAL_SRC_FILES := @PROJECT_ANDROID_SOURCES@
# Flags
LOCAL_CFLAGS := -std=c99
# Build library
LOCAL_MODULE := liblua
include $(BUILD_SHARED_LIBRARY)
CMakeLists.txt:
cmake_minimum_required (VERSION 2.8)
project(lua)
# Config
set(SOURCE_PATH "${PROJECT_SOURCE_DIR}/lua-5.2.1")
# Source and includes
file(GLOB PROJECT_SOURCES "${SOURCE_PATH}/src/*.c")
set(PROJECT_INCLUDE_DIRS "${SOURCE_PATH}/src")
# Win32 config
if(WIN32)
add_definitions( "-DLUA_API=__declspec(dllexport)" )
endif(WIN32)
# Build library
include_directories(${PROJECT_INCLUDE_DIRS})
add_library(lua SHARED ${PROJECT_SOURCES})
target_link_libraries(lua m)
# Build android library
option(BUILD_ANDROID "Build android library" OFF)
set(PROJECT_ANDROID_LIBRARIES "")
if(BUILD_ANDROID)
find_program(NDK_BUILD NAMES ndk_build)
foreach(INC ${PROJECT_INCLUDE_DIRS})
set(PROJECT_ANDROID_INCLUDES "${PROJECT_ANDROID_INCLUDES} \\\n ${INC}")
endforeach()
foreach(SRC ${PROJECT_SOURCES})
set(PROJECT_ANDROID_SOURCES "${PROJECT_ANDROID_SOURCES} \\\n ${SRC}")
endforeach()
file(COPY ${PROJECT_SOURCE_DIR}/android/Application.mk DESTINATION
${PROJECT_BINARY_DIR}/android/jni)
configure_file(${PROJECT_SOURCE_DIR}/android/Android.mk.in
${PROJECT_BINARY_DIR}/android/jni/Android.mk @ONLY)
add_custom_command(TARGET lua POST_BUILD COMMAND ${NDK_BUILD}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/android COMMENT "Building
android...")
set(PROJECT_ANDROID_LIBRARIES
"${PROJECT_BINARY_DIR}/android/libs/armeabi/liblua.so")
endif()
# Export libraries
set(PROJECT_LIBRARIES lua;m)
set(PROJECT_NAME "LUA")
CONFIGURE_FILE(luaConfig.cmake.in "${PROJECT_BINARY_DIR}/luaConfig.cmake")
If you do it often I recommend creating a function for it.
You could conceivably have some function that takes a valid cmake
build and automatically generates these files... but I suspect you'd
hit a lot of edge cases (try compiling openssl using cmake! -> it's a
pain), especially if you're using something ported from automake.
Cheers,
Doug.
On Tue, Aug 14, 2012 at 9:02 PM, John Barnum <John.Barnum at sas.com> wrote:
> I understand that you can build Android with make files and the
> standalone-toolchain (still in beta), but is there a generator that produces
> Android.mk files using the syntax in the NDK specification?
>
>
>
> Thanks,
>
>
>
> John
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list