I am trying to build OpenAL with the Android NDK. The license requires that the library be dynamically loaded. I receive the following message when attempting to build:
CMake Warning (dev) at CMakeLists.txt:1032 (ADD_LIBRARY):
ADD_LIBRARY called with SHARED option but the target platform does not
support dynamic linking. Building a STATIC library instead. This may lead
to problems.
My toolchain file includes SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS true)
and looks like this:
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_C_COMPILER "${HOST}-gcc")
SET(CMAKE_CXX_COMPILER "${HOST}-g++")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
set(ENV{PKG_CONFIG_PATH} "")
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS true)
I create a build
directory in the source and invoke cmake with the following:
cmake .. -DALSOFT_BACKEND_WAVE=0 -DALSOFT_REQUIRE_OPENSL=1 -DALSOFT_NO_CONFIG_UTIL=1 -DALSOFT_EXAMPLES=0 -DALSOFT_UTILS=0 -DALSOFT_CONFIG=0 -DCMAKE_INSTALL_PREFIX=$ANDROID_DEV/opt -DCMAKE_INSTALL_RPATH=$ANDROID_DEV/opt -DHOST= -DCMAKE_TOOLCHAIN_FILE=../../android-toolchain.cmake
I have verified that the toolchain file is loaded by adding garbage to it and seeing the cmake command result in an error.
The CMakeLists.txt
file starts like this:
# CMake build file list for OpenAL
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(OpenAL)
IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0005 NEW)
ENDIF(COMMAND CMAKE_POLICY)
SET(CMAKE_MODULE_PATH "${OpenAL_SOURCE_DIR}/cmake")
I have successfully built the library as a dynamic module by placing SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS true)
in CMakeList.txt
immediately after the PROJECT(OpenAL)
. If I place it before this the build results in a static library with the previously mentioned warning.
It seems as though the property TARGET_SUPPORTS_SHARED_LIBS
is being reset after PROJECT(OpenAL)
. I have read the documetnation for PROJECT
, TARGET_SUPPORTS_SHARED_LIBS
and including a toolchain file but have not found anything that explicitly mentions resetting of target toolchain variables.
Does CMake have some rules that causes this variable to be reset between the toolchain file and the CMakeLists.txt processing, or perhaps before and after the PROJECT
command?
I am using CMake 2.8.12.2. Each time I issue the CMake command, I do so with a fresh copy of the source directory to be sure that there isn't a caching issue.