zmusic/cmake/FindMPG123.cmake
Braden Obrzut b3c4b55dab Overhaul CMakeLists to conform with modern CMake
- Prefer target properties instead of setting variables whenever possible.
  A zmusic-obj target now exists to represent the commonality between zmusic
  and zmusiclite.
- Factored out as much as possible from global settings to per target settings
  which will make it easier to support using ZMusic as a submodule. Moved
  helper functions into a ZUtility.cmake module.
- We now generate and install ZMusicConfig.cmake so find_package(ZMusic)
  will work either automatically or given ZMusic_DIR is set.
- CPack is enabled although some refinement is still needed.
- Requires CMake >= 3.13 which is newer than I would normally like, but given
  how no one like to refactor these things it may be better to deal with the
  short term pain of going a little aggressive on the requirement in order to
  avoid having to make things ugly. Especially given that these scripts have
  a tendency to be copy/pasted into sister projects. CMake itself has very few
  dependencies so users of old Linux distros should be able to easily compile
  a supported version of CMake.
- On Windows CMake >= 3.15 is required for redistributable results.
- Cleaned out bits that were copied from GZDoom but not relevant to ZMusic.
2021-02-16 01:38:10 -05:00

43 lines
1.1 KiB
CMake

# - Find mpg123
# Find the native mpg123 includes and library
#
# MPG123_INCLUDE_DIR - where to find mpg123.h
# MPG123_LIBRARY - Path to mpg123 library.
# MPG123_FOUND - True if mpg123 found.
if(MPG123_INCLUDE_DIR AND MPG123_LIBRARY)
# Already in cache, be silent
set(MPG123_FIND_QUIETLY TRUE)
endif(MPG123_INCLUDE_DIR AND MPG123_LIBRARY)
if(NOT MPG123_INCLUDE_DIR)
find_path(MPG123_INCLUDE_DIR mpg123.h
PATHS "${MPG123_DIR}"
PATH_SUFFIXES include
)
endif()
if(NOT MPG123_LIBRARY)
find_library(MPG123_LIBRARY NAMES mpg123 mpg123-0
PATHS "${MPG123_DIR}"
PATH_SUFFIXES lib
)
endif()
# handle the QUIETLY and REQUIRED arguments and set MPG123_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MPG123 DEFAULT_MSG MPG123_LIBRARY MPG123_INCLUDE_DIR)
if(MPG123_FOUND)
add_library(mpg123 UNKNOWN IMPORTED)
set_target_properties(mpg123
PROPERTIES
IMPORTED_LOCATION "${MPG123_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MPG123_INCLUDE_DIR}"
)
# Legacy variables
set(MPG123_INCLUDE_DIRS ${MPG123_INCLUDE_DIR})
set(MPG123_LIBRARIES ${MPG123_LIBRARY})
endif()