diff --git a/.gitignore b/.gitignore index 1b3df357..3b3f18ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /bazel-* cmake/build* +Testing diff --git a/CMakeLists.txt b/CMakeLists.txt index 6daac76d..7d4815ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,10 +16,13 @@ # 2022, and is our newest officially supported compiler. The next CMake release was v3.23.0, on # March 29, 2022. Therefore, our minimum version must be at least CMake 3.23. # +# We also use the `CMAKE_VERIFY_INTERFACE_HEADER_SETS`, which was added in CMake +# 3.24, which means the minimum must also be at least 3.24. +# # The maximum version should be the latest version we've tested the project with. # # [1]: https://cliutils.gitlab.io/modern-cmake/chapters/intro/dodonot.html -cmake_minimum_required(VERSION 3.23...3.29) +cmake_minimum_required(VERSION 3.24...3.29) project( Au @@ -28,3 +31,25 @@ project( HOMEPAGE_URL "https://aurora-opensource.github.io/au/0.3.4/" LANGUAGES CXX ) + +enable_testing() + +# Bring in GoogleTest so we can build and run the tests. +include(FetchContent) +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG 58d77fa8070e8cec2dc1ed015d66b454c8d78850 # Release 1.12.1 + FIND_PACKAGE_ARGS + 1.12.1 + NAMES GTest +) + +# https://google.github.io/googletest/quickstart-cmake.html +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +FetchContent_MakeAvailable(googletest) +include(GoogleTest) + +add_subdirectory(au) diff --git a/WORKSPACE b/WORKSPACE index 512bfc0b..a0e62592 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -113,6 +113,7 @@ gcc_register_toolchain( http_archive( name = "com_google_googletest", sha256 = "24564e3b712d3eb30ac9a85d92f7d720f60cc0173730ac166f27dda7fed76cb2", + # NOTE: if updating this version, also update the version numbers in `CMakelists.txt`. strip_prefix = "googletest-release-1.12.1", urls = ["https://github.com/google/googletest/archive/refs/tags/release-1.12.1.zip"], ) diff --git a/au/CMakeLists.txt b/au/CMakeLists.txt new file mode 100644 index 00000000..5647f405 --- /dev/null +++ b/au/CMakeLists.txt @@ -0,0 +1,43 @@ +# Copyright 2024 Aurora Operations, Inc. +# +# 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_path(GET CMAKE_CURRENT_SOURCE_DIR PARENT_PATH AU_BASE_DIRECTORY) + +# +# Private implementation detail targets +# + +add_library(stdx INTERFACE) +target_sources(stdx + INTERFACE + FILE_SET HEADERS + BASE_DIRS ${AU_BASE_DIRECTORY} + FILES + stdx/experimental/is_detected.hh + stdx/functional.hh + stdx/type_traits.hh + stdx/utility.hh +) + +add_executable(stdx_test) +target_sources(stdx_test + PRIVATE + stdx/test/utility_test.cc +) +target_link_libraries(stdx_test + PRIVATE + stdx + GTest::gtest_main +) +gtest_discover_tests(stdx_test) diff --git a/docs/install.md b/docs/install.md index 7986c062..d9fd94ec 100644 --- a/docs/install.md +++ b/docs/install.md @@ -257,10 +257,15 @@ To build the library using this experimental CMake support, follow these steps: ```sh # CMake is a "meta build system", not a build system. # This first command generates the actual build files. -cmake -B cmake/build -S . - -# This command builds the library. -cmake --build cmake/build +cmake -S . -B cmake/build -DCMAKE_VERIFY_INTERFACE_HEADER_SETS=TRUE + +# This command builds Au, checks include paths, and runs unit tests. +cmake \ + --build cmake/build \ + --target \ + all \ + all_verify_interface_header_sets \ + test ``` #### Other build systems (CMake / conan / vcpkg / ...)