Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible cmake build implementation #199

Open
mgood7123 opened this issue Jul 2, 2020 · 1 comment
Open

possible cmake build implementation #199

mgood7123 opened this issue Jul 2, 2020 · 1 comment

Comments

@mgood7123
Copy link

mgood7123 commented Jul 2, 2020

something like this would work

# this exports two variables, BOOST_INCLUDE, and BOOST_LIBRARY
add_subdirectory(Boost-for-Android)
include_directories(${BOOST_INCLUDE})

add_library(GLIS STATIC shm.cpp ashmem.cpp)

# link with BOOST
target_link_libraries(GLIS log freetype glm EGL GLESv3 WinKernel ${BOOST_LIBRARY})
cmake_minimum_required(VERSION 3.4.1)

project(BOOST_FOR_ANDROID)

set(BOOST_VERSION 1_73)
set(BOOST_LIBRARY BOOST-FOR-ANDROID PARENT_SCOPE)
set(BOOST_LIBRARY BOOST-FOR-ANDROID)

# for libraries, boost uses a mapping sequence: <compiler>-<threadType>-<architecture>-<version>
set(BOOST_MAPPING_COMPONENT_COMPILER clang)
set(BOOST_MAPPING_COMPONENT_THREAD_TYPE mt)
set(BOOST_MAPPING_COMPONENT_VERSION ${BOOST_VERSION})

# boost mappings do not follow the CMAKE ABI
if(CMAKE_ANDROID_ARCH_ABI STREQUAL armeabi-v7a)
    set(BOOST_MAPPING_COMPONENT_ARCHITECTURE a32)
elseif(CMAKE_ANDROID_ARCH_ABI STREQUAL arm64-v8a)
    set(BOOST_MAPPING_COMPONENT_ARCHITECTURE a64)
elseif(CMAKE_ANDROID_ARCH_ABI STREQUAL x86)
    set(BOOST_MAPPING_COMPONENT_ARCHITECTURE x32)
else()
    set(BOOST_MAPPING_COMPONENT_ARCHITECTURE x64)
endif()

set(BOOST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build/out/${CMAKE_ANDROID_ARCH_ABI})
set(BOOST_INCLUDE ${BOOST_DIR}/include/boost-${BOOST_VERSION} PARENT_SCOPE)
set(BOOST_LIBS ${BOOST_DIR}/lib)
set(BOOST_LIBS_PREFIX ${BOOST_LIBS}/libboost_)

set(BMCC ${BOOST_MAPPING_COMPONENT_COMPILER})
set(BMCTT ${BOOST_MAPPING_COMPONENT_THREAD_TYPE})
set(BMCA ${BOOST_MAPPING_COMPONENT_ARCHITECTURE})
set(BMCV ${BOOST_MAPPING_COMPONENT_VERSION})
set(BOOST_MAPPING ${BMCC}-${BMCTT}-${BMCA}-${BMCV})

add_library(BOOST_ATOMIC STATIC IMPORTED)
set_target_properties(
        BOOST_ATOMIC PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}atomic-${BOOST_MAPPING}.a
)

add_library(BOOST_CHRONO STATIC IMPORTED)
set_target_properties(
        BOOST_CHRONO PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}chrono-${BOOST_MAPPING}.a
)

add_library(BOOST_CONTAINER STATIC IMPORTED)
set_target_properties(
        BOOST_CONTAINER PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}container-${BOOST_MAPPING}.a
)

add_library(BOOST_CONTEXT STATIC IMPORTED)
set_target_properties(
        BOOST_CONTEXT PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}context-${BOOST_MAPPING}.a
)

add_library(BOOST_CONTRACT STATIC IMPORTED)
set_target_properties(
        BOOST_CONTRACT PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}contract-${BOOST_MAPPING}.a
)

add_library(BOOST_COROUTINE STATIC IMPORTED)
set_target_properties(
        BOOST_COROUTINE PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}coroutine-${BOOST_MAPPING}.a
)

