mirror of
https://github.com/taglib/taglib.git
synced 2025-05-25 12:10:26 -04:00
The following user-settable values for CMake are supported: - TESTS_DIR: Tests directory, is path to unit test data when 'data' is appended. Can be used to run the unit tests on a target. - TESTS_TMPDIR: Directory for temporary files created during unit tests, system tmpdir is used if undefined. Has to be defined on systems without global temporary directory.
This commit is contained in:
parent
ee1931b811
commit
fbbead3efd
@ -48,7 +48,10 @@ set(TAGLIB_INSTALL_SUFFIX "" CACHE STRING
|
||||
"Suffix added to installed files (include directory, libraries, .pc)")
|
||||
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
set(TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
|
||||
set(TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/" CACHE STRING
|
||||
"Tests directory, is path to unit test data when 'data' is appended")
|
||||
set(TESTS_TMPDIR "" CACHE STRING
|
||||
"Directory for temporary files created during unit tests, system tmpdir is used if undefined")
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
|
54
INSTALL.md
54
INSTALL.md
@ -42,6 +42,9 @@ CMakeLists.txt file.
|
||||
| `TAGLIB_INSTALL_SUFFIX` | Suffix added to installed libraries, includes, ... |
|
||||
| `ENABLE_STATIC_RUNTIME` | Link with MSVC runtime statically |
|
||||
| `BUILD_FRAMEWORK` | Build a macOS framework |
|
||||
| `TESTS_DIR` | Where to find unit test data (with data appended) |
|
||||
| `TESTS_TMPDIR` | Where to create temporary files in unit tests |
|
||||
|
||||
|
||||
If you want to install TagLib 2 alongside TagLib 1, you can use
|
||||
`-DTAGLIB_INSTALL_SUFFIX=-2` and make sure that `BUILD_EXAMPLES` is not `ON`
|
||||
@ -462,3 +465,54 @@ cmake --build build_mingw --config Release
|
||||
PATH=$PATH:$TAGLIB_PREFIX/bin
|
||||
build_mingw/tagreader /path/to/audio-file
|
||||
```
|
||||
|
||||
## Android
|
||||
|
||||
### Using vcpkg
|
||||
|
||||
The bash script below can be used to build TagLib for Android using vcpkg.
|
||||
It must be started in the parent folder of the taglib source folder and will
|
||||
build in a folder _android_build_ and install into _android_pkg_.
|
||||
The package and the unit tests are then transferred to an Android device
|
||||
and the unit tests are run on the device.
|
||||
|
||||
Note that `TESTS_TMPDIR` is set because there is no system-wide temporary folder
|
||||
on Android. `TESTS_DIR` is set to run the tests on the target.
|
||||
|
||||
```
|
||||
# You may have to adapt the NDK and vcpkg paths and the ABI/triplet.
|
||||
|
||||
export ANDROID_NDK_HOME=$HOME/Development/android-sdk/ndk/23.1.7779620
|
||||
export VCPKG_ROOT=$HOME/Development/vcpkg
|
||||
PATH=$PATH:$VCPKG_ROOT
|
||||
|
||||
# armeabi-v7a/arm-android or arm64-v8a/arm64-android or x86/x86-android or x86_64/x64-android
|
||||
android_abi=armeabi-v7a
|
||||
vcpkg_target_triplet=arm-android
|
||||
|
||||
vcpkg_toolchain_file=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
|
||||
android_toolchain_file=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake
|
||||
|
||||
vcpkg install --triplet $vcpkg_target_triplet utfcpp zlib cppunit
|
||||
|
||||
cmake -B android_build -S taglib \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$vcpkg_toolchain_file \
|
||||
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$android_toolchain_file \
|
||||
-DVCPKG_TARGET_TRIPLET=$vcpkg_target_triplet \
|
||||
-DANDROID_ABI=$android_abi \
|
||||
-GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release \
|
||||
-DVISIBILITY_HIDDEN=ON -DENABLE_CCACHE=ON -DBUILD_EXAMPLES=ON -DBUILD_TESTING=ON \
|
||||
-DTESTS_DIR=/data/local/tmp/tests/ -DTESTS_TMPDIR=/data/local/tmp
|
||||
cmake --build android_build --config Release
|
||||
cmake --install android_build --config Release --prefix android_pkg --strip
|
||||
cp -a android_build/tests/test_runner android_pkg/bin/
|
||||
|
||||
if hash adb 2>/dev/null; then
|
||||
adb push android_pkg /data/local/tmp/
|
||||
adb push android_build/tests/test_runner /data/local/tmp/tests/test_runner
|
||||
adb push taglib/tests/data /data/local/tmp/tests/
|
||||
adb shell "env LD_LIBRARY_PATH=/data/local/tmp/android_pkg/lib /data/local/tmp/tests/test_runner"
|
||||
# You could also try an example binary:
|
||||
# adb shell "env LD_LIBRARY_PATH=/data/local/tmp/android_pkg/lib /data/local/tmp/android_pkg/bin/tagreader '/sdcard/Music/Some Album/A Track.mp3'"
|
||||
fi
|
||||
```
|
||||
|
@ -20,5 +20,6 @@
|
||||
#cmakedefine TRACE_IN_RELEASE 1
|
||||
|
||||
#cmakedefine TESTS_DIR "@TESTS_DIR@"
|
||||
#cmakedefine TESTS_TMPDIR "@TESTS_TMPDIR@"
|
||||
|
||||
#endif
|
||||
|
@ -54,12 +54,14 @@ inline string copyFile(const string &filename, const string &ext)
|
||||
{
|
||||
char testFileName[1024];
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef TESTS_TMPDIR
|
||||
snprintf(testFileName, sizeof(testFileName), "%s/taglib-test%s", TESTS_TMPDIR, ext.c_str());
|
||||
#elif defined _WIN32
|
||||
char tempDir[MAX_PATH + 1];
|
||||
GetTempPathA(sizeof(tempDir), tempDir);
|
||||
wsprintfA(testFileName, "%s\\taglib-test%s", tempDir, ext.c_str());
|
||||
#else
|
||||
snprintf(testFileName, sizeof(testFileName), "/%s/taglib-test%s", P_tmpdir, ext.c_str());
|
||||
snprintf(testFileName, sizeof(testFileName), "%s/taglib-test%s", P_tmpdir, ext.c_str());
|
||||
#endif
|
||||
|
||||
string sourceFileName = testFilePath(filename) + ext;
|
||||
|
Loading…
Reference in New Issue
Block a user