applied multiple fixes and cleanups to the android cmake projects.
authorOzkan Sezer <sezeroz@gmail.com>
Sun, 01 Dec 2019 11:20:02 +0300
changeset 1050300088719593
parent 1049 22ad5c77e1be
child 1051 54ace9af9480
applied multiple fixes and cleanups to the android cmake projects.

the cmake stuff in SDL_mixer tree is incomplete, and it being for
android-only is stupid: maybe we should remove..
CMakeLists.txt
external/audio_codec_common.cmake
external/flac-1.3.3.patch
external/flac-1.3.3/CMakeLists.txt
external/flac-1.3.3/android/config.h
external/libogg-1.3.2/CMakeLists.txt
external/libvorbisidec-1.2.1/CMakeLists.txt
src/codecs/timidity/CMakeLists.txt
     1.1 --- a/CMakeLists.txt	Thu Nov 28 03:10:00 2019 +0300
     1.2 +++ b/CMakeLists.txt	Sun Dec 01 11:20:02 2019 +0300
     1.3 @@ -1,4 +1,4 @@
     1.4 -cmake_minimum_required(VERSION 3.0)
     1.5 +cmake_minimum_required(VERSION 2.8.11)
     1.6  project(SDL_mixer C)
     1.7  
     1.8  
     2.1 --- a/external/audio_codec_common.cmake	Thu Nov 28 03:10:00 2019 +0300
     2.2 +++ b/external/audio_codec_common.cmake	Sun Dec 01 11:20:02 2019 +0300
     2.3 @@ -1,37 +1,20 @@
     2.4 -# If platform is Emscripten
     2.5  if(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
     2.6      set(EMSCRIPTEN 1)
     2.7  endif()
     2.8  
     2.9 -# Strip garbage
    2.10 -if(APPLE)
    2.11 -    string(REGEX REPLACE "-O3" ""
    2.12 -        CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
    2.13 -    string(REGEX REPLACE "-O3" ""
    2.14 -        CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
    2.15 -    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
    2.16 -    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
    2.17 -    set(LINK_FLAGS_RELEASE  "${LINK_FLAGS_RELEASE} -dead_strip")
    2.18 -elseif(NOT MSVC)
    2.19 +if(MSVC)
    2.20 +    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
    2.21 +    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
    2.22 +    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
    2.23 +else()
    2.24 +    add_definitions(-Wall)
    2.25      if(EMSCRIPTEN)
    2.26 -        set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Os -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-s")
    2.27 -        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-s")
    2.28 -        set(LINK_FLAGS_RELEASE  "${LINK_FLAGS_RELEASE} -Wl,--gc-sections -Wl,-s")
    2.29 +        string(REGEX REPLACE "-O3" "-Os" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
    2.30 +        string(REGEX REPLACE "-O3" "-Os" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
    2.31      else()
    2.32 -        string(REGEX REPLACE "-O3" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
    2.33 -        string(REGEX REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
    2.34 -        set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -fdata-sections -ffunction-sections")
    2.35 -        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fdata-sections -ffunction-sections")
    2.36 -        if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    2.37 -            set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -Wl,--gc-sections -Wl,-s")
    2.38 -            set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -Wl,--gc-sections -Wl,-s")
    2.39 -            set(LINK_FLAGS_RELEASE  "${LINK_FLAGS_RELEASE} -Wl,--gc-sections -Wl,-s")
    2.40 -        endif()
    2.41 +        string(REGEX REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
    2.42 +        string(REGEX REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
    2.43      endif()
    2.44 -endif()
    2.45 -
    2.46 -# Global optimization flags
    2.47 -if(NOT MSVC)
    2.48      set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fno-omit-frame-pointer")
    2.49      set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-omit-frame-pointer")
    2.50  endif()
    2.51 @@ -41,39 +24,12 @@
    2.52  endif()
    2.53  
    2.54  string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
    2.55 -
    2.56  if(CMAKE_BUILD_TYPE_LOWER STREQUAL "release")
    2.57      add_definitions(-DNDEBUG)
    2.58  endif()
    2.59  
    2.60 -if(MSVC)
    2.61 -    # Force to always compile with W4
    2.62 -    if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
    2.63 -        string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
    2.64 -    else()
    2.65 -        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
    2.66 -        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
    2.67 -    endif()
    2.68 -elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
    2.69 -    # Update if necessary
    2.70 -    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
    2.71 -    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")
    2.72 -endif()
    2.73 -
    2.74 -# Disable bogus MSVC warnings
    2.75 -if(MSVC)
    2.76 -    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
    2.77 -endif()
    2.78 -
    2.79 -# -fPIC thing
    2.80 -if(NOT WIN32)
    2.81 -    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
    2.82 -    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
    2.83 -endif()
    2.84 -
    2.85  # Prevent shared libraries has "lib" prefix on Windows DLL files
    2.86  if(WIN32)
    2.87      set(CMAKE_SHARED_LIBRARY_PREFIX "")
    2.88  endif()
    2.89  
    2.90 -
     3.1 --- a/external/flac-1.3.3.patch	Thu Nov 28 03:10:00 2019 +0300
     3.2 +++ b/external/flac-1.3.3.patch	Sun Dec 01 11:20:02 2019 +0300
     3.3 @@ -1,7 +1,7 @@
     3.4  diff -u /dev/null flac-1.3.3/android/config.h
     3.5  --- /dev/null
     3.6  +++ flac-1.3.3/android/config.h
     3.7 -@@ -0,0 +1,252 @@
     3.8 +@@ -0,0 +1,254 @@
     3.9  +/* config.h.  Generated from config.h.in by configure.  */
    3.10  +/* config.h.in.  Generated from configure.ac by autoheader.  */
    3.11  +
    3.12 @@ -162,7 +162,9 @@
    3.13  +#define LT_OBJDIR ".libs/"
    3.14  +
    3.15  +/* Define if debugging is disabled */
    3.16 ++#ifndef NDEBUG
    3.17  +#define NDEBUG
    3.18 ++#endif
    3.19  +
    3.20  +/* Name of package */
    3.21  +#define PACKAGE "flac"
    3.22 @@ -321,4 +323,3 @@
    3.23   FLAC_API const char *FLAC__VERSION_STRING = PACKAGE_VERSION;
    3.24   
    3.25   FLAC_API const char *FLAC__VENDOR_STRING = "reference libFLAC " PACKAGE_VERSION " 20190804";
    3.26 -
     4.1 --- a/external/flac-1.3.3/CMakeLists.txt	Thu Nov 28 03:10:00 2019 +0300
     4.2 +++ b/external/flac-1.3.3/CMakeLists.txt	Sun Dec 01 11:20:02 2019 +0300
     4.3 @@ -1,20 +1,12 @@
     4.4 -cmake_minimum_required(VERSION 3.2)
     4.5 -project(libFLAC VERSION 1.3.3 LANGUAGES C)
     4.6 +cmake_minimum_required(VERSION 2.8.11)
     4.7 +project(libFLAC C)
     4.8  
     4.9 -include(CheckIncludeFiles)
    4.10 +set(FLAC_VERSION "1.3.3")
    4.11 +
    4.12  include(CheckFunctionExists)
    4.13  
    4.14  include(${CMAKE_CURRENT_SOURCE_DIR}/../audio_codec_common.cmake)
    4.15  
    4.16 -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
    4.17 -    # Turn on warnings and legacy C/C++ standards to support more compilers
    4.18 -    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wno-pedantic")
    4.19 -endif()
    4.20 -
    4.21 -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
    4.22 -    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shift-negative-value")
    4.23 -endif()
    4.24 -
    4.25  if(MSVC)
    4.26      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4267 /wd4334 /wd4996 /wd4244")
    4.27  endif()
    4.28 @@ -24,15 +16,12 @@
    4.29      -DFLAC__NO_DLL
    4.30  )
    4.31  
    4.32 -set(FLAC_VERSION "${libFLAC_VERSION}")
    4.33 -
    4.34  CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO)
    4.35  if(HAVE_FSEEKO)
    4.36      add_definitions(-DHAVE_FSEEKO)
    4.37  endif()
    4.38  
    4.39  set(FLAC_SRC)
    4.40 -
    4.41  list(APPEND FLAC_SRC
    4.42      src/libFLAC/bitmath.c
    4.43      src/libFLAC/bitreader.c
    4.44 @@ -56,7 +45,6 @@
    4.45      src/libFLAC/ogg_helper.c
    4.46      src/libFLAC/ogg_mapping.c
    4.47  )
    4.48 -
    4.49  if(WIN32)
    4.50      list(APPEND FLAC_SRC
    4.51          src/libFLAC/windows_unicode_filenames.c
    4.52 @@ -67,18 +55,17 @@
    4.53      ${FLAC_SRC}
    4.54  )
    4.55  
    4.56 -target_include_directories(FLAC PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
    4.57  target_compile_definitions(FLAC PRIVATE
    4.58      -DVERSION="${FLAC_VERSION}"
    4.59      -DPACKAGE_VERSION="${FLAC_VERSION}"
    4.60  )
    4.61  target_include_directories(FLAC PUBLIC
    4.62 +    ${CMAKE_CURRENT_SOURCE_DIR}/include
    4.63      ${CMAKE_CURRENT_SOURCE_DIR}/../libogg-1.3.2/include
    4.64      ${CMAKE_CURRENT_SOURCE_DIR}/../libogg-1.3.2/android
    4.65  )
    4.66  target_include_directories(FLAC PRIVATE
    4.67      ${CMAKE_CURRENT_SOURCE_DIR}/include
    4.68 -    ${CMAKE_CURRENT_SOURCE_DIR}/include_p
    4.69      ${CMAKE_CURRENT_SOURCE_DIR}/src/libFLAC
    4.70      ${CMAKE_CURRENT_SOURCE_DIR}/src/libFLAC/include
    4.71      ${CMAKE_CURRENT_SOURCE_DIR}/android
     5.1 --- a/external/flac-1.3.3/android/config.h	Thu Nov 28 03:10:00 2019 +0300
     5.2 +++ b/external/flac-1.3.3/android/config.h	Sun Dec 01 11:20:02 2019 +0300
     5.3 @@ -158,7 +158,9 @@
     5.4  #define LT_OBJDIR ".libs/"
     5.5  
     5.6  /* Define if debugging is disabled */
     5.7 +#ifndef NDEBUG
     5.8  #define NDEBUG
     5.9 +#endif
    5.10  
    5.11  /* Name of package */
    5.12  #define PACKAGE "flac"
     6.1 --- a/external/libogg-1.3.2/CMakeLists.txt	Thu Nov 28 03:10:00 2019 +0300
     6.2 +++ b/external/libogg-1.3.2/CMakeLists.txt	Sun Dec 01 11:20:02 2019 +0300
     6.3 @@ -1,5 +1,5 @@
     6.4 -cmake_minimum_required(VERSION 3.2)
     6.5 -project(libOGG VERSION 1.3.3 LANGUAGES C)
     6.6 +cmake_minimum_required(VERSION 2.8.11)
     6.7 +project(libogg C)
     6.8  
     6.9  include(${CMAKE_CURRENT_SOURCE_DIR}/../audio_codec_common.cmake)
    6.10  
    6.11 @@ -11,16 +11,13 @@
    6.12  target_include_directories(ogg PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
    6.13  target_include_directories(ogg PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/android)
    6.14  
    6.15 -
    6.16  install(TARGETS ogg
    6.17          LIBRARY DESTINATION "lib"
    6.18          ARCHIVE DESTINATION "lib"
    6.19          INCLUDES DESTINATION "include")
    6.20  
    6.21  install(FILES
    6.22 -        include/ogg/config_types.h
    6.23 +        android/ogg/config_types.h
    6.24          include/ogg/ogg.h
    6.25          include/ogg/os_types.h
    6.26          DESTINATION include/ogg)
    6.27 -
    6.28 -
     7.1 --- a/external/libvorbisidec-1.2.1/CMakeLists.txt	Thu Nov 28 03:10:00 2019 +0300
     7.2 +++ b/external/libvorbisidec-1.2.1/CMakeLists.txt	Sun Dec 01 11:20:02 2019 +0300
     7.3 @@ -1,13 +1,9 @@
     7.4 -cmake_minimum_required(VERSION 3.2)
     7.5 -project(libVorbis VERSION 1.3.6 LANGUAGES C)
     7.6 +cmake_minimum_required(VERSION 2.8.11)
     7.7 +project(libvorbisidec C)
     7.8  
     7.9  include(${CMAKE_CURRENT_SOURCE_DIR}/../audio_codec_common.cmake)
    7.10  
    7.11 -add_definitions(
    7.12 -    -DHAVE_CONFIG_H -DHAVE_ALLOCA
    7.13 -)
    7.14 -
    7.15 -add_definitions(-DFLOAT_LOOKUP -DINT_LOOKUP)
    7.16 +add_definitions(-DHAVE_ALLOCA -DFLOAT_LOOKUP -DINT_LOOKUP)
    7.17  
    7.18  if(MSVC)
    7.19      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244 /wd4267 /wd4305")
    7.20 @@ -26,32 +22,23 @@
    7.21      sharedbook.c
    7.22      synthesis.c
    7.23      window.c
    7.24 -)
    7.25 -
    7.26 -add_library(vorbisfile STATIC
    7.27      vorbisfile.c
    7.28  )
    7.29  
    7.30 -
    7.31  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
    7.32  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
    7.33  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libogg-1.3.2/include)
    7.34 -
    7.35  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libogg-1.3.2/android)
    7.36 - 
    7.37 -
    7.38  
    7.39  target_include_directories(vorbisidec PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
    7.40 -target_include_directories(vorbisfile PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
    7.41  
    7.42 -install(TARGETS vorbisidec vorbisfile 
    7.43 +install(TARGETS vorbisidec
    7.44          LIBRARY DESTINATION "lib"
    7.45          ARCHIVE DESTINATION "lib"
    7.46          INCLUDES DESTINATION "include")
    7.47  
    7.48  install(FILES
    7.49 -        include/vorbis/codec.h
    7.50 -        include/vorbis/vorbisfile.h
    7.51 -        DESTINATION include/vorbis)
    7.52 -
    7.53 -
    7.54 +        config_types.h
    7.55 +        ivorbiscodec.h
    7.56 +        ivorbisfile.h
    7.57 +        DESTINATION include/tremor)
     8.1 --- a/src/codecs/timidity/CMakeLists.txt	Thu Nov 28 03:10:00 2019 +0300
     8.2 +++ b/src/codecs/timidity/CMakeLists.txt	Sun Dec 01 11:20:02 2019 +0300
     8.3 @@ -1,12 +1,9 @@
     8.4 -cmake_minimum_required(VERSION 3.2)
     8.5 -project(libTimiditySDL VERSION 0.2 LANGUAGES C)
     8.6 +cmake_minimum_required(VERSION 2.8.11)
     8.7 +project(timidity_sdl C)
     8.8  
     8.9 -include(${CMAKE_CURRENT_SOURCE_DIR}/../external/audio_codec_common.cmake)
    8.10 +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../external/audio_codec_common.cmake)
    8.11  
    8.12 -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
    8.13 -    # Turn on warnings and legacy C/C++ standards to support more compilers
    8.14 -    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -std=c90")
    8.15 -endif()
    8.16 +find_package(SDL2 REQUIRED)
    8.17  
    8.18  add_library(timidity STATIC
    8.19      common.c
    8.20 @@ -20,18 +17,8 @@
    8.21      timidity.c
    8.22  )
    8.23  
    8.24 -if(DOWNLOAD_SDL2_DEPENDENCY)
    8.25 -    add_dependencies(timidity SDL2HG)
    8.26 -elseif(SDL2_REPO_PATH)
    8.27 -    include_directories(${SDL2_REPO_PATH}/include)
    8.28 -else()
    8.29 -    find_library(SDL2_LIBRARY SDL2)
    8.30 -    message("Found ${SDL2_LIBRARY}")
    8.31 -endif()
    8.32 -
    8.33 -target_link_libraries(timidity SDL2)
    8.34 -
    8.35  target_include_directories(timidity PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
    8.36 +target_include_directories(timidity PUBLIC ${SDL2_INCLUDE_DIRS})
    8.37  
    8.38  install(TARGETS timidity
    8.39          LIBRARY DESTINATION "lib"
    8.40 @@ -39,7 +26,5 @@
    8.41          INCLUDES DESTINATION "include")
    8.42  
    8.43  install(FILES
    8.44 -        include/timidity.h
    8.45 +        timidity.h
    8.46          DESTINATION include/)
    8.47 -
    8.48 -