CMake添加第三方库

Clion CMake中添加第三方依赖库

cmake_minimum_required(VERSION 3.14)
project(untitled C)

set(CMAKE_C_STANDARD 99)

set(INC_DIR /usr/local/include/)
set(LINK_DIR /usr/local/lib)

include_directories(${INC_DIR}) # 头文件目录
link_directories(${LINK_DIR}) # 库目录
link_libraries(pcre) # 要包含的库

add_executable(untitled t.c)

target_link_libraries(untitled pcre) # 将库链接到程序


 

 

 

展开阅读全文