generic.cmake needs to be able to refer to 3rd party packages
Created by: wangkuiyi
For each target, CMake requires a call to target_link_libraries
to specify the to-be-linked libraries and a call to add_dependencies
to specify the dependencies. An example is https://github.com/PaddlePaddle/Paddle/pull/2326/files#diff-7a3600c73304487a6d5f6bd3fa3fd662R41
It seems that we need a way to associate each 3rd-party dependency to its libraries.
Currently, we specify a 3rd-party dependency, for example, glog
, by calling ExternalProject_Add
in cmake/external/*.cmake
. For example, https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/external/glog.cmake#L30. And we specify the libraries of this 3rd-party dependency by defining a variable, like GLOG_LIBRARIES
in https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/external/glog.cmake#L24.
Could we rename GLOG_LIBRARIES
to be glog_libs
in cmake/external/glog.cmake
, and use the following directive to specify 3rd-party dependencies,
cc_library(some_target SRCS some_source.cc DEPS some_paddle_deps 3RDS glog)
where the definition of cc_library
calls somethingl like ${cc_library_DEP}_libs
to refer to glog_libs
defined in cmake/external/glog.cmake
?