mpg123: build: beginning to addresss bug 345, Android PICy assembly with cmake

From 1339a81d101d2bd44228dc9fa3bd28d2166fd4ee Mon Sep 17 00:00:00 2001
From: thor <[EMAIL REDACTED]>
Date: Thu, 13 Oct 2022 20:54:33 +0000
Subject: [PATCH] build: beginning to addresss bug 345, Android PICy assembly
 with cmake

This adds the missing -DPIC for libmpg123 when building shared libs with
cmake, and also a toolchain file to ease testing of a 32 bit build
(can't be as easy as with autotools, eh?).




git-svn-id: svn://scm.orgis.org/mpg123/trunk@5171 35dc7657-300d-0410-a2e5-dc2837fedb53
---
 ports/cmake/linux_i686.toolchain.cmake   | 7 +++++++
 ports/cmake/src/libmpg123/CMakeLists.txt | 3 +++
 2 files changed, 10 insertions(+)
 create mode 100644 ports/cmake/linux_i686.toolchain.cmake

diff --git a/ports/cmake/linux_i686.toolchain.cmake b/ports/cmake/linux_i686.toolchain.cmake
new file mode 100644
index 0000000..d33184e
--- /dev/null
+++ b/ports/cmake/linux_i686.toolchain.cmake
@@ -0,0 +1,7 @@
+
+set(CMAKE_SYSTEM_NAME Linux)
+set(CMAKE_SYSTEM_VERSION 1)
+set(CMAKE_SYSTEM_PROCESSOR "i686")
+
+set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
+set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -m32" CACHE STRING "asm flags")
diff --git a/ports/cmake/src/libmpg123/CMakeLists.txt b/ports/cmake/src/libmpg123/CMakeLists.txt
index 9305452..9f0f75a 100644
--- a/ports/cmake/src/libmpg123/CMakeLists.txt
+++ b/ports/cmake/src/libmpg123/CMakeLists.txt
@@ -214,6 +214,9 @@ endif()
 
 set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME mpg123)
 
+target_compile_definitions(${TARGET} PRIVATE
+    $<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC>)
+
 target_compile_definitions(${TARGET} PRIVATE
     ${PLATFORM_DEFINITIONS}
     $<$<BOOL:${HAVE_FPU}>:REAL_IS_FLOAT>