|
| 1 | +load( |
| 2 | + "//ign_bazel:build_defs.bzl", |
| 3 | + "IGNITION_FEATURES", |
| 4 | + "IGNITION_VISIBILITY", |
| 5 | + "cmake_configure_file", |
| 6 | + "generate_include_header", |
| 7 | + "ign_config_header", |
| 8 | + "ign_export_header", |
| 9 | +) |
| 10 | + |
| 11 | +package( |
| 12 | + default_visibility = IGNITION_VISIBILITY, |
| 13 | + features = IGNITION_FEATURES, |
| 14 | +) |
| 15 | + |
| 16 | +licenses(["notice"]) |
| 17 | + |
| 18 | +exports_files(["LICENSE"]) |
| 19 | + |
| 20 | +PROJECT_NAME = "ignition-math" |
| 21 | + |
| 22 | +PROJECT_MAJOR = 6 |
| 23 | + |
| 24 | +PROJECT_MINOR = 8 |
| 25 | + |
| 26 | +PROJECT_PATCH = 0 |
| 27 | + |
| 28 | +# Generates config.hh based on the version numbers in CMake code. |
| 29 | +ign_config_header( |
| 30 | + name = "config", |
| 31 | + src = "include/ignition/math/config.hh.in", |
| 32 | + cmakelists = ["CMakeLists.txt"], |
| 33 | + project_name = "ignition-math", |
| 34 | + project_version = (PROJECT_MAJOR, PROJECT_MINOR, PROJECT_PATCH), |
| 35 | +) |
| 36 | + |
| 37 | +ign_export_header( |
| 38 | + name = "include/ignition/math/Export.hh", |
| 39 | + export_base = "IGNITION_MATH", |
| 40 | + lib_name = "ignition-math", |
| 41 | + visibility = ["//visibility:private"], |
| 42 | +) |
| 43 | + |
| 44 | +public_headers_no_gen = glob([ |
| 45 | + "include/ignition/math/*.hh", |
| 46 | + "include/ignition/math/detail/*.hh", |
| 47 | + "include/ignition/math/graph/*.hh", |
| 48 | +]) |
| 49 | + |
| 50 | +private_headers = glob(["src/*.hh"]) |
| 51 | + |
| 52 | +sources = glob( |
| 53 | + ["src/*.cc"], |
| 54 | + exclude = ["src/*_TEST.cc"], |
| 55 | +) |
| 56 | + |
| 57 | +generate_include_header( |
| 58 | + name = "mathhh_genrule", |
| 59 | + out = "include/ignition/math.hh", |
| 60 | + hdrs = public_headers_no_gen + [ |
| 61 | + "include/ignition/math/config.hh", |
| 62 | + "include/ignition/math/Export.hh", |
| 63 | + ], |
| 64 | +) |
| 65 | + |
| 66 | +public_headers = public_headers_no_gen + [ |
| 67 | + "include/ignition/math/config.hh", |
| 68 | + "include/ignition/math/Export.hh", |
| 69 | + "include/ignition/math.hh", |
| 70 | +] |
| 71 | + |
| 72 | +cc_library( |
| 73 | + name = "ign_math", |
| 74 | + srcs = sources + private_headers, |
| 75 | + hdrs = public_headers, |
| 76 | + includes = ["include"], |
| 77 | +) |
| 78 | + |
| 79 | +# use shared library only when absolutely needd |
| 80 | +cc_binary( |
| 81 | + name = "libignition-math6.so", |
| 82 | + includes = ["include"], |
| 83 | + linkopts = ["-Wl,-soname,libignition-math6.so"], |
| 84 | + linkshared = True, |
| 85 | + deps = [ |
| 86 | + ":ign_math", |
| 87 | + ], |
| 88 | +) |
| 89 | + |
| 90 | +[cc_test( |
| 91 | + name = src.replace("/", "_").replace(".cc", "").replace("src_", ""), |
| 92 | + srcs = [src], |
| 93 | + deps = [ |
| 94 | + ":ign_math", |
| 95 | + "@gtest", |
| 96 | + "@gtest//:gtest_main", |
| 97 | + ], |
| 98 | +) for src in glob( |
| 99 | + [ |
| 100 | + "src/*_TEST.cc", |
| 101 | + "src/graph/*_TEST.cc", |
| 102 | + ], |
| 103 | +)] |
0 commit comments