gangliao / bazel.cmake Goto Github PK
View Code? Open in Web Editor NEWbazel.cmake mimics the behavior of bazel to simplify the usability of CMake
License: Apache License 2.0
bazel.cmake mimics the behavior of bazel to simplify the usability of CMake
License: Apache License 2.0
I'd have to write
cc_test(to_string_test SRCS to_string_test.cc DEPS gtest)
instead
cc_test(to_string_test SRCS to_string_test.cc)
Otherwise, make
would complain about missing gtest symbols.
I'd thought that the only key difference between cc_test and cc_binary is that cc_test equals to cc_binary(... DEPS gtest), and thus we don't need to write DEPS gtest
when we use cc_test. Am I correct?
Thanks!
le Drive/github/bazel.cmake/test/build/proto" "/usr/local/bin/python" "add_person.py" "addr_proto.bin"
4: Test timeout computed to be: 10000000
4: Traceback (most recent call last):
4: File "add_person.py", line 5, in <module>
4: import addressbook_pb2
4: File "/Users/liaogang/Google Drive/github/bazel.cmake/test/build/proto/addressbook_pb2.py", line 25, in <module>
4: dependencies=[google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,])
4: TypeError: __init__() got an unexpected keyword argument 'serialized_options'
4/4 Test #4: test_add_person ..................***Failed 0.25 sec
75% tests passed, 1 tests failed out of 4
Total Test time (real) = 0.89 sec
Rollback to 3.4.0 can solve it!
In my recent project https://github.com/wangkuiyi/fluid/blob/develop/python/fluid/CMakeLists.txt, I started from the Python part. Can we have py_test
at least?
I simplified your original version in https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/generic.cmake into https://github.com/wangkuiyi/fluid/blob/develop/tools/cmake/like-bazel.cmake, which has
proto_library
, which generates Python and C++ source files from the protobuf definition, andpy_test
, which generates Python tests.I tried to set up a very simple project following instructions in https://github.com/gangliao/bazel.cmake/, which I tried many times before and works well with C++ projects. But, in this simple project, I am having a .proto file, and it is my first time to try proto_library.
Here follows the content of the /CMakeLists.txt
file:
cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/bazel.cmake/cmake)
include(bazel)
proto_library(framework_proto SRCS framework.proto)
When I run cmake ..
after creating and entering ./build
, where I am using cmake version 3.11, I got the following errors:
-- Python executable: /usr/bin/python
-- Python library: /usr/lib/libpython2.7.dylib
-- Python include: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/python2.7
-- Generate Protobuf CPP Source Files: /tmp/learn/buld/framework.pb.cc
-- Generate Protobuf CPP Header Files: /tmp/learn/buld/framework.pb.h
-- Generate Protobuf Python Source Files: /tmp/learn/buld/framework_pb2.py
CMake Error at bazel.cmake/cmake/bazel.cmake:82 (add_dependencies):
Cannot add target-level dependencies to non-existent target
"framework_proto".
The add_dependencies works for top-level logical targets created by the
add_executable, add_library, or add_custom_target commands. If you want to
add file-level dependencies see the DEPENDS option of the add_custom_target
and add_custom_command commands.
Call Stack (most recent call first):
bazel.cmake/cmake/bazel.cmake:158 (cmake_library)
CMakeLists.txt:6 (proto_library)
CMake Error at bazel.cmake/cmake/bazel.cmake:83 (target_link_libraries):
Cannot specify link libraries for target "framework_proto" which is not
built by this project.
Call Stack (most recent call first):
bazel.cmake/cmake/bazel.cmake:158 (cmake_library)
CMakeLists.txt:6 (proto_library)
-- Configuring incomplete, errors occurred!
I am trying to use bazel.cmake with Tape, the tape-based framework of PaddlePaddle that relies on Fluid's operator base.
I want to use PaddlePaddle as an external project. Do I have to create a paddle.cmake file and put it in https://github.com/gangliao/bazel.cmake/tree/master/cmake/external ? Or, is it possible for me to put the paddle.cmake in Tape's repo?
The following line has a bug
Lines 25 to 29 in b2d0260
as it assigns the value of ${CUDA_FOUND}, which could be TRUE
or FALSE
, to ${WITH_GPU}, which should be either ON
or OFF
.
This causes a bug on my macOS with CMake 3.11 that even if CMake found CUDA and set CUDA_FOUND to be TRUE, WITH_GPU will be OFF, because CMake doesn't think TRUE as ON.
I did the following on my macOS 10.13.5 and 3.11.4:
cd /tmp
git clone --recursive https://github.com/gangliao/bazel.cmake
cd bazel.cmake/test
mkdir build
cd build
cmake ..
and got error messages:
-- Generate Protobuf CPP Source Files: /tmp/bazel.cmake/test/build/proto/addressbook.pb.cc
-- Generate Protobuf CPP Header Files: /tmp/bazel.cmake/test/build/proto/addressbook.pb.h
-- Generate Protobuf Python Source Files: /tmp/bazel.cmake/test/build/proto/addressbook_pb2.py
-- Configuring done
CMake Error at /tmp/bazel.cmake/cmake/bazel.cmake:82 (add_dependencies):
The dependency target "protobuf" of target "addressbook" does not exist.
Call Stack (most recent call first):
/tmp/bazel.cmake/cmake/bazel.cmake:158 (cmake_library)
proto/CMakeLists.txt:4 (proto_library)
-- Generating done
-- Build files have been written to: /tmp/bazel.cmake/test/build
I have protobuf 3.1 installed using Homebrew.
I just noticed that bazel.cmake doesn't work with cmake 3.5.1 when I used it to build a very simple project. But it could build that project with cmake 3.11.4.
I don't know which exactly the oldest version of cmake is compatible with bazel.cmake, nor the reason it doesn't work with 3.5.1. But I can explain the symptoms I noticed.
I did the verification experiment in a Docker container that runs Ubuntu 16.4 (Xenial):
docker run --rm -it ubuntu:xenial /bin/bash
We need to install the following packages in the container:
apt-get install -y cmake make gcc git build-essential
I created a very simple project in this container. It is basically this example, except for that I made the hello.cc calls LOG(INFO) << "Hello World!
instead of printf
. This would make the target hello
depends on glog
.
If I run cmake -DWITH_PYTHON=OFF -DWITH_GPU=OFF ..
, where the default version of cmake in Xenial is 3.5.1, it complains:
CMake Error at bazel.cmake/cmake/bazel.cmake:67 (list):
list does not recognize sub-command FILTER
Call Stack (most recent call first):
bazel.cmake/cmake/bazel.cmake:92 (_build_target)
bazel.cmake/cmake/bazel.cmake:135 (cmake_library)
CMakeLists.txt:6 (cc_test)
CMake Error at bazel.cmake/cmake/bazel.cmake:94 (add_dependencies):
Cannot add target-level dependencies to non-existent target "hello".
The add_dependencies works for top-level logical targets created by the
add_executable, add_library, or add_custom_target commands. If you want to
add file-level dependencies see the DEPENDS option of the add_custom_target
and add_custom_command commands.
Call Stack (most recent call first):
bazel.cmake/cmake/bazel.cmake:135 (cmake_library)
CMakeLists.txt:6 (cc_test)
CMake Error at bazel.cmake/cmake/bazel.cmake:95 (target_link_libraries):
Cannot specify link libraries for target "hello" which is not built by this
project.
Call Stack (most recent call first):
bazel.cmake/cmake/bazel.cmake:135 (cmake_library)
CMakeLists.txt:6 (cc_test)
Then I downloaded the source code of CMake 3.11.4 and build it. When I run
/tmp/cmake-3.11.4/bin/cmake -DWITH_PYTHON=OFF -DWITH_GPU=OFF ..
everything goes well.
I wrote a CMakeLists.txt file like the following
nv_library(gpu_info SRCS gpu_info.cc)
cc_library(malloc SRCS malloc.cc DEPS gpu_info)
cc_test(malloc_test SRCS malloc_test.cc DEPS malloc)
The linking stage of malloc_test complains that it cannot find CUDA symbols like _cudaFree
and _cudaMalloc
.
I noticed that if I switch calls to cc_library and cc_test into nv_library and nv_test, the build would succeed. However, what would imply that users would have to write a lot of if(WITH_GPU)
in their CMakeLists.txt files.
Is it alright to change bazel.cmake to have the behavior that if any dependent relies on CUDA, all dependees rely on CUDA too?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.