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})
if(SHERPA_ONNX_ENABLE_PYTHON)
message(STATUS "PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
@@ -648,7 +648,7 @@ endforeach()
# For clang-tidy
add_custom_target(
clang-tidy-check
clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json --config-file ${CMAKE_SOURCE_DIR}/.clang-tidy ${srcs_to_check}
clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json --config-file ${PROJECT_SOURCE_DIR}/.clang-tidy ${srcs_to_check}
DEPENDS ${sources})
add_custom_target(check DEPENDS clang-tidy-check)