Giter Club home page Giter Club logo

bazel.cmake's Issues

cc_test must rely on CMake target gtest

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!

bazel.cmake requires a very recent version of cmake

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.

The Setup

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.

Symptoms

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.

Cannot find protobuf as a dependency when use proto_library on macOS

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.

Shouldn't assign value of $CUDA_FOUND to $WITH_GPU

The following line has a bug

if(NOT CMAKE_CROSSCOMPILING)
find_package(CUDA QUIET)
endif(NOT CMAKE_CROSSCOMPILING)
option(WITH_GPU "Compile Source Code with NVIDIA GPU" ${CUDA_FOUND})

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.

Need py_xxx and proto_xxx functions

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

  1. proto_library, which generates Python and C++ source files from the protobuf definition, and
  2. py_test, which generates Python tests.

Protobuf 3.5.x bug

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!

The propagation of dependencies to CUDA libraries

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!

proto_library refuses to work with macOS

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.