Enhance find_library_create_target() cmake macro
As today, the find_library_create_target() cmake macro https://github.com/NVIDIA/TensorRT-LLM/blob/3e035f221976a353f8b88a2597aa9f0d286665c7/cpp/cmake/modules/find_library_create_target.cmake
blindly continues even if the lib is not found, adding "{lib}LIB_PATH-NOTFOUND" to the target and making the build failing anyway later with non obvious reasons, eg
CMake Error at CMakeLists.txt:718 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
Would you mind if I just add in find_library_create_target() a sanity test such as:
...
find_library(${lib}_LIB_PATH ${lib})
message(STATUS "Library that was found ${${lib}_LIB_PATH}")
if (${${lib}_LIB_PATH} STREQUAL "${lib}_LIB_PATH-NOTFOUND")
message(FATAL_ERROR "${lib} not found. hints: ${hints}")
endif()
?
Who can help?
@byshiue
Information
- [ ] The official example scripts
- [ ] My own modified scripts
Tasks
- [ ] An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - [ ] My own task or dataset (give details below)
Reproduction
1 cd TensorRT-LLM 2 cd cpp 3 cd build 4 cmake .. 5 if a lib is not installed/foundable, see (non obvious) error
CMake Error at CMakeLists.txt:718 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
Expected behavior
cmake to early fails with proper error message if a dep is not found: eg "library X not found".
actual behavior
CMake Error at CMakeLists.txt:718 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
CMake Error at CMakeLists.txt:720 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
CMake Error at CMakeLists.txt:718 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
CMake Error at CMakeLists.txt:720 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
CMake Error at CMakeLists.txt:718 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
additional notes
Note: we are not interested by the prebuilt/docker build, must build ourself manually for reasons not explainable publicly here.
@WilliamTambellini
Thanks for reporting this issue, William!
For sure your are more than welcome to contribute the fix.
@niukuo or @tongyuantongyu can help review your MR when it is ready.
cc @chzblych @zeroepoch for vis also.
Thanks June
Tks @juney-nvidia https://github.com/NVIDIA/TensorRT-LLM/pull/3113