c++ - Cmake external library .a -
i have external library here:
${project_source_dir}/thirdparty/yaml-cpp/
it made makefile: thirdparty/makefile
. executing makefile so:
add_custom_target( yaml-cpp command make working_directory ${cmake_source_dir}/thirdparty )
i attempting link library, builds thirdparty/yaml-cpp/build/libyaml-cpp.a
. this part not working:
target_link_libraries(load_balancer_node ${cmake_source_dir}/thirdparty/yaml-cpp/build/libyaml-cpp.a)
i error:
target "yaml-cpp" of type utility may not linked target. 1 may link static or shared libraries, or executables enable_exports property set.
how execute makefile , link .a
file?
so makes sense cmake can't figure out dependencies here: have parse makefile , find output. have tell output someone. nearest can figure, best way use custom_command rather custom target:
add_custom_command( output ${cmake_source_dir}/thirdparty/yaml-cpp/build/libyaml-cpp.a command make working_directory ${cmake_source_dir}/thirdparty) add_custom_target( yaml-cpp depends ${cmake_source_dir}/thirdparty/yaml-cpp/build/libyaml-cpp.a) ... add_dependencies(load_balancer_node yaml-cpp) target_link_libraries(load_balancer_node ${cmake_source_dir}/thirdparty/yaml-cpp/build/libyaml-cpp.a)
i having linker troubles though (stupid windows machine), cmake worked , made libraries before trying link.
Comments
Post a Comment