Browse Source

CMake: make it possible to override include install location.

Needed so Gradle CMake on Android "just works".
pull/205/head
Vladimír Vondruš 8 years ago
parent
commit
fec9b4ea7e
  1. 12
      CMakeLists.txt
  2. 17
      doc/building.dox
  3. 3
      doc/cmake.dox
  4. 11
      modules/FindMagnum.cmake
  5. 1
      package/archlinux/PKGBUILD-android-arm64

12
CMakeLists.txt

@ -165,6 +165,8 @@ endif()
set(MAGNUM_DEPLOY_PREFIX "."
CACHE STRING "Prefix where to put final application executables")
set(MAGNUM_INCLUDE_INSTALL_PREFIX "."
CACHE STRING "Prefix where to put platform-independent include and other files")
option(BUILD_STATIC "Build static libraries (default are shared)" OFF)
option(BUILD_STATIC_PIC "Build static libraries and plugins with position-independent code" ON)
@ -270,11 +272,11 @@ endif()
include(${CORRADE_LIB_SUFFIX_MODULE})
set(MAGNUM_BINARY_INSTALL_DIR bin)
set(MAGNUM_LIBRARY_INSTALL_DIR lib${LIB_SUFFIX})
set(MAGNUM_DATA_INSTALL_DIR share/magnum)
set(MAGNUM_CMAKE_MODULE_INSTALL_DIR share/cmake/Magnum)
set(MAGNUM_INCLUDE_INSTALL_DIR include/Magnum)
set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR include/MagnumExternal)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR include/MagnumPlugins)
set(MAGNUM_DATA_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/share/magnum)
set(MAGNUM_CMAKE_MODULE_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/share/cmake/Magnum)
set(MAGNUM_INCLUDE_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/include/Magnum)
set(MAGNUM_EXTERNAL_INCLUDE_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/include/MagnumExternal)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/include/MagnumPlugins)
# Separate install dirs for debug and release plugins
set(MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_BINARY_INSTALL_DIR}/magnum-d)

17
doc/building.dox

@ -358,6 +358,13 @@ installed files. The following variables are supported:
are installed, so you can have libraries installed to a system location and
utilities to your webserver, for example. Defaults to ``.``. If a relative
path is used, it's relative to `CMAKE_INSTALL_PREFIX`.
- `MAGNUM_INCLUDE_INSTALL_PREFIX` --- Used on @ref CORRADE_TARGET_ANDROID "Android"
to override location where platform-independent include files, CMake
scripts and other files are installed. CMake on Android by default searches
for binaries in <tt>&lt;ndk&gt;/platforms/android-&lt;api&gt;/arch-&lt;arch&gt;/usr</tt>
based on target API and platform, but looks for headers in a central
location at <tt>&lt;ndk&gt;/sysroot/usr</tt>. Defaults to ``.``. If a
relative path is used, it's relative to `CMAKE_INSTALL_PREFIX`.
The library is constantly evolving and thus some APIs are deprecated and then
later removed in favor of better ones. To preserve backwards compatibility,
@ -834,8 +841,12 @@ use and `CMAKE_ANDROID_ARCH_ABI` to target platform ABI. Check the
for further information.
If you set `CMAKE_INSTALL_PREFIX` to `/usr` subdirectory of the particular
Android sysroot, the package will get found automatically when compiling
subprojects, otherwise you may need to explicitly set `CMAKE_PREFIX_PATH`.
Android platform sysroot, the package will get found automatically when
compiling subprojects. Gradle and other Android buildsystems expect
platform-independent includes and other files to be stored in a central
location, you can set `MAGNUM_INCLUDE_INSTALL_PREFIX` to `/usr` subdirectory of
the global NDK sysroot. Another option is to explicitly set `CMAKE_PREFIX_PATH`
to the install location in depending projects.
Note that `BUILD_STATIC` is implicitly enabled, because manually loading all
depending shared libraries using JNI would be too inconvenient. The engine is
@ -850,8 +861,8 @@ cmake .. \
-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang \
-DCMAKE_ANDROID_STL_TYPE=c++_static \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH=/opt/android-ndk/platforms/android-22/arch-arm/usr \
-DCMAKE_INSTALL_PREFIX=/opt/android-ndk/platforms/android-22/arch-arm/usr \
-DMAGNUM_INCLUDE_INSTALL_PREFIX=/opt/android-ndk/sysroot/usr \
-DTARGET_GLES2=OFF \
-DWITH_ANDROIDAPPLICATION=ON
cmake --build .

