I am trying to link against a system library: /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
, when I have this CMakeLists.txt
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(all)
find_library(TCMALLOC_LIB NAMES tcmalloc)
if(TCMALLOC_LIB)
message("Found TCMALLOC_LIB: ${TCMALLOC_LIB}")
else()
message(FATAL_ERROR "TCMALLOC_LIB library not found")
endif()
(also tried find_library(TCMALLOC_LIB tcmalloc)
)
I get
CMake Error at CMakeLists.txt:13 (message):
TCMALLOC_LIB library not found
While, if I have
find_library(TCMALLOC_LIB NAMES libtcmalloc.so.4)
everything is fine: Found TCMALLOC_LIB: /usr/lib/x86_64-linux-gnu/libtcmalloc.so.4
Am I doing something wrong? Why do I need to specify filename precisely? How can I debug find_library
?