cmake导入静态库,动态库,header only库

  • Post author:
  • Post category:其他


cmake_minimum_required(VERSION 3.5)

project (testmath)

#静态库

add_library(libmyadd STATIC IMPORTED)

set_target_properties(libmyadd PROPERTIES

INTERFACE_INCLUDE_DIRECTORIES “/opt/work/myadd”

IMPORTED_LOCATION “/opt/work/myadd/libmyadd.a”

)

#动态库

add_library(libmysub SHARED IMPORTED)

set_target_properties(libmysub PROPERTIES

INTERFACE_INCLUDE_DIRECTORIES “/opt/work/mysub”

IMPORTED_LOCATION “/opt/work/mysub/libmysub.so”

)

#header only 库

add_library(libhadd INTERFACE IMPORTED)

set_target_properties(libhadd PROPERTIES

INTERFACE_INCLUDE_DIRECTORIES “/opt/work/headeronlyadd”

)


add_executable(testmath testmath.cpp)

target_link_libraries(testmath

PRIVATE  libmyadd

PRIVATE  libmysub

PRIVATE  libhadd

)



版权声明:本文为caohongfei881原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。