Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ cmake——让子目录使用它自己的Makefile_C++_Linux_Makefile_Cmake - Fatal编程技术网

C++ cmake——让子目录使用它自己的Makefile

C++ cmake——让子目录使用它自己的Makefile,c++,linux,makefile,cmake,C++,Linux,Makefile,Cmake,我有一个主要使用CMake的项目 但是,第三方/传统库中有一个子目录。它有一个Makefile,可以将自己编译成第三方。一个库文件 我自己的CMakeLists.txt能否调用该Makefile,生成它的第三方.a库,并让我的代码链接到它?我不想将其遗留的Makefile修改为CMakeLists.txt ├── my_source_folder_1 ├── my_source_folder_2 ├── CMakeLists.txt ├── 3rd_party │   ├── 3rd_party

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

但是,第三方/传统库中有一个子目录。它有一个Makefile,可以将自己编译成第三方。一个库文件

我自己的CMakeLists.txt能否调用该Makefile,生成它的第三方.a库,并让我的代码链接到它?我不想将其遗留的Makefile修改为CMakeLists.txt

├── my_source_folder_1
├── my_source_folder_2
├── CMakeLists.txt
├── 3rd_party
│   ├── 3rd_party_source
│   ├── 3rd_party_make
│   |   ├── Makefile
谢谢

相关:

从上面的链接可以看出,您可以使用一个特殊命令来概述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)
这应该足够让你离开地面了