go cmake improvement
Created by: helinwang
The current implementation of go cmake (go_library, go_binary, go_test located at https://github.com/PaddlePaddle/Paddle/blob/develop/cmake/generic.cmake) is not satisfactory:
-
go_library
- I think we only need go_library to build shard and static c library. We don't need it for go library. The go library dependency probably is better managed by go tool using
go get
(see next item). - need to manually specify go library dependency.
This is not manageable since there will be a lot of go dependencies, manually specifying in cmake is redundant, and easily become out of date. go tool already provides a way of automatically downloading the dependencies. We better use that. I wrote an example implementation: https://github.com/PaddlePaddle/Paddle/blob/develop/go/cmake/golang.cmake#L27 , however, my cmake knowledge is poor. We may need to make some polish before it goes into
paddle/cmake
folder.
- I think we only need go_library to build shard and static c library. We don't need it for go library. The go library dependency probably is better managed by go tool using
-
go_binary
- need to manually specify go library dependency. same as go_library.
-
go_test
- need to manually specify go library dependency.
same as go_library.
go get -t
can actually do that automatically.$ go get --help ... The -t flag instructs get to also download the packages required to build the tests for the specified packages. ...
- need to manually specify what file to test.
This could easily become unmanageable. There typically are a lot of test files. go tool already provide command
go test
to test currently directly and all subdirectories. I think a better way is to ask cmake to test current package (go test .
), or better, to test current directory and all subdirectories (go test ./...
). Here is some more information about go test:This should run all tests in current directory and all of its subdirectories: $ go test ./... This should run all tests with import path prefixed with foo/: $ go test foo/... This should run all tests import path prefixed with foo: $ go test foo... This should run all tests in your $GOPATH: $ go test ...
- need to manually specify go library dependency.
same as go_library.