Fixes for macOS build. Also run tests in CMake test.

pull/13171/head
Joshua Haberman 6 years ago
parent 9e44a757ed
commit 35fa3df8ec
  1. 2
      BUILD
  2. 6
      CMakeLists.txt
  3. 2
      build_defs.bzl
  4. 30
      tools/make_cmakelists.py

@ -407,7 +407,7 @@ cc_binary(
make_shell_script(
name = "gen_run_cmake_build",
out = "run_cmake_build.sh",
contents = "mkdir build && cd build && cmake .. && make -j8"
contents = "mkdir build && cd build && cmake .. && make -j8 && make test"
)
sh_test(

@ -117,11 +117,9 @@ add_library(upb_json
upb/json/printer.h)
target_link_libraries(upb_json
upb)
add_library(upb_cc_bindings
upb/bindings/stdc++/string.h)
target_link_libraries(upb_cc_bindings
add_library(upb_cc_bindings INTERFACE)
target_link_libraries(upb_cc_bindings INTERFACE
upb)
set_target_properties(upb_cc_bindings PROPERTIES LINKER_LANGUAGE CXX)
add_library(upb_test
tests/testmain.cc
tests/test_util.h

@ -147,7 +147,7 @@ def generated_file_staleness_test(name, outs, generated_pattern):
srcs = [script_src],
testonly = 1,
cmd = "cat $(location " + script_src + ") > $@; " +
"sed -i 's|INSERT_FILE_LIST_HERE|" + "\\n ".join(file_list) + "|' $@",
"sed -i '' -e 's|INSERT_FILE_LIST_HERE|" + "\\\n ".join(file_list) + "|' $@",
)
native.py_test(

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

Loading…
Cancel
Save