Allow building repository as CMake subdirectory (#2059)

* Use PROJECT_SOURCE_DIR rather than CMAKE_SOURCE_DIR to allow building as subdirectory

* Also use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR in c/cxx api examples

* Only build examples by default when not building as subdirectory

* Do not suggest building binaries either

---------

Co-authored-by: user <user@mail.tld>
This commit is contained in:
niansa/tuxifan
2025-03-28 23:27:59 +01:00
committed by GitHub
parent a5dd0cdfc3
commit 9d23606ee6
7 changed files with 19 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR})
set(srcs
audio-tagging.cc
@@ -51,7 +51,7 @@ set(srcs
wave-writer.cc
)
if(SHERPA_ONNX_HAS_ALSA)
list(APPEND srcs ${CMAKE_SOURCE_DIR}/sherpa-onnx/csrc/alsa.cc alsa.cc)
list(APPEND srcs ${PROJECT_SOURCE_DIR}/sherpa-onnx/csrc/alsa.cc alsa.cc)
else()
list(APPEND srcs faked-alsa.cc)
endif()