3
doc/cmake.dox

@ -62,6 +62,9 @@ This module tries to find base Magnum library and then defines:
- `MAGNUM_DEPLOY_PREFIX` --- Prefix where to put final application
executables, defaults to `.`. If a relative path is used, it's relative to
`CMAKE_INSTALL_PREFIX`.
- `MAGNUM_INCLUDE_INSTALL_PREFIX` --- Prefix where to put
platform-independent include and other files, defaults to `.`. If a
relative path is used, it's relative to `CMAKE_INSTALL_PREFIX`.
- `MAGNUM_PLUGINS_DEBUG_DIR` --- Base directory with dynamic plugins for debug
builds, defaults to `magnum-d/` subdirectory of dir where Magnum library
was found

11
modules/FindMagnum.cmake

@ -13,6 +13,9 @@
# MAGNUM_DEPLOY_PREFIX - Prefix where to put final application
# executables, defaults to ``.``. If a relative path is used, it's relative
# to :variable:`CMAKE_INSTALL_PREFIX`.
# MAGNUM_INCLUDE_INSTALL_PREFIX - Prefix where to put platform-independent
# include and other files, defaults to ``.``. If a relative path is used,
# it's relative to :variable:`CMAKE_INSTALL_PREFIX`.
# MAGNUM_PLUGINS_DEBUG_DIR - Base directory with dynamic plugins for
# debug builds, defaults to magnum-d/ subdirectory of dir where Magnum
# library was found
@ -787,11 +790,13 @@ endif()
# Installation and deploy dirs
set(MAGNUM_DEPLOY_PREFIX "."
CACHE STRING "Prefix where to put final application executables")
set(MAGNUM_INCLUDE_INSTALL_PREFIX "."
CACHE STRING "Prefix where to put platform-independent include and other files")
include(${CORRADE_LIB_SUFFIX_MODULE})
set(MAGNUM_BINARY_INSTALL_DIR bin)
set(MAGNUM_LIBRARY_INSTALL_DIR lib${LIB_SUFFIX})
set(MAGNUM_DATA_INSTALL_DIR share/magnum)
set(MAGNUM_DATA_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/share/magnum)
set(MAGNUM_PLUGINS_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_BINARY_INSTALL_DIR}/magnum-d)
set(MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_LIBRARY_INSTALL_DIR}/magnum-d)
set(MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_BINARY_INSTALL_DIR}/magnum)
@ -814,8 +819,8 @@ set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG
set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_DEBUG_LIBRARY_INSTALL_DIR}/audioimporters)
set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_BINARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_BINARY_INSTALL_DIR}/audioimporters)
set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_LIBRARY_INSTALL_DIR ${MAGNUM_PLUGINS_RELEASE_LIBRARY_INSTALL_DIR}/audioimporters)
set(MAGNUM_INCLUDE_INSTALL_DIR include/Magnum)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR include/MagnumPlugins)
set(MAGNUM_INCLUDE_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/include/Magnum)
set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/include/MagnumPlugins)
# Get base plugin directory from main library location. This is *not* PATH,
# because CMake always converts the path to an absolute location internally,

1
package/archlinux/PKGBUILD-android-arm64

@ -31,6 +31,7 @@ build() {
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/android-ndk/platforms/android-22/arch-arm64/usr \
-DMAGNUM_INCLUDE_INSTALL_PREFIX=/opt/android-ndk/sysroot/usr \
-DWITH_MAGNUMFONT=ON \
-DWITH_OBJIMPORTER=ON \
-DWITH_TGAIMAGECONVERTER=ON \

Loading…
Cancel
Save