Skip to content
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

[audio] mv paddlespeech/audio to paddleaudio #2706

Merged
merged 126 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
86ac7b8
Add sox io.
KPatr1ck Apr 24, 2022
eead92a
Add sox io.
KPatr1ck Apr 26, 2022
ee4d7bb
add kaldi fbank to paddleaudio
SmileGoat Jun 17, 2022
c072f35
rm kaldi_frontend_main
SmileGoat Jun 17, 2022
d46cee6
Merge branch 'develop' of github.com:SmileGoat/PaddleSpeech into audi…
SmileGoat Jun 17, 2022
0550d09
Merge branch 'audio' into io
zh794390558 Jun 18, 2022
0756709
update setup
zh794390558 Jun 18, 2022
e1e1dd6
Merge pull request #2053 from zh794390558/io
zh794390558 Jun 18, 2022
f94cb48
rename to audio
zh794390558 Jun 18, 2022
b7e908a
merge audio
SmileGoat Jun 19, 2022
602e18e
put audio into paddlespeech
zh794390558 Jun 20, 2022
24692eb
fix header error
SmileGoat Jun 21, 2022
1480b55
Merge branch 'audio' of github.com:SmileGoat/PaddleSpeech into audio_dev
SmileGoat Jun 21, 2022
38b79b8
mv kaldi feature to paddlespeech/audio
SmileGoat Jun 21, 2022
ee24df1
clean code
SmileGoat Jun 21, 2022
0e27088
clean
SmileGoat Jun 21, 2022
a81e281
clean code
SmileGoat Jun 21, 2022
e17b754
Merge pull request #2051 from SmileGoat/audio_dev
zh794390558 Jun 21, 2022
9762b4a
fix fst/type.h error
zh794390558 Jun 28, 2022
59f67db
paddleaudio as extenstion
zh794390558 Jun 28, 2022
532aeb8
add cpplint
zh794390558 Jun 28, 2022
fb1300f
format
zh794390558 Jun 28, 2022
fb7cbb3
Merge pull request #2088 from zh794390558/cpplint
zh794390558 Jun 28, 2022
a3911ab
Merge pull request #2089 from zh794390558/cpplint
zh794390558 Jun 28, 2022
aa2aad7
add cmake summary
zh794390558 Jun 28, 2022
d63895f
audio with kaldi
zh794390558 Jun 29, 2022
52477a1
sox can build
zh794390558 Jun 29, 2022
357a364
pybind kaldi can make
zh794390558 Jun 29, 2022
9b577b4
fix undefine symbol
zh794390558 Jun 29, 2022
3dcf923
Merge pull request #2094 from zh794390558/kaldi
SmileGoat Jun 29, 2022
f42c0cc
format code
zh794390558 Jun 29, 2022
da6692c
Merge pull request #2102 from zh794390558/format
zh794390558 Jun 29, 2022
f55c457
more backend api
zh794390558 Jun 30, 2022
5d34b7f
Merge pull request #2108 from zh794390558/api
zh794390558 Jun 30, 2022
ad3b1ab
fix ext so not in build/lib.xxx
zh794390558 Jul 1, 2022
4bcecc1
format
zh794390558 Jul 1, 2022
cc277d0
add backends
zh794390558 Jul 1, 2022
3301c53
add pitch
SmileGoat Jul 5, 2022
a16a044
add pybind.cpp
SmileGoat Jul 5, 2022
7ae36b2
add kaldi feature pitch
SmileGoat Jul 7, 2022
e52e061
add unittest
SmileGoat Jul 7, 2022
ddc1619
mv data to testdata
SmileGoat Jul 12, 2022
09d9b61
fix copyright && refactor kaldi_feature
SmileGoat Jul 13, 2022
3bb904b
Merge pull request #2119 from SmileGoat/audio_add_pitch
zh794390558 Jul 13, 2022
a7181bc
fix pybind11/numpy.h not found
zh794390558 Jul 15, 2022
84e5bc0
format
zh794390558 Jul 15, 2022
a2e8b76
Merge pull request #2157 from zh794390558/py
SmileGoat Jul 15, 2022
cffe555
make loading _paddleaudio.so work
SmileGoat Jul 18, 2022
38c55e4
merge audio
SmileGoat Jul 18, 2022
76b7616
fix _paddleaudio import
SmileGoat Jul 19, 2022
59276cf
Merge pull request #2164 from SmileGoat/add_pitch2
zh794390558 Jul 19, 2022
98300b8
add sox load_audio&&effets
SmileGoat Jul 27, 2022
7f5e0e9
Merge branch 'audio' of github.com:SmileGoat/PaddleSpeech into add_pi…
SmileGoat Jul 27, 2022
c938a46
slove link error
SmileGoat Jul 29, 2022
5e30f92
clean code
SmileGoat Jul 29, 2022
c37782c
add more pybind funciton
SmileGoat Jul 29, 2022
63b4494
fix optional bind, add sox_effects
SmileGoat Aug 1, 2022
59d82c0
add test_load.py
SmileGoat Aug 2, 2022
d264118
add save test&&fix effects_chain bug
SmileGoat Aug 9, 2022
22a5344
fix save && effect test
SmileGoat Aug 12, 2022
59edc64
add copyrigh
SmileGoat Aug 15, 2022
7abfad8
fix typo
SmileGoat Aug 15, 2022
a55592f
modify info test
SmileGoat Aug 15, 2022
4dc5f25
Merge pull request #2195 from SmileGoat/add_pitch2
zh794390558 Aug 16, 2022
b0fd327
merge develop
SmileGoat Aug 16, 2022
5c72e8c
Merge pull request #2253 from SmileGoat/add_pitch2
zh794390558 Aug 16, 2022
91ce0d8
add soundfile backend
SmileGoat Aug 16, 2022
dc6f8ff
Merge pull request #2257 from SmileGoat/add_pitch2
zh794390558 Aug 16, 2022
622d388
make soundfile compatible
SmileGoat Aug 17, 2022
cfd32d0
Merge pull request #2262 from SmileGoat/add_pitch2
zh794390558 Aug 17, 2022
bc3ded3
fix typo
SmileGoat Sep 14, 2022
adcf6e0
Merge pull request #2382 from SmileGoat/ps_audio_dev
SmileGoat Sep 14, 2022
4df081b
split paddleaudio
SmileGoat Sep 15, 2022
7261d86
add test & benchmark
SmileGoat Sep 15, 2022
12a3d6b
Merge pull request #2388 from SmileGoat/split_paddle_audio
zh794390558 Sep 16, 2022
1131799
Merge branch 'develop' into audio_dev_merge
zh794390558 Sep 16, 2022
57463b6
Merge pull request #2400 from zh794390558/audio_dev_merge
SmileGoat Sep 17, 2022
b336ccf
update audio api in apps
SmileGoat Sep 18, 2022
79f1431
Merge pull request #2414 from SmileGoat/update_audio_api_in_apps
zh794390558 Sep 20, 2022
d94996f
format audio
SmileGoat Sep 20, 2022
bc893c1
Merge pull request #2417 from SmileGoat/update_audio_api_in_apps
zh794390558 Sep 20, 2022
13ee17c
clean paddlespeech/audio
SmileGoat Sep 20, 2022
7cfdbe0
del audio tests
SmileGoat Sep 20, 2022
25f2a2f
Merge pull request #2420 from SmileGoat/update_audio_api_in_apps
zh794390558 Sep 20, 2022
f81fe25
update docs of audio
SmileGoat Sep 20, 2022
3169995
Merge pull request #2423 from SmileGoat/update_audio_api_in_apps
zh794390558 Sep 20, 2022
5819770
test tess dataset&& esc50 dataset by paddle2.4
SmileGoat Sep 27, 2022
bf3eb49
add different tess feature config
SmileGoat Sep 29, 2022
382503f
update READMe
SmileGoat Sep 29, 2022
a9f9188
fix punc in readme
SmileGoat Sep 29, 2022
62fe3d4
Merge pull request #2482 from SmileGoat/check_ec50
yt605155624 Sep 29, 2022
0ffcd47
add sox, kaldi feature to paddleaudio && make it work on mac, windows…
SmileGoat Nov 21, 2022
0d76ff5
add version && link fortran.dylib in mac (#2684)
SmileGoat Nov 25, 2022
6ceeb6e
merge develop
SmileGoat Nov 28, 2022
ea5483d
benchmark:replace paddleaudio.layer.feature with features in paddle
SmileGoat Nov 29, 2022
2c57bc7
make mac audio compile stable
SmileGoat Nov 29, 2022
a46898e
rm python lib in paddleaudio
SmileGoat Nov 30, 2022
4b58c83
fix padddlespeech setup.py
SmileGoat Nov 30, 2022
9d05295
patch
SmileGoat Nov 30, 2022
c2ab73c
rm pybind in external
SmileGoat Nov 30, 2022
488a5c2
format
SmileGoat Dec 2, 2022
ee2f648
exclude cpplint pybind file
SmileGoat Dec 2, 2022
860ea8a
ffix paddleaudio api
yt605155624 Dec 2, 2022
c571f38
ffix for pre-commit
yt605155624 Dec 2, 2022
71bca8f
fix python vrsion
yt605155624 Dec 2, 2022
b14d55b
Update requirements.txt
yt605155624 Dec 2, 2022
3be5fa4
Update requirements.txt
yt605155624 Dec 2, 2022
70ea205
Update requirements.txt
yt605155624 Dec 2, 2022
f823f6d
Update .readthedocs.yml
yt605155624 Dec 2, 2022
8d467d9
Delete setup.rst
yt605155624 Dec 2, 2022
2c5bbc2
Update modules.rst
yt605155624 Dec 2, 2022
d3229a4
make mac compile stable
SmileGoat Dec 4, 2022
bffd838
fiox setup.py
SmileGoat Dec 4, 2022
fff8692
rm libgcc.dylib
SmileGoat Dec 4, 2022
f7b0ba8
set python>=3.6
SmileGoat Dec 5, 2022
9a553e6
Merge branch 'develop' of github.com:SmileGoat/PaddleSpeech into audi…
SmileGoat Dec 5, 2022
4597f5f
fix coding style
SmileGoat Dec 6, 2022
6ebc712
Merge branch 'audio_merge_dev' into add_api
SmileGoat Dec 7, 2022
76e7bcc
Merge pull request #1 from yt605155624/add_api
SmileGoat Dec 7, 2022
d8bf8c6
fix precommit
yt605155624 Dec 7, 2022
384f978
Merge pull request #2 from yt605155624/add_api
SmileGoat Dec 7, 2022
d472217
linux:add libfortran to lib
SmileGoat Dec 7, 2022
b242393
windows:close build cpp extern in paddleaudio
SmileGoat Dec 8, 2022
7513c7d
fix format, add warning when load libpaddleaudio fail
SmileGoat Dec 8, 2022
1079aaf
catch _paddleaudio crush
SmileGoat Dec 8, 2022
a8d62e9
add readme, test=doc
SmileGoat Dec 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
build
*output/

audio/dist/
audio/fc_patch/

docs/build/
docs/topic/ctc/warp-ctc/

Expand All @@ -42,6 +45,7 @@ tools/python-soundfile/
tools/onnx
tools/onnxruntime
tools/Paddle2ONNX
tools/onnx-simplifier/

speechx/fc_patch/

Expand Down
27 changes: 14 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ repos:
rev: v0.16.0
hooks:
- id: yapf
files: \.py$
exclude: (?=third_party).*(\.py)$
name: yapf
language: python
entry: yapf
args: [-i, -vv]
types: [python]
exclude: (?=speechx/speechx/kaldi|audio/paddleaudio/src|third_party).*(\.cpp|\.cc|\.h\.hpp|\.py)$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: a11d9314b22d8f8c7556443875b731ef05965464
hooks:
Expand All @@ -30,7 +35,8 @@ repos:
- --ignore=E501,E228,E226,E261,E266,E128,E402,W503
- --builtins=G,request
- --jobs=1
exclude: (?=third_party).*(\.py)$
exclude: (?=speechx/speechx/kaldi|audio/paddleaudio/src|third_party).*(\.cpp|\.cc|\.h\.hpp|\.py)$

- repo : https://github.com/Lucas-C/pre-commit-hooks
rev: v1.0.1
hooks:
Expand All @@ -42,30 +48,25 @@ repos:
files: \.md$
- id: remove-tabs
files: \.md$

- repo: local
hooks:
- id: clang-format
name: clang-format
description: Format files with ClangFormat
entry: bash .pre-commit-hooks/clang-format.hook -i
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$
exclude: (?=speechx/speechx/kaldi|speechx/patch|speechx/tools/fstbin|speechx/tools/lmbin|third_party/ctc_decoders).*(\.cpp|\.cc|\.h|\.py)$
#- id: copyright_checker
# name: copyright_checker
# entry: python .pre-commit-hooks/copyright-check.hook
# language: system
# files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|py)$
# exclude: (?=third_party|pypinyin|speechx/speechx/kaldi|speechx/patch|speechx/tools/fstbin|speechx/tools/lmbin).*(\.cpp|\.cc|\.h|\.py)$
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
exclude: (?=speechx/speechx/kaldi|audio/paddleaudio/src|speechx/patch|speechx/tools/fstbin|speechx/tools/lmbin|third_party/ctc_decoders).*(\.cpp|\.cc|\.h|\.hpp|\.py)$
- id: cpplint
name: cpplint
description: Static code analysis of C/C++ files
language: python
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
exclude: (?=speechx/speechx/kaldi|speechx/patch|speechx/tools/fstbin|speechx/tools/lmbin|third_party/ctc_decoders).*(\.cpp|\.cc|\.h|\.py)$
exclude: (?=speechx/speechx/kaldi|audio/paddleaudio/src|speechx/patch|speechx/tools/fstbin|speechx/tools/lmbin|third_party/ctc_decoders).*(\.cpp|\.cc|\.h|\.hpp|\.py)$
entry: cpplint --filter=-build,-whitespace,+whitespace/comma,-whitespace/indent
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.4.0
hooks:
- id: reorder-python-imports
exclude: (?=third_party).*(\.py)$
exclude: (?=speechx/speechx/kaldi|audio/paddleaudio/src|speechx/patch|speechx/tools/fstbin|speechx/tools/lmbin|third_party/ctc_decoders).*(\.cpp|\.cc|\.h\.hpp|\.py)$
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ python:
- requirements: docs/requirements.txt
- method: setuptools
path: .
system_packages: true
system_packages: true
70 changes: 70 additions & 0 deletions audio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)

