<commit_before>######################################
##### CMake environment setup    #####
######################################
project(libebur128 C)
cmake_minimum_required(VERSION 2.6.4)
set(CMAKE_MODULE_PATH ${${PROJECT_NAME}_SOURCE_DIR}/cmake)
set(EXECUTABLE_OUTPUT_PATH ${${PROJECT_NAME}_BINARY_DIR})

if(NOT WIN32)
  if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
    list(APPEND LINK_DIRECTORIES ${${PROJECT_NAME}_SOURCE_DIR}/lib64)
  elseif(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
    list(APPEND LINK_DIRECTORIES ${${PROJECT_NAME}_SOURCE_DIR}/lib)
  endif()
else()
  if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
    list(APPEND LINK_DIRECTORIES ${${PROJECT_NAME}_SOURCE_DIR}/mingw-lib64)
  elseif(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
    list(APPEND LINK_DIRECTORIES ${${PROJECT_NAME}_SOURCE_DIR}/mingw-lib)
  endif()
endif()
link_directories(${LINK_DIRECTORIES})

if(IS_DIRECTORY ${${PROJECT_NAME}_SOURCE_DIR}/include)
  list(APPEND INCLUDE_DIRECTORIES ${${PROJECT_NAME}_SOURCE_DIR}/include)
endif()
if(WIN32 AND IS_DIRECTORY ${${PROJECT_NAME}_SOURCE_DIR}/mingw-include)
  list(APPEND INCLUDE_DIRECTORIES ${${PROJECT_NAME}_SOURCE_DIR}/mingw-include)
endif()
include_directories(SYSTEM ${INCLUDE_DIRECTORIES})


######################################
##### Library setup              #####
######################################

include(FindPkgConfig)
if("${CMAKE_C_COMPILER}" MATCHES ".*lsb.*")
  set(LSB_COMPILER_FOUND TRUE)
endif()

##### glib
if(NOT WIN32 AND NOT LSB_COMPILER_FOUND)
  pkg_check_modules(GLIB glib-2.0)
  pkg_check_modules(GTHREAD gthread-2.0)
  include_directories(SYSTEM ${GLIB_INCLUDEDIR})
  include_directories(SYSTEM ${GTHREAD_INCLUDEDIR})
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem${GLIB_INCLUDEDIR}/glib-2.0 -isystem${GLIB_LIBDIR}/glib-2.0/include/ -isystem${GTHREAD_INCLUDEDIR}/glib-2.0")
  link_directories(${GLIB_LIBDIR})
  link_directories(${GTHREAD_LIBDIR})
elseif(WIN32)
  find_library(GLIB_LIBRARIES glib-2.0
               PATHS ${LINK_DIRECTORIES} CMAKE_FIND_ROOT_PATH_BOTH)
  find_library(GTHREAD_LIBRARIES gthread-2.0
               PATHS ${LINK_DIRECTORIES} CMAKE_FIND_ROOT_PATH_BOTH)
  set(GLIB_FOUND ${GLIB_LIBRARIES})
  set(GTHREAD_FOUND ${GTHREAD_LIBRARIES})
elseif(LSB_COMPILER_FOUND)
  set(GLIB_LIBRARIES glib-2.0)
  set(GTHREAD_LIBRARIES gthread-2.0)
  set(GLIB_FOUND TRUE)
  set(GTHREAD_FOUND TRUE)
endif()

message(STATUS "${GLIB_LIBRARIES}")

##### libsndfile
if(NOT WIN32 AND NOT LSB_COMPILER_FOUND)
  pkg_check_modules(SNDFILE sndfile>=1.0.21)
  include_directories(SYSTEM ${SNDFILE_INCLUDEDIR})
  link_directories(${SNDFILE_LIBRARY_DIRS})
elseif(WIN32)
  find_library(SNDFILE_LIBRARIES sndfile-1
               PATHS ${LINK_DIRECTORIES} CMAKE_FIND_ROOT_PATH_BOTH)
  set(SNDFILE_FOUND ${SNDFILE_LIBRARIES})
elseif(LSB_COMPILER_FOUND)
  set(SNDFILE_LIBRARIES sndfile)
  set(SNDFILE_FOUND TRUE)
endif()

##### ffmpeg
set(FFMPEG_VERSION "0.6.1" CACHE STRING "FFmpeg version to link to")
if(IS_DIRECTORY ${${PROJECT_NAME}_SOURCE_DIR}/include/ffmpeg-${FFMPEG_VERSION})
  list(APPEND INCLUDE_DIRECTORIES ${${PROJECT_NAME}_SOURCE_DIR}/include/ffmpeg-${FFMPEG_VERSION})
endif()
if(NOT WIN32 AND NOT LSB_COMPILER_FOUND)
  pkg_check_modules(LIBAVCODEC libavcodec)
  pkg_check_modules(LIBAVFORMAT libavformat)
  include_directories(SYSTEM ${LIBAVCODEC_INCLUDEDIR})
  include_directories(SYSTEM ${LIBAVFORMAT_INCLUDEDIR})
  link_directories(${LIBAVCODEC_LIBRARY_DIRS})
  link_directories(${LIBAVFORMAT_LIBRARY_DIRS})
elseif(WIN32)
  find_library(LIBAVCODEC_LIBRARIES avcodec-52
               PATHS ${LINK_DIRECTORIES} CMAKE_FIND_ROOT_PATH_BOTH)
  find_library(LIBAVFORMAT_LIBRARIES avformat-52
               PATHS ${LINK_DIRECTORIES} CMAKE_FIND_ROOT_PATH_BOTH)
  find_library(LIBAVUTIL_LIBRARIES avutil-50
               PATHS ${LINK_DIRECTORIES} CMAKE_FIND_ROOT_PATH_BOTH)
  set(LIBAVCODEC_FOUND ${LIBAVCODEC_LIBRARIES})
  set(LIBAVFORMAT_FOUND ${LIBAVFORMAT_LIBRARIES})
  set(LIBAVUTIL_FOUND ${LIBAVCODEC_LIBRARIES})
elseif(LSB_COMPILER_FOUND)
  link_directories(${${PROJECT_NAME}_SOURCE_DIR}/lib64/ffmpeg-${FFMPEG_VERSION})
  link_directories(${${PROJECT_NAME}_SOURCE_DIR}/lib/ffmpeg-${FFMPEG_VERSION})
  set(LIBAVCODEC_LIBRARIES avcodec)
  set(LIBAVFORMAT_LIBRARIES avformat)
  set(LIBAVUTIL_LIBRARIES "")
  set(LIBAVCODEC_FOUND TRUE)
  set(LIBAVFORMAT_FOUND TRUE)
  set(LIBAVUTIL_FOUND TRUE)
endif()
if(LIBAVCODEC_FOUND AND LIBAVFORMAT_FOUND AND (NOT WIN32 OR LIBAVUTIL_FOUND))
  set(FFMPEG_FOUND TRUE)
endif()

##### mpg123
if(NOT WIN32 AND NOT LSB_COMPILER_FOUND)
  pkg_check_modules(MPG123 libmpg123)
  include_directories(SYSTEM ${MPG123_INCLUDEDIR})
  link_directories(${MPG123_LIBRARY_DIRS})
elseif(WIN32)
  find_library(MPG123_LIBRARIES mpg123-0
               PATHS ${LINK_DIRECTORIES} CMAKE_FIND_ROOT_PATH_BOTH)
  set(MPG123_FOUND ${MPG123_LIBRARIES})
elseif(LSB_COMPILER_FOUND)
  set(MPG123_LIBRARIES mpg123)
  set(MPG123_FOUND TRUE)
endif()

##### mpddec
find_path(MPCDEC_INCLUDE_DIR mpcdec.h PATH_SUFFIXES mpc)
if(MPCDEC_INCLUDE_DIR)
  list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
  find_library(MPCDEC_LIBRARY NAMES mpcdec mpcdec_static
               PATHS ${LINK_DIRECTORIES} CMAKE_FIND_ROOT_PATH_BOTH)
  list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
  if(MPCDEC_LIBRARY)
    set(MPCDEC_FOUND TRUE)
  else()
    set(MPCDEC_FOUND FALSE)
    message(STATUS "Could not find the mpcdec library! Will not build mpcdec example.")
  endif()
else()
  set(MPCDEC_FOUND FALSE)
  message(STATUS "Could not find mpc include dir! Will not build mpcdec example.")
endif()


######################################
##### Compiler setup             #####
######################################
include("${CMAKE_MODULE_PATH}/CompilerFlags.txt")  # This sets VALID_FLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi ${VALID_FLAGS}")

set(USE_SSE2 FALSE CACHE BOOL "Enable to build with SSE2")
if(USE_SSE2)
  if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mfpmath=sse")
  endif()
endif()


######################################
##### Add libraries/executables  #####
######################################
add_library(ebur128 src/ebur128.c)
if(NOT WIN32)
  target_link_libraries(ebur128 m)<commit_msg>clean up library detection in makefile<commit_after>######################################
##### CMake environment setup    #####
######################################
project(libebur128 C)
cmake_minimum_required(VERSION 2.6.4)
set(CMAKE_MODULE_PATH ${${PROJECT_NAME}_SOURCE_DIR}/cmake)
set(EXECUTABLE_OUTPUT_PATH ${${PROJECT_NAME}_BINARY_DIR})


######################################
##### Library setup              #####
######################################

include(FindPkgConfig)
if("${CMAKE_C_COMPILER}" MATCHES ".*lsb.*")
  set(LSB_COMPILER_FOUND TRUE)
  set(PKG_CONFIG_PREFIX "/opt/lsb/lib/pkgconfig/")
  set(PKG_CONFIG_SUFFIX ".pc")
endif()

##### glib
if(NOT WIN32)
  pkg_check_modules(GLIB "${PKG_CONFIG_PREFIX}glib-2.0${PKG_CONFIG_SUFFIX}")
  pkg_check_modules(GTHREAD "${PKG_CONFIG_PREFIX}gthread-2.0${PKG_CONFIG_SUFFIX}")
  if(GLIB_FOUND AND GTHREAD_FOUND)
    include_directories(SYSTEM ${GLIB_INCLUDE_DIRS})
    include_directories(SYSTEM ${GTHREAD_INCLUDE_DIRS})
    link_directories(${GLIB_LIBRARY_DIRS})
    link_directories(${GTHREAD_LIBRARY_DIRS})
  endif()
else()
  find_library(GLIB_LIBRARIES glib-2.0)
  find_library(GTHREAD_LIBRARIES gthread-2.0)
  if(GLIB_LIBRARIES AND GTHREAD_LIBRARIES)
    set(GLIB_FOUND TRUE)
    set(GTHREAD_FOUND TRUE)
  endif()
endif()

##### libsndfile
if(NOT WIN32)
  pkg_check_modules(SNDFILE sndfile>=1.0.21)
  if(SNDFILE_FOUND)
    include_directories(SYSTEM ${SNDFILE_INCLUDE_DIRS})
    link_directories(${SNDFILE_LIBRARY_DIRS})
  endif()
else()
  find_library(SNDFILE_LIBRARIES sndfile-1)
  if(SNDFILE_LIBRARIES)
    set(SNDFILE_FOUND TRUE)
  endif()
endif()

##### ffmpeg
if(NOT WIN32)
  pkg_check_modules(LIBAVCODEC libavcodec)
  pkg_check_modules(LIBAVFORMAT libavformat)
  if(LIBAVCODEC_FOUND AND LIBAVFORMAT_FOUND)
    include_directories(SYSTEM ${LIBAVCODEC_INCLUDE_DIRS})
    include_directories(SYSTEM ${LIBAVFORMAT_INCLUDE_DIRS})
    link_directories(${LIBAVCODEC_LIBRARY_DIRS})
    link_directories(${LIBAVFORMAT_LIBRARY_DIRS})
    set(FFMPEG_FOUND TRUE)
  endif()
else()
  find_library(LIBAVCODEC_LIBRARIES avcodec-52)
  find_library(LIBAVFORMAT_LIBRARIES avformat-52)
  find_library(LIBAVUTIL_LIBRARIES avutil-50)
  if(LIBAVCODEC_LIBRARIES AND LIBAVFORMAT_LIBRARIES AND LIBAVUTIL_LIBRARIES)
    set(FFMPEG_FOUND TRUE)
  endif()
endif()

##### mpg123
if(NOT WIN32)
  pkg_check_modules(MPG123 libmpg123)
  if(MPG123_FOUND)
    include_directories(SYSTEM ${MPG123_INCLUDE_DIRS})
    link_directories(${MPG123_LIBRARY_DIRS})
  endif()
else()
  find_library(MPG123_LIBRARIES mpg123-0)
  if(MPG123_LIBRARIES)
    set(MPG123_FOUND TRUE)
  endif()
endif()

##### mpddec
find_path(MPCDEC_INCLUDE_DIR mpcdec.h PATH_SUFFIXES mpc)
if(MPCDEC_INCLUDE_DIR)
  list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
  find_library(MPCDEC_LIBRARY NAMES mpcdec mpcdec_static)
  list(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
  if(MPCDEC_LIBRARY)
    set(MPCDEC_FOUND TRUE)
  else()
    message(STATUS "Could not find the mpcdec library! Will not build mpcdec example.")
  endif()
else()
  message(STATUS "Could not find mpc include dir! Will not build mpcdec example.")
endif()


######################################
##### Compiler setup             #####
######################################
include("${CMAKE_MODULE_PATH}/CompilerFlags.txt")  # This sets VALID_FLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi ${VALID_FLAGS}")

set(USE_SSE2 FALSE CACHE BOOL "Enable to build with SSE2")
if(USE_SSE2)
  if (${CMAKE_SIZEOF_VOID_P} EQUAL 4)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mfpmath=sse")
  endif()
endif()


######################################
##### Add libraries/executables  #####
######################################
add_library(ebur128 src/ebur128.c)
if(NOT WIN32)
  target_link_libraries(ebur128 m)
{'fraction_non_alphanumeric': 0.16868442292171107, 'fraction_numerical': 0.020480225988700564, 'mean_word_length': 6.898804780876494, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1248234', 'n_tokens_mistral': 4075, 'n_tokens_neox': 3727, 'n_words': 549}