Cmake - let your own Makefile be used in a subdirectory

I have a project that mainly uses CMake.

However, there is a subdirectory from a third-party / old library. It has a Makefile that will be compiled into the 3rd_party.a library file.

Can my own CMakeLists.txt manage the call to this Makefile, generate its 3rd_party.a library and give a link to my code? I do not want to adapt my old Makefile to CMakeLists.txt

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

Thanks!

+6
source share
1 answer

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

From the link above, you can see that you can use a special command to describe how CMake should make the goal:

 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) 

That should be enough to make you sit down.

+3
source

Source: https://habr.com/ru/post/986896/


All Articles