cmake - 让子目录使用自己的Makefile

Ven*_*tta 9 c++ linux makefile cmake

我有一个主要使用CMake的项目.

但是,第三方/旧版库中有一个子目录.它有一个Makefile,可以将自己编译成3rd_party.a库文件.

我自己的CMakeLists.txt可以管理调用Makefile,生成它的3rd_party.a库,让我的代码链接到它吗?我不想将其遗留的Makefile改编成CMakeLists.txt

??? my_source_folder_1
??? my_source_folder_2
??? CMakeLists.txt
??? 3rd_party
?   ??? 3rd_party_source
?   ??? 3rd_party_make
?   |   ??? Makefile
Run Code Online (Sandbox Code Playgroud)

谢谢!

Cin*_*nch 5

相关:http : //www.cmake.org/pipermail/cmake/2010-November/040631.html

在上面的链接中,您似乎可以使用特殊的命令来概述CMake如何实现目标:

add_custom_target(
   extern_lib
   COMMAND make
   WORKING_DIRECTORY full_path to where Makefile is located
)
add_executable(myexecutable myexcutable.c)
target_link_libraries(myexecutable full_path_to_generated_library)
add_dependencies(myexecutable extern_lib)
Run Code Online (Sandbox Code Playgroud)

这应该足以使您入门。