Below is a minimal CMakeLists.txt that imports an external library

cmake_minimum_required(VERSION 3.10)
project(external_import)

add_library(external_library STATIC IMPORTED)
set_target_properties(external_library PROPERTIES IMPORTED_LOCATION /path/to/external/library.a)

add_executable(executable main.cc)
target_link_libraries(executable external_library)

A few things to note

  • the external library can be either STATIC or SHARED. Must provide the corresponding STATIC/SHARED library file
  • the library file path after IMPORTED_LOCATION cannot be a relative path. It can be referenced with ${CMAKE_SOURCE_DIR} or can be an absolute path.