add_library(BOOST_DATE_TIME STATIC IMPORTED)
set_target_properties(
        BOOST_DATE_TIME PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}date_time-${BOOST_MAPPING}.a
)

add_library(BOOST_EXCEPTION STATIC IMPORTED)
set_target_properties(
        BOOST_EXCEPTION PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}exception-${BOOST_MAPPING}.a
)

add_library(BOOST_FIBER STATIC IMPORTED)
set_target_properties(
        BOOST_FIBER PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}fiber-${BOOST_MAPPING}.a
)

add_library(BOOST_FILESYSTEM STATIC IMPORTED)
set_target_properties(
        BOOST_FILESYSTEM PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}filesystem-${BOOST_MAPPING}.a
)

add_library(BOOST_GRAPH STATIC IMPORTED)
set_target_properties(
        BOOST_GRAPH PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}graph-${BOOST_MAPPING}.a
)

add_library(BOOST_IOSTREAMS STATIC IMPORTED)
set_target_properties(
        BOOST_IOSTREAMS PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}iostreams-${BOOST_MAPPING}.a
)

add_library(BOOST_LOG STATIC IMPORTED)
set_target_properties(
        BOOST_LOG PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}log-${BOOST_MAPPING}.a
)

add_library(BOOST_LOG_SETUP STATIC IMPORTED)
set_target_properties(
        BOOST_LOG_SETUP PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}log_setup-${BOOST_MAPPING}.a
)

add_library(BOOST_MATH_C99 STATIC IMPORTED)
set_target_properties(
        BOOST_MATH_C99 PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}math_c99-${BOOST_MAPPING}.a
)

add_library(BOOST_MATH_C99F STATIC IMPORTED)
set_target_properties(
        BOOST_MATH_C99F PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}math_c99f-${BOOST_MAPPING}.a
)

add_library(BOOST_MATH_C99L STATIC IMPORTED)
set_target_properties(
        BOOST_MATH_C99L PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}math_c99l-${BOOST_MAPPING}.a
)

add_library(BOOST_MATH_TR1 STATIC IMPORTED)
set_target_properties(
        BOOST_MATH_TR1 PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}math_tr1-${BOOST_MAPPING}.a
)

add_library(BOOST_MATH_TR1F STATIC IMPORTED)
set_target_properties(
        BOOST_MATH_TR1F PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}math_tr1f-${BOOST_MAPPING}.a
)

add_library(BOOST_MATH_TR1L STATIC IMPORTED)
set_target_properties(
        BOOST_MATH_TR1L PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}math_tr1l-${BOOST_MAPPING}.a
)

add_library(BOOST_NOWIDE STATIC IMPORTED)
set_target_properties(
        BOOST_NOWIDE PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}nowide-${BOOST_MAPPING}.a
)

add_library(BOOST_PRG_EXEC_MONITOR STATIC IMPORTED)
set_target_properties(
        BOOST_PRG_EXEC_MONITOR PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}prg_exec_monitor-${BOOST_MAPPING}.a
)

add_library(BOOST_PROGRAM_OPTIONS STATIC IMPORTED)
set_target_properties(
        BOOST_PROGRAM_OPTIONS PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}program_options-${BOOST_MAPPING}.a
)

add_library(BOOST_RANDOM STATIC IMPORTED)
set_target_properties(
        BOOST_RANDOM PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}random-${BOOST_MAPPING}.a
)

add_library(BOOST_REGEX STATIC IMPORTED)
set_target_properties(
        BOOST_REGEX PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}regex-${BOOST_MAPPING}.a
)

add_library(BOOST_SERIALIZATION STATIC IMPORTED)
set_target_properties(
        BOOST_SERIALIZATION PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}serialization-${BOOST_MAPPING}.a
)

add_library(BOOST_STACKTRACE_BASIC STATIC IMPORTED)
set_target_properties(
        BOOST_STACKTRACE_BASIC PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}stacktrace_basic-${BOOST_MAPPING}.a
)

