aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Freilich <sfreilich@google.com>2022-02-11 13:45:30 -0500
committerSamuel Freilich <sfreilich@google.com>2022-02-11 14:41:39 -0500
commita77c2d8aa514480b08dc74f9195149cf74b5f716 (patch)
treea9494bb0e70edc9de712f6be7856a80257bdf8cd
parent7246c9f37ef324c1dc0685fac06807bf5ea629b8 (diff)
downloadink-stroke-modeler-a77c2d8aa514480b08dc74f9195149cf74b5f716.tar.gz
Add CMake build/test
PiperOrigin-RevId: 428039385
-rw-r--r--CMakeLists.txt72
-rw-r--r--WORKSPACE14
-rw-r--r--cmake/InkBazelEquivalents.cmake43
-rw-r--r--ink_stroke_modeler/.bazelignore4
-rw-r--r--ink_stroke_modeler/.gitignore12
-rw-r--r--ink_stroke_modeler/BUILD14
-rw-r--r--ink_stroke_modeler/CMakeLists.txt98
-rw-r--r--ink_stroke_modeler/internal/BUILD14
-rw-r--r--ink_stroke_modeler/internal/CMakeLists.txt136
-rw-r--r--ink_stroke_modeler/internal/prediction/BUILD14
-rw-r--r--ink_stroke_modeler/internal/prediction/CMakeLists.txt86
-rw-r--r--ink_stroke_modeler/internal/prediction/kalman_filter/BUILD14
-rw-r--r--ink_stroke_modeler/internal/prediction/kalman_filter/CMakeLists.txt54
13 files changed, 575 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..924a88a
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,72 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+cmake_minimum_required(VERSION 3.15)
+Project(InkStrokeModeler VERSION 0.1 LANGUAGES CXX)
+
+enable_testing()
+
+include(FetchContent)
+
+FetchContent_Declare(
+ googletest
+ GIT_REPOSITORY https://github.com/google/googletest.git
+ GIT_TAG release-1.11.0
+ GIT_SHALLOW TRUE
+ GIT_PROGRESS TRUE
+)
+FetchContent_MakeAvailable(googletest)
+
+FetchContent_Declare(
+ abseil-cpp
+ GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
+ GIT_TAG 20211102.0
+ GIT_SHALLOW TRUE
+ GIT_PROGRESS TRUE
+)
+set(ABSL_PROPAGATE_CXX_STD ON)
+if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
+ set(ABSL_ENABLE_INSTALL ON)
+endif()
+# No reason to get two different versions of Googletest.
+set(ABSL_USE_EXTERNAL_GOOGLETEST ON)
+FetchContent_MakeAvailable(abseil-cpp)
+
+if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
+ set(CMAKE_CXX_STANDARD 17)
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
+ set(CMAKE_CXX_COMPILER clang++)
+endif()
+
+if(CMAKE_CXX_STANDARD LESS 17)
+ message(FATAL_ERROR
+ "${PROJECT_NAME} requires CMAKE_CXX_STANDARD >= 17 (got: ${CMAKE_CXX_STANDARD})")
+endif()
+
+include_directories("${CMAKE_SOURCE_DIR}")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
+include(InkBazelEquivalents)
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+
+add_subdirectory(ink_stroke_modeler)
+
+if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
+ install(EXPORT ${PROJECT_NAME}Targets
+ NAMESPACE InkStrokeModeler::
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
+ )
+endif()
diff --git a/WORKSPACE b/WORKSPACE
index 6314ac9..50f3866 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -1,3 +1,17 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
diff --git a/cmake/InkBazelEquivalents.cmake b/cmake/InkBazelEquivalents.cmake
new file mode 100644
index 0000000..e1a3d6a
--- /dev/null
+++ b/cmake/InkBazelEquivalents.cmake
@@ -0,0 +1,43 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+function(ink_cc_library)
+ cmake_parse_arguments(INK_CC_LIB
+ "PUBLIC"
+ "NAME"
+ "HDRS;SRCS;DEPS"
+ ${ARGN}
+ )
+ add_library(${INK_CC_LIB_NAME} ${INK_CC_LIB_SRCS} ${INK_CC_LIB_HDRS})
+ if(NOT DEFINED INK_CC_LIB_SRCS)
+ set_target_properties(${INK_CC_LIB_NAME} PROPERTIES LINKER_LANGUAGE CXX)
+ endif()
+ target_link_libraries(${INK_CC_LIB_NAME} PUBLIC ${INK_CC_LIB_DEPS})
+ if(INK_CC_LIB_PUBLIC)
+ install(TARGETS ${INK_CC_LIB_NAME} EXPORT ${PROJECT_NAME}Targets)
+ endif()
+ target_compile_features(${INK_CC_LIB_NAME} PUBLIC cxx_std_17)
+endfunction()
+
+function(ink_cc_test)
+ cmake_parse_arguments(INK_CC_TEST
+ ""
+ "NAME"
+ "SRCS;DEPS"
+ ${ARGN}
+ )
+ add_executable(${INK_CC_TEST_NAME} ${INK_CC_TEST_SRCS})
+ target_link_libraries(${INK_CC_TEST_NAME} ${INK_CC_TEST_DEPS})
+ add_test(NAME ${INK_CC_TEST_NAME} COMMAND ${INK_CC_TEST_NAME})
+endfunction()
diff --git a/ink_stroke_modeler/.bazelignore b/ink_stroke_modeler/.bazelignore
new file mode 100644
index 0000000..ef8804c
--- /dev/null
+++ b/ink_stroke_modeler/.bazelignore
@@ -0,0 +1,4 @@
+bin
+lib
+Testing
+_deps
diff --git a/ink_stroke_modeler/.gitignore b/ink_stroke_modeler/.gitignore
new file mode 100644
index 0000000..0c0c7e7
--- /dev/null
+++ b/ink_stroke_modeler/.gitignore
@@ -0,0 +1,12 @@
+*\#
+*~
+/bazel-*
+/bin/
+/lib/
+/Testing/
+/_deps/
+CMakeCache.txt
+CMakeFiles
+cmake_install.cmake
+CTestTestfile.cmake
+Makefile
diff --git a/ink_stroke_modeler/BUILD b/ink_stroke_modeler/BUILD
index 26c912a..f711149 100644
--- a/ink_stroke_modeler/BUILD
+++ b/ink_stroke_modeler/BUILD
@@ -1,3 +1,17 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
diff --git a/ink_stroke_modeler/CMakeLists.txt b/ink_stroke_modeler/CMakeLists.txt
new file mode 100644
index 0000000..c204cac
--- /dev/null
+++ b/ink_stroke_modeler/CMakeLists.txt
@@ -0,0 +1,98 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_subdirectory(internal)
+
+ink_cc_library(
+ NAME
+ params
+ SRCS
+ params.cc
+ HDRS
+ params.h
+ DEPS
+ types
+ absl::status
+ absl::strings
+ absl::variant
+ PUBLIC
+)
+
+ink_cc_test(
+ NAME
+ params_test
+ SRCS
+ params_test.cc
+ DEPS
+ params
+ absl::status
+ GTest::gmock_main
+)
+
+ink_cc_library(
+ NAME
+ types
+ HDRS
+ types.h
+ PUBLIC
+)
+
+ink_cc_test(
+ NAME
+ types_test
+ SRCS
+ types_test.cc
+ DEPS
+ types
+ type_matchers
+ GTest::gmock_main
+)
+
+ink_cc_library(
+ NAME
+ stroke_modeler
+ SRCS
+ stroke_modeler.cc
+ HDRS
+ stroke_modeler.h
+ DEPS
+ params
+ types
+ internal_types
+ position_modeler
+ stylus_state_modeler
+ wobble_smoother
+ input_predictor
+ kalman_predictor
+ stroke_end_predictor
+ absl::core_headers
+ absl::memory
+ absl::status
+ absl::statusor
+ absl::optional
+ absl::variant
+)
+
+ink_cc_test(
+ NAME
+ stroke_modeler_test
+ SRCS
+ stroke_modeler_test.cc
+ DEPS
+ params
+ stroke_modeler
+ type_matchers
+ absl::status
+ GTest::gmock_main
+)
diff --git a/ink_stroke_modeler/internal/BUILD b/ink_stroke_modeler/internal/BUILD
index 88ac101..9679529 100644
--- a/ink_stroke_modeler/internal/BUILD
+++ b/ink_stroke_modeler/internal/BUILD
@@ -1,3 +1,17 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
package(
default_visibility = ["//ink_stroke_modeler:__subpackages__"],
)
diff --git a/ink_stroke_modeler/internal/CMakeLists.txt b/ink_stroke_modeler/internal/CMakeLists.txt
new file mode 100644
index 0000000..9d78957
--- /dev/null
+++ b/ink_stroke_modeler/internal/CMakeLists.txt
@@ -0,0 +1,136 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_subdirectory(prediction)
+
+ink_cc_library(
+ NAME
+ internal_types
+ HDRS
+ internal_types.h
+ DEPS
+ types
+)
+
+ink_cc_library(
+ NAME
+ type_matchers
+ SRCS
+ type_matchers.cc
+ HDRS
+ type_matchers.h
+ DEPS
+ internal_types
+ types
+ GTest::gmock_main
+)
+
+ink_cc_library(
+ NAME
+ utils
+ HDRS
+ utils.h
+ DEPS
+ types
+)
+
+ink_cc_test(
+ NAME
+ utils_test
+ SRCS
+ utils_test.cc
+ DEPS
+ type_matchers
+ utils
+ GTest::gmock_main
+)
+
+ink_cc_library(
+ NAME
+ wobble_smoother
+ SRCS
+ wobble_smoother.cc
+ HDRS
+ wobble_smoother.h
+ DEPS
+ utils
+ params
+ types
+)
+
+ink_cc_test(
+ NAME
+ wobble_smoother_test
+ SRCS
+ wobble_smoother_test.cc
+ DEPS
+ type_matchers
+ wobble_smoother
+ params
+ types
+ GTest::gmock_main
+)
+
+ink_cc_library(
+ NAME
+ position_modeler
+ HDRS
+ position_modeler.h
+ DEPS
+ internal_types
+ utils
+ params
+ types
+)
+
+ink_cc_test(
+ NAME
+ position_modeler_test
+ SRCS
+ position_modeler_test.cc
+ DEPS
+ internal_types
+ position_modeler
+ type_matchers
+ params
+ types
+ GTest::gmock_main
+)
+
+ink_cc_library(
+ NAME
+ stylus_state_modeler
+ SRCS
+ stylus_state_modeler.cc
+ HDRS
+ stylus_state_modeler.h
+ DEPS
+ internal_types
+ utils
+ params
+)
+
+ink_cc_test(
+ NAME
+ stylus_state_modeler_test
+ SRCS
+ stylus_state_modeler_test.cc
+ DEPS
+ internal_types
+ stylus_state_modeler
+ type_matchers
+ params
+ types
+ GTest::gmock_main
+)
diff --git a/ink_stroke_modeler/internal/prediction/BUILD b/ink_stroke_modeler/internal/prediction/BUILD
index 5f2651c..2d94289 100644
--- a/ink_stroke_modeler/internal/prediction/BUILD
+++ b/ink_stroke_modeler/internal/prediction/BUILD
@@ -1,3 +1,17 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
package(
default_visibility = ["//ink_stroke_modeler:__subpackages__"],
)
diff --git a/ink_stroke_modeler/internal/prediction/CMakeLists.txt b/ink_stroke_modeler/internal/prediction/CMakeLists.txt
new file mode 100644
index 0000000..d3fcd76
--- /dev/null
+++ b/ink_stroke_modeler/internal/prediction/CMakeLists.txt
@@ -0,0 +1,86 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+add_subdirectory(kalman_filter)
+
+ink_cc_library(
+ NAME
+ input_predictor
+ HDRS
+ input_predictor.h
+ DEPS
+ params
+ types
+ internal_types
+)
+
+ink_cc_library(
+ NAME
+ kalman_predictor
+ SRCS
+ kalman_predictor.cc
+ HDRS
+ kalman_predictor.h
+ DEPS
+ input_predictor
+ params
+ types
+ internal_types
+ utils
+ kalman_filter
+)
+
+ink_cc_test(
+ NAME
+ kalman_predictor_test
+ SRCS
+ kalman_predictor_test.cc
+ DEPS
+ input_predictor
+ kalman_predictor
+ params
+ types
+ type_matchers
+ absl::optional
+ GTest::gmock_main
+)
+
+ink_cc_library(
+ NAME
+ stroke_end_predictor
+ SRCS
+ stroke_end_predictor.cc
+ HDRS
+ stroke_end_predictor.h
+ DEPS
+ input_predictor
+ params
+ types
+ internal_types
+ position_modeler
+ absl::optional
+)
+
+ink_cc_test(
+ NAME
+ stroke_end_predictor_test
+ SRCS
+ stroke_end_predictor_test.cc
+ DEPS
+ input_predictor
+ stroke_end_predictor
+ params
+ type_matchers
+ GTest::gmock_main
+)
diff --git a/ink_stroke_modeler/internal/prediction/kalman_filter/BUILD b/ink_stroke_modeler/internal/prediction/kalman_filter/BUILD
index 1307730..e487c16 100644
--- a/ink_stroke_modeler/internal/prediction/kalman_filter/BUILD
+++ b/ink_stroke_modeler/internal/prediction/kalman_filter/BUILD
@@ -1,3 +1,17 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
package(
default_visibility = ["//ink_stroke_modeler:__subpackages__"],
)
diff --git a/ink_stroke_modeler/internal/prediction/kalman_filter/CMakeLists.txt b/ink_stroke_modeler/internal/prediction/kalman_filter/CMakeLists.txt
new file mode 100644
index 0000000..2661a10
--- /dev/null
+++ b/ink_stroke_modeler/internal/prediction/kalman_filter/CMakeLists.txt
@@ -0,0 +1,54 @@
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ink_cc_library(
+ NAME
+ matrix
+ HDRS
+ matrix.h
+)
+
+ink_cc_test(
+ NAME
+ matrix_test
+ SRCS
+ matrix_test.cc
+ DEPS
+ matrix
+ GTest::gmock_main
+)
+
+ink_cc_library(
+ NAME
+ kalman_filter
+ SRCS
+ axis_predictor.cc
+ kalman_filter.cc
+ HDRS
+ axis_predictor.h
+ kalman_filter.h
+ DEPS
+ matrix
+ absl::memory
+)
+
+ink_cc_test(
+ NAME
+ axis_predictor_test
+ SRCS
+ axis_predictor_test.cc
+ DEPS
+ kalman_filter
+ GTest::gmock_main
+)