From b7397031e9c03363c4e3e3119ff371b0d8a13e7c Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 4 Jul 2017 13:47:02 +0800 Subject: [PATCH] Add target_link_libraries for cc_library It will fix #2728. Maybe it is silly to `target_link_libraries` for static library, because a static library do not need to link other libraries. But it will tell cmake how to propagate dependencies. The solution comes from [here](http://floooh.github.io/2016/01/12/cmake-dependency-juggling.html). * Also change op_proto_test DEPS for testing this fix works. --- cmake/generic.cmake | 2 ++ paddle/framework/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/generic.cmake b/cmake/generic.cmake index fb2222440ca..cae9524b2fe 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -162,6 +162,7 @@ function(cc_library TARGET_NAME) endif() if (cc_library_DEPS) add_dependencies(${TARGET_NAME} ${cc_library_DEPS}) + target_link_libraries(${TARGET_NAME} ${cc_library_DEPS}) endif() else(cc_library_SRCS) if (cc_library_DEPS) @@ -211,6 +212,7 @@ function(nv_library TARGET_NAME) endif() if (nv_library_DEPS) add_dependencies(${TARGET_NAME} ${nv_library_DEPS}) + target_link_libraries(${TARGET_NAME} ${nv_library_DEPS}) endif() else(nv_library_SRCS) if (nv_library_DEPS) diff --git a/paddle/framework/CMakeLists.txt b/paddle/framework/CMakeLists.txt index e7818667592..baad38e3c1e 100644 --- a/paddle/framework/CMakeLists.txt +++ b/paddle/framework/CMakeLists.txt @@ -7,4 +7,4 @@ cc_test(scope_test SRCS scope_test.cc) cc_test(enforce_test SRCS enforce_test.cc) proto_library(attr_type SRCS attr_type.proto) proto_library(op_proto SRCS op_proto.proto DEPS attr_type) -cc_test(op_proto_test SRCS op_proto_test.cc DEPS op_proto attr_type protobuf) +cc_test(op_proto_test SRCS op_proto_test.cc DEPS op_proto protobuf) -- GitLab