Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add OBJECT property in generic cmake #2359

Closed
wants to merge 7 commits into from

Conversation

gangliao
Copy link
Contributor

@gangliao gangliao commented Jun 2, 2017

cc_library|nv_library(<target_name>
[STATIC SHARED OBJECT]
  SRCS <file>...
  OBJS <objs>...
  DEPS <libs>...)

cc_library and nv_library can generate *.o, *.a, or *.so
if the corresponding keyword OBJECT, STATIC or SHARED is specified.

cc_binary|nv_binary(<target_name>
  SRCS <file>...
  OBJS <objs>...
  DEPS <libs>...)

cc_binary and nv_binary can build source code and link the dependent
libraries to generate a binary.

cc_test|nv_test(<target_name>
  SRCS <file>...
  OBJS <objs>...
  DEPS <libs>...)

cc_test and nv_test can build test code, link gtest and other dependents
libraries to generate the test suite.

For example, in one folder, it contains
  ddim{.h, .cc, _test.cc, _test.cu}
  place{.h, cc, _test.cc}

We can add build script as follows: 

cc_library(place OBJECT
   SRCS place.cc)

place.cc -> place.o
cc_library's OBJECT OPTION will generate place.o.

cc_test(place_test
   SRCS place_test.cc
   OBJS place
   DEPS glog gflags)

place_test.cc, place.o, glog, gflags -> place_test
cc_test will combine place_test.cc, place.o with libglog.a
and libgflags.a to generate place_test.

cc_library(ddim OBJECT
   SRCS ddim.cc)

ddim.cc -> ddim.o
cc_library's OBJECT OPTION will generate ddim.o.

cc_test(ddim_test
   SRCS ddim_test.cc
   OBJS ddim)

ddim_test.cc, ddim.o -> ddim_test
cc_test will build ddim_test.cc with ddim.o to generate ddim_test.

nv_test(dim_test
   SRCS dim_test.cu
   OBJS ddim)

dim_test.cu, ddim.o -> dim_test
nv_test will build dim_test.cu with ddim.o to generate dim_test.

cc_library(majel
   OBJS place ddim)

place.o, ddim.o -> libmajel.a
cc_library's default OPTION is STATIC. It will archive place.o
and ddim.o to generate libmajel.a.


nv_test(cuda_test SRCS cuda_test.cu)
nv_test(dim_test SRCS dim_test.cu DEPS ddim)
cc_library(majel
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate libmajel.a from place and ddim.

@gangliao gangliao requested review from wangkuiyi and removed request for wangkuiyi June 2, 2017 11:24
@wangkuiyi
Copy link
Collaborator

I would highly recommend not to expose the fact that the building system generates .a and .o to end users. I mean let us don't add the OBJECT parameter.

@Xreki
Copy link
Contributor

Xreki commented Jun 7, 2017

Maybe we can decide to generate *.o, *.a according to whether there are SRCS. As in your example, there is no SRCS when combining several *.o to a x.a.

cc_library(majel
   OBJS place ddim)

@gangliao gangliao closed this Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants