diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..d64e620c --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,39 @@ +name: Build and Push GCC Docker image + +on: + schedule: + # 每天 UTC 0点运行(对应北京时间 8点) + - cron: '0 0 * * *' + workflow_dispatch: # 允许手动触发 + +jobs: + build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./scripts + file: ./scripts/Dockerfile + push: true + tags: | + luohaothu/gcc-trunk:latest + luohaothu/gcc-trunk:${{ github.run_number }} + cache-from: type=registry,ref=luohaothu/gcc-trunk:latest + cache-to: type=inline \ No newline at end of file diff --git a/.gitignore b/.gitignore index 12c54b30..317c740d 100644 --- a/.gitignore +++ b/.gitignore @@ -370,4 +370,5 @@ doc/build doc/*.html venv build*/ -.vscode/ \ No newline at end of file +.vscode/ +install/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e766ec80..31ea2476 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # ---------------------------------------------------------------------------- # -# Copyright (c) 2019 - 2023 by the OpFlow developers +# Copyright (c) 2019 - 2025 by the OpFlow developers # # This file is part of OpFlow. # @@ -14,7 +14,15 @@ # # ---------------------------------------------------------------------------- -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 4.0.2 FATAL_ERROR) +# The specific value used for CMake==4.0.2 +set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD + # This specific value changes as experimental support evolves. See + # `Help/dev/experimental.rst` in the CMake source corresponding to + # your CMake build for the exact value to use. + "a9e1cf81-9932-4810-974b-6eccaf14e457") +set(CMAKE_EXPERIMENTAL_EXPORT_BUILD_DATABASE 4bd552e2-b7fb-429a-ab23-c83ef53f3f13) +set(CMAKE_EXPORT_BUILD_DATABASE 1) # ---------------------------------------------------------------------------- # Start opflow project @@ -33,73 +41,57 @@ project(opflow VERSION ${OPFLOW_VERSION} LANGUAGES C CXX) set(OPFLOW_VERSION_STRING "${OPFLOW_VERSION} - ${SHORT_SHA1} - ${GIT_CHANGE}") message(STATUS "Build opflow: ${OPFLOW_VERSION_STRING}") +set(CMAKE_EXPERIMENTAL_EXPORT_BUILD_DATABASE 4bd552e2-b7fb-429a-ab23-c83ef53f3f13) +set(CMAKE_EXPORT_BUILD_DATABASE 1) + +set(CMAKE_CXX_MODULE_STD 1) + include(GNUInstallDirs) # ---------------------------------------------------------------------------- # Set CMake policies to support later version behaviour # ---------------------------------------------------------------------------- -if (POLICY CMP0077) +if(POLICY CMP0077) cmake_policy(SET CMP0077 NEW) # option() honors variables already set -endif () +endif() # ---------------------------------------------------------------------------- # Set default build to release # ---------------------------------------------------------------------------- -if (NOT CMAKE_BUILD_TYPE) +if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE) -endif () +endif() # ---------------------------------------------------------------------------- # Compiler config # ---------------------------------------------------------------------------- -if (NOT CMAKE_C_STANDARD) - set(CMAKE_C_STANDARD 11) - set(CMAKE_C_STANDARD_REQUIRED ON) -elseif (CMAKE_C_STANDARD LESS 11) - message(WARNING "OpFlow needs C11 to compile. Changing the standard to C11.") - set(CMAKE_C_STANDARD 11) - set(CMAKE_C_STANDARD_REQUIRED ON) -endif () - # make sure __cplusplus is defined when using msvc -if (MSVC) +if(MSVC) string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus /wd4267 /wd4390 /wd4244") -endif () +endif() # supress possible abi warning by upgrade compiler set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi") # temporary fix for macOS 14 & CLT 15 -if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" - AND CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 23) +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" + AND CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 23) add_link_options(-Wl,-ld_classic) -endif () +endif() set(CMAKE_CXX_EXTENSIONS OFF) -if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS") +if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS") set(CMAKE_CXX_EXTENSIONS ON) -endif () +endif() -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_THREAD_LIBS_INIT "-lpthread") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(CMAKE_USE_WIN32_THREADS_INIT 0) set(CMAKE_USE_PTHREADS_INIT 1) set(THREADS_PREFER_PTHREAD_FLAG ON) #set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi") -endif () - -# ---------------------------------------------------------------------------- -# Set OPFLOW_MASTER_PROJECT to ON if we are building opflow -# ---------------------------------------------------------------------------- -# Check if opflow is being used directly or via add_subdirectory, but allow overriding -if (NOT DEFINED OPFLOW_MASTER_PROJECT) - if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) - set(OPFLOW_MASTER_PROJECT ON) - else () - set(OPFLOW_MASTER_PROJECT OFF) - endif () -endif () +endif() option(OPFLOW_BUILD_ALL "Build all artifacts" OFF) @@ -136,9 +128,10 @@ option(OPFLOW_SANITIZE_UB "Enable undefined behavior sanitizer in tests" OFF) # compile options option(OPFLOW_BUILD_WARNINGS "Enable compiler warnings" OFF) option(OPFLOW_NO_EXCEPTIONS "Compile with -fno-exceptions" OFF) +option(OPFLOW_ENABLE_MODULE "Enable C++ modules support" OFF) # install options -option(OPFLOW_INSTALL "Generate the install target" ${OPFLOW_MASTER_PROJECT}) +option(OPFLOW_INSTALL "Generate the install target" ${PROJECT_IS_TOP_LEVEL}) # the default behavior is to use bundled HYPRE, VTK & TBB option(OPFLOW_WITH_VTK "Build OpFlow with VTK" OFF) option(OPFLOW_HYPRE_EXTERNAL "Use external HYPRE library instead of bundled" OFF) @@ -146,298 +139,116 @@ option(OPFLOW_VTK_EXTERNAL "Use external VTK library instead of bundled" OFF) option(OPFLOW_TBB_EXTERNAL "Use external Intel TBB library instead of bundled" OFF) # clang-tidy -if (${CMAKE_VERSION} VERSION_GREATER "3.5") +if(${CMAKE_VERSION} VERSION_GREATER "3.5") option(OPFLOW_TIDY "run clang-tidy" OFF) -endif () +endif() -if (OPFLOW_TIDY) +if(OPFLOW_TIDY) set(CMAKE_CXX_CLANG_TIDY "clang-tidy") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) message(STATUS "Enabled clang-tidy") -endif () +endif() message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) +add_subdirectory(src) # ---------------------------------------------------------------------------- -# Header only version -# ---------------------------------------------------------------------------- -add_library(opflow INTERFACE) -add_library(opflow::opflow ALIAS opflow) - -# Create & include the version header -configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/Version.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Version.hpp @ONLY) - -target_include_directories(opflow INTERFACE - "$" - "$" - "$" - "$" - "$") - -# ---------------------------------------------------------------------------- -# Compile options -# ---------------------------------------------------------------------------- -include(CheckCXXCompilerFlag) -check_cxx_compiler_flag(-std=c++20 c++20support) -if (NOT c++20support) - message(FATAL_ERROR "OpFlow requires C++20 to compile.") -endif () -target_compile_options(opflow INTERFACE -std=c++20) - -# ---------------------------------------------------------------------------- -# Use fmt package +# External dependencies # ---------------------------------------------------------------------------- -if (OPFLOW_INSTALL) - # Build, install & link to the installed libfmt - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FMTConfig.cmake) - CONFIG_AND_INSTALL_FMT() - find_package(fmt REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) -else () - # Add the bundled fmt library as a subproject - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/fmt EXCLUDE_FROM_ALL) -endif () -target_link_libraries(opflow INTERFACE fmt::fmt) - -# ---------------------------------------------------------------------------- -# Use spdlog package -# ---------------------------------------------------------------------------- -if (OPFLOW_INSTALL) - # Same as libfmt - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/SPDLOGConfig.cmake) - CONFIG_AND_INSTALL_SPDLOG() - find_package(spdlog REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) -else () - set(SPDLOG_FMT_EXTERNAL ON) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/spdlog EXCLUDE_FROM_ALL) -endif () -target_link_libraries(opflow INTERFACE spdlog::spdlog) - -# ---------------------------------------------------------------------------- -# Use AMGCL -# ---------------------------------------------------------------------------- -if (OPFLOW_INSTALL) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/AMGCLConfig.cmake) - CONFIG_AND_INSTALL_AMGCL() - find_package(amgcl REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) -else () - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/amgcl EXCLUDE_FROM_ALL) -endif () -target_link_libraries(opflow INTERFACE amgcl::amgcl) - -# ---------------------------------------------------------------------------- -# Use TBB -# ---------------------------------------------------------------------------- -if (OPFLOW_TBB_EXTERNAL) - if (NOT DEFINED TBB_DIR) - message(FATAL "Variable TBB_DIR not defined. Use -DTBB_DIR to specify TBB's install path.") - endif () - find_package(TBB REQUIRED PATHS ${TBB_DIR} NO_DEFAULT_PATH) -else () - if (OPFLOW_INSTALL) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TBBConfig.cmake) - CONFIG_AND_INSTALL_TBB() - find_package(tbb NAMES tbb TBB REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) - else () - set(BUILD_SHARED_LIBS ON) - set(TBB_TEST OFF) - set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/tbb EXCLUDE_FROM_ALL) - find_package(tbb NAMES tbb TBB REQUIRED) - endif () -endif () -target_link_libraries(opflow INTERFACE TBB::tbb) +add_subdirectory(external) # ---------------------------------------------------------------------------- # Find MPI # ---------------------------------------------------------------------------- -if (OPFLOW_WITH_MPI) +if(OPFLOW_WITH_MPI) find_package(MPI REQUIRED) target_link_libraries(opflow INTERFACE MPI::MPI_C MPI::MPI_CXX) list(APPEND PKG_CONFIG_REQUIRES MPI) -endif () +endif() # ---------------------------------------------------------------------------- # Find OpenMP # ---------------------------------------------------------------------------- -if (OPFLOW_WITH_OPENMP) +if(OPFLOW_WITH_OPENMP) # workarounds for CI to find the correct libomp - if (APPLE) - if (EXISTS /usr/local/opt/llvm/lib) + if(APPLE) + if(EXISTS /usr/local/opt/llvm/lib) link_directories("/usr/local/opt/llvm/lib") - elseif (EXISTS /opt/homebrew/lib) + elseif(EXISTS /opt/homebrew/lib) link_directories("/opt/homebrew/lib") - endif () - endif () - if (CMAKE_C_COMPILER_ID MATCHES "Clang") + endif() + endif() + if(CMAKE_C_COMPILER_ID MATCHES "Clang") set(OpenMP_C "${CMAKE_C_COMPILER}") set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument -Wno-deprecated-pragma") set(OpenMP_C_LIB_NAMES "omp") set(OpenMP_omp_LIBRARY ${OpenMP_C_LIB_NAMES}) - endif () - if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(OpenMP_CXX "${CMAKE_CXX_COMPILER}") set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument") set(OpenMP_CXX_LIB_NAMES "omp") set(OpenMP_omp_LIBRARY ${OpenMP_CXX_LIB_NAMES}) - endif () + endif() find_package(OpenMP REQUIRED) target_link_libraries(opflow INTERFACE OpenMP::OpenMP_C OpenMP::OpenMP_CXX) target_compile_options(opflow INTERFACE ${OpenMP_CXX_FLAGS}) list(APPEND PKG_CONFIG_REQUIRES OpenMP) -endif () - -# ---------------------------------------------------------------------------- -# Use HYPRE package -# ---------------------------------------------------------------------------- -if (OPFLOW_HYPRE_EXTERNAL) - if (NOT DEFINED HYPRE_DIR) - message(FATAL "Variable HYPRE_DIR not set. Use -DHYPRE_DIR to specify HYPRE's install path") - endif () - # Use external HYPRE - find_package(HYPRE REQUIRED PATHS ${HYPRE_DIR} NO_DEFAULT_PATH) - # Here we hard link to the found HYPRE to avoid find again at client - target_link_libraries(opflow INTERFACE HYPRE) -else () - # Use bundled HYPRE - if (OPFLOW_INSTALL) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/HYPREConfig.cmake) - CONFIG_AND_INSTALL_HYPRE() - find_package(HYPRE REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) - # HYPRE::HYPRE is only exported on install - target_link_libraries(opflow INTERFACE HYPRE::HYPRE) - else () - set(HYPRE_BUILD_TYPE Debug) - set(HYPRE_WITH_OPENMP ${OPFLOW_WITH_OPENMP}) - set(HYPRE_ENABLE_SINGLE ${OPFLOW_SINGLE_PRECISION}) - set(HYPRE_WITH_MPI ${OPFLOW_WITH_MPI}) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/hypre/src EXCLUDE_FROM_ALL) - target_link_libraries(opflow INTERFACE HYPRE) - endif () -endif () - -# ---------------------------------------------------------------------------- -# Use VTK package -# ---------------------------------------------------------------------------- -if (OPFLOW_WITH_VTK) - target_compile_definitions(opflow INTERFACE OPFLOW_WITH_VTK) - if (OPFLOW_VTK_EXTERNAL) - if (NOT TARGET VTK) - if (NOT DEFINED VTK_DIR) - message(FATAL "Variable VTK_DIR not defined. Use -DVTK_DIR to specify VTK's install path") - endif () - find_package(VTK REQUIRED PATHS ${VTK_DIR} NO_DEFAULT_PATH) - target_compile_definitions(opflow INTERFACE OPFLOW_VTK_EXTERNAL) - endif () - else () - include(cmake/VTKConfig.cmake) - CONFIG_VTK() - endif () - list(APPEND PKG_CONFIG_REQUIRES VTK) - target_include_directories(opflow INTERFACE ${VTK_INCLUDE_DIRS}) - target_link_directories(opflow INTERFACE ${VTK_LIBRARY_DIRS}) - target_link_libraries(opflow INTERFACE ${VTK_LIBRARIES}) -endif () - -# ---------------------------------------------------------------------------- -# Use HDF5 package -# ---------------------------------------------------------------------------- -if (OPFLOW_WITH_HDF5) - if (OPFLOW_WITH_MPI) - set(HDF5_PREFER_PARALLEL TRUE) - endif () - set(HDF5_USE_STATIC_LIBRARIES ON) - include(FindHDF5) - find_package(HDF5 COMPONENTS C REQUIRED) - if (HDF5_PREFER_PARALLEL AND NOT HDF5_IS_PARALLEL) - message(FATAL_ERROR "Cannot find parallel HDF5 library") - endif () - target_include_directories(opflow INTERFACE ${HDF5_C_INCLUDE_DIRS}) - target_link_libraries(opflow INTERFACE ${HDF5_C_LIBRARIES}) - target_compile_definitions(opflow INTERFACE OPFLOW_WITH_HDF5 ${HDF5_C_DEFINITIONS}) - if (OPFLOW_WITH_MPI) - target_compile_definitions(opflow INTERFACE H5_HAVE_PARALLEL) - endif () -endif () - -# ---------------------------------------------------------------------------- -# Use TecIO library -# ---------------------------------------------------------------------------- -if (OPFLOW_INSTALL) - include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/TECIOConfig.cmake) - CONFIG_AND_INSTALL_TECIO() - target_include_directories(opflow INTERFACE ${CMAKE_INSTALL_PREFIX}/include/tecio) - target_link_directories(opflow INTERFACE ${CMAKE_INSTALL_PREFIX}/lib) - if (OPFLOW_WITH_MPI) - target_link_libraries(opflow INTERFACE teciompi) - target_compile_definitions(opflow INTERFACE TECIOMPI) - else () - target_link_libraries(opflow INTERFACE tecio) - endif () -else () - if (OPFLOW_WITH_MPI) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc EXCLUDE_FROM_ALL) - target_include_directories(opflow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc) - target_link_libraries(opflow INTERFACE teciompi) - else () - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc EXCLUDE_FROM_ALL) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc) - target_link_libraries(opflow INTERFACE tecio) - endif () -endif () +endif() # ---------------------------------------------------------------------------- # Platform detection # ---------------------------------------------------------------------------- -if (UNIX) +if(UNIX) target_compile_definitions(opflow INTERFACE OPFLOW_PLATFORM_UNIX) -elseif (APPLE) +elseif(APPLE) target_compile_definitions(opflow INTERFACE OPFLOW_PLATFORM_APPLE) -elseif (WIN32) +elseif(WIN32) target_compile_definitions(opflow INTERFACE OPFLOW_PLATFORM_WIN) -endif () +endif() # ---------------------------------------------------------------------------- # Language & library features detection # ---------------------------------------------------------------------------- include(CheckIncludeFiles) check_include_files("sys/mman.h" HAS_SYS_MMAN_H) -if (HAS_SYS_MMAN_H) +if(HAS_SYS_MMAN_H) target_compile_definitions(opflow INTERFACE OPFLOW_HAS_MMAN_H) -endif () +endif() # ---------------------------------------------------------------------------- # Misc definitions according to tweak options # ---------------------------------------------------------------------------- -foreach ( - OPFLOW_OPTION - OPFLOW_SINGLE_PRECISION - OPFLOW_WITH_MPI - OPFLOW_WITH_OPENMP) - if (${OPFLOW_OPTION}) +foreach( + OPFLOW_OPTION + OPFLOW_SINGLE_PRECISION + OPFLOW_WITH_MPI + OPFLOW_WITH_OPENMP) + if(${OPFLOW_OPTION}) target_compile_definitions(opflow INTERFACE ${OPFLOW_OPTION}) - endif () -endforeach () -if (OPFLOW_WITH_MPI) + endif() +endforeach() +if(OPFLOW_WITH_MPI) target_compile_definitions(opflow INTERFACE OPFLOW_DISTRIBUTE_MODEL_MPI) -endif () +endif() -if (OPFLOW_NO_EXCEPTIONS AND NOT MSVC) +if(OPFLOW_NO_EXCEPTIONS AND NOT MSVC) target_compile_options(opflow INTERFACE -fno-exceptions) -endif () +endif() # sanitizer flags target_compile_options(opflow - INTERFACE $<$: -fsanitize=address> - INTERFACE $<$: -fsanitize=leak> - INTERFACE $<$: -fsanitize=thread> - INTERFACE $<$: -fsanitize=undefined>) + INTERFACE $<$: -fsanitize=address> + INTERFACE $<$: -fsanitize=leak> + INTERFACE $<$: -fsanitize=thread> + INTERFACE $<$: -fsanitize=undefined>) target_link_options(opflow - INTERFACE $<$: -fsanitize=address> - INTERFACE $<$: -fsanitize=leak> - INTERFACE $<$: -fsanitize=thread> - INTERFACE $<$: -fsanitize=undefined>) + INTERFACE $<$: -fsanitize=address> + INTERFACE $<$: -fsanitize=leak> + INTERFACE $<$: -fsanitize=thread> + INTERFACE $<$: -fsanitize=undefined>) # ---------------------------------------------------------------------------- # All_CI target (= AllExamples + AllBenchmarks + AllTests) @@ -447,24 +258,24 @@ add_custom_target(All_CI) # ---------------------------------------------------------------------------- # Build binaries # ---------------------------------------------------------------------------- -if (OPFLOW_BUILD_EXAMPLES OR OPFLOW_BUILD_ALL) +if(OPFLOW_BUILD_EXAMPLES OR OPFLOW_BUILD_ALL) message(STATUS "Generating examples") add_subdirectory(examples) -endif () +endif() # ---------------------------------------------------------------------------- # Build tests # ---------------------------------------------------------------------------- -if (OPFLOW_BUILD_TESTS OR OPFLOW_BUILD_ALL) +if(OPFLOW_BUILD_TESTS OR OPFLOW_BUILD_ALL) message(STATUS "Generating tests") enable_testing() add_subdirectory(test) -endif () +endif() # ---------------------------------------------------------------------------- # Build benchmarks # ---------------------------------------------------------------------------- -if (OPFLOW_BUILD_BENCHMARKS OR OPFLOW_BUILD_ALL) +if(OPFLOW_BUILD_BENCHMARKS OR OPFLOW_BUILD_ALL) message(STATUS "Generating benchmarks") # config google benchmark as part of the project set(BENCHMARK_ENABLE_INSTALL OFF) @@ -472,91 +283,72 @@ if (OPFLOW_BUILD_BENCHMARKS OR OPFLOW_BUILD_ALL) set(BENCHMARK_ENABLE_GTEST_TESTS OFF) add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/benchmark EXCLUDE_FROM_ALL) add_subdirectory(benchmark) -endif () +endif() # ---------------------------------------------------------------------------- # Build docs # ---------------------------------------------------------------------------- -if (OPFLOW_BUILD_DOCS OR OPFLOW_BUILD_ALL) +if(OPFLOW_BUILD_DOCS OR OPFLOW_BUILD_ALL) message(STATUS "Generating docs") find_program(SPHINX_PATH sphinx-build - HINTS $ENV{PATH} ${SPHINX_DIR}) - if (NOT SPHINX_PATH) + HINTS $ENV{PATH} ${SPHINX_DIR}) + if(NOT SPHINX_PATH) message(FATAL_ERROR "sphinx-build not found. Please install it via \ instructions at https://www.sphinx-doc.org/en/master/usage/installation.html") - else () + else() message(STATUS "Found sphinx-build at ${SPHINX_PATH}") - endif () + endif() find_program(DOXYGEN_PATH doxygen - HINTS ${DOXYGEN_DIR} - REQUIRED - ) - if (NOT DOXYGEN_PATH) + HINTS ${DOXYGEN_DIR} + REQUIRED + ) + if(NOT DOXYGEN_PATH) message(FATAL_ERROR "Doxygen not found. Please install doxygen with version >= 1.9.2") - else () + else() execute_process( - COMMAND ${DOXYGEN_PATH} --version - RESULT_VARIABLE _ - OUTPUT_VARIABLE _out + COMMAND ${DOXYGEN_PATH} --version + RESULT_VARIABLE _ + OUTPUT_VARIABLE _out ) string(REGEX REPLACE "\n$" "" _out "${_out}") - if (${_out} VERSION_LESS "1.9.2") + if(${_out} VERSION_LESS "1.9.2") message(FATAL_ERROR "Doxygen version too low. Found v${_out}, require >= v1.9.2") - endif () - endif () + endif() + endif() message(STATUS "Found Doxygen version: ${_out}") configure_file(doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/doxygen) add_custom_target(doxygen_doc - COMMAND ${DOXYGEN_PATH} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + COMMAND ${DOXYGEN_PATH} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) add_custom_target(doc - COMMAND ${SPHINX_PATH} -b html - -Dbreathe_projects.OpFlow=${CMAKE_CURRENT_BINARY_DIR}/doc/doxygen/xml - ${CMAKE_CURRENT_LIST_DIR}/doc ${CMAKE_CURRENT_BINARY_DIR}/doc - DEPENDS doxygen_doc - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -endif () + COMMAND ${SPHINX_PATH} -b html + -Dbreathe_projects.OpFlow=${CMAKE_CURRENT_BINARY_DIR}/doc/doxygen/xml + ${CMAKE_CURRENT_LIST_DIR}/doc ${CMAKE_CURRENT_BINARY_DIR}/doc + DEPENDS doxygen_doc + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +endif() # ---------------------------------------------------------------------------- # Install # ---------------------------------------------------------------------------- -if (OPFLOW_INSTALL) +if(OPFLOW_INSTALL) message(STATUS "Generating install") - IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}" CACHE PATH "" FORCE) message(STATUS "Install prefix set to: ${CMAKE_INSTALL_PREFIX}") - ENDIF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(project_config_in "${CMAKE_CURRENT_LIST_DIR}/cmake/opflowConfig.cmake.in") set(project_config_out "${CMAKE_CURRENT_BINARY_DIR}/opflowConfig.cmake") - set(config_targets_file "opflowConfigTargets.cmake") set(version_config_file "${CMAKE_CURRENT_BINARY_DIR}/opflowConfigVersion.cmake") set(export_dest_dir "${CMAKE_INSTALL_LIBDIR}/cmake/opflow") set(pkgconfig_install_dir "${CMAKE_INSTALL_LIBDIR}/pkgconfig") set(pkg_config "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc") - # ---------------------------------------------------------------------------- - # Include files - # ---------------------------------------------------------------------------- - install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") - install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/src/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/src") - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Version.hpp DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") - install( - TARGETS opflow - EXPORT opflow - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) - - if (OPFLOW_WITH_VTK AND NOT OPFLOW_VTK_EXTERNAL) + if(OPFLOW_WITH_VTK AND NOT OPFLOW_VTK_EXTERNAL) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/vtk/ - DESTINATION "${CMAKE_INSTALL_PREFIX}") - endif () - - # ---------------------------------------------------------------------------- - # Install CMake config files - # ---------------------------------------------------------------------------- - install(EXPORT opflow DESTINATION ${export_dest_dir} NAMESPACE opflow:: FILE ${config_targets_file}) + DESTINATION "${CMAKE_INSTALL_PREFIX}") + endif() include(CMakePackageConfigHelpers) configure_file("${project_config_in}" "${project_config_out}" @ONLY) @@ -568,15 +360,15 @@ if (OPFLOW_INSTALL) # Support creation of installable packages # ---------------------------------------------------------------------------- #include(cmake/opflowCPack.cmake) -endif () +endif() # uninstall target -if (NOT TARGET uninstall) +if(NOT TARGET uninstall) configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - IMMEDIATE @ONLY) + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + IMMEDIATE @ONLY) add_custom_target(uninstall - COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) -endif () + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) +endif() diff --git a/README.md b/README.md index c8a20247..12bcbb11 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,11 @@ [![Latest Release](https://img.shields.io/github/v/release/OpFlow-dev/OpFlow?color=blue&label=Latest%20Release)](https://github.com/OpFlow-dev/OpFlow/releases/latest) [![License](https://img.shields.io/badge/license-MPL--2.0-blue)](https://github.com/OpFlow-dev/OpFlow/blob/master/LICENSE) [![Downloads](https://img.shields.io/github/downloads/OpFlow-dev/OpFlow/total?color=blue&label=Downloads)](https://github.com/OpFlow-dev/OpFlow/releases/latest) -[![Format](https://img.shields.io/github/actions/workflow/status/OpFlow-dev/OpFlow/AutoFormat.yml?branch=master?color=green&label=Format)](https://github.com/OpFlow-dev/OpFlow/actions/workflows/AutoFormat.yml) -[![Build](https://img.shields.io/github/actions/workflow/status/OpFlow-dev/OpFlow/Build.yml?branch=master?color=green&label=Build)](https://github.com/OpFlow-dev/OpFlow/actions/workflows/Build.yml) ## Overview diff --git a/README_zh.md b/README_zh.md new file mode 100644 index 00000000..7b3f1501 --- /dev/null +++ b/README_zh.md @@ -0,0 +1,56 @@ + + +[![最新版本](https://img.shields.io/github/v/release/OpFlow-dev/OpFlow?color=blue&label=Latest%20Release)](https://github.com/OpFlow-dev/OpFlow/releases/latest) +[![许可证](https://img.shields.io/badge/license-MPL--2.0-blue)](https://github.com/OpFlow-dev/OpFlow/blob/master/LICENSE) +[![下载次数](https://img.shields.io/github/downloads/OpFlow-dev/OpFlow/total?color=blue&label=Downloads)](https://github.com/OpFlow-dev/OpFlow/releases/latest) + +## 概述 + +**OpFlow** (运筹) 是一个面向偏微分方程(PDE)求解器开发的嵌入式领域特定语言(EDSL)。它深度应用现代C++元编程技术,提供富有表现力的前端接口。通过**表达式模板**和**模板元编程**技术,OpFlow支持**显式**表达式求值与**隐式**线性系统求解。通过解耦表达式、算子及求值引擎的实现,OpFlow实现了算法、数据结构与执行调度的完全分离。其核心优势包括: + +- **完全静态**:关键路径零动态调度开销 +- **零成本抽象**:所有操作在编译期明确定义并强制内联 +- **自动并行化**:基于用户定义策略自动并行化表达式分区与求值 +- **隐式方程求解**:支持任意定义良好的隐式方程求解 +- **仅头文件 & 原生C++嵌入**:纯头文件实现,与C++生态无缝集成 +- **数学化API设计**:前端接口高度贴近数学表示法,最小化语言噪声 +- **精准抽象层级**:在避免底层编码的同时,保持所有转换操作在前端可见,离散化过程直观透明 + +## 示例 +[](examples/CONV1D/CONV1D.cpp) +[](examples/FTCS2D/FTCS-OMP.cpp) +[](examples/LidDriven/LidDriven2D.cpp) +[](examples/LevelSet/AMRLS.cpp) + +## 快速开始 + +0. 安装依赖: + +- Linux:(以Ubuntu为例) +```bash +sudo apt install -y gcc-10 g++-10 +``` +- macOS:(使用Homebrew) +```bash +brew install gcc +``` +1. 配置项目: +```bash +mkdir build && cd build && cmake -DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10 -DOPFLOW_BUILD_EXAMPLES=ON .. +``` +2. 构建与运行: +```bash +cmake --build . -t CONV1D && ./examples/CONV1D/CONV1D +``` + +## 安装 + +完整安装指南请参阅文档。 + +## 致谢 +特别感谢JetBrains提供免费的[开源开发许可证](https://jb.gg/OpenSourceSupport)支持OpFlow开发。CLion是优秀的跨平台C/C++ IDE,强烈推荐用于OpFlow开发。 + +JetBrains Logo (Main) logo. diff --git a/cmake/AMGCLConfig.cmake b/cmake/AMGCLConfig.cmake index dfc433d1..257f8332 100644 --- a/cmake/AMGCLConfig.cmake +++ b/cmake/AMGCLConfig.cmake @@ -16,19 +16,22 @@ macro(CONFIG_AND_INSTALL_AMGCL) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/amgcl-build) - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/amgcl - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/amgcl-build) - if (result) + execute_process(COMMAND ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ${CMAKE_CURRENT_LIST_DIR}/../external/amgcl + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/amgcl-build) + if(result) message(FATAL_ERROR "CMake step for AMGCL failed: ${result}") endif() execute_process(COMMAND ${CMAKE_COMMAND} --install . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/amgcl-build) - if (result) + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/amgcl-build) + if(result) message(FATAL_ERROR "Build & install step for AMGCL failed: ${result}") endif() -endmacro() \ No newline at end of file +endmacro() diff --git a/cmake/FMTConfig.cmake b/cmake/FMTConfig.cmake index 2518c16c..cbe08c87 100644 --- a/cmake/FMTConfig.cmake +++ b/cmake/FMTConfig.cmake @@ -21,7 +21,7 @@ macro(CONFIG_AND_INSTALL_FMT) -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DFMT_DOC=OFF -DFMT_TEST=OFF -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/fmt + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_LIST_DIR}/../external/fmt RESULT_VARIABLE result WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fmt-build) if (result) diff --git a/cmake/HYPREConfig.cmake b/cmake/HYPREConfig.cmake index 69c9e2e7..ba8690f6 100644 --- a/cmake/HYPREConfig.cmake +++ b/cmake/HYPREConfig.cmake @@ -20,8 +20,8 @@ macro(CONFIG_AND_INSTALL_HYPRE) "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DHYPRE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" "-DHYPRE_ENABLE_SINGLE=${OPFLOW_SINGLE_PRECISION}" - "-DHYPRE_WITH_OPENMP=${OPFLOW_WITH_OPENMP}" - "-DHYPRE_WITH_MPI=${OPFLOW_WITH_MPI}" + "-DHYPRE_ENABLE_OPENMP=${OPFLOW_WITH_OPENMP}" + "-DHYPRE_ENABLE_MPI=${OPFLOW_WITH_MPI}" "-DHYPRE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") string(REPLACE " " "\t\n" _hypre_options ${HYPRE_OPTIONS}) message(STATUS "HYPRE is to be configured with:\t\n${_hypre_options}") @@ -32,10 +32,10 @@ macro(CONFIG_AND_INSTALL_HYPRE) -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DHYPRE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DHYPRE_ENABLE_SINGLE=${OPFLOW_SINGLE_PRECISION} - -DHYPRE_WITH_OPENMP=${OPFLOW_WITH_OPENMP} - -DHYPRE_WITH_MPI=${OPFLOW_WITH_MPI} + -DHYPRE_ENABLE_OPENMP=${OPFLOW_WITH_OPENMP} + -DHYPRE_ENABLE_MPI=${OPFLOW_WITH_MPI} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - ${CMAKE_CURRENT_SOURCE_DIR}/external/hypre/src + ${CMAKE_CURRENT_LIST_DIR}/../external/hypre/src RESULT_VARIABLE _result WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/hypre-build) if (_result) diff --git a/cmake/SPDLOGConfig.cmake b/cmake/SPDLOGConfig.cmake index b5a4c2d6..7987d36e 100644 --- a/cmake/SPDLOGConfig.cmake +++ b/cmake/SPDLOGConfig.cmake @@ -17,25 +17,28 @@ macro(CONFIG_AND_INSTALL_SPDLOG) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spdlog-build) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DSPDLOG_BUILD_EXAMPLE=OFF - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/spdlog - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spdlog-build) - if (result) + -DCMAKE_CXX_STANDARD=20 + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DSPDLOG_BUILD_EXAMPLE=OFF + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DSPDLOG_USE_STD_FORMAT=ON + ${CMAKE_CURRENT_LIST_DIR}/../external/spdlog + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spdlog-build) + if(result) message(FATAL_ERROR "CMake step for spdlog failed: ${result}") - endif () + endif() execute_process(COMMAND ${CMAKE_COMMAND} --build . -j - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spdlog-build) - if (result) + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spdlog-build) + if(result) message(FATAL_ERROR "Build step for spdlog failed: ${result}") - endif () + endif() execute_process(COMMAND ${CMAKE_COMMAND} --install . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spdlog-build) - if (result) + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/spdlog-build) + if(result) message(FATAL_ERROR "Install step for spdlog failed: ${result}") - endif () -endmacro() \ No newline at end of file + endif() +endmacro() diff --git a/cmake/TBBConfig.cmake b/cmake/TBBConfig.cmake index 9c928dad..22c0aeb9 100644 --- a/cmake/TBBConfig.cmake +++ b/cmake/TBBConfig.cmake @@ -16,25 +16,31 @@ macro(CONFIG_AND_INSTALL_TBB) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb-build) - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DTBB_TEST=OFF -DTBB_STRICT=OFF - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/tbb - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb-build) - if (result) + execute_process(COMMAND ${CMAKE_COMMAND} + -G "${CMAKE_GENERATOR}" + -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} + -DTBB_TEST=OFF + -DTBB_STRICT=OFF + -DCMAKE_CXX_STANDARD=17 + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ${CMAKE_CURRENT_LIST_DIR}/../external/tbb + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb-build) + if(result) message(FATAL_ERROR "CMake step for TBB failed: ${result}") - endif () + endif() execute_process(COMMAND ${CMAKE_COMMAND} --build . -j - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb-build) - if (result) + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb-build) + if(result) message(FATAL_ERROR "Build step for TBB failed: ${result}") - endif () + endif() execute_process(COMMAND ${CMAKE_COMMAND} --install . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb-build) - if (result) + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb-build) + if(result) message(FATAL_ERROR "Install step for TBB failed: ${result}") - endif () -endmacro() \ No newline at end of file + endif() +endmacro() diff --git a/cmake/TECIOConfig.cmake b/cmake/TECIOConfig.cmake index e64b2e24..4dacb60e 100644 --- a/cmake/TECIOConfig.cmake +++ b/cmake/TECIOConfig.cmake @@ -19,14 +19,14 @@ macro(CONFIG_AND_INSTALL_TECIO) if (OPFLOW_WITH_MPI) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciompisrc RESULT_VARIABLE result WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tecio-build) else () execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciosrc RESULT_VARIABLE result WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tecio-build) endif () @@ -42,25 +42,25 @@ macro(CONFIG_AND_INSTALL_TECIO) # Manually install file(MAKE_DIRECTORY ${CMAKE_INSTALL_PREFIX}/include/tecio) if (OPFLOW_WITH_MPI) - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc/TECIO.h - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc/tecio_Exports.h - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc/tecio.inc - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc/tecio.for - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc/tecio.f90 - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc/tecio_license_agreement.txt - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciompisrc/StandardIntegralTypes.h - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/tecio) + file(COPY ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciompisrc/TECIO.h + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciompisrc/tecio_Exports.h + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciompisrc/tecio.inc + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciompisrc/tecio.for + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciompisrc/tecio.f90 + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciompisrc/tecio_license_agreement.txt + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciompisrc/StandardIntegralTypes.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/tecio) file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tecio-build/libteciompi.a DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) else () - file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc/TECIO.h - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc/tecio_Exports.h - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc/tecio.inc - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc/tecio.for - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc/tecio.f90 - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc/tecio_license_agreement.txt - ${CMAKE_CURRENT_SOURCE_DIR}/external/tecio/teciosrc/StandardIntegralTypes.h - DESTINATION ${CMAKE_INSTALL_PREFIX}/include/tecio) + file(COPY ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciosrc/TECIO.h + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciosrc/tecio_Exports.h + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciosrc/tecio.inc + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciosrc/tecio.for + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciosrc/tecio.f90 + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciosrc/tecio_license_agreement.txt + ${CMAKE_CURRENT_LIST_DIR}/../external/tecio/teciosrc/StandardIntegralTypes.h + DESTINATION ${CMAKE_INSTALL_PREFIX}/include/tecio) file(COPY ${CMAKE_CURRENT_BINARY_DIR}/tecio-build/libtecio.a DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) endif () diff --git a/cmake/Version.hpp.in b/cmake/Version.hpp.in index d1b122fb..b9442866 100644 --- a/cmake/Version.hpp.in +++ b/cmake/Version.hpp.in @@ -1,5 +1,7 @@ +#ifndef OPFLOW_INSIDE_MODULE #include +#endif namespace OpFlow::internal { - inline constexpr static auto OPFLOW_VERSION_STRING = std::string_view {"@OPFLOW_VERSION_STRING@"}; + inline constexpr auto OPFLOW_VERSION_STRING = std::string_view {"@OPFLOW_VERSION_STRING@"}; } \ No newline at end of file diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt new file mode 100644 index 00000000..6aa09b1d --- /dev/null +++ b/external/CMakeLists.txt @@ -0,0 +1,117 @@ +# ---------------------------------------------------------------------------- +# External dependencies configuration +# ---------------------------------------------------------------------------- + +# Use spdlog package +if(OPFLOW_INSTALL) + # Same as libfmt + include(${CMAKE_SOURCE_DIR}/cmake/SPDLOGConfig.cmake) + CONFIG_AND_INSTALL_SPDLOG() + find_package(spdlog REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) +else() + add_subdirectory(${CMAKE_SOURCE_DIR}/external/spdlog EXCLUDE_FROM_ALL) +endif() +target_link_libraries(opflow PUBLIC spdlog::spdlog) + +# Use AMGCL +if(OPFLOW_INSTALL) + include(${CMAKE_SOURCE_DIR}/cmake/AMGCLConfig.cmake) + CONFIG_AND_INSTALL_AMGCL() + find_package(amgcl REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) +else() + add_subdirectory(${CMAKE_SOURCE_DIR}/external/amgcl EXCLUDE_FROM_ALL) +endif() +target_link_libraries(opflow PUBLIC amgcl::amgcl) + +# Use TBB +if(OPFLOW_TBB_EXTERNAL) + if(NOT DEFINED TBB_DIR) + message(FATAL "Variable TBB_DIR not defined. Use -DTBB_DIR to specify TBB's install path.") + endif() + find_package(TBB REQUIRED PATHS ${TBB_DIR} NO_DEFAULT_PATH) +else() + if(OPFLOW_INSTALL) + include(${CMAKE_SOURCE_DIR}/cmake/TBBConfig.cmake) + CONFIG_AND_INSTALL_TBB() + find_package(tbb NAMES tbb TBB REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) + else() + set(BUILD_SHARED_LIBS ON) + set(TBB_TEST OFF) + set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) + add_subdirectory(${CMAKE_SOURCE_DIR}/external/tbb EXCLUDE_FROM_ALL) + find_package(tbb NAMES tbb TBB REQUIRED) + endif() +endif() +target_link_libraries(opflow PUBLIC TBB::tbb) + +# Use HYPRE package +if(OPFLOW_HYPRE_EXTERNAL) + if(NOT DEFINED HYPRE_DIR) + message(FATAL "Variable HYPRE_DIR not set. Use -DHYPRE_DIR to specify HYPRE's install path") + endif() + # Use external HYPRE + find_package(HYPRE REQUIRED PATHS ${HYPRE_DIR} NO_DEFAULT_PATH) + # Here we hard link to the found HYPRE to avoid find again at client + target_link_libraries(opflow PUBLIC HYPRE) +else() + # Use bundled HYPRE + if(OPFLOW_INSTALL) + include(${CMAKE_SOURCE_DIR}/cmake/HYPREConfig.cmake) + CONFIG_AND_INSTALL_HYPRE() + find_package(HYPRE REQUIRED PATHS ${CMAKE_INSTALL_PREFIX} NO_DEFAULT_PATH) + # HYPRE::HYPRE is only exported on install + target_link_libraries(opflow PUBLIC HYPRE::HYPRE) + else() + set(HYPRE_BUILD_TYPE Debug) + set(HYPRE_WITH_OPENMP ${OPFLOW_WITH_OPENMP}) + set(HYPRE_ENABLE_SINGLE ${OPFLOW_SINGLE_PRECISION}) + set(HYPRE_WITH_MPI ${OPFLOW_WITH_MPI}) + add_subdirectory(${CMAKE_SOURCE_DIR}/external/hypre/src EXCLUDE_FROM_ALL) + target_link_libraries(opflow PUBLIC HYPRE) + endif() +endif() + +# Use VTK package +if(OPFLOW_WITH_VTK) + target_compile_definitions(opflow PUBLIC OPFLOW_WITH_VTK) + if(OPFLOW_VTK_EXTERNAL) + if(NOT TARGET VTK) + if(NOT DEFINED VTK_DIR) + message(FATAL "Variable VTK_DIR not defined. Use -DVTK_DIR to specify VTK's install path") + endif() + find_package(VTK REQUIRED PATHS ${VTK_DIR} NO_DEFAULT_PATH) + target_compile_definitions(opflow PUBLIC OPFLOW_VTK_EXTERNAL) + endif() + else() + include(${CMAKE_SOURCE_DIR}/cmake/VTKConfig.cmake) + CONFIG_VTK() + endif() + list(APPEND PKG_CONFIG_REQUIRES VTK) + target_include_directories(opflow PUBLIC ${VTK_INCLUDE_DIRS}) + target_link_directories(opflow PUBLIC ${VTK_LIBRARY_DIRS}) + target_link_libraries(opflow PUBLIC ${VTK_LIBRARIES}) +endif() + +# Use TecIO library +if(OPFLOW_INSTALL) + include(${CMAKE_SOURCE_DIR}/cmake/TECIOConfig.cmake) + CONFIG_AND_INSTALL_TECIO() + target_include_directories(opflow PUBLIC ${CMAKE_INSTALL_PREFIX}/include/tecio) + target_link_directories(opflow PUBLIC ${CMAKE_INSTALL_PREFIX}/lib) + if(OPFLOW_WITH_MPI) + target_link_libraries(opflow PUBLIC teciompi) + target_compile_definitions(opflow PUBLIC TECIOMPI) + else() + target_link_libraries(opflow PUBLIC tecio) + endif() +else() + if(OPFLOW_WITH_MPI) + add_subdirectory(${CMAKE_SOURCE_DIR}/external/tecio/teciompisrc EXCLUDE_FROM_ALL) + target_include_directories(opflow PUBLIC ${CMAKE_SOURCE_DIR}/external/tecio/teciompisrc) + target_link_libraries(opflow PUBLIC teciompi) + else() + add_subdirectory(${CMAKE_SOURCE_DIR}/external/tecio/teciosrc EXCLUDE_FROM_ALL) + target_include_directories(opflow PUBLIC ${CMAKE_SOURCE_DIR}/external/tecio/teciosrc) + target_link_libraries(opflow PUBLIC tecio) + endif() +endif() diff --git a/external/amgcl/CMakeLists.txt b/external/amgcl/CMakeLists.txt index f2288442..44162c72 100755 --- a/external/amgcl/CMakeLists.txt +++ b/external/amgcl/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.1...3.28) if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Build type") message(STATUS "No build type selected, default to ${CMAKE_BUILD_TYPE}") @@ -7,7 +7,7 @@ endif() project(AMGCL) if (NOT (CMAKE_VERSION LESS 3.3)) - cmake_policy(SET CMP0058 OLD) + #cmake_policy(SET CMP0058 OLD) endif() set(AMGCL_MASTER_PROJECT OFF) diff --git a/external/amgcl/amgcl/backend/builtin.hpp b/external/amgcl/amgcl/backend/builtin.hpp index de3b58d2..1b3492c2 100644 --- a/external/amgcl/amgcl/backend/builtin.hpp +++ b/external/amgcl/amgcl/backend/builtin.hpp @@ -718,7 +718,7 @@ namespace amgcl { // Use Power method when power_iters > 0. // When scale = true, scale the matrix by its inverse diagonal. template - static typename math::scalar_of::type>::type + typename math::scalar_of::type>::type spectral_radius(const Matrix &A, int power_iters = 0) { AMGCL_TIC("spectral radius"); typedef typename backend::value_type::type value_type; diff --git a/external/googletest/.clang-format b/external/googletest/.clang-format index 56ba7ee4..5b9bfe6d 100644 --- a/external/googletest/.clang-format +++ b/external/googletest/.clang-format @@ -1,4 +1,4 @@ # Run manually to reformat a file: # clang-format -i --style=file -Language: Cpp -BasedOnStyle: Google +Language: Cpp +BasedOnStyle: Google diff --git a/external/googletest/.github/ISSUE_TEMPLATE/00-bug_report.md b/external/googletest/.github/ISSUE_TEMPLATE/00-bug_report.md deleted file mode 100644 index 8bfa24a3..00000000 --- a/external/googletest/.github/ISSUE_TEMPLATE/00-bug_report.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Bug report about: Create a report to help us improve title: '' -labels: 'bug' assignees: '' ---- - -**Describe the bug** - -Include a clear and concise description of what the problem is, including what you expected to happen, and what actually -happened. - -**Steps to reproduce the bug** - -It's important that we are able to reproduce the problem that you are experiencing. Please provide all code and relevant -steps to reproduce the problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links to a GitHub -branch or [godbolt.org](https://godbolt.org/) that demonstrate the problem are also helpful. - -**Does the bug persist in the most recent commit?** - -We recommend using the latest commit in the master branch in your projects. - -**What operating system and version are you using?** - -If you are using a Linux distribution please include the name and version of the distribution as well. - -**What compiler and version are you using?** - -Please include the output of `gcc -v` or `clang -v`, or the equivalent for your compiler. - -**What build system are you using?** - -Please include the output of `bazel --version` or `cmake --version`, or the equivalent for your build system. - -**Additional context** - -Add any other context about the problem here. diff --git a/external/googletest/.github/ISSUE_TEMPLATE/00-bug_report.yml b/external/googletest/.github/ISSUE_TEMPLATE/00-bug_report.yml new file mode 100644 index 00000000..586779ad --- /dev/null +++ b/external/googletest/.github/ISSUE_TEMPLATE/00-bug_report.yml @@ -0,0 +1,53 @@ +name: Bug Report +description: Let us know that something does not work as expected. +title: "[Bug]: Please title this bug report" +body: + - type: textarea + id: what-happened + attributes: + label: Describe the issue + description: What happened, and what did you expect to happen? + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce the problem + description: It is important that we are able to reproduce the problem that you are experiencing. Please provide all code and relevant steps to reproduce the problem, including your `BUILD`/`CMakeLists.txt` file and build commands. Links to a GitHub branch or [godbolt.org](https://godbolt.org/) that demonstrate the problem are also helpful. + validations: + required: true + - type: textarea + id: version + attributes: + label: What version of GoogleTest are you using? + description: Please include the output of `git rev-parse HEAD` or the GoogleTest release version number that you are using. + validations: + required: true + - type: textarea + id: os + attributes: + label: What operating system and version are you using? + description: If you are using a Linux distribution please include the name and version of the distribution as well. + validations: + required: true + - type: textarea + id: compiler + attributes: + label: What compiler and version are you using? + description: Please include the output of `gcc -v` or `clang -v`, or the equivalent for your compiler. + validations: + required: true + - type: textarea + id: buildsystem + attributes: + label: What build system are you using? + description: Please include the output of `bazel --version` or `cmake --version`, or the equivalent for your build system. + validations: + required: true + - type: textarea + id: additional + attributes: + label: Additional context + description: Add any other context about the problem here. + validations: + required: false diff --git a/external/googletest/.github/ISSUE_TEMPLATE/10-feature_request.md b/external/googletest/.github/ISSUE_TEMPLATE/10-feature_request.md deleted file mode 100644 index 586b9b2e..00000000 --- a/external/googletest/.github/ISSUE_TEMPLATE/10-feature_request.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -name: Feature request about: Propose a new feature title: '' -labels: 'enhancement' assignees: '' ---- - -**Does the feature exist in the most recent commit?** - -We recommend using the latest commit from GitHub in your projects. - -**Why do we need this feature?** - -Ideally, explain why a combination of existing features cannot be used instead. - -**Describe the proposal** - -Include a detailed description of the feature, with usage examples. - -**Is the feature specific to an operating system, compiler, or build system version?** - -If it is, please specify which versions. - diff --git a/external/googletest/.github/ISSUE_TEMPLATE/10-feature_request.yml b/external/googletest/.github/ISSUE_TEMPLATE/10-feature_request.yml new file mode 100644 index 00000000..f3bbc091 --- /dev/null +++ b/external/googletest/.github/ISSUE_TEMPLATE/10-feature_request.yml @@ -0,0 +1,33 @@ +name: Feature request +description: Propose a new feature. +title: "[FR]: Please title this feature request" +labels: "enhancement" +body: + - type: textarea + id: version + attributes: + label: Does the feature exist in the most recent commit? + description: We recommend using the latest commit from GitHub in your projects. + validations: + required: true + - type: textarea + id: why + attributes: + label: Why do we need this feature? + description: Ideally, explain why a combination of existing features cannot be used instead. + validations: + required: true + - type: textarea + id: proposal + attributes: + label: Describe the proposal. + description: Include a detailed description of the feature, with usage examples. + validations: + required: true + - type: textarea + id: platform + attributes: + label: Is the feature specific to an operating system, compiler, or build system version? + description: If it is, please specify which versions. + validations: + required: true diff --git a/external/googletest/.github/ISSUE_TEMPLATE/config.yml b/external/googletest/.github/ISSUE_TEMPLATE/config.yml index 3ba13e0c..65170d10 100644 --- a/external/googletest/.github/ISSUE_TEMPLATE/config.yml +++ b/external/googletest/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1,5 @@ blank_issues_enabled: false +contact_links: + - name: Get Help + url: https://github.com/google/googletest/discussions + about: Please ask and answer questions here. diff --git a/external/googletest/.gitignore b/external/googletest/.gitignore index f08cb72a..f0df39db 100644 --- a/external/googletest/.gitignore +++ b/external/googletest/.gitignore @@ -8,6 +8,7 @@ bazel-genfiles bazel-googletest bazel-out bazel-testlogs +MODULE.bazel.lock # python *.pyc @@ -24,6 +25,10 @@ Win32-Release/ x64-Debug/ x64-Release/ +# VSCode files +.cache/ +cmake-variants.yaml + # Ignore autoconf / automake files Makefile.in aclocal.m4 diff --git a/external/googletest/BUILD.bazel b/external/googletest/BUILD.bazel index 965c518d..53501454 100644 --- a/external/googletest/BUILD.bazel +++ b/external/googletest/BUILD.bazel @@ -30,19 +30,38 @@ # # Bazel Build for Google C++ Testing Framework(Google Test) -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") - package(default_visibility = ["//visibility:public"]) licenses(["notice"]) exports_files(["LICENSE"]) +config_setting( + name = "qnx", + constraint_values = ["@platforms//os:qnx"], +) + config_setting( name = "windows", constraint_values = ["@platforms//os:windows"], ) +config_setting( + name = "freebsd", + constraint_values = ["@platforms//os:freebsd"], +) + +config_setting( + name = "openbsd", + constraint_values = ["@platforms//os:openbsd"], +) + +# NOTE: Fuchsia is not an officially supported platform. +config_setting( + name = "fuchsia", + constraint_values = ["@platforms//os:fuchsia"], +) + config_setting( name = "msvc_compiler", flag_values = { @@ -64,6 +83,10 @@ cc_library( ) # Google Test including Google Mock + +# For an actual test, use `gtest` and also `gtest_main` if you depend on gtest's +# main(). For a library, use `gtest_for_library` instead if the library can be +# testonly. cc_library( name = "gtest", srcs = glob( @@ -86,6 +109,7 @@ cc_library( "googlemock/include/gmock/*.h", ]), copts = select({ + ":qnx": [], ":windows": [], "//conditions:default": ["-pthread"], }), @@ -104,23 +128,59 @@ cc_library( "googletest/include", ], linkopts = select({ + ":qnx": ["-lregex"], ":windows": [], + ":freebsd": [ + "-lm", + "-pthread", + ], + ":openbsd": [ + "-lm", + "-pthread", + ], "//conditions:default": ["-pthread"], }), deps = select({ ":has_absl": [ - "@com_google_absl//absl/debugging:failure_signal_handler", - "@com_google_absl//absl/debugging:stacktrace", - "@com_google_absl//absl/debugging:symbolize", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/types:any", - "@com_google_absl//absl/types:optional", - "@com_google_absl//absl/types:variant", + "@abseil-cpp//absl/container:flat_hash_set", + "@abseil-cpp//absl/debugging:failure_signal_handler", + "@abseil-cpp//absl/debugging:stacktrace", + "@abseil-cpp//absl/debugging:symbolize", + "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/flags:parse", + "@abseil-cpp//absl/flags:reflection", + "@abseil-cpp//absl/flags:usage", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/types:any", + "@abseil-cpp//absl/types:optional", + "@abseil-cpp//absl/types:variant", + "@re2//:re2", + ], + "//conditions:default": [], + }) + select({ + # `gtest-death-test.cc` has `EXPECT_DEATH` that spawns a process, + # expects it to crash and inspects its logs with the given matcher, + # so that's why these libraries are needed. + # Otherwise, builds targeting Fuchsia would fail to compile. + ":fuchsia": [ + "@fuchsia_sdk//pkg/fdio", + "@fuchsia_sdk//pkg/syslog", + "@fuchsia_sdk//pkg/zx", ], "//conditions:default": [], }), ) +# `gtest`, but testonly. See guidance on `gtest` for when to use this. +alias( + name = "gtest_for_library", + actual = ":gtest", + testonly = True, +) + +# Implements main() for tests using gtest. Prefer to depend on `gtest` as well +# to ensure compliance with the layering_check Bazel feature where only the +# direct hdrs values are available. cc_library( name = "gtest_main", srcs = ["googlemock/src/gmock_main.cc"], diff --git a/external/googletest/CMakeLists.txt b/external/googletest/CMakeLists.txt index c94dc57c..0567ae7d 100644 --- a/external/googletest/CMakeLists.txt +++ b/external/googletest/CMakeLists.txt @@ -1,37 +1,36 @@ # Note: CMake support is community-based. The maintainers do not use CMake # internally. -cmake_minimum_required(VERSION 2.8.12) - -if (POLICY CMP0048) - cmake_policy(SET CMP0048 NEW) -endif (POLICY CMP0048) +cmake_minimum_required(VERSION 3.16) project(googletest-distribution) -set(GOOGLETEST_VERSION 1.11.0) +set(GOOGLETEST_VERSION 1.17.0) -if (CMAKE_VERSION VERSION_GREATER "3.0.2") - if (NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) - set(CMAKE_CXX_EXTENSIONS OFF) - endif () -endif () +if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() enable_testing() include(CMakeDependentOption) include(GNUInstallDirs) -#Note that googlemock target already builds googletest +# Note that googlemock target already builds googletest. option(BUILD_GMOCK "Builds the googlemock subproject" ON) option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) - -# temporary fix for macOS 14 & CLT 15 -if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" - AND CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 23) - add_link_options(-Wl,-ld_classic) -endif () -if (BUILD_GMOCK) - add_subdirectory(googlemock) -else () - add_subdirectory(googletest) -endif () +option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF) + +if(GTEST_HAS_ABSL) + if(NOT TARGET absl::base) + find_package(absl REQUIRED) + endif() + if(NOT TARGET re2::re2) + find_package(re2 REQUIRED) + endif() +endif() + +if(BUILD_GMOCK) + add_subdirectory( googlemock ) +else() + add_subdirectory( googletest ) +endif() diff --git a/external/googletest/CONTRIBUTING.md b/external/googletest/CONTRIBUTING.md index e93fe630..ab5a47bf 100644 --- a/external/googletest/CONTRIBUTING.md +++ b/external/googletest/CONTRIBUTING.md @@ -2,80 +2,95 @@ ## Contributor License Agreements -We'd love to accept your patches! Before we can take them, we have to jump a couple of legal hurdles. +We'd love to accept your patches! Before we can take them, we have to jump a +couple of legal hurdles. Please fill out either the individual or corporate Contributor License Agreement (CLA). -* If you are an individual writing original source code and you're sure you own the intellectual property, then you'll - need to sign an - [individual CLA](https://developers.google.com/open-source/cla/individual). -* If you work for a company that wants to allow you to contribute your work, then you'll need to sign a - [corporate CLA](https://developers.google.com/open-source/cla/corporate). +* If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an + [individual CLA](https://developers.google.com/open-source/cla/individual). +* If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a + [corporate CLA](https://developers.google.com/open-source/cla/corporate). -Follow either of the two links above to access the appropriate CLA and instructions for how to sign and return it. Once -we receive it, we'll be able to accept your pull requests. +Follow either of the two links above to access the appropriate CLA and +instructions for how to sign and return it. Once we receive it, we'll be able to +accept your pull requests. ## Are you a Googler? -If you are a Googler, please make an attempt to submit an internal change rather than a GitHub Pull Request. If you are -not able to submit an internal change a PR is acceptable as an alternative. +If you are a Googler, please make an attempt to submit an internal contribution +rather than a GitHub Pull Request. If you are not able to submit internally, a +PR is acceptable as an alternative. ## Contributing A Patch -1. Submit an issue describing your proposed change to the - [issue tracker](https://github.com/google/googletest/issues). -2. Please don't mix more than one logical change per submittal, because it makes the history hard to follow. If you want - to make a change that doesn't have a corresponding issue in the issue tracker, please create one. -3. Also, coordinate with team members that are listed on the issue in question. This ensures that work isn't being - duplicated and communicating your plan early also generally leads to better patches. -4. If your proposed change is accepted, and you haven't already done so, sign a Contributor License Agreement (see - details above). -5. Fork the desired repo, develop and test your code changes. -6. Ensure that your code adheres to the existing style in the sample to which you are contributing. -7. Ensure that your code has an appropriate set of unit tests which all pass. -8. Submit a pull request. +1. Submit an issue describing your proposed change to the + [issue tracker](https://github.com/google/googletest/issues). +2. Please don't mix more than one logical change per submittal, because it + makes the history hard to follow. If you want to make a change that doesn't + have a corresponding issue in the issue tracker, please create one. +3. Also, coordinate with team members that are listed on the issue in question. + This ensures that work isn't being duplicated and communicating your plan + early also generally leads to better patches. +4. If your proposed change is accepted, and you haven't already done so, sign a + Contributor License Agreement + ([see details above](#contributor-license-agreements)). +5. Fork the desired repo, develop and test your code changes. +6. Ensure that your code adheres to the existing style in the sample to which + you are contributing. +7. Ensure that your code has an appropriate set of unit tests which all pass. +8. Submit a pull request. ## The Google Test and Google Mock Communities The Google Test community exists primarily through the -[discussion group](http://groups.google.com/group/googletestframework) and the GitHub repository. Likewise, the Google -Mock community exists primarily through their own [discussion group](http://groups.google.com/group/googlemock). You are -definitely encouraged to contribute to the discussion and you can also help us to keep the effectiveness of the group -high by following and promoting the guidelines listed here. +[discussion group](https://groups.google.com/group/googletestframework) and the +GitHub repository. Likewise, the Google Mock community exists primarily through +their own [discussion group](https://groups.google.com/group/googlemock). You +are definitely encouraged to contribute to the discussion and you can also help +us to keep the effectiveness of the group high by following and promoting the +guidelines listed here. ### Please Be Friendly -Showing courtesy and respect to others is a vital part of the Google culture, and we strongly encourage everyone -participating in Google Test development to join us in accepting nothing less. Of course, being courteous is not the -same as failing to constructively disagree with each other, but it does mean that we should be respectful of each other -when enumerating the 42 technical reasons that a particular proposal may not be the best choice. There's never a reason -to be antagonistic or dismissive toward anyone who is sincerely trying to contribute to a discussion. +Showing courtesy and respect to others is a vital part of the Google culture, +and we strongly encourage everyone participating in Google Test development to +join us in accepting nothing less. Of course, being courteous is not the same as +failing to constructively disagree with each other, but it does mean that we +should be respectful of each other when enumerating the 42 technical reasons +that a particular proposal may not be the best choice. There's never a reason to +be antagonistic or dismissive toward anyone who is sincerely trying to +contribute to a discussion. -Sure, C++ testing is serious business and all that, but it's also a lot of fun. Let's keep it that way. Let's strive to -be one of the friendliest communities in all of open source. +Sure, C++ testing is serious business and all that, but it's also a lot of fun. +Let's keep it that way. Let's strive to be one of the friendliest communities in +all of open source. -As always, discuss Google Test in the official GoogleTest discussion group. You don't have to actually submit code in -order to sign up. Your participation itself is a valuable contribution. +As always, discuss Google Test in the official GoogleTest discussion group. You +don't have to actually submit code in order to sign up. Your participation +itself is a valuable contribution. ## Style -To keep the source consistent, readable, diffable and easy to merge, we use a fairly rigid coding style, as defined by -the -[google-styleguide](https://github.com/google/styleguide) project. All patches will be expected to conform to the style -outlined +To keep the source consistent, readable, diffable and easy to merge, we use a +fairly rigid coding style, as defined by the +[google-styleguide](https://github.com/google/styleguide) project. All patches +will be expected to conform to the style outlined [here](https://google.github.io/styleguide/cppguide.html). Use -[.clang-format](https://github.com/google/googletest/blob/master/.clang-format) -to check your formatting. +[.clang-format](https://github.com/google/googletest/blob/main/.clang-format) to +check your formatting. ## Requirements for Contributors -If you plan to contribute a patch, you need to build Google Test, Google Mock, and their own tests from a git checkout, -which has further requirements: +If you plan to contribute a patch, you need to build Google Test, Google Mock, +and their own tests from a git checkout, which has further requirements: -* [Python](https://www.python.org/) v2.3 or newer (for running some of the tests and re-generating certain source files - from templates) -* [CMake](https://cmake.org/) v2.8.12 or newer +* [Python](https://www.python.org/) v3.6 or newer (for running some of the + tests and re-generating certain source files from templates) +* [CMake](https://cmake.org/) v2.8.12 or newer ## Developing Google Test and Google Mock @@ -83,31 +98,44 @@ This section discusses how to make your own changes to the Google Test project. ### Testing Google Test and Google Mock Themselves -To make sure your changes work as intended and don't break existing functionality, you'll want to compile and run Google -Test and GoogleMock's own tests. For that you can use CMake: +To make sure your changes work as intended and don't break existing +functionality, you'll want to compile and run Google Test and GoogleMock's own +tests. For that you can use CMake: - mkdir mybuild - cd mybuild - cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR} +``` +mkdir mybuild +cd mybuild +cmake -Dgtest_build_tests=ON -Dgmock_build_tests=ON ${GTEST_REPO_DIR} +``` -To choose between building only Google Test or Google Mock, you may modify your cmake command to be one of each +To choose between building only Google Test or Google Mock, you may modify your +cmake command to be one of each - cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests - cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests +``` +cmake -Dgtest_build_tests=ON ${GTEST_DIR} # sets up Google Test tests +cmake -Dgmock_build_tests=ON ${GMOCK_DIR} # sets up Google Mock tests +``` -Make sure you have Python installed, as some of Google Test's tests are written in Python. If the cmake command -complains about not being able to find Python -(`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it explicitly where your Python executable can -be found: +Make sure you have Python installed, as some of Google Test's tests are written +in Python. If the cmake command complains about not being able to find Python +(`Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE)`), try telling it +explicitly where your Python executable can be found: - cmake -DPYTHON_EXECUTABLE=path/to/python ... +``` +cmake -DPYTHON_EXECUTABLE=path/to/python ... +``` -Next, you can build Google Test and / or Google Mock and all desired tests. On \*nix, this is usually done by +Next, you can build Google Test and / or Google Mock and all desired tests. On +\*nix, this is usually done by - make +``` +make +``` To run the tests, do - make test +``` +make test +``` All tests should pass. diff --git a/external/googletest/CONTRIBUTORS b/external/googletest/CONTRIBUTORS index 76db0b40..ccea41ea 100644 --- a/external/googletest/CONTRIBUTORS +++ b/external/googletest/CONTRIBUTORS @@ -34,6 +34,7 @@ Manuel Klimek Mario Tanev Mark Paskin Markus Heule +Martijn Vels Matthew Simmons Mika Raento Mike Bland @@ -54,7 +55,9 @@ Russ Cox Russ Rufer Sean Mcafee Sigurður Ásgeirsson +Soyeon Kim Sverre Sundsdal +Szymon Sobik Takeshi Yoshino Tracy Bialik Vadim Berman diff --git a/external/googletest/googletest/scripts/upload_gtest.py b/external/googletest/MODULE.bazel similarity index 50% rename from external/googletest/googletest/scripts/upload_gtest.py rename to external/googletest/MODULE.bazel index efb7101b..5cb0b156 100644 --- a/external/googletest/googletest/scripts/upload_gtest.py +++ b/external/googletest/MODULE.bazel @@ -1,7 +1,6 @@ -#!/usr/bin/env python +# Copyright 2024 Google Inc. +# All Rights Reserved. # -# Copyright 2009, Google Inc. -# All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -29,50 +28,49 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -"""upload_gtest.py v0.1.0 -- uploads a Google Test patch for review. +# https://bazel.build/external/overview#bzlmod -This simple wrapper passes all command line flags and ---cc=googletestframework@googlegroups.com to upload.py. +module( + name = "googletest", + version = "1.17.0", + compatibility_level = 1, +) -USAGE: upload_gtest.py [options for upload.py] -""" +# Only direct dependencies need to be listed below. +# Please keep the versions in sync with the versions in the WORKSPACE file. -__author__ = 'wan@google.com (Zhanyong Wan)' +bazel_dep( + name = "abseil-cpp", + version = "20250127.1", +) +bazel_dep( + name = "platforms", + version = "0.0.11", +) +bazel_dep( + name = "re2", + version = "2024-07-02.bcr.1", +) -import os -import sys +bazel_dep( + name = "rules_python", + version = "1.3.0", + dev_dependency = True, +) -CC_FLAG = '--cc=' -GTEST_GROUP = 'googletestframework@googlegroups.com' +# https://rules-python.readthedocs.io/en/stable/toolchains.html#library-modules-with-dev-only-python-usage +python = use_extension( + "@rules_python//python/extensions:python.bzl", + "python", + dev_dependency = True, +) +python.toolchain( + ignore_root_user_error = True, + is_default = True, + python_version = "3.12", +) - -def main(): - # Finds the path to upload.py, assuming it is in the same directory - # as this file. - my_dir = os.path.dirname(os.path.abspath(__file__)) - upload_py_path = os.path.join(my_dir, 'upload.py') - - # Adds Google Test discussion group to the cc line if it's not there - # already. - upload_py_argv = [upload_py_path] - found_cc_flag = False - for arg in sys.argv[1:]: - if arg.startswith(CC_FLAG): - found_cc_flag = True - cc_line = arg[len(CC_FLAG):] - cc_list = [addr for addr in cc_line.split(',') if addr] - if GTEST_GROUP not in cc_list: - cc_list.append(GTEST_GROUP) - upload_py_argv.append(CC_FLAG + ','.join(cc_list)) - else: - upload_py_argv.append(arg) - - if not found_cc_flag: - upload_py_argv.append(CC_FLAG + GTEST_GROUP) - - # Invokes upload.py with the modified command line flags. - os.execv(upload_py_path, upload_py_argv) - - -if __name__ == '__main__': - main() +# See fake_fuchsia_sdk.bzl for instructions on how to override this with a real SDK, if needed. +fuchsia_sdk = use_extension("//:fake_fuchsia_sdk.bzl", "fuchsia_sdk") +fuchsia_sdk.create_fake() +use_repo(fuchsia_sdk, "fuchsia_sdk") diff --git a/external/googletest/README.md b/external/googletest/README.md index 95ada68a..598cf312 100644 --- a/external/googletest/README.md +++ b/external/googletest/README.md @@ -2,38 +2,38 @@ ### Announcements -#### Live at Head - -GoogleTest now follows the -[Abseil Live at Head philosophy](https://abseil.io/about/philosophy#upgrade-support). We recommend using the latest -commit in the `master` branch in your projects. - #### Documentation Updates Our documentation is now live on GitHub Pages at -https://google.github.io/googletest/. We recommend browsing the documentation on GitHub Pages rather than directly in -the repository. +https://google.github.io/googletest/. We recommend browsing the documentation on +GitHub Pages rather than directly in the repository. + +#### Release 1.17.0 + +[Release 1.17.0](https://github.com/google/googletest/releases/tag/v1.17.0) is +now available. -#### Release 1.10.x +The 1.17.x branch [requires at least C++17]((https://opensource.google/documentation/policies/cplusplus-support#c_language_standard). -[Release 1.10.x](https://github.com/google/googletest/releases/tag/release-1.10.0) -is now available. +#### Continuous Integration + +We use Google's internal systems for continuous integration. #### Coming Soon -* We are planning to take a dependency on - [Abseil](https://github.com/abseil/abseil-cpp). -* More documentation improvements are planned. +* We are planning to take a dependency on + [Abseil](https://github.com/abseil/abseil-cpp). ## Welcome to **GoogleTest**, Google's C++ test framework! -This repository is a merger of the formerly separate GoogleTest and GoogleMock projects. These were so closely related -that it makes sense to maintain and release them together. +This repository is a merger of the formerly separate GoogleTest and GoogleMock +projects. These were so closely related that it makes sense to maintain and +release them together. ### Getting Started -See the [GoogleTest User's Guide](https://google.github.io/googletest/) for documentation. We recommend starting with -the +See the [GoogleTest User's Guide](https://google.github.io/googletest/) for +documentation. We recommend starting with the [GoogleTest Primer](https://google.github.io/googletest/primer.html). More information about building GoogleTest can be found at @@ -41,88 +41,93 @@ More information about building GoogleTest can be found at ## Features -* An [xUnit](https://en.wikipedia.org/wiki/XUnit) test framework. -* Test discovery. -* A rich set of assertions. -* User-defined assertions. -* Death tests. -* Fatal and non-fatal failures. -* Value-parameterized tests. -* Type-parameterized tests. -* Various options for running the tests. -* XML test report generation. +* xUnit test framework: \ + Googletest is based on the [xUnit](https://en.wikipedia.org/wiki/XUnit) + testing framework, a popular architecture for unit testing +* Test discovery: \ + Googletest automatically discovers and runs your tests, eliminating the need + to manually register your tests +* Rich set of assertions: \ + Googletest provides a variety of assertions, such as equality, inequality, + exceptions, and more, making it easy to test your code +* User-defined assertions: \ + You can define your own assertions with Googletest, making it simple to + write tests that are specific to your code +* Death tests: \ + Googletest supports death tests, which verify that your code exits in a + certain way, making it useful for testing error-handling code +* Fatal and non-fatal failures: \ + You can specify whether a test failure should be treated as fatal or + non-fatal with Googletest, allowing tests to continue running even if a + failure occurs +* Value-parameterized tests: \ + Googletest supports value-parameterized tests, which run multiple times with + different input values, making it useful for testing functions that take + different inputs +* Type-parameterized tests: \ + Googletest also supports type-parameterized tests, which run with different + data types, making it useful for testing functions that work with different + data types +* Various options for running tests: \ + Googletest provides many options for running tests including running + individual tests, running tests in a specific order and running tests in + parallel ## Supported Platforms -GoogleTest requires a codebase and compiler compliant with the C++11 standard or newer. - -The GoogleTest code is officially supported on the following platforms. Operating systems or tools not listed below are -community-supported. For community-supported platforms, patches that do not complicate the code may be considered. - -If you notice any problems on your platform, please file an issue on the -[GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues). Pull requests containing fixes are -welcome! - -### Operating Systems - -* Linux -* macOS -* Windows - -### Compilers - -* gcc 5.0+ -* clang 5.0+ -* MSVC 2015+ - -**macOS users:** Xcode 9.3+ provides clang 5.0+. - -### Build Systems - -* [Bazel](https://bazel.build/) -* [CMake](https://cmake.org/) - -**Note:** Bazel is the build system used by the team internally and in tests. CMake is supported on a best-effort basis -and by the community. +GoogleTest follows Google's +[Foundational C++ Support Policy](https://opensource.google/documentation/policies/cplusplus-support). +See +[this table](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md) +for a list of currently supported versions of compilers, platforms, and build +tools. ## Who Is Using GoogleTest? -In addition to many internal projects at Google, GoogleTest is also used by the following notable projects: +In addition to many internal projects at Google, GoogleTest is also used by the +following notable projects: -* The [Chromium projects](http://www.chromium.org/) (behind the Chrome browser and Chrome OS). -* The [LLVM](http://llvm.org/) compiler. -* [Protocol Buffers](https://github.com/google/protobuf), Google's data interchange format. -* The [OpenCV](http://opencv.org/) computer vision library. +* The [Chromium projects](https://www.chromium.org/) (behind the Chrome + browser and Chrome OS). +* The [LLVM](https://llvm.org/) compiler. +* [Protocol Buffers](https://github.com/google/protobuf), Google's data + interchange format. +* The [OpenCV](https://opencv.org/) computer vision library. ## Related Open Source Projects -[GTest Runner](https://github.com/nholthaus/gtest-runner) is a Qt5 based automated test-runner and Graphical User -Interface with powerful features for Windows and Linux platforms. +[GTest Runner](https://github.com/nholthaus/gtest-runner) is a Qt5 based +automated test-runner and Graphical User Interface with powerful features for +Windows and Linux platforms. -[GoogleTest UI](https://github.com/ospector/gtest-gbar) is a test runner that runs your test binary, allows you to track -its progress via a progress bar, and displays a list of test failures. Clicking on one shows failure text. Google Test +[GoogleTest UI](https://github.com/ospector/gtest-gbar) is a test runner that +runs your test binary, allows you to track its progress via a progress bar, and +displays a list of test failures. Clicking on one shows failure text. GoogleTest UI is written in C#. -[GTest TAP Listener](https://github.com/kinow/gtest-tap-listener) is an event listener for GoogleTest that implements -the -[TAP protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol) for test result output. If your test runner -understands TAP, you may find it useful. +[GTest TAP Listener](https://github.com/kinow/gtest-tap-listener) is an event +listener for GoogleTest that implements the +[TAP protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol) for test +result output. If your test runner understands TAP, you may find it useful. -[gtest-parallel](https://github.com/google/gtest-parallel) is a test runner that runs tests from your binary in parallel -to provide significant speed-up. +[gtest-parallel](https://github.com/google/gtest-parallel) is a test runner that +runs tests from your binary in parallel to provide significant speed-up. [GoogleTest Adapter](https://marketplace.visualstudio.com/items?itemName=DavidSchuldenfrei.gtest-adapter) -is a VS Code extension allowing to view GoogleTest in a tree view, and run/debug your tests. +is a VS Code extension allowing to view GoogleTest in a tree view and run/debug +your tests. -[C++ TestMate](https://github.com/matepek/vscode-catch2-test-adapter) is a VS Code extension allowing to view GoogleTest -in a tree view, and run/debug your tests. +[C++ TestMate](https://github.com/matepek/vscode-catch2-test-adapter) is a VS +Code extension allowing to view GoogleTest in a tree view and run/debug your +tests. -[Cornichon](https://pypi.org/project/cornichon/) is a small Gherkin DSL parser that generates stub code for GoogleTest. +[Cornichon](https://pypi.org/project/cornichon/) is a small Gherkin DSL parser +that generates stub code for GoogleTest. ## Contributing Changes Please read -[`CONTRIBUTING.md`](https://github.com/google/googletest/blob/master/CONTRIBUTING.md) +[`CONTRIBUTING.md`](https://github.com/google/googletest/blob/main/CONTRIBUTING.md) for details on how to contribute to this project. Happy testing! diff --git a/external/googletest/WORKSPACE b/external/googletest/WORKSPACE index 614f5577..0ae5dee9 100644 --- a/external/googletest/WORKSPACE +++ b/external/googletest/WORKSPACE @@ -1,24 +1,61 @@ -workspace(name = "com_google_googletest") +# Copyright 2024 Google Inc. +# All Rights Reserved. +# +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +workspace(name = "googletest") + +load("//:googletest_deps.bzl", "googletest_deps") +googletest_deps() load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( - name = "com_google_absl", - urls = ["https://github.com/abseil/abseil-cpp/archive/7971fb358ae376e016d2d4fc9327aad95659b25e.zip"], # 2021-05-20T02:59:16Z - strip_prefix = "abseil-cpp-7971fb358ae376e016d2d4fc9327aad95659b25e", - sha256 = "aeba534f7307e36fe084b452299e49b97420667a8d28102cf9a0daeed340b859", + name = "rules_python", + sha256 = "2cc26bbd53854ceb76dd42a834b1002cd4ba7f8df35440cf03482e045affc244", + strip_prefix = "rules_python-1.3.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/1.3.0/rules_python-1.3.0.tar.gz", ) +# https://github.com/bazelbuild/rules_python/releases/tag/1.1.0 +load("@rules_python//python:repositories.bzl", "py_repositories") +py_repositories() http_archive( - name = "rules_cc", - urls = ["https://github.com/bazelbuild/rules_cc/archive/68cb652a71e7e7e2858c50593e5a9e3b94e5b9a9.zip"], # 2021-05-14T14:51:14Z - strip_prefix = "rules_cc-68cb652a71e7e7e2858c50593e5a9e3b94e5b9a9", - sha256 = "1e19e9a3bc3d4ee91d7fcad00653485ee6c798efbbf9588d40b34cbfbded143d", + name = "bazel_skylib", + sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94", + urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"], ) http_archive( - name = "rules_python", - urls = ["https://github.com/bazelbuild/rules_python/archive/ed6cc8f2c3692a6a7f013ff8bc185ba77eb9b4d2.zip"], # 2021-05-17T00:24:16Z - strip_prefix = "rules_python-ed6cc8f2c3692a6a7f013ff8bc185ba77eb9b4d2", - sha256 = "98b3c592faea9636ac8444bfd9de7f3fb4c60590932d6e6ac5946e3f8dbd5ff6", + name = "platforms", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.11/platforms-0.0.11.tar.gz", + ], + sha256 = "29742e87275809b5e598dc2f04d86960cc7a55b3067d97221c9abbc9926bff0f", ) diff --git a/external/googletest/WORKSPACE.bzlmod b/external/googletest/WORKSPACE.bzlmod new file mode 100644 index 00000000..381432c5 --- /dev/null +++ b/external/googletest/WORKSPACE.bzlmod @@ -0,0 +1,35 @@ +# Copyright 2024 Google Inc. +# All Rights Reserved. +# +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# https://bazel.build/external/migration#workspace.bzlmod +# +# This file is intentionally empty. When bzlmod is enabled and this +# file exists, the content of WORKSPACE is ignored. This prevents +# bzlmod builds from unintentionally depending on the WORKSPACE file. diff --git a/external/googletest/ci/linux-presubmit.sh b/external/googletest/ci/linux-presubmit.sh index 6bea1cde..6491e798 100644 --- a/external/googletest/ci/linux-presubmit.sh +++ b/external/googletest/ci/linux-presubmit.sh @@ -31,39 +31,59 @@ set -euox pipefail -readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20210525" -readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20201015" +readonly LINUX_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_hybrid-latest:20241218" +readonly LINUX_GCC_FLOOR_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-floor:20250205" if [[ -z ${GTEST_ROOT:-} ]]; then GTEST_ROOT="$(realpath $(dirname ${0})/..)" fi if [[ -z ${STD:-} ]]; then - STD="c++11 c++14 c++17 c++20" + STD="c++17 c++20" fi -# Test the CMake build -for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do - for cmake_off_on in OFF ON; do - time docker run \ - --volume="${GTEST_ROOT}:/src:ro" \ - --tmpfs="/build:exec" \ - --workdir="/build" \ - --rm \ - --env="CC=${cc}" \ - --env="CXX_FLAGS=\"-Werror -Wdeprecated\"" \ - ${LINUX_LATEST_CONTAINER} \ - /bin/bash -c " - cmake /src \ - -DCMAKE_CXX_STANDARD=11 \ - -Dgtest_build_samples=ON \ - -Dgtest_build_tests=ON \ - -Dgmock_build_tests=ON \ - -Dcxx_no_exception=${cmake_off_on} \ - -Dcxx_no_rtti=${cmake_off_on} && \ - make -j$(nproc) && \ - ctest -j$(nproc) --output-on-failure" - done +# Test CMake + GCC +for cmake_off_on in OFF ON; do + time docker run \ + --volume="${GTEST_ROOT}:/src:ro" \ + --tmpfs="/build:exec" \ + --workdir="/build" \ + --rm \ + --env="CC=/usr/local/bin/gcc" \ + --env=CXXFLAGS="-Werror -Wdeprecated" \ + ${LINUX_LATEST_CONTAINER} \ + /bin/bash -c " + cmake /src \ + -DCMAKE_CXX_STANDARD=17 \ + -Dgtest_build_samples=ON \ + -Dgtest_build_tests=ON \ + -Dgmock_build_tests=ON \ + -Dcxx_no_exception=${cmake_off_on} \ + -Dcxx_no_rtti=${cmake_off_on} && \ + make -j$(nproc) && \ + ctest -j$(nproc) --output-on-failure" +done + +# Test CMake + Clang +for cmake_off_on in OFF ON; do + time docker run \ + --volume="${GTEST_ROOT}:/src:ro" \ + --tmpfs="/build:exec" \ + --workdir="/build" \ + --rm \ + --env="CC=/opt/llvm/clang/bin/clang" \ + --env=CXXFLAGS="-Werror -Wdeprecated --gcc-toolchain=/usr/local" \ + ${LINUX_LATEST_CONTAINER} \ + /bin/bash -c " + cmake /src \ + -DCMAKE_CXX_STANDARD=17 \ + -Dgtest_build_samples=ON \ + -Dgtest_build_tests=ON \ + -Dgmock_build_tests=ON \ + -Dcxx_no_exception=${cmake_off_on} \ + -Dcxx_no_rtti=${cmake_off_on} && \ + make -j$(nproc) && \ + ctest -j$(nproc) --output-on-failure" done # Do one test with an older version of GCC @@ -72,11 +92,16 @@ time docker run \ --workdir="/src" \ --rm \ --env="CC=/usr/local/bin/gcc" \ + --env="BAZEL_CXXOPTS=-std=c++17" \ ${LINUX_GCC_FLOOR_CONTAINER} \ /usr/local/bin/bazel test ... \ --copt="-Wall" \ --copt="-Werror" \ + --copt="-Wuninitialized" \ + --copt="-Wundef" \ --copt="-Wno-error=pragmas" \ + --enable_bzlmod=false \ + --features=external_include_paths \ --keep_going \ --show_timestamps \ --test_output=errors @@ -94,8 +119,11 @@ for std in ${STD}; do /usr/local/bin/bazel test ... \ --copt="-Wall" \ --copt="-Werror" \ + --copt="-Wuninitialized" \ + --copt="-Wundef" \ --define="absl=${absl}" \ - --distdir="/bazel-distdir" \ + --enable_bzlmod=true \ + --features=external_include_paths \ --keep_going \ --show_timestamps \ --test_output=errors @@ -116,8 +144,11 @@ for std in ${STD}; do --copt="--gcc-toolchain=/usr/local" \ --copt="-Wall" \ --copt="-Werror" \ + --copt="-Wuninitialized" \ + --copt="-Wundef" \ --define="absl=${absl}" \ - --distdir="/bazel-distdir" \ + --enable_bzlmod=true \ + --features=external_include_paths \ --keep_going \ --linkopt="--gcc-toolchain=/usr/local" \ --show_timestamps \ diff --git a/external/googletest/ci/macos-presubmit.sh b/external/googletest/ci/macos-presubmit.sh index d6423faa..5370ed60 100644 --- a/external/googletest/ci/macos-presubmit.sh +++ b/external/googletest/ci/macos-presubmit.sh @@ -31,6 +31,9 @@ set -euox pipefail +# Use Xcode 16.0 +sudo xcode-select -s /Applications/Xcode_16.0.app/Contents/Developer + if [[ -z ${GTEST_ROOT:-} ]]; then GTEST_ROOT="$(realpath $(dirname ${0})/..)" fi @@ -40,20 +43,20 @@ for cmake_off_on in OFF ON; do BUILD_DIR=$(mktemp -d build_dir.XXXXXXXX) cd ${BUILD_DIR} time cmake ${GTEST_ROOT} \ - -DCMAKE_CXX_STANDARD=11 \ + -DCMAKE_CXX_STANDARD=17 \ -Dgtest_build_samples=ON \ -Dgtest_build_tests=ON \ -Dgmock_build_tests=ON \ -Dcxx_no_exception=${cmake_off_on} \ -Dcxx_no_rtti=${cmake_off_on} - time make + time make -j$(nproc) time ctest -j$(nproc) --output-on-failure done # Test the Bazel build # If we are running on Kokoro, check for a versioned Bazel binary. -KOKORO_GFILE_BAZEL_BIN="bazel-3.7.0-darwin-x86_64" +KOKORO_GFILE_BAZEL_BIN="bazel-8.0.0-darwin-x86_64" if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}" chmod +x ${BAZEL_BIN} @@ -66,7 +69,11 @@ for absl in 0 1; do ${BAZEL_BIN} test ... \ --copt="-Wall" \ --copt="-Werror" \ + --copt="-Wundef" \ + --cxxopt="-std=c++17" \ --define="absl=${absl}" \ + --enable_bzlmod=true \ + --features=external_include_paths \ --keep_going \ --show_timestamps \ --test_output=errors diff --git a/external/googletest/ci/windows-presubmit.bat b/external/googletest/ci/windows-presubmit.bat new file mode 100644 index 00000000..e2664c53 --- /dev/null +++ b/external/googletest/ci/windows-presubmit.bat @@ -0,0 +1,75 @@ +SETLOCAL ENABLEDELAYEDEXPANSION + +SET BAZEL_EXE=%KOKORO_GFILE_DIR%\bazel-8.0.0-windows-x86_64.exe + +SET PATH=C:\Python34;%PATH% +SET BAZEL_PYTHON=C:\python34\python.exe +SET BAZEL_SH=C:\tools\msys64\usr\bin\bash.exe +SET CMAKE_BIN="cmake.exe" +SET CTEST_BIN="ctest.exe" +SET CTEST_OUTPUT_ON_FAILURE=1 +SET CMAKE_BUILD_PARALLEL_LEVEL=16 +SET CTEST_PARALLEL_LEVEL=16 + +SET GTEST_ROOT=%~dp0\.. +IF %errorlevel% neq 0 EXIT /B 1 + +:: ---------------------------------------------------------------------------- +:: CMake +SET CMAKE_BUILD_PATH=cmake_msvc2022 +MKDIR %CMAKE_BUILD_PATH% +CD %CMAKE_BUILD_PATH% + +%CMAKE_BIN% %GTEST_ROOT% ^ + -G "Visual Studio 17 2022" ^ + -DCMAKE_CXX_STANDARD=17 ^ + -DPYTHON_EXECUTABLE:FILEPATH=c:\python37\python.exe ^ + -DPYTHON_INCLUDE_DIR:PATH=c:\python37\include ^ + -DPYTHON_LIBRARY:FILEPATH=c:\python37\lib\site-packages\pip ^ + -Dgtest_build_samples=ON ^ + -Dgtest_build_tests=ON ^ + -Dgmock_build_tests=ON +IF %errorlevel% neq 0 EXIT /B 1 + +%CMAKE_BIN% --build . --target ALL_BUILD --config Debug -- -maxcpucount +IF %errorlevel% neq 0 EXIT /B 1 + +%CTEST_BIN% -C Debug --timeout 600 +IF %errorlevel% neq 0 EXIT /B 1 + +CD %GTEST_ROOT% +RMDIR /S /Q %CMAKE_BUILD_PATH% + +:: ---------------------------------------------------------------------------- +:: Bazel + +:: The default home directory on Kokoro is a long path which causes errors +:: because of Windows limitations on path length. +:: --output_user_root=C:\tmp causes Bazel to use a shorter path. +SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community + +:: C++17 +%BAZEL_EXE% ^ + --output_user_root=C:\tmp ^ + test ... ^ + --compilation_mode=dbg ^ + --copt=/std:c++17 ^ + --copt=/WX ^ + --enable_bzlmod=true ^ + --keep_going ^ + --test_output=errors ^ + --test_tag_filters=-no_test_msvc2017 +IF %errorlevel% neq 0 EXIT /B 1 + +:: C++20 +%BAZEL_EXE% ^ + --output_user_root=C:\tmp ^ + test ... ^ + --compilation_mode=dbg ^ + --copt=/std:c++20 ^ + --copt=/WX ^ + --enable_bzlmod=true ^ + --keep_going ^ + --test_output=errors ^ + --test_tag_filters=-no_test_msvc2017 +IF %errorlevel% neq 0 EXIT /B 1 diff --git a/external/googletest/docs/_data/navigation.yml b/external/googletest/docs/_data/navigation.yml index 8d13e343..9f333270 100644 --- a/external/googletest/docs/_data/navigation.yml +++ b/external/googletest/docs/_data/navigation.yml @@ -1,43 +1,43 @@ nav: - - section: "Get Started" - items: - - title: "Supported Platforms" - url: "/platforms.html" - - title: "Quickstart: Bazel" - url: "/quickstart-bazel.html" - - title: "Quickstart: CMake" - url: "/quickstart-cmake.html" - - section: "Guides" - items: - - title: "GoogleTest Primer" - url: "/primer.html" - - title: "Advanced Topics" - url: "/advanced.html" - - title: "Mocking for Dummies" - url: "/gmock_for_dummies.html" - - title: "Mocking Cookbook" - url: "/gmock_cook_book.html" - - title: "Mocking Cheat Sheet" - url: "/gmock_cheat_sheet.html" - - section: "References" - items: - - title: "Testing Reference" - url: "/reference/testing.html" - - title: "Mocking Reference" - url: "/reference/mocking.html" - - title: "Assertions" - url: "/reference/assertions.html" - - title: "Matchers" - url: "/reference/matchers.html" - - title: "Actions" - url: "/reference/actions.html" - - title: "Testing FAQ" - url: "/faq.html" - - title: "Mocking FAQ" - url: "/gmock_faq.html" - - title: "Code Samples" - url: "/samples.html" - - title: "Using pkg-config" - url: "/pkgconfig.html" - - title: "Community Documentation" - url: "/community_created_documentation.html" +- section: "Get Started" + items: + - title: "Supported Platforms" + url: "/platforms.html" + - title: "Quickstart: Bazel" + url: "/quickstart-bazel.html" + - title: "Quickstart: CMake" + url: "/quickstart-cmake.html" +- section: "Guides" + items: + - title: "GoogleTest Primer" + url: "/primer.html" + - title: "Advanced Topics" + url: "/advanced.html" + - title: "Mocking for Dummies" + url: "/gmock_for_dummies.html" + - title: "Mocking Cookbook" + url: "/gmock_cook_book.html" + - title: "Mocking Cheat Sheet" + url: "/gmock_cheat_sheet.html" +- section: "References" + items: + - title: "Testing Reference" + url: "/reference/testing.html" + - title: "Mocking Reference" + url: "/reference/mocking.html" + - title: "Assertions" + url: "/reference/assertions.html" + - title: "Matchers" + url: "/reference/matchers.html" + - title: "Actions" + url: "/reference/actions.html" + - title: "Testing FAQ" + url: "/faq.html" + - title: "Mocking FAQ" + url: "/gmock_faq.html" + - title: "Code Samples" + url: "/samples.html" + - title: "Using pkg-config" + url: "/pkgconfig.html" + - title: "Community Documentation" + url: "/community_created_documentation.html" diff --git a/external/googletest/docs/_layouts/default.html b/external/googletest/docs/_layouts/default.html index db30419f..c7f331b8 100644 --- a/external/googletest/docs/_layouts/default.html +++ b/external/googletest/docs/_layouts/default.html @@ -1,63 +1,58 @@ - - + + - {% seo %} - +{% seo %} + - - -