Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: cmake compilation of external libs, thanks Vitaly Novichkov …
…(bug 3918)
- Loading branch information
Showing
7 changed files
with
440 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# If platform is Emscripten | ||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") | ||
set(EMSCRIPTEN 1) | ||
endif() | ||
|
||
# Strip garbage | ||
if(APPLE) | ||
string(REGEX REPLACE "-O3" "" | ||
CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") | ||
string(REGEX REPLACE "-O3" "" | ||
CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") | ||
set(LINK_FLAGS_RELEASE "${LINK_FLAGS_RELEASE} -dead_strip") | ||
elseif(NOT MSVC) | ||
if(EMSCRIPTEN) | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-s") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-s") | ||
set(LINK_FLAGS_RELEASE "${LINK_FLAGS_RELEASE} -Wl,--gc-sections -Wl,-s") | ||
else() | ||
string(REGEX REPLACE "-O3" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") | ||
string(REGEX REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -fdata-sections -ffunction-sections") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fdata-sections -ffunction-sections") | ||
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -Wl,--gc-sections -Wl,-s") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -Wl,--gc-sections -Wl,-s") | ||
set(LINK_FLAGS_RELEASE "${LINK_FLAGS_RELEASE} -Wl,--gc-sections -Wl,-s") | ||
endif() | ||
endif() | ||
endif() | ||
|
||
# Global optimization flags | ||
if(NOT MSVC) | ||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-omit-frame-pointer") | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-omit-frame-pointer") | ||
endif() | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "Release") | ||
endif() | ||
|
||
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) | ||
|
||
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "release") | ||
add_definitions(-DNDEBUG) | ||
endif() | ||
|
||
if(MSVC) | ||
# Force to always compile with W4 | ||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") | ||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
else() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") | ||
endif() | ||
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) | ||
# Update if necessary | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic") | ||
endif() | ||
|
||
# Disable bogus MSVC warnings | ||
if(MSVC) | ||
add_definitions(-D_CRT_SECURE_NO_WARNINGS) | ||
endif() | ||
|
||
# -fPIC thing | ||
if(NOT WIN32) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") | ||
endif() | ||
|
||
# Prevent shared libraries has "lib" prefix on Windows DLL files | ||
if(WIN32) | ||
set(CMAKE_SHARED_LIBRARY_PREFIX "") | ||
endif() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
project(libFLAC VERSION 1.3.2 LANGUAGES C) | ||
|
||
include(CheckIncludeFiles) | ||
include(CheckFunctionExists) | ||
|
||
include(${CMAKE_CURRENT_SOURCE_DIR}/../audio_codec_common.cmake) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) | ||
# Turn on warnings and legacy C/C++ standards to support more compilers | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wno-pedantic") | ||
endif() | ||
|
||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shift-negative-value") | ||
endif() | ||
|
||
if(MSVC) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4267 /wd4334 /wd4996 /wd4244") | ||
endif() | ||
|
||
add_definitions( | ||
-DHAVE_CONFIG_H | ||
-DFLAC__NO_DLL | ||
) | ||
|
||
set(FLAC_VERSION "${libFLAC_VERSION}") | ||
|
||
CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO) | ||
if(HAVE_FSEEKO) | ||
add_definitions(-DHAVE_FSEEKO) | ||
endif() | ||
|
||
if(WIN32) | ||
CHECK_FUNCTION_EXISTS(_wutime64 HAFE_WUTIME64) | ||
try_compile(HAFE_WUTIME64_BUILT | ||
${CMAKE_BINARY_DIR}/compile_tests | ||
${CMAKE_CURRENT_SOURCE_DIR}/config.tests/wutime64/wutime64_test.c | ||
) | ||
if(HAFE_WUTIME64 AND HAFE_WUTIME64_BUILT) | ||
message("TEST: _wutime64 found and compiling!") | ||
add_definitions(-DHAFE_WUTIME64) | ||
else() | ||
message("TEST: _wutime64 DISABLED: found: [${HAFE_WUTIME64}] compiling: [${HAFE_WUTIME64_BUILT}]") | ||
endif() | ||
endif() | ||
|
||
set(FLAC_SRC) | ||
|
||
list(APPEND FLAC_SRC | ||
src/libFLAC/bitmath.c | ||
src/libFLAC/bitreader.c | ||
src/libFLAC/bitwriter.c | ||
src/libFLAC/cpu.c | ||
src/libFLAC/crc.c | ||
src/libFLAC/fixed.c | ||
src/libFLAC/format.c | ||
src/libFLAC/lpc.c | ||
src/libFLAC/md5.c | ||
src/libFLAC/memory.c | ||
src/libFLAC/metadata_iterators.c | ||
src/libFLAC/metadata_object.c | ||
src/libFLAC/ogg_decoder_aspect.c | ||
src/libFLAC/ogg_encoder_aspect.c | ||
src/libFLAC/ogg_helper.c | ||
src/libFLAC/ogg_mapping.c | ||
src/libFLAC/stream_decoder.c | ||
src/libFLAC/stream_encoder.c | ||
src/libFLAC/stream_encoder_framing.c | ||
src/libFLAC/window.c | ||
) | ||
|
||
if(WIN32) | ||
add_definitions(-DUNICODE -D_UNICODE) | ||
list(APPEND FLAC_SRC | ||
src/share/win_utf8_io/win_utf8_io.c | ||
src/libFLAC/windows_unicode_filenames.c | ||
) | ||
endif() | ||
|
||
add_library(FLAC STATIC | ||
${FLAC_SRC} | ||
) | ||
|
||
target_include_directories(FLAC PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
target_compile_definitions(FLAC PRIVATE | ||
-DVERSION="${FLAC_VERSION}" | ||
-DPACKAGE_VERSION="${FLAC_VERSION}" | ||
) | ||
target_include_directories(FLAC PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR}/../libogg-1.3.2/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/../libogg-1.3.2/android | ||
) | ||
target_include_directories(FLAC PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/include_p | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/libFLAC | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/libFLAC/include | ||
${CMAKE_CURRENT_SOURCE_DIR}/android | ||
) | ||
|
||
install(TARGETS FLAC | ||
LIBRARY DESTINATION "lib" | ||
ARCHIVE DESTINATION "lib" | ||
INCLUDES DESTINATION "include") | ||
|
||
install(FILES | ||
include/FLAC/all.h | ||
include/FLAC/assert.h | ||
include/FLAC/callback.h | ||
include/FLAC/export.h | ||
include/FLAC/format.h | ||
include/FLAC/metadata.h | ||
include/FLAC/ordinals.h | ||
include/FLAC/stream_decoder.h | ||
include/FLAC/stream_encoder.h | ||
DESTINATION include/FLAC/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
project(libModPlug VERSION 0.8.9.0 LANGUAGES CXX) | ||
|
||
include(CheckFunctionExists) | ||
include(CheckIncludeFile) | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/../audio_codec_common.cmake) | ||
|
||
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -std=gnu99") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-pedantic -std=gnu++98 -Wno-sequence-point") | ||
if(NOT APPLE) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable") | ||
endif() | ||
endif() | ||
|
||
if(MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4100 /wd4244 /wd4267 /wd4996 /wd4702 /wd4706 /wd4456") | ||
endif() | ||
|
||
add_definitions( | ||
#-DMODPLUG_NO_FILESAVE | ||
#-DNO_MIDIFORMATS | ||
#-DNO_WAVFORMAT | ||
-DHAVE_CONFIG_H | ||
-DHAVE_CMAKE_CONFIG_H | ||
-DMODPLUG_STATIC | ||
-DMODPLUG_BUILD=1 | ||
-D_REENTRANT | ||
-D_USE_MATH_DEFINES | ||
) | ||
|
||
foreach(_FN | ||
setenv putenv | ||
) | ||
string(TOUPPER ${_FN} _UPPER) | ||
set(_HAVEVAR "HAVE_${_UPPER}") | ||
CHECK_FUNCTION_EXISTS("${_FN}" ${_HAVEVAR}) | ||
endforeach() | ||
|
||
CHECK_INCLUDE_FILE("malloc.h" HAVE_MALLOC_H) | ||
CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H) | ||
CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H) | ||
|
||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config/config.h) | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/config/) | ||
|
||
add_library(modplug STATIC | ||
src/fastmix.cpp | ||
src/load_669.cpp | ||
src/load_abc.cpp | ||
src/load_amf.cpp | ||
src/load_ams.cpp | ||
src/load_dbm.cpp | ||
src/load_dmf.cpp | ||
src/load_dsm.cpp | ||
src/load_far.cpp | ||
src/load_it.cpp | ||
# src/load_j2b.cpp | ||
src/load_mdl.cpp | ||
src/load_med.cpp | ||
#src/load_mid.cpp | ||
src/load_mod.cpp | ||
src/load_mt2.cpp | ||
src/load_mtm.cpp | ||
src/load_okt.cpp | ||
src/load_pat.cpp | ||
src/load_psm.cpp | ||
src/load_ptm.cpp | ||
src/load_s3m.cpp | ||
src/load_stm.cpp | ||
src/load_ult.cpp | ||
src/load_umx.cpp | ||
#src/load_wav.cpp | ||
src/load_xm.cpp | ||
src/mmcmp.cpp | ||
src/modplug.cpp | ||
src/snd_dsp.cpp | ||
src/snd_flt.cpp | ||
src/snd_fx.cpp | ||
src/sndfile.cpp | ||
src/sndmix.cpp | ||
) | ||
|
||
# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include_p) | ||
# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) | ||
# include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libogg/include) | ||
|
||
target_include_directories(modplug PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
target_include_directories(modplug PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/include/libmodplug | ||
${CMAKE_CURRENT_SOURCE_DIR}/src | ||
${CMAKE_CURRENT_SOURCE_DIR}/src/libmodplug | ||
) | ||
|
||
install(TARGETS modplug | ||
LIBRARY DESTINATION "lib" | ||
ARCHIVE DESTINATION "lib" | ||
INCLUDES DESTINATION "include") | ||
|
||
install(FILES | ||
include/libmodplug/modplug.h | ||
DESTINATION include/libmodplug/) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
cmake_minimum_required(VERSION 3.2) | ||
project(libOGG VERSION 1.3.3 LANGUAGES C) | ||
|
||
include(${CMAKE_CURRENT_SOURCE_DIR}/../audio_codec_common.cmake) | ||
|
||
add_library(ogg STATIC | ||
src/bitwise.c | ||
src/framing.c | ||
) | ||
|
||
target_include_directories(ogg PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
target_include_directories(ogg PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/android) | ||
|
||
|
||
install(TARGETS ogg | ||
LIBRARY DESTINATION "lib" | ||
ARCHIVE DESTINATION "lib" | ||
INCLUDES DESTINATION "include") | ||
|
||
install(FILES | ||
include/ogg/config_types.h | ||
include/ogg/ogg.h | ||
include/ogg/os_types.h | ||
DESTINATION include/ogg) | ||
|
||
|
Oops, something went wrong.