|
|
@ -22,11 +22,12 @@ class BuildFileFunctions(object): |
|
|
|
def __init__(self, converter): |
|
|
|
def __init__(self, converter): |
|
|
|
self.converter = converter |
|
|
|
self.converter = converter |
|
|
|
|
|
|
|
|
|
|
|
def _add_deps(self, kwargs): |
|
|
|
def _add_deps(self, kwargs, keyword=""): |
|
|
|
if "deps" not in kwargs: |
|
|
|
if "deps" not in kwargs: |
|
|
|
return |
|
|
|
return |
|
|
|
self.converter.toplevel += "target_link_libraries(%s\n %s)\n" % ( |
|
|
|
self.converter.toplevel += "target_link_libraries(%s%s\n %s)\n" % ( |
|
|
|
kwargs["name"], |
|
|
|
kwargs["name"], |
|
|
|
|
|
|
|
keyword, |
|
|
|
"\n ".join(StripColons(kwargs["deps"])) |
|
|
|
"\n ".join(StripColons(kwargs["deps"])) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -37,17 +38,22 @@ class BuildFileFunctions(object): |
|
|
|
if kwargs["name"] == "amalgamation" or kwargs["name"] == "upbc_generator": |
|
|
|
if kwargs["name"] == "amalgamation" or kwargs["name"] == "upbc_generator": |
|
|
|
return |
|
|
|
return |
|
|
|
files = kwargs.get("srcs", []) + kwargs.get("hdrs", []) |
|
|
|
files = kwargs.get("srcs", []) + kwargs.get("hdrs", []) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if filter(IsSourceFile, files): |
|
|
|
|
|
|
|
# Has sources, make this a normal library. |
|
|
|
self.converter.toplevel += "add_library(%s\n %s)\n" % ( |
|
|
|
self.converter.toplevel += "add_library(%s\n %s)\n" % ( |
|
|
|
kwargs["name"], |
|
|
|
kwargs["name"], |
|
|
|
"\n ".join(files) |
|
|
|
"\n ".join(files) |
|
|
|
) |
|
|
|
) |
|
|
|
self._add_deps(kwargs) |
|
|
|
self._add_deps(kwargs) |
|
|
|
|
|
|
|
else: |
|
|
|
# CMake wants to know if each library is C or C++. |
|
|
|
# Header-only library, have to do a couple things differently. |
|
|
|
# If there are only .h files, it can't infer. Assume C++. |
|
|
|
# For some info, see: |
|
|
|
if not filter(IsSourceFile, files): |
|
|
|
# http://mariobadr.com/creating-a-header-only-library-with-cmake.html |
|
|
|
line = "set_target_properties(%s PROPERTIES LINKER_LANGUAGE CXX)\n" |
|
|
|
self.converter.toplevel += "add_library(%s INTERFACE)\n" % ( |
|
|
|
self.converter.toplevel += line % (kwargs["name"]) |
|
|
|
kwargs["name"] |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
self._add_deps(kwargs, " INTERFACE") |
|
|
|
|
|
|
|
|
|
|
|
def cc_binary(self, **kwargs): |
|
|
|
def cc_binary(self, **kwargs): |
|
|
|
pass |
|
|
|
pass |
|
|
|