# Use compiler ID "AppleClang" instead of "Clang" for XCode.
# Not setting this sometimes makes XCode C compiler gets detected as "Clang",
# even when the C++ one is detected as "AppleClang".
cmake_policy(SET CMP0010 NEW)
cmake_policy(SET CMP0025 NEW)

# Suppress warning flags in default MSVC configuration. It's not
# mandatory that we do this (and we don't if cmake is old), but it's
# nice when it's possible, and it's possible on our Windows configs.
if(NOT CMAKE_VERSION VERSION_LESS 3.15.0)
cmake_policy(SET CMP0092 NEW)
endif()

project(paddleaudio)

# check and set CMAKE_CXX_STANDARD
string(FIND "${CMAKE_CXX_FLAGS}" "-std=c++" env_cxx_standard)
if(env_cxx_standard GREATER -1)
message(
WARNING "C++ standard version definition detected in environment variable."
"paddleaudio requires -std=c++14. Please remove -std=c++ settings in your environment.")
endif()


set(CMAKE_CXX_STANDARD 14)
set(CMAKE_C_STANDARD 11)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_VERBOSE_MAKEFILE ON)

# Options
option(BUILD_SOX "Build libsox statically" ON)
option(BUILD_MAD "Enable libmad" ON)
option(BUILD_KALDI "Build kaldi statically" ON)
option(BUILD_PADDLEAUDIO_PYTHON_EXTENSION "Build Python extension" ON)


