-
-
Notifications
You must be signed in to change notification settings - Fork 988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor find vorbis file cmake #6671
Merged
Pentarctagon
merged 3 commits into
wesnoth:master
from
bencsikandrei:refactor_find_vorbis_file_cmake
May 2, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
@@ -1,96 +1,121 @@ | ||
# Locate VorbisFile | ||
# This module defines XXX_FOUND, XXX_INCLUDE_DIRS and XXX_LIBRARIES standard variables | ||
# | ||
# $VORBISDIR is an environment variable that would | ||
# correspond to the ./configure --prefix=$VORBISDIR | ||
# used in building Vorbis. | ||
#[=======================================================================[.rst: | ||
FindVorbisFile | ||
-------------- | ||
|
||
# Copied from | ||
# http://code.google.com/p/osgaudio/source/browse/trunk/CMakeModules/FindVorbisFile.cmake | ||
Find the VorbisFile includes and library. | ||
|
||
SET(VORBISFILE_SEARCH_PATHS | ||
Environment | ||
^^^^^^^^^^^ | ||
|
||
$ENV{VORBISDIR} is an environment variable that would correspond to | ||
the `./configure --prefix=$VORBISDIR` used in building Vorbis. | ||
|
||
|
||
IMPORTED Targets | ||
^^^^^^^^^^^^^^^^ | ||
|
||
This module defines the `IMPORTED` target ``VorbisFile::VorbisFile``, if | ||
VorbisFile has been found. | ||
|
||
Result Variables | ||
^^^^^^^^^^^^^^^^ | ||
|
||
This module defines the following variables: | ||
|
||
VORBISFILE_FOUND - True if VorbisFile found. | ||
VORBISFILE_INCLUDE_DIR - Where to find vorbis/vorbisfile.h. | ||
VORBISFILE_LIBRARIES - Libraries when using VorbisFile. | ||
|
||
Inspiration | ||
^^^^^^^^^^^ | ||
|
||
http://code.google.com/p/osgaudio/source/browse/trunk/CMakeModules/FindVorbisFile.cmake | ||
|
||
#]=======================================================================] | ||
|
||
set(VORBISFILE_SEARCH_PATHS | ||
~/Library/Frameworks | ||
/Library/Frameworks | ||
/usr/local | ||
/usr/local | ||
/usr | ||
/sw # Fink | ||
/opt/local # DarwinPorts | ||
/opt/csw # Blastwave | ||
/opt | ||
) | ||
|
||
SET(MSVC_YEAR_NAME) | ||
IF (MSVC_VERSION GREATER 1599) # >= 1600 | ||
SET(MSVC_YEAR_NAME VS2010) | ||
ELSEIF(MSVC_VERSION GREATER 1499) # >= 1500 | ||
SET(MSVC_YEAR_NAME VS2008) | ||
ELSEIF(MSVC_VERSION GREATER 1399) # >= 1400 | ||
SET(MSVC_YEAR_NAME VS2005) | ||
ELSEIF(MSVC_VERSION GREATER 1299) # >= 1300 | ||
SET(MSVC_YEAR_NAME VS2003) | ||
ELSEIF(MSVC_VERSION GREATER 1199) # >= 1200 | ||
SET(MSVC_YEAR_NAME VS6) | ||
ENDIF() | ||
|
||
FIND_PATH(VORBISFILE_INCLUDE_DIR | ||
find_path(VORBISFILE_INCLUDE_DIR | ||
NAMES vorbis/vorbisfile.h | ||
HINTS | ||
$ENV{VORBISFILEDIR} | ||
$ENV{VORBISFILE_PATH} | ||
$ENV{VORBISDIR} | ||
$ENV{VORBIS_PATH} | ||
$ENV{VORBISFILEDIR} | ||
$ENV{VORBISFILE_PATH} | ||
$ENV{VORBISDIR} | ||
$ENV{VORBIS_PATH} | ||
PATH_SUFFIXES include | ||
PATHS ${VORBISFILE_SEARCH_PATHS} | ||
) | ||
|
||
FIND_LIBRARY(VORBISFILE_LIBRARY | ||
find_library(VORBISFILE_LIBRARY | ||
NAMES vorbisfile libvorbisfile | ||
HINTS | ||
$ENV{VORBISFILEDIR} | ||
$ENV{VORBISFILE_PATH} | ||
$ENV{VORBISDIR} | ||
$ENV{VORBIS_PATH} | ||
PATH_SUFFIXES lib lib64 win32/VorbisFile_Dynamic_Release "Win32/${MSVC_YEAR_NAME}/x64/Release" "Win32/${MSVC_YEAR_NAME}/Win32/Release" | ||
$ENV{VORBISFILEDIR} | ||
$ENV{VORBISFILE_PATH} | ||
$ENV{VORBISDIR} | ||
$ENV{VORBIS_PATH} | ||
PATH_SUFFIXES | ||
lib | ||
lib64 | ||
PATHS ${VORBISFILE_SEARCH_PATHS} | ||
) | ||
|
||
# First search for d-suffixed libs | ||
FIND_LIBRARY(VORBISFILE_LIBRARY_DEBUG | ||
find_library(VORBISFILE_LIBRARY_DEBUG | ||
NAMES vorbisfiled vorbisfile_d libvorbisfiled libvorbisfile_d | ||
HINTS | ||
$ENV{VORBISFILEDIR} | ||
$ENV{VORBISFILE_PATH} | ||
$ENV{VORBISDIR} | ||
$ENV{VORBIS_PATH} | ||
PATH_SUFFIXES lib lib64 win32/VorbisFile_Dynamic_Debug "Win32/${MSVC_YEAR_NAME}/x64/Debug" "Win32/${MSVC_YEAR_NAME}/Win32/Debug" | ||
$ENV{VORBISFILEDIR} | ||
$ENV{VORBISFILE_PATH} | ||
$ENV{VORBISDIR} | ||
$ENV{VORBIS_PATH} | ||
PATH_SUFFIXES | ||
lib | ||
lib64 | ||
PATHS ${VORBISFILE_SEARCH_PATHS} | ||
) | ||
|
||
IF(NOT VORBISFILE_LIBRARY_DEBUG) | ||
if(NOT VORBISFILE_LIBRARY_DEBUG) | ||
# Then search for non suffixed libs if necessary, but only in debug dirs | ||
FIND_LIBRARY(VORBISFILE_LIBRARY_DEBUG | ||
find_library(VORBISFILE_LIBRARY_DEBUG | ||
NAMES vorbisfile libvorbisfile | ||
HINTS | ||
$ENV{VORBISFILEDIR} | ||
$ENV{VORBISFILE_PATH} | ||
$ENV{VORBISDIR} | ||
$ENV{VORBIS_PATH} | ||
PATH_SUFFIXES win32/VorbisFile_Dynamic_Debug "Win32/${MSVC_YEAR_NAME}/x64/Debug" "Win32/${MSVC_YEAR_NAME}/Win32/Debug" | ||
$ENV{VORBISFILEDIR} | ||
$ENV{VORBISFILE_PATH} | ||
$ENV{VORBISDIR} | ||
$ENV{VORBIS_PATH} | ||
PATHS ${VORBISFILE_SEARCH_PATHS} | ||
) | ||
ENDIF() | ||
|
||
endif() | ||
|
||
IF(VORBISFILE_LIBRARY) | ||
IF(VORBISFILE_LIBRARY_DEBUG) | ||
SET(VORBISFILE_LIBRARIES optimized "${VORBISFILE_LIBRARY}" debug "${VORBISFILE_LIBRARY_DEBUG}") | ||
ELSE() | ||
SET(VORBISFILE_LIBRARIES "${VORBISFILE_LIBRARY}") # Could add "general" keyword, but it is optional | ||
ENDIF() | ||
ENDIF() | ||
if(VORBISFILE_LIBRARY) | ||
if(VORBISFILE_LIBRARY_DEBUG) | ||
set(VORBISFILE_LIBRARIES optimized "${VORBISFILE_LIBRARY}" debug "${VORBISFILE_LIBRARY_DEBUG}") | ||
else() | ||
set(VORBISFILE_LIBRARIES "${VORBISFILE_LIBRARY}") # Could add "general" keyword, but it is optional | ||
endif() | ||
endif() | ||
|
||
# handle the QUIETLY and REQUIRED arguments and set XXX_FOUND to TRUE if all listed variables are TRUE | ||
INCLUDE(FindPackageHandleStandardArgs) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(VorbisFile DEFAULT_MSG VORBISFILE_LIBRARIES VORBISFILE_INCLUDE_DIR) | ||
# handle the QUIETLY and REQUIRED arguments and set VORBISFILE_FOUND to TRUE if all listed variables are TRUE | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(VorbisFile DEFAULT_MSG VORBISFILE_LIBRARIES VORBISFILE_INCLUDE_DIR) | ||
|
||
mark_as_advanced(VORBISFILE_INCLUDE_DIR VORBISFILE_LIBRARIES VORBISFILE_LIBRARY VORBISFILE_LIBRARY_DEBUG) | ||
|
||
if(VORBISFILE_FOUND AND (NOT TARGET VorbisFile::VorbisFile)) | ||
add_library(VorbisFile::VorbisFile UNKNOWN IMPORTED) | ||
set_target_properties(VorbisFile::VorbisFile PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${VORBISFILE_INCLUDE_DIR}") | ||
if(VORBISFILE_LIBRARY_DEBUG) | ||
set_target_properties(VorbisFile::VorbisFile PROPERTIES IMPORTED_LOCATION_DEBUG "${VORBISFILE_LIBRARY_DEBUG}") | ||
set_target_properties(VorbisFile::VorbisFile PROPERTIES IMPORTED_LOCATION_RELEASE "${VORBISFILE_LIBRARY}") | ||
else() | ||
set_target_properties(VorbisFile::VorbisFile PROPERTIES IMPORTED_LOCATION "${VORBISFILE_LIBRARY}") | ||
endif() | ||
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces -> tabs