add_library(BOOST_STACKTRACE_NOOP STATIC IMPORTED)
set_target_properties(
        BOOST_STACKTRACE_NOOP PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}stacktrace_noop-${BOOST_MAPPING}.a
)

add_library(BOOST_SYSTEM STATIC IMPORTED)
set_target_properties(
        BOOST_SYSTEM PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}system-${BOOST_MAPPING}.a
)

add_library(BOOST_TEST_EXEC_MONITOR STATIC IMPORTED)
set_target_properties(
        BOOST_TEST_EXEC_MONITOR PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}test_exec_monitor-${BOOST_MAPPING}.a
)

add_library(BOOST_THREAD STATIC IMPORTED)
set_target_properties(
        BOOST_THREAD PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}thread-${BOOST_MAPPING}.a
)

add_library(BOOST_TIMER STATIC IMPORTED)
set_target_properties(
        BOOST_TIMER PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}timer-${BOOST_MAPPING}.a
)

add_library(BOOST_TYPE_ERASURE STATIC IMPORTED)
set_target_properties(
        BOOST_TYPE_ERASURE PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}type_erasure-${BOOST_MAPPING}.a
)

add_library(BOOST_UNIT_TEST_FRAMEWORK STATIC IMPORTED)
set_target_properties(
        BOOST_UNIT_TEST_FRAMEWORK PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}unit_test_framework-${BOOST_MAPPING}.a
)

add_library(BOOST_WAVE STATIC IMPORTED)
set_target_properties(
        BOOST_WAVE PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}wave-${BOOST_MAPPING}.a
)

add_library(BOOST_WSERIALIZATION STATIC IMPORTED)
set_target_properties(
        BOOST_WSERIALIZATION PROPERTIES IMPORTED_LOCATION
        ${BOOST_LIBS_PREFIX}wserialization-${BOOST_MAPPING}.a
)

# supply an empty C++ file in order to get library to compile

add_library (${BOOST_LIBRARY} STATIC boost-dummy.cpp)
target_link_libraries (
        ${BOOST_LIBRARY}

        # static libraries
        BOOST_ATOMIC
        BOOST_CHRONO
        BOOST_CONTAINER
        BOOST_CONTEXT
        BOOST_CONTRACT
        BOOST_COROUTINE
        BOOST_DATE_TIME
        BOOST_EXCEPTION
        BOOST_FIBER
        BOOST_FILESYSTEM
        BOOST_GRAPH
        BOOST_IOSTREAMS
        BOOST_LOG
        BOOST_LOG_SETUP
        BOOST_MATH_C99
        BOOST_MATH_C99F
        BOOST_MATH_C99L
        BOOST_MATH_TR1
        BOOST_MATH_TR1F
        BOOST_MATH_TR1L
        BOOST_NOWIDE
        BOOST_PRG_EXEC_MONITOR
        BOOST_PROGRAM_OPTIONS
        BOOST_RANDOM
        BOOST_REGEX
        BOOST_SERIALIZATION
        BOOST_STACKTRACE_BASIC
        BOOST_STACKTRACE_NOOP
        BOOST_SYSTEM
        BOOST_TEST_EXEC_MONITOR
        BOOST_THREAD
        BOOST_TIMER
        BOOST_TYPE_ERASURE
        BOOST_UNIT_TEST_FRAMEWORK
        BOOST_WAVE
        BOOST_WSERIALIZATION
)
@mgood7123 mgood7123 changed the title multiple build architectures including into a project with multiple build architectures Jul 2, 2020
@mgood7123 mgood7123 changed the title including into a project with multiple build architectures possible cmake build implementation Jul 4, 2020
@mgood7123 mgood7123 mentioned this issue Jul 4, 2020
@AhmedX6
Copy link

AhmedX6 commented May 19, 2022

Hello everyone,

Is it possible to have a documentation how to integrate boost on Android for JNI CMake based Project ??
This is so needed !

Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants