Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

include(show-info)

if(SHERPA_ONNX_ENABLE_WASM)
# Enable it for debugging in case there is something wrong.
# string(APPEND CMAKE_CXX_FLAGS " -g4 -s ASSERTIONS=2 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=1 ")
Expand Down
87 changes: 87 additions & 0 deletions cmake/show-info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
message(STATUS "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")
message(STATUS "PROJECT_BINARY_DIR: ${PROJECT_BINARY_DIR}")
message(STATUS "CMake version: ${CMAKE_VERSION}")
message(STATUS "CMAKE_SYSTEM: ${CMAKE_SYSTEM}")
message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")

find_package(Git QUIET)
if(Git_FOUND)
execute_process(COMMAND
"${GIT_EXECUTABLE}" describe --always --abbrev=40
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE SHERPA_ONNX_GIT_SHA1
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(COMMAND
"${GIT_EXECUTABLE}" log -1 --format=%ad --date=local
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE SHERPA_ONNX_GIT_DATE
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "sherpa-onnx git sha1: ${SHERPA_ONNX_GIT_SHA1}")
message(STATUS "sherpa-onnx git date: ${SHERPA_ONNX_GIT_DATE}")
else()
message(WARNING "git is not found")
endif()

if(UNIX AND NOT APPLE)
execute_process(COMMAND
lsb_release -sd

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invoking lsb_release without checking availability may fail on systems where it's not installed. Use find_program to locate lsb_release and guard the execute_process call if not found.

Copilot uses AI. Check for mistakes.
OUTPUT_VARIABLE SHERPA_ONNX_OS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
elseif(APPLE)
execute_process(COMMAND
sw_vers -productName
OUTPUT_VARIABLE _product_name
OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(COMMAND
sw_vers -productVersion
OUTPUT_VARIABLE _product_version
OUTPUT_STRIP_TRAILING_WHITESPACE
)

execute_process(COMMAND
sw_vers -buildVersion
OUTPUT_VARIABLE _build_version
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(SHERPA_ONNX_OS "${_product_name} ${_product_version} ${_build_version}")
elseif(WIN32)
execute_process(COMMAND
wmic os get caption,version
OUTPUT_VARIABLE SHERPA_ONNX_OS_TWO_LINES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Now SHERPA_ONNX_OS_TWO_LINES contains something like
# Caption Version
# Microsoft Windows 10 Pro 10.0.18362
string(REPLACE "\n" ";" SHERPA_ONNX_OS_LIST ${SHERPA_ONNX_OS_TWO_LINES})

Copilot AI Jun 25, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WMIC output may include carriage returns (\r) on Windows. Consider stripping \r before splitting on \n to avoid residual \r characters in list elements.

Suggested change
string(REPLACE "\n" ";" SHERPA_ONNX_OS_LIST ${SHERPA_ONNX_OS_TWO_LINES})
string(REPLACE "\r" "" SHERPA_ONNX_OS_TWO_LINES_CLEANED ${SHERPA_ONNX_OS_TWO_LINES})
string(REPLACE "\n" ";" SHERPA_ONNX_OS_LIST ${SHERPA_ONNX_OS_TWO_LINES_CLEANED})

Copilot uses AI. Check for mistakes.
list(GET SHERPA_ONNX_OS_LIST 1 SHERPA_ONNX_OS)
else()
set(SHERPA_ONNX_OS "Unknown")
endif()
message(STATUS "OS used to build sherpa-onnx: ${SHERPA_ONNX_OS}")

if(CMAKE_CXX_COMPILER)
message(STATUS "C++ compiler: ${CMAKE_CXX_COMPILER}")
if(CMAKE_CXX_COMPILER_ID)
message(STATUS "C++ compiler ID: ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "C++ compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
endif()
endif()

if(CMAKE_C_COMPILER)
message(STATUS "C compiler: ${CMAKE_C_COMPILER}")
if(CMAKE_C_COMPILER_ID)
message(STATUS "C compiler ID: ${CMAKE_C_COMPILER_ID}")
message(STATUS "C compiler version: ${CMAKE_C_COMPILER_VERSION}")
endif()
endif()
Loading