# cmake
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake;${PROJECT_SOURCE_DIR}/cmake/external")

if (NOT MSVC)
find_package(GFortranLibs REQUIRED)
include(FortranCInterface)
include(FindGFortranLibs REQUIRED)
endif()

# fc_patch dir
set(FETCHCONTENT_QUIET off)
get_filename_component(fc_patch "fc_patch" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
set(FETCHCONTENT_BASE_DIR ${fc_patch})
set(THIRD_PARTY_PATH ${fc_patch})

include(openblas)

set(PYBIND11_PYTHON_VERSION ${PY_VERSION})
include(cmake/pybind.cmake)
include_directories(${PYTHON_INCLUDE_DIR})

# packages
find_package(Python3 COMPONENTS Interpreter Development)

# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -O0 -Wall -g")
add_subdirectory(paddleaudio)

# Summary
include(cmake/summary.cmake)
onnx_print_configuration_summary()
35 changes: 35 additions & 0 deletions audio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# PaddleAudio

安装方式: pip install paddleaudio

目前支持的平台:Linux:

## Environment

## Build wheel

Linux test build whl environment:
* docker - `registry.baidubce.com/paddlepaddle/paddle:2.2.2`
* os - Ubuntu 16.04.7 LTS
* gcc/g++/gfortran - 8.2.0
* cmake - 3.18.0 (need install)

* [How to Install Docker](https://docs.docker.com/engine/install/)
* [A Docker Tutorial for Beginners](https://docker-curriculum.com/)

1. First to launch docker container.

```
docker run --privileged --net=host --ipc=host -it --rm -v $PWD:/workspace --name=dev registry.baidubce.com/paddlepaddle/paddle:2.2.2 /bin/bash
```
2. python setup.py bdist_wheel

MAC:test build whl envrioment:
* os
* gcc/g++/gfortran 12.2.0
* cpu Intel Xeon E5 x86_64


Windows:
not support: paddleaudio C++ extension lib (sox io, kaldi native fbank)
python setup.py bdist_wheel
153 changes: 153 additions & 0 deletions audio/cmake/FindGFortranLibs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#.rst:
# FindGFortranLibs
# --------
# https://github.com/Argonne-National-Laboratory/PIPS/blob/master/cmake/Modules/FindGFortranLibs.cmake
# https://enccs.github.io/cmake-workshop/cxx-fortran/
#
# Find gcc Fortran compiler & library paths
#
# The module defines the following variables:
#
# ::
#
#
# GFORTRANLIBS_FOUND - true if system has gfortran
# LIBGFORTRAN_LIBRARIES - path to libgfortran
# LIBQUADMATH_LIBRARIES - path to libquadmath
# GFORTRAN_LIBARIES_DIR - directory containing libgfortran, libquadmath
# GFORTRAN_INCLUDE_DIR - directory containing gfortran/gcc headers
# LIBGOMP_LIBRARIES - path to libgomp
# LIBGOMP_INCLUDE_DIR - directory containing omp.h header
# GFORTRAN_VERSION_STRING - version of gfortran found
#
set(CMAKE_REQUIRED_QUIET ${LIBIOMP_FIND_QUIETLY})

if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Looking for gfortran related libraries...")
endif()

enable_language(Fortran)
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")

# Basically, call "gfortran -v" to dump compiler info to the string
# GFORTRAN_VERBOSE_STR, which will be used to get necessary paths
message(STATUS "Extracting library and header information by calling 'gfortran -v'...")
execute_process(COMMAND "${CMAKE_Fortran_COMPILER}" "-v" ERROR_VARIABLE
GFORTRAN_VERBOSE_STR RESULT_VARIABLE FLAG)

# For debugging
message(STATUS "'gfortran -v' returned:")
message(STATUS "${GFORTRAN_VERBOSE_STR}")

# Detect gfortran version
string(REGEX MATCH "gcc version [^\t\n ]+" GFORTRAN_VER_STR "${GFORTRAN_VERBOSE_STR}")
string(REGEX REPLACE "gcc version ([^\t\n ]+)" "\\1" GFORTRAN_VERSION_STRING "${GFORTRAN_VER_STR}")
message(STATUS "Detected gfortran version ${GFORTRAN_VERSION_STRING}")
unset(GFORTRAN_VER_STR)

set(MATCH_REGEX "[^\t\n ]+[\t\n ]+")
set(REPLACE_REGEX "([^\t\n ]+)")

# Find architecture for compiler
string(REGEX MATCH "Target: [^\t\n ]+"
GFORTRAN_ARCH_STR "${GFORTRAN_VERBOSE_STR}")
message(STATUS "Architecture string: ${GFORTRAN_ARCH_STR}")
string(REGEX REPLACE "Target: ([^\t\n ]+)" "\\1"
GFORTRAN_ARCH "${GFORTRAN_ARCH_STR}")
message(STATUS "Detected gfortran architecture: ${GFORTRAN_ARCH}")
unset(GFORTRAN_ARCH_STR)

# Find install prefix, if it exists; if not, use default
string(REGEX MATCH "--prefix=[^\t\n ]+[\t\n ]+"
GFORTRAN_PREFIX_STR "${GFORTRAN_VERBOSE_STR}")
if(NOT GFORTRAN_PREFIX_STR)
message(STATUS "Detected default gfortran prefix")
set(GFORTRAN_PREFIX_DIR "/usr/local") # default prefix for gcc install
else()
string(REGEX REPLACE "--prefix=([^\t\n ]+)" "\\1"
GFORTRAN_PREFIX_DIR "${GFORTRAN_PREFIX_STR}")
endif()
message(STATUS "Detected gfortran prefix: ${GFORTRAN_PREFIX_DIR}")
unset(GFORTRAN_PREFIX_STR)

# Find install exec-prefix, if it exists; if not, use default
string(REGEX MATCH "--exec-prefix=[^\t\n ]+[\t\n ]+" "\\1"
GFORTRAN_EXEC_PREFIX_STR "${GFORTRAN_VERBOSE_STR}")
if(NOT GFORTRAN_EXEC_PREFIX_STR)
message(STATUS "Detected default gfortran exec-prefix")
set(GFORTRAN_EXEC_PREFIX_DIR "${GFORTRAN_PREFIX_DIR}")
else()
string(REGEX REPLACE "--exec-prefix=([^\t\n ]+)" "\\1"
GFORTRAN_EXEC_PREFIX_DIR "${GFORTRAN_EXEC_PREFIX_STR}")
endif()
message(STATUS "Detected gfortran exec-prefix: ${GFORTRAN_EXEC_PREFIX_DIR}")
UNSET(GFORTRAN_EXEC_PREFIX_STR)

# Find library directory and include directory, if library directory specified
string(REGEX MATCH "--libdir=[^\t\n ]+"
GFORTRAN_LIB_DIR_STR "${GFORTRAN_VERBOSE_STR}")
if(NOT GFORTRAN_LIB_DIR_STR)
message(STATUS "Found --libdir flag -- not found")
message(STATUS "Using default gfortran library & include directory paths")
string(STRIP ${GFORTRAN_PREFIX_DIR} TMPLIBDIR)
set(GFORTRAN_LIBRARIES_DIR "${TMPLIBDIR}/lib64")
set(GFORTRAN_INCLUDE_DIR "${TMPLIBDIR}/include")
else()
message(STATUS "Found --libdir flag -- yes")
string(REGEX REPLACE "--libdir=([^\t\n ]+)" "\\1"
GFORTRAN_LIBRARIES_DIR "${GFORTRAN_LIB_DIR_STR}")
string(CONCAT GFORTRAN_INCLUDE_DIR "${GFORTRAN_LIBRARIES_DIR}" "/gcc/" "${GFORTRAN_ARCH}" "/" "${GFORTRAN_VERSION_STRING}" "/include")
endif()
message(STATUS "gfortran libraries path: ${GFORTRAN_LIBRARIES_DIR}")
message(STATUS "gfortran include path dir: ${GFORTRAN_INCLUDE_DIR}")
unset(GFORTRAN_LIB_DIR_STR)

# There are lots of other build options for gcc & gfortran. For now, the
# options implemented above should cover a lot of common use cases.

# Clean up be deleting the output string from "gfortran -v"
unset(GFORTRAN_VERBOSE_STR)

# Find paths for libgfortran, libquadmath, libgomp
# libgomp needed for OpenMP support without Clang
find_library(LIBGFORTRAN_LIBRARIES NAMES gfortran libgfortran
HINTS ${GFORTRAN_LIBRARIES_DIR})
find_library(LIBQUADMATH_LIBRARIES NAMES quadmath libquadmath
HINTS ${GFORTRAN_LIBRARIES_DIR})
find_library(LIBGOMP_LIBRARIES NAMES gomp libgomp
HINTS ${GFORTRAN_LIBRARIES_DIR})

# Find OpenMP headers
find_path(LIBGOMP_INCLUDE_DIR NAMES omp.h HINTS ${GFORTRAN_INCLUDE_DIR})

else()
message(STATUS "CMAKE_Fortran_COMPILER_ID does not match 'GNU'!")
endif()

include(FindPackageHandleStandardArgs)

# Required: libgfortran, libquadmath, path for gfortran libraries
# Optional: libgomp, path for OpenMP headers, path for gcc/gfortran headers
find_package_handle_standard_args(GFortranLibs
REQUIRED_VARS LIBGFORTRAN_LIBRARIES LIBQUADMATH_LIBRARIES GFORTRAN_LIBRARIES_DIR
VERSION_VAR GFORTRAN_VERSION_STRING)

if(GFORTRANLIBS_FOUND)
message(STATUS "Looking for gfortran libraries -- found")
message(STATUS "gfortran version: ${GFORTRAN_VERSION_STRING}")
else()
message(STATUS "Looking for gfortran libraries -- not found")
endif()

mark_as_advanced(LIBGFORTRAN_LIBRARIES LIBQUADMATH_LIBRARIES
LIBGOMP_LIBRARIES LIBGOMP_INCLUDE_DIR
GFORTRAN_LIBRARIES_DIR GFORTRAN_INCLUDE_DIR)
# FindGFortranLIBS.cmake ends here


message(STATUS LIBGFORTRAN_LIBRARIES= ${LIBGFORTRAN_LIBRARIES})
message(STATUS LIBQUADMATH_LIBRARIES= ${LIBQUADMATH_LIBRARIES})
message(STATUS LIBGOMP_LIBRARIES= ${LIBGOMP_LIBRARIES})
message(STATUS LIBGOMP_INCLUDE_DIR= ${LIBGOMP_INCLUDE_DIR})
message(STATUS GFORTRAN_LIBRARIES_DIR= ${GFORTRAN_LIBRARIES_DIR})
message(STATUS GFORTRAN_INCLUDE_DIR= ${GFORTRAN_INCLUDE_DIR})
Loading