From 8ef74627772fb5299ecef695484e987d592c0c91 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 10 Jul 2021 11:27:53 +0100 Subject: [PATCH 01/78] [ci] add github workflow --- .github/workflows/cmake-build.yml | 60 +++++++++++++++++++++++++++++++ CMakeLists.txt | 3 +- conanfile.txt | 9 +++++ 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/cmake-build.yml create mode 100644 conanfile.txt diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml new file mode 100644 index 0000000000..57e5932152 --- /dev/null +++ b/.github/workflows/cmake-build.yml @@ -0,0 +1,60 @@ +name: cmake-build +on: [push] +jobs: + linux-build: + strategy: + matrix: + image: [conanio/gcc11] + libcxx: [libstdc++11] + include: + - image: conanio/clang11 + libcxx: libc++ + runs-on: ubuntu-20.04 + container: + image: ${{ matrix.image }} + options: '--user=root' + steps: + - uses: actions/checkout@v2 + - name: Install and configure conan + run: | + python -m pip install --upgrade pip + pip install --upgrade \ + conan \ + ninja + conan install . -if build \ + -s compiler.libcxx=${{ matrix.libcxx }} -s build_type=Release \ + --build missing + - name: build with cmake + run: | + cmake -S . -B build -G Ninja \ + -D CONAN=MANUAL \ + -D WITH_BOOST=OFF + cmake --build build + - name: run tests + run: | + ctest -vvv build + windows-build: + runs-on: windows-2019 + steps: + - uses: actions/checkout@v2 + - name: Install and configure conan + run: | + python -m pip install --upgrade pip + pip install --upgrade \ + conan \ + ninja + conan install . -if build \ + -s compiler="Visual Studio" -s compiler.version="16" -s build_type=Release \ + --build missing + shell: bash + - name: build with cmake + run: | + cmake -S . -B build -G "Visual Studio 16 2019" -A x64 \ + -D CONAN=MANUAL \ + -D WITH_BOOST=OFF + cmake --build build + shell: bash + - name: run tests + run: | + ctest -vvv build + shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 096a28705a..7fd40c34d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/catch2/cma #============================================================================= # Conan #============================================================================= -# SET(CONAN_DISABLE_CHECK_COMPILER TRUE) -set(CONAN_PROFILE "default" CACHE STRING "Name of conan profile to use, uses default by default") set(CONAN "AUTO" CACHE STRING "conan options AUTO (conan must be in path), MANUAL (expects conanbuildinfo.cmake in build directory) or DISABLE") +set(CONAN_PROFILE "default" CACHE STRING "Name of conan profile to use, uses default by default") set(CONAN_FILE "conanfile_ess.txt" CACHE STRING "The conanfile to use for the build") if(${CONAN} MATCHES "AUTO") include(${EXTRA_MODULES_DIR}/ConanSetup.cmake) diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000000..c52c312903 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,9 @@ +[requires] +hdf5/1.12.0 + +[build_requires] +gtest/1.11.0 + +[generators] +cmake +cmake_find_package From caa84620bb27953b26c218a2e8bff878ff301b07 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Aug 2021 21:44:47 +0100 Subject: [PATCH 02/78] [cmake] add cmake binary dir to module path for conan find packages --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fd40c34d1..f8c96da9f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/catch2/cma set(CONAN "AUTO" CACHE STRING "conan options AUTO (conan must be in path), MANUAL (expects conanbuildinfo.cmake in build directory) or DISABLE") set(CONAN_PROFILE "default" CACHE STRING "Name of conan profile to use, uses default by default") set(CONAN_FILE "conanfile_ess.txt" CACHE STRING "The conanfile to use for the build") + if(${CONAN} MATCHES "AUTO") include(${EXTRA_MODULES_DIR}/ConanSetup.cmake) conan_cmake_run(CONANFILE ${CONAN_FILE} @@ -27,10 +28,12 @@ if(${CONAN} MATCHES "AUTO") BASIC_SETUP NO_OUTPUT_DIRS KEEP_RPATHS BUILD_TYPE "None" BUILD outdated) + list(PREPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) elseif(${CONAN} MATCHES "MANUAL") if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(NO_OUTPUT_DIRS KEEP_RPATHS) + list(PREPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) else() message(FATAL_ERROR "CONAN set to MANUAL but no file named conanbuildinfo.cmake found in build directory") endif() From 348165919bdfdbbbb6789b49066ebca4248121b9 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Aug 2021 21:51:54 +0100 Subject: [PATCH 03/78] [ci] setup msbuild on windows workflow --- .github/workflows/cmake-build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 57e5932152..2085f4353a 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -9,6 +9,7 @@ jobs: include: - image: conanio/clang11 libcxx: libc++ + runs-on: ubuntu-20.04 container: image: ${{ matrix.image }} @@ -37,6 +38,8 @@ jobs: runs-on: windows-2019 steps: - uses: actions/checkout@v2 + - name: Add MSVC to PATH + uses: ilammy/msvc-dev-cmd@v1 - name: Install and configure conan run: | python -m pip install --upgrade pip @@ -49,7 +52,8 @@ jobs: shell: bash - name: build with cmake run: | - cmake -S . -B build -G "Visual Studio 16 2019" -A x64 \ + cmake -S . -B build -G "Ninja" \ + -D CMAKE_CXX_COMPILER=cl \ -D CONAN=MANUAL \ -D WITH_BOOST=OFF cmake --build build From 7e75dc6997de11a5981173b3bd7a2ae56f2ffce3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Aug 2021 22:57:04 +0100 Subject: [PATCH 04/78] [cmake] support static hdf5 library on windows and link using targets --- cmake/HDF5LibraryConfig.cmake | 3 --- src/h5cpp/CMakeLists.txt | 24 ++++-------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/cmake/HDF5LibraryConfig.cmake b/cmake/HDF5LibraryConfig.cmake index d02025ca68..1ec52aed90 100644 --- a/cmake/HDF5LibraryConfig.cmake +++ b/cmake/HDF5LibraryConfig.cmake @@ -15,9 +15,6 @@ message(STATUS "Found HDF5 HDF5_VERSION = ${HDF5_VERSION}") message(STATUS "Found HDF5 HDF5_IS_PARALLEL = ${HDF5_IS_PARALLEL}") message(STATUS "==============================================================") -if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) - add_definitions(-DH5_BUILT_AS_DYNAMIC_LIB) -endif() if(WITH_MPI) if(NOT HDF5_IS_PARALLEL) diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index 60656175a1..cfe888e732 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -36,27 +36,9 @@ else() list(APPEND H5CPP_LINKS $<$,$,11.0>>:c++fs>) endif() -# -# remove the absolute path from the library name -# -set(H5CPP_INTERFACE_LIBS) -set(H5CPP_PRIVATE_LIBS ${HDF5_LIBRARIES}) -foreach(HDF5_LIBRARY ${HDF5_LIBRARIES}) - get_filename_component(LIB_NAME ${HDF5_LIBRARY} NAME) - list(APPEND H5CPP_INTERFACE_LIBS ${LIB_NAME}) -endforeach() - -set(H5CPP_HL_PRIVATE_LIBS ${HDF5_HL_LIBRARIES}) -foreach(HDF5_LIBRARY ${HDF5_HL_LIBRARIES}) - get_filename_component(LIB_NAME ${HDF5_LIBRARY} NAME) - list(APPEND H5CPP_INTERFACE_LIBS ${LIB_NAME}) -endforeach() - target_include_directories(h5cpp PRIVATE ${PROJECT_SOURCE_DIR}/src - PUBLIC ${HDF5_INCLUDE_DIRS} - PUBLIC ${MPI_CXX_INCLUDE_PATH} INTERFACE $ INTERFACE $ ) @@ -79,8 +61,10 @@ set_target_properties(h5cpp enable_coverage(h5cpp) target_link_libraries(h5cpp - PUBLIC ${H5CPP_LINKS} - PRIVATE ${COVERAGE_LIBRARIES} ${H5CPP_PRIVATE_LIBS} ${H5CPP_HL_PRIVATE_LIBS} + PUBLIC + ${H5CPP_LINKS} + PRIVATE ${COVERAGE_LIBRARIES} + hdf5::hdf5 hdf5::hdf5_hl INTERFACE ${H5CPP_INTERFACE_LIBS}) include(GNUInstallDirs) #Required for CMAKE_INSTALL_XXX From 0785615f5eeb4a146aa9e01a3d07b5954d0414f8 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Aug 2021 22:58:55 +0100 Subject: [PATCH 05/78] [cmake] support building static library --- src/h5cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index cfe888e732..6e746c084f 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -19,7 +19,7 @@ add_subdirectory(utilities) add_doxygen_source_deps(${h5cpp_headers}) -add_library(h5cpp SHARED +add_library(h5cpp ${h5cpp_sources} ${h5cpp_headers} ) From 94b6f67187829edfed6a67458c5107d38aef4a0c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Aug 2021 23:10:02 +0100 Subject: [PATCH 06/78] [ci] build static and shared libraries --- .github/workflows/cmake-build.yml | 17 ++++++++++++++--- conanfile.txt | 3 +++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 2085f4353a..712bcb7302 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -6,6 +6,7 @@ jobs: matrix: image: [conanio/gcc11] libcxx: [libstdc++11] + shared: [true, false] include: - image: conanio/clang11 libcxx: libc++ @@ -23,18 +24,24 @@ jobs: conan \ ninja conan install . -if build \ - -s compiler.libcxx=${{ matrix.libcxx }} -s build_type=Release \ + -s compiler.libcxx=${{ matrix.libcxx }} \ + -s build_type=Release \ + -s hdf5:shared=${{ matrix.shared }} \ --build missing - name: build with cmake run: | cmake -S . -B build -G Ninja \ -D CONAN=MANUAL \ - -D WITH_BOOST=OFF + -D WITH_BOOST=OFF \ + -D BUILD_SHARED_LIBS=${{ matrix.shared }} cmake --build build - name: run tests run: | ctest -vvv build windows-build: + strategy: + matrix: + shared: [true, false] runs-on: windows-2019 steps: - uses: actions/checkout@v2 @@ -47,13 +54,17 @@ jobs: conan \ ninja conan install . -if build \ - -s compiler="Visual Studio" -s compiler.version="16" -s build_type=Release \ + -s compiler="Visual Studio" \ + -s compiler.version="16" \ + -s build_type=Release \ + -s hdf5:shared=${{ matrix.shared }} \ --build missing shell: bash - name: build with cmake run: | cmake -S . -B build -G "Ninja" \ -D CMAKE_CXX_COMPILER=cl \ + -D BUILD_SHARED_LIBS=${{ matrix.shared }} \ -D CONAN=MANUAL \ -D WITH_BOOST=OFF cmake --build build diff --git a/conanfile.txt b/conanfile.txt index c52c312903..55cdd5e6e9 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -7,3 +7,6 @@ gtest/1.11.0 [generators] cmake cmake_find_package + +[options] +hdf5:enable_cxx=False From 4d63220d2790e0dbac93e874151aec85e8602bf1 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Aug 2021 23:16:21 +0100 Subject: [PATCH 07/78] [ci] add macos configuration --- .github/workflows/cmake-build.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 712bcb7302..a9a176ebf8 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -73,3 +73,27 @@ jobs: run: | ctest -vvv build shell: bash + mac-build: + runs-on: macos-10.15 + steps: + - uses: actions/checkout@v2 + - name: Install and configure conan + run: | + python -m pip install --upgrade pip + pip install --upgrade \ + conan \ + ninja + conan install . -if build \ + -s build_type=Release \ + -s hdf5:shared=${{ matrix.shared }} \ + --build missing + - name: build with cmake + run: | + cmake -S . -B build -G Ninja \ + -D CONAN=MANUAL \ + -D WITH_BOOST=OFF \ + -D BUILD_SHARED_LIBS=${{ matrix.shared }} + cmake --build build + - name: run tests + run: | + ctest -vvv build From fed12b393a105175dd975f28254110b5020aaaf0 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Aug 2021 23:19:05 +0100 Subject: [PATCH 08/78] [ci] fix shared option --- .github/workflows/cmake-build.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index a9a176ebf8..74c2a70483 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -4,11 +4,11 @@ jobs: linux-build: strategy: matrix: - image: [conanio/gcc11] - libcxx: [libstdc++11] - shared: [true, false] - include: - - image: conanio/clang11 + image: [conanio/gcc11, conanio/clang11] + libcxx: [libstdc++11, libc++] + shared: ["True", "False"] + exclude: + - image: conanio/gcc11 libcxx: libc++ runs-on: ubuntu-20.04 @@ -26,7 +26,7 @@ jobs: conan install . -if build \ -s compiler.libcxx=${{ matrix.libcxx }} \ -s build_type=Release \ - -s hdf5:shared=${{ matrix.shared }} \ + -o hdf5:shared=${{ matrix.shared }} \ --build missing - name: build with cmake run: | @@ -41,7 +41,7 @@ jobs: windows-build: strategy: matrix: - shared: [true, false] + shared: ["True", "False"] runs-on: windows-2019 steps: - uses: actions/checkout@v2 @@ -57,7 +57,7 @@ jobs: -s compiler="Visual Studio" \ -s compiler.version="16" \ -s build_type=Release \ - -s hdf5:shared=${{ matrix.shared }} \ + -o hdf5:shared=${{ matrix.shared }} \ --build missing shell: bash - name: build with cmake @@ -74,9 +74,15 @@ jobs: ctest -vvv build shell: bash mac-build: + strategy: + matrix: + shared: ["True", "False"] runs-on: macos-10.15 steps: - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.x' - name: Install and configure conan run: | python -m pip install --upgrade pip @@ -85,7 +91,7 @@ jobs: ninja conan install . -if build \ -s build_type=Release \ - -s hdf5:shared=${{ matrix.shared }} \ + -o hdf5:shared=${{ matrix.shared }} \ --build missing - name: build with cmake run: | From 1870685fd9ec62296144018bd323fc4130b15c65 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sat, 7 Aug 2021 23:51:19 +0100 Subject: [PATCH 09/78] [cmake] use full hdf5 target until conan package is updated --- src/h5cpp/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index 6e746c084f..5411854892 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -64,7 +64,7 @@ target_link_libraries(h5cpp PUBLIC ${H5CPP_LINKS} PRIVATE ${COVERAGE_LIBRARIES} - hdf5::hdf5 hdf5::hdf5_hl + HDF5::HDF5 INTERFACE ${H5CPP_INTERFACE_LIBS}) include(GNUInstallDirs) #Required for CMAKE_INSTALL_XXX From 71454b9b624f59af191af27251743127116e8587 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 8 Aug 2021 00:20:38 +0100 Subject: [PATCH 10/78] [ci] add boost and stdfs configurations --- .github/workflows/cmake-build.yml | 36 +++++++++++++++++++++---------- .github/workflows/set_env_vars.sh | 11 ++++++++++ conanfile.txt | 1 + 3 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/set_env_vars.sh diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 74c2a70483..73c26f038c 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -6,7 +6,8 @@ jobs: matrix: image: [conanio/gcc11, conanio/clang11] libcxx: [libstdc++11, libc++] - shared: ["True", "False"] + shared: ["shared", "static"] + boost: ["boost", "stdfs"] exclude: - image: conanio/gcc11 libcxx: libc++ @@ -17,6 +18,9 @@ jobs: options: '--user=root' steps: - uses: actions/checkout@v2 + - name: Set environment variables + run: | + bash .github/workflows/set_env_vars.sh - name: Install and configure conan run: | python -m pip install --upgrade pip @@ -26,14 +30,14 @@ jobs: conan install . -if build \ -s compiler.libcxx=${{ matrix.libcxx }} \ -s build_type=Release \ - -o hdf5:shared=${{ matrix.shared }} \ + -o hdf5:shared=${H5CPP_SHARED} \ --build missing - name: build with cmake run: | cmake -S . -B build -G Ninja \ -D CONAN=MANUAL \ - -D WITH_BOOST=OFF \ - -D BUILD_SHARED_LIBS=${{ matrix.shared }} + -D WITH_BOOST=${H5CPP_WITH_BOOST} \ + -D BUILD_SHARED_LIBS=${H5CPP_SHARED} cmake --build build - name: run tests run: | @@ -41,12 +45,17 @@ jobs: windows-build: strategy: matrix: - shared: ["True", "False"] + shared: ["shared", "static"] + boost: ["boost", "stdfs"] runs-on: windows-2019 steps: - uses: actions/checkout@v2 - name: Add MSVC to PATH uses: ilammy/msvc-dev-cmd@v1 + - name: Set environment variables + run: | + bash .github/workflows/set_env_vars.sh + shell: bash - name: Install and configure conan run: | python -m pip install --upgrade pip @@ -57,16 +66,16 @@ jobs: -s compiler="Visual Studio" \ -s compiler.version="16" \ -s build_type=Release \ - -o hdf5:shared=${{ matrix.shared }} \ + -o hdf5:shared=${H5CPP_SHARED} \ --build missing shell: bash - name: build with cmake run: | cmake -S . -B build -G "Ninja" \ -D CMAKE_CXX_COMPILER=cl \ - -D BUILD_SHARED_LIBS=${{ matrix.shared }} \ + -D BUILD_SHARED_LIBS=${H5CPP_SHARED} \ -D CONAN=MANUAL \ - -D WITH_BOOST=OFF + -D WITH_BOOST=${H5CPP_WITH_BOOST} cmake --build build shell: bash - name: run tests @@ -76,13 +85,17 @@ jobs: mac-build: strategy: matrix: - shared: ["True", "False"] + shared: ["shared", "static"] + boost: ["boost", "stdfs"] runs-on: macos-10.15 steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: '3.x' + - name: Set environment variables + run: | + bash .github/workflows/set_env_vars.sh - name: Install and configure conan run: | python -m pip install --upgrade pip @@ -91,14 +104,15 @@ jobs: ninja conan install . -if build \ -s build_type=Release \ - -o hdf5:shared=${{ matrix.shared }} \ + -o hdf5:shared=${H5CPP_SHARED} \ --build missing - name: build with cmake run: | cmake -S . -B build -G Ninja \ -D CONAN=MANUAL \ -D WITH_BOOST=OFF \ - -D BUILD_SHARED_LIBS=${{ matrix.shared }} + -D BUILD_SHARED_LIBS=${H5CPP_SHARED} \ + -D WITH_BOOST=${H5CPP_WITH_BOOST} cmake --build build - name: run tests run: | diff --git a/.github/workflows/set_env_vars.sh b/.github/workflows/set_env_vars.sh new file mode 100644 index 0000000000..c61c2e1f51 --- /dev/null +++ b/.github/workflows/set_env_vars.sh @@ -0,0 +1,11 @@ +#!/bin/bash +if [ "$1" = "shared" ]; then + echo "H5CPP_SHARED=True" >> $GITHUB_ENV +else + echo "H5CPP_SHARED=False" >> $GITHUB_ENV +fi +if [ "$2" = "boost" ]; then + echo "H5CPP_WITH_BOOST=True" >> $GITHUB_ENV +else + echo "H5CPP_WITH_BOOST=False" >> $GITHUB_ENV +fi \ No newline at end of file diff --git a/conanfile.txt b/conanfile.txt index 55cdd5e6e9..a78fe34108 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,4 +1,5 @@ [requires] +boost/1.76.0 hdf5/1.12.0 [build_requires] From d673fc0e1ecb2fd14a3c03c312d7250b94b22280 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 8 Aug 2021 16:11:17 +0100 Subject: [PATCH 11/78] [ci] add openmpi config to linux and mac builds --- .github/workflows/cmake-build.yml | 11 ++++++++--- .github/workflows/set_env_vars.sh | 7 ++++++- conanfile.txt | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 73c26f038c..874ff141b2 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -8,6 +8,7 @@ jobs: libcxx: [libstdc++11, libc++] shared: ["shared", "static"] boost: ["boost", "stdfs"] + mpi: ["mpi", "serial"] exclude: - image: conanio/gcc11 libcxx: libc++ @@ -31,13 +32,15 @@ jobs: -s compiler.libcxx=${{ matrix.libcxx }} \ -s build_type=Release \ -o hdf5:shared=${H5CPP_SHARED} \ + -o hdf5:parallel=${H5CPP_WITH_MPI} \ --build missing - name: build with cmake run: | cmake -S . -B build -G Ninja \ -D CONAN=MANUAL \ - -D WITH_BOOST=${H5CPP_WITH_BOOST} \ -D BUILD_SHARED_LIBS=${H5CPP_SHARED} + -D WITH_BOOST=${H5CPP_WITH_BOOST} \ + -D WITH_MPI=${H5CPP_WITH_MPI} \ cmake --build build - name: run tests run: | @@ -73,8 +76,8 @@ jobs: run: | cmake -S . -B build -G "Ninja" \ -D CMAKE_CXX_COMPILER=cl \ - -D BUILD_SHARED_LIBS=${H5CPP_SHARED} \ -D CONAN=MANUAL \ + -D BUILD_SHARED_LIBS=${H5CPP_SHARED} \ -D WITH_BOOST=${H5CPP_WITH_BOOST} cmake --build build shell: bash @@ -87,6 +90,7 @@ jobs: matrix: shared: ["shared", "static"] boost: ["boost", "stdfs"] + mpi: ["mpi", "serial"] runs-on: macos-10.15 steps: - uses: actions/checkout@v2 @@ -105,13 +109,14 @@ jobs: conan install . -if build \ -s build_type=Release \ -o hdf5:shared=${H5CPP_SHARED} \ + -o hdf5:parallel=${H5CPP_WITH_MPI} \ --build missing - name: build with cmake run: | cmake -S . -B build -G Ninja \ -D CONAN=MANUAL \ - -D WITH_BOOST=OFF \ -D BUILD_SHARED_LIBS=${H5CPP_SHARED} \ + -D WITH_MPI=${H5CPP_WITH_MPI} \ -D WITH_BOOST=${H5CPP_WITH_BOOST} cmake --build build - name: run tests diff --git a/.github/workflows/set_env_vars.sh b/.github/workflows/set_env_vars.sh index c61c2e1f51..f239d47c93 100644 --- a/.github/workflows/set_env_vars.sh +++ b/.github/workflows/set_env_vars.sh @@ -8,4 +8,9 @@ if [ "$2" = "boost" ]; then echo "H5CPP_WITH_BOOST=True" >> $GITHUB_ENV else echo "H5CPP_WITH_BOOST=False" >> $GITHUB_ENV -fi \ No newline at end of file +fi +if [ "$3" = "mpi" ]; then + echo "H5CPP_WITH_MPI=True" >> $GITHUB_ENV +else + echo "H5CPP_WITH_MPI=False" >> $GITHUB_ENV +fi diff --git a/conanfile.txt b/conanfile.txt index a78fe34108..229f250240 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,6 +1,7 @@ [requires] boost/1.76.0 hdf5/1.12.0 +openmpi/4.1.0 [build_requires] gtest/1.11.0 From 9a55d069c70c3ddce440a86af1e5b57b640b8f9d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 8 Aug 2021 18:15:06 +0100 Subject: [PATCH 12/78] [ci] use a python conanfile to install os specific dependencies --- .github/workflows/cmake-build.yml | 25 +++++++++++++++------- conanfile.py | 35 +++++++++++++++++++++++++++++++ conanfile.txt | 14 ------------- 3 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 conanfile.py delete mode 100644 conanfile.txt diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 874ff141b2..edd9ca2782 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -21,7 +21,10 @@ jobs: - uses: actions/checkout@v2 - name: Set environment variables run: | - bash .github/workflows/set_env_vars.sh + bash .github/workflows/set_env_vars.sh \ + ${{ matrix.shared }} \ + ${{ matrix.boost }} \ + ${{ matrix.mpi }} - name: Install and configure conan run: | python -m pip install --upgrade pip @@ -31,8 +34,8 @@ jobs: conan install . -if build \ -s compiler.libcxx=${{ matrix.libcxx }} \ -s build_type=Release \ - -o hdf5:shared=${H5CPP_SHARED} \ - -o hdf5:parallel=${H5CPP_WITH_MPI} \ + -o with_boost=${H5CPP_WITH_BOOST} \ + -o with_mpi=${H5CPP_WITH_MPI} \ --build missing - name: build with cmake run: | @@ -57,7 +60,9 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 - name: Set environment variables run: | - bash .github/workflows/set_env_vars.sh + bash .github/workflows/set_env_vars.sh \ + ${{ matrix.shared }} \ + ${{ matrix.boost }} shell: bash - name: Install and configure conan run: | @@ -69,7 +74,8 @@ jobs: -s compiler="Visual Studio" \ -s compiler.version="16" \ -s build_type=Release \ - -o hdf5:shared=${H5CPP_SHARED} \ + -o with_boost=${H5CPP_WITH_BOOST} \ + -o with_mpi=${H5CPP_WITH_MPI} \ --build missing shell: bash - name: build with cmake @@ -99,7 +105,10 @@ jobs: python-version: '3.x' - name: Set environment variables run: | - bash .github/workflows/set_env_vars.sh + bash .github/workflows/set_env_vars.sh \ + ${{ matrix.shared }} \ + ${{ matrix.boost }} \ + ${{ matrix.mpi }} - name: Install and configure conan run: | python -m pip install --upgrade pip @@ -108,8 +117,8 @@ jobs: ninja conan install . -if build \ -s build_type=Release \ - -o hdf5:shared=${H5CPP_SHARED} \ - -o hdf5:parallel=${H5CPP_WITH_MPI} \ + -o with_boost=${H5CPP_WITH_BOOST} \ + -o with_mpi=${H5CPP_WITH_MPI} \ --build missing - name: build with cmake run: | diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000000..057def068e --- /dev/null +++ b/conanfile.py @@ -0,0 +1,35 @@ +from conans import ConanFile, CMake + + +class H5CppConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake", "gcc", "txt" + options = { + "with_mpi": [True, False], + "with_boost": [True, False] + } + default_options = { + "with_mpi": False, + "with_boost": True, + "hdf5:enable_cxx": False + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.with_mpi + + def configure(self): + if self.options.get_safe("with_mpi", False): + self.options["hdf5"].parallel = True + + def requirements(self): + self.requires("hdf5/1.12.0") + if self.options.with_boost: + self.requires("boost/1.76.0") + if self.options.with_mpi: + self.requires("openmpi/4.1.0") + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index 229f250240..0000000000 --- a/conanfile.txt +++ /dev/null @@ -1,14 +0,0 @@ -[requires] -boost/1.76.0 -hdf5/1.12.0 -openmpi/4.1.0 - -[build_requires] -gtest/1.11.0 - -[generators] -cmake -cmake_find_package - -[options] -hdf5:enable_cxx=False From bc749ef8e44fed59c3f4a15e3eb1e43786e020ca Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 8 Aug 2021 18:27:06 +0100 Subject: [PATCH 13/78] [ci] use conan to build using cmake --- .github/workflows/cmake-build.yml | 28 +++++++++------------------- conanfile.py | 18 +++++++++++++++--- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index edd9ca2782..9605c0fa62 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -36,15 +36,12 @@ jobs: -s build_type=Release \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ + -o shared=${H5CPP_SHARED} \ + -o hdf5:shared=${H5CPP_SHARED} \ --build missing - name: build with cmake run: | - cmake -S . -B build -G Ninja \ - -D CONAN=MANUAL \ - -D BUILD_SHARED_LIBS=${H5CPP_SHARED} - -D WITH_BOOST=${H5CPP_WITH_BOOST} \ - -D WITH_MPI=${H5CPP_WITH_MPI} \ - cmake --build build + conan build . --build-folder build - name: run tests run: | ctest -vvv build @@ -75,17 +72,13 @@ jobs: -s compiler.version="16" \ -s build_type=Release \ -o with_boost=${H5CPP_WITH_BOOST} \ - -o with_mpi=${H5CPP_WITH_MPI} \ + -o shared=${H5CPP_SHARED} \ + -o hdf5:shared=${H5CPP_SHARED} \ --build missing shell: bash - name: build with cmake run: | - cmake -S . -B build -G "Ninja" \ - -D CMAKE_CXX_COMPILER=cl \ - -D CONAN=MANUAL \ - -D BUILD_SHARED_LIBS=${H5CPP_SHARED} \ - -D WITH_BOOST=${H5CPP_WITH_BOOST} - cmake --build build + conan build . --build-folder build shell: bash - name: run tests run: | @@ -119,15 +112,12 @@ jobs: -s build_type=Release \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ + -o shared=${H5CPP_SHARED} \ + -o hdf5:shared=${H5CPP_SHARED} \ --build missing - name: build with cmake run: | - cmake -S . -B build -G Ninja \ - -D CONAN=MANUAL \ - -D BUILD_SHARED_LIBS=${H5CPP_SHARED} \ - -D WITH_MPI=${H5CPP_WITH_MPI} \ - -D WITH_BOOST=${H5CPP_WITH_BOOST} - cmake --build build + conan build . --build-folder build - name: run tests run: | ctest -vvv build diff --git a/conanfile.py b/conanfile.py index 057def068e..d4c1dc09c0 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,17 +3,24 @@ class H5CppConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake", "gcc", "txt" + generators = "cmake", "cmake_find_package" options = { + "shared": [True, False], + "fPIC": [True, False], "with_mpi": [True, False], "with_boost": [True, False] } default_options = { + "shared": False, + "fPIC": True, "with_mpi": False, "with_boost": True, "hdf5:enable_cxx": False } + def build_requirements(self): + self.build_requires("gtest/1.11.0") + def config_options(self): if self.settings.os == "Windows": del self.options.with_mpi @@ -26,10 +33,15 @@ def requirements(self): self.requires("hdf5/1.12.0") if self.options.with_boost: self.requires("boost/1.76.0") - if self.options.with_mpi: + if self.options.get_safe("with_mpi", False): self.requires("openmpi/4.1.0") def build(self): - cmake = CMake(self) + cmake = CMake(self, generator="Ninja") + cmake.definitions.update({ + "CONAN": "MANUAL", + "WITH_MPI": self.options.get_safe("with_mpi", False), + "WITH_BOOST": self.options.with_boost + }) cmake.configure() cmake.build() From 6be5f77659bdd3fce6c95ba604d697e68f7db058 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 8 Aug 2021 19:12:42 +0100 Subject: [PATCH 14/78] [ci] disable mpi until conan hdf5 package is updated (github conan-io/conan-center-index#6747) --- .github/workflows/cmake-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 9605c0fa62..dead76e99d 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -8,7 +8,7 @@ jobs: libcxx: [libstdc++11, libc++] shared: ["shared", "static"] boost: ["boost", "stdfs"] - mpi: ["mpi", "serial"] + mpi: ["serial"] exclude: - image: conanio/gcc11 libcxx: libc++ @@ -89,7 +89,7 @@ jobs: matrix: shared: ["shared", "static"] boost: ["boost", "stdfs"] - mpi: ["mpi", "serial"] + mpi: ["serial"] runs-on: macos-10.15 steps: - uses: actions/checkout@v2 From e6809744da28404e101417255eaf297960c8b612 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 8 Aug 2021 21:01:10 +0100 Subject: [PATCH 15/78] [cmake] remove boost cmake config (not required) --- CMakeLists.txt | 2 +- cmake/BoostLibraryConfig.cmake | 10 ---------- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 cmake/BoostLibraryConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f8c96da9f0..9b08305488 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,8 @@ include(DoxygenUtilities) #============================================================================= set(WITH_BOOST ON CACHE BOOL "enable Boost filesystem support") if(WITH_BOOST) + find_package(Boost 1.41 COMPONENTS filesystem system REQUIRED) message(STATUS "Using Boost library for filesystem") - include(${EXTRA_MODULES_DIR}/BoostLibraryConfig.cmake) else() # if we do not use Boost we have to ensure a C++ standard of at least 2017 # since we require the std::filesystem API diff --git a/cmake/BoostLibraryConfig.cmake b/cmake/BoostLibraryConfig.cmake deleted file mode 100644 index 4a296c16ce..0000000000 --- a/cmake/BoostLibraryConfig.cmake +++ /dev/null @@ -1,10 +0,0 @@ - -set(Boost_USE_STATIC_LIBS OFF) -set(Boost_USE_MULTITHREADED ON) -set(Boost_USE_STATIC_RUNTIME OFF) - -find_package(Boost 1.41 COMPONENTS filesystem system REQUIRED) - -if (CMAKE_CXX_COMPILER_ID MATCHES MSVC) - add_definitions(-DBOOST_ALL_DYN_LINK) -endif () From 317afc29fc0a05ff9e62f2eac87ff478f40a168d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 00:22:08 +0100 Subject: [PATCH 16/78] [cmake] add google tests to ctest --- .github/workflows/cmake-build.yml | 6 +++--- CMakeLists.txt | 6 +++--- cmake/HDF5LibraryConfig.cmake | 2 +- conanfile.py | 5 +++-- test/CMakeLists.txt | 9 --------- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index dead76e99d..72e1d82cc1 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -44,7 +44,7 @@ jobs: conan build . --build-folder build - name: run tests run: | - ctest -vvv build + ctest --extra-verbose --test-dir build windows-build: strategy: matrix: @@ -82,7 +82,7 @@ jobs: shell: bash - name: run tests run: | - ctest -vvv build + ctest --extra-verbose --test-dir build shell: bash mac-build: strategy: @@ -120,4 +120,4 @@ jobs: conan build . --build-folder build - name: run tests run: | - ctest -vvv build + ctest --extra-verbose --test-dir build diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b08305488..ecb98e482b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.10) project(h5cpp LANGUAGES CXX C # VERSION 0.4.1 @@ -91,8 +91,8 @@ install(DIRECTORY examples #============================================================================= set(DISABLE_TESTS False CACHE BOOL "Disable building unit tests") if(NOT DISABLE_TESTS) - enable_testing() - include(Catch) + enable_testing() + include(Catch) add_subdirectory(test) endif() diff --git a/cmake/HDF5LibraryConfig.cmake b/cmake/HDF5LibraryConfig.cmake index 1ec52aed90..b064575d7a 100644 --- a/cmake/HDF5LibraryConfig.cmake +++ b/cmake/HDF5LibraryConfig.cmake @@ -2,7 +2,7 @@ if(WITH_MPI) set(HDF5_PREFER_PARALLEL TRUE) endif() -find_package(HDF5 REQUIRED COMPONENTS C HL) +find_package(HDF5) message(STATUS "==============================================================") message(STATUS "========================Found HDF5============================") message(STATUS "==============================================================") diff --git a/conanfile.py b/conanfile.py index d4c1dc09c0..048146f0f3 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile, CMake +from conans import ConanFile, CMake, tools class H5CppConan(ConanFile): @@ -44,4 +44,5 @@ def build(self): "WITH_BOOST": self.options.with_boost }) cmake.configure() - cmake.build() + with tools.run_environment(self): + cmake.build() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b956e3c87b..65bb478abd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,15 +13,6 @@ include_directories(${PROJECT_SOURCE_DIR}/src ${HDF5_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/subprojects/catch2/include) -foreach(HDF5_LIB ${HDF5_LIBRARIES}) - get_filename_component(LIB_PATH ${HDF5_LIB} DIRECTORY) - link_directories(${LIB_PATH}) -endforeach() -foreach(HDF5_LIB ${HDF5_HL_LIBRARIES}) - get_filename_component(LIB_PATH ${HDF5_LIB} DIRECTORY) - link_directories(${LIB_PATH}) -endforeach() - configure_file(h5py_test_data.h5 h5py_test_data.h5 COPYONLY) configure_file(h5py_test_boolattr.h5 h5py_test_boolattr.h5 COPYONLY) configure_file(pniio_test_boolattr.h5 pniio_test_boolattr.h5 COPYONLY) From 2acecfff10048013136cd8ec4a1a751a9e98bc77 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 00:44:53 +0100 Subject: [PATCH 17/78] [ci] build tests in conanfile --- conanfile.py | 4 ++-- src/h5cpp/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conanfile.py b/conanfile.py index 048146f0f3..78ed8029a2 100644 --- a/conanfile.py +++ b/conanfile.py @@ -44,5 +44,5 @@ def build(self): "WITH_BOOST": self.options.with_boost }) cmake.configure() - with tools.run_environment(self): - cmake.build() + cmake.build() + cmake.build(target="unit_tests") diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index 5411854892..c9e81f2a8e 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -32,11 +32,11 @@ if(WITH_BOOST) list(APPEND H5CPP_LINKS Boost::filesystem Boost::system) else() # Link stdc++fs or c++experimental to get std::experimental::filesystem when necessary - list(APPEND H5CPP_LINKS $<$,$,11.0>>:stdc++fs>) + target_compile_features(h5cpp PUBLIC cxx_std_17) + list(APPEND H5CPP_LINKS $<$,$,9.0>>:stdc++fs>) list(APPEND H5CPP_LINKS $<$,$,11.0>>:c++fs>) endif() - target_include_directories(h5cpp PRIVATE ${PROJECT_SOURCE_DIR}/src INTERFACE $ From fc5ff1958175506af62dafd4fa6525d2191a7ae2 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 01:47:36 +0100 Subject: [PATCH 18/78] [cmake] add stdfs linker option for clang if necessary --- src/h5cpp/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index c9e81f2a8e..2e4cb2a3d6 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -35,6 +35,16 @@ else() target_compile_features(h5cpp PUBLIC cxx_std_17) list(APPEND H5CPP_LINKS $<$,$,9.0>>:stdc++fs>) list(APPEND H5CPP_LINKS $<$,$,11.0>>:c++fs>) + # handle clang with libstdc++ that requires an additional flag + if(NOT MSVC) + get_target_property(_h5cpp_compile_flags h5cpp COMPILE_OPTIONS) + string(FIND "${_h5cpp_compile_flags}" "stdlibc++" USING_GNU_LIBCXX) + if (NOT ${USING_GNU_LIBCXX} EQUAL -1) + list(APPEND H5CPP_LINKS $<$:stdc++fs>) + endif() + message(STATUS "compile flags: ${_h5cpp_compile_flags}") + message(STATUS "libstd++: ${USING_GNU_LIBCXX}") + endif() endif() target_include_directories(h5cpp From 21f8de0809f5b4c282d8ab3e286d30602219860c Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 11:35:25 +0100 Subject: [PATCH 19/78] [ci] update the conan container images --- .github/workflows/cmake-build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 72e1d82cc1..d413db8ce0 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -4,13 +4,16 @@ jobs: linux-build: strategy: matrix: - image: [conanio/gcc11, conanio/clang11] + image: [ + "conanio/gcc11-ubuntu16.04:1.39.0", + "conanio/clang12-ubuntu16.04:1.39.0" + ] libcxx: [libstdc++11, libc++] shared: ["shared", "static"] boost: ["boost", "stdfs"] mpi: ["serial"] exclude: - - image: conanio/gcc11 + - image: conanio/gcc11-ubuntu16.04:1.39.0 libcxx: libc++ runs-on: ubuntu-20.04 From 96d7d4209e89d152b632070a5e5dbb1c65ccc932 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 11:47:00 +0100 Subject: [PATCH 20/78] [ci] fix ctest command line --- .github/workflows/cmake-build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index d413db8ce0..e172646b4d 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -47,7 +47,8 @@ jobs: conan build . --build-folder build - name: run tests run: | - ctest --extra-verbose --test-dir build + cd build + ctest --extra-verbose windows-build: strategy: matrix: @@ -85,7 +86,8 @@ jobs: shell: bash - name: run tests run: | - ctest --extra-verbose --test-dir build + cd build + ctest --extra-verbose shell: bash mac-build: strategy: @@ -123,4 +125,5 @@ jobs: conan build . --build-folder build - name: run tests run: | - ctest --extra-verbose --test-dir build + cd build + ctest --extra-verbose From aeeea4523678067d32411ba6cf6b2a0df8ec26de Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 19:50:30 +0100 Subject: [PATCH 21/78] [ci] run windows tests under conan virtualrunenv --- .github/workflows/cmake-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index e172646b4d..a9b3d53c18 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -78,6 +78,7 @@ jobs: -o with_boost=${H5CPP_WITH_BOOST} \ -o shared=${H5CPP_SHARED} \ -o hdf5:shared=${H5CPP_SHARED} \ + -g virtualrunenv \ --build missing shell: bash - name: build with cmake @@ -87,6 +88,7 @@ jobs: - name: run tests run: | cd build + source ./activate_run.sh ctest --extra-verbose shell: bash mac-build: From c720581292f1e6b43e5e88db8c5bf2f1e9f9e310 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 20:49:15 +0100 Subject: [PATCH 22/78] [cmake] support building static library on windows --- CMakeLists.txt | 4 ++++ src/h5cpp/CMakeLists.txt | 15 ++++----------- src/h5cpp/core/windows.hpp | 18 +++++++++++------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ecb98e482b..c9077de520 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ set(EXTRA_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake) list(APPEND CMAKE_MODULE_PATH ${EXTRA_MODULES_DIR}) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/catch2/cmake) +option(H5CPP_BUILD_SHARED "Build h5cpp as a shared library" OFF) +if (BUILD_SHARED_LIBS) + set(H5CPP_BUILD_SHARED ON) +endif() #============================================================================= # Conan #============================================================================= diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index 2e4cb2a3d6..303340eab6 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -26,7 +26,10 @@ add_library(h5cpp add_doxygen_source_deps(${h5cpp_headers}) -target_compile_definitions(h5cpp PRIVATE DLL_BUILD) +if (H5CPP_BUILD_SHARED OR BUILD_SHARED_LIBS) + target_compile_definitions(h5cpp PRIVATE H5CPP_EXPORTS PUBLIC H5CPP_BUILD_SHARED) +endif() + set(H5CPP_LINKS ${MPI_CXX_LIBRARIES}) if(WITH_BOOST) list(APPEND H5CPP_LINKS Boost::filesystem Boost::system) @@ -35,16 +38,6 @@ else() target_compile_features(h5cpp PUBLIC cxx_std_17) list(APPEND H5CPP_LINKS $<$,$,9.0>>:stdc++fs>) list(APPEND H5CPP_LINKS $<$,$,11.0>>:c++fs>) - # handle clang with libstdc++ that requires an additional flag - if(NOT MSVC) - get_target_property(_h5cpp_compile_flags h5cpp COMPILE_OPTIONS) - string(FIND "${_h5cpp_compile_flags}" "stdlibc++" USING_GNU_LIBCXX) - if (NOT ${USING_GNU_LIBCXX} EQUAL -1) - list(APPEND H5CPP_LINKS $<$:stdc++fs>) - endif() - message(STATUS "compile flags: ${_h5cpp_compile_flags}") - message(STATUS "libstd++: ${USING_GNU_LIBCXX}") - endif() endif() target_include_directories(h5cpp diff --git a/src/h5cpp/core/windows.hpp b/src/h5cpp/core/windows.hpp index bfaa7e8349..b1e8b139a4 100644 --- a/src/h5cpp/core/windows.hpp +++ b/src/h5cpp/core/windows.hpp @@ -25,14 +25,18 @@ // #pragma once -#ifdef _MSC_VER - #ifdef DLL_BUILD - #define DLL_EXPORT __declspec(dllexport) - #else - #define DLL_EXPORT __declspec(dllimport) - #endif -#else +#ifndef H5CPP_BUILD_SHARED #define DLL_EXPORT +#else + #ifdef _MSC_VER + #ifdef H5CPP_EXPORTS + #define DLL_EXPORT __declspec(dllexport) + #else + #define DLL_EXPORT __declspec(dllimport) + #endif + #else + #define DLL_EXPORT + #endif #endif #ifdef _MSC_VER From 7ba2810a5a7e275e5a3d3ecf794b290737827b4a Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 22:16:31 +0100 Subject: [PATCH 23/78] [ci] run windows tests in default shell --- .github/workflows/cmake-build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index a9b3d53c18..49455fbf46 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -88,9 +88,8 @@ jobs: - name: run tests run: | cd build - source ./activate_run.sh + .\activate_run.ps1 ctest --extra-verbose - shell: bash mac-build: strategy: matrix: From 8b922ec2c635b497d913322c6476d9e8511affd3 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 22:33:56 +0100 Subject: [PATCH 24/78] [ci] add caching for conan dependencies --- .github/workflows/cmake-build.yml | 44 +++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 49455fbf46..50ed50f82c 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -34,7 +34,7 @@ jobs: pip install --upgrade \ conan \ ninja - conan install . -if build \ + conan lock create conanfile.py \ -s compiler.libcxx=${{ matrix.libcxx }} \ -s build_type=Release \ -o with_boost=${H5CPP_WITH_BOOST} \ @@ -42,9 +42,21 @@ jobs: -o shared=${H5CPP_SHARED} \ -o hdf5:shared=${H5CPP_SHARED} \ --build missing + - name: cache conan dependencies + uses: actions/cache@v2 + with: + path: ~/.conan/data + key: conan-${{ hashFiles('conan.lock') }} + - name: install conan dependencies + run: | + conan install . \ + --install-folder build \ + --lockfile conan.lock \ + --build missing - name: build with cmake run: | - conan build . --build-folder build + conan build . \ + --build-folder build - name: run tests run: | cd build @@ -71,16 +83,27 @@ jobs: pip install --upgrade \ conan \ ninja - conan install . -if build \ + conan lock create conanfile.py \ -s compiler="Visual Studio" \ -s compiler.version="16" \ -s build_type=Release \ -o with_boost=${H5CPP_WITH_BOOST} \ -o shared=${H5CPP_SHARED} \ -o hdf5:shared=${H5CPP_SHARED} \ - -g virtualrunenv \ --build missing shell: bash + - name: cache conan dependencies + uses: actions/cache@v2 + with: + path: ~/.conan/data + key: conan-${{ hashFiles('conan.lock') }} + - name: install conan dependencies + run: | + conan install . \ + --install-folder build \ + --lockfile conan.lock \ + --build missing \ + --generator virtualrunenv - name: build with cmake run: | conan build . --build-folder build @@ -114,13 +137,24 @@ jobs: pip install --upgrade \ conan \ ninja - conan install . -if build \ + conan lock create conanfile.py \ -s build_type=Release \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ -o shared=${H5CPP_SHARED} \ -o hdf5:shared=${H5CPP_SHARED} \ --build missing + - name: cache conan dependencies + uses: actions/cache@v2 + with: + path: ~/.conan/data + key: conan-${{ hashFiles('conan.lock') }} + - name: install conan dependencies + run: | + conan install . \ + --install-folder build \ + --lockfile conan.lock \ + --build missing - name: build with cmake run: | conan build . --build-folder build From 05b97c85ca91612c9f35128486f0133c129ea2f5 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Mon, 9 Aug 2021 23:56:05 +0100 Subject: [PATCH 25/78] [ci] add profiles and cache restore keys --- .github/workflows/cmake-build.yml | 32 ++++++++++++------- .../workflows/conan/profiles/apple-clang12 | 9 ++++++ .../workflows/conan/profiles/clang12-libc++ | 9 ++++++ .../conan/profiles/clang12-libstdc++ | 9 ++++++ .github/workflows/conan/profiles/gcc11 | 9 ++++++ .github/workflows/conan/profiles/vs2019 | 9 ++++++ 6 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/conan/profiles/apple-clang12 create mode 100644 .github/workflows/conan/profiles/clang12-libc++ create mode 100644 .github/workflows/conan/profiles/clang12-libstdc++ create mode 100644 .github/workflows/conan/profiles/gcc11 create mode 100644 .github/workflows/conan/profiles/vs2019 diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 50ed50f82c..48a30c0d50 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -9,13 +9,21 @@ jobs: "conanio/clang12-ubuntu16.04:1.39.0" ] libcxx: [libstdc++11, libc++] - shared: ["shared", "static"] - boost: ["boost", "stdfs"] - mpi: ["serial"] + shared: [shared, static] + boost: [boost, stdfs] + mpi: [serial] exclude: - image: conanio/gcc11-ubuntu16.04:1.39.0 libcxx: libc++ - + include: + - image: conanio/gcc11-ubuntu16.04:1.39.0 + profile: gcc11 + - image: conanio/clang12-ubuntu16.04:1.39.0 + libcxx: libstdc++11 + profile: clang12-libstdc++ + - image: conanio/clang12-ubuntu16.04:1.39.0 + libcxx: libc++ + profile: clang12-libc++ runs-on: ubuntu-20.04 container: image: ${{ matrix.image }} @@ -35,8 +43,7 @@ jobs: conan \ ninja conan lock create conanfile.py \ - -s compiler.libcxx=${{ matrix.libcxx }} \ - -s build_type=Release \ + --profile .github/workflows/conan/profiles/${{ matrix.profile }} \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ -o shared=${H5CPP_SHARED} \ @@ -47,6 +54,7 @@ jobs: with: path: ~/.conan/data key: conan-${{ hashFiles('conan.lock') }} + restore-keys: conan-${{ matrix.profile }} - name: install conan dependencies run: | conan install . \ @@ -84,9 +92,7 @@ jobs: conan \ ninja conan lock create conanfile.py \ - -s compiler="Visual Studio" \ - -s compiler.version="16" \ - -s build_type=Release \ + --profile .github/workflows/conan/profiles/vs2019 \ -o with_boost=${H5CPP_WITH_BOOST} \ -o shared=${H5CPP_SHARED} \ -o hdf5:shared=${H5CPP_SHARED} \ @@ -97,6 +103,7 @@ jobs: with: path: ~/.conan/data key: conan-${{ hashFiles('conan.lock') }} + restore-keys: conan-vs2019 - name: install conan dependencies run: | conan install . \ @@ -104,6 +111,7 @@ jobs: --lockfile conan.lock \ --build missing \ --generator virtualrunenv + shell: bash - name: build with cmake run: | conan build . --build-folder build @@ -138,17 +146,17 @@ jobs: conan \ ninja conan lock create conanfile.py \ - -s build_type=Release \ + --profile .github/workflows/conan/profiles/apple-clang12 \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ -o shared=${H5CPP_SHARED} \ - -o hdf5:shared=${H5CPP_SHARED} \ - --build missing + -o hdf5:shared=${H5CPP_SHARED} - name: cache conan dependencies uses: actions/cache@v2 with: path: ~/.conan/data key: conan-${{ hashFiles('conan.lock') }} + restore-keys: conan-apple-clang12 - name: install conan dependencies run: | conan install . \ diff --git a/.github/workflows/conan/profiles/apple-clang12 b/.github/workflows/conan/profiles/apple-clang12 new file mode 100644 index 0000000000..1c81d9406d --- /dev/null +++ b/.github/workflows/conan/profiles/apple-clang12 @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +arch_build=x86_64 +build_type=Release +compiler=apple-clang +compiler.libcxx=libc++ +compiler.version=12.0 +os=Macos +os_build=Macos diff --git a/.github/workflows/conan/profiles/clang12-libc++ b/.github/workflows/conan/profiles/clang12-libc++ new file mode 100644 index 0000000000..b7b12af76f --- /dev/null +++ b/.github/workflows/conan/profiles/clang12-libc++ @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +arch_build=x86_64 +build_type=Release +compiler=clang +compiler.libcxx=libc++ +compiler.version=12 +os=Linux +os_build=Linux diff --git a/.github/workflows/conan/profiles/clang12-libstdc++ b/.github/workflows/conan/profiles/clang12-libstdc++ new file mode 100644 index 0000000000..8433e1043f --- /dev/null +++ b/.github/workflows/conan/profiles/clang12-libstdc++ @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +arch_build=x86_64 +build_type=Release +compiler=clang +compiler.libcxx=libstdc++11 +compiler.version=12 +os=Linux +os_build=Linux diff --git a/.github/workflows/conan/profiles/gcc11 b/.github/workflows/conan/profiles/gcc11 new file mode 100644 index 0000000000..fd7203d449 --- /dev/null +++ b/.github/workflows/conan/profiles/gcc11 @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +arch_build=x86_64 +build_type=Release +compiler=gcc +compiler.libcxx=libstdc++11 +compiler.version=11 +os=Linux +os_build=Linux diff --git a/.github/workflows/conan/profiles/vs2019 b/.github/workflows/conan/profiles/vs2019 new file mode 100644 index 0000000000..c1f9e6e406 --- /dev/null +++ b/.github/workflows/conan/profiles/vs2019 @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +arch_build=x86_64 +build_type=Release +compiler=Visual Studio +compiler.runtime=MD +compiler.version=16 +os=Windows +os_build=Windows From c67e1bd8dae33f57ddb3159490dd42b8be5ee293 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 10 Aug 2021 10:38:42 +0100 Subject: [PATCH 26/78] [cmake] prefix cmake options with library name --- CMakeLists.txt | 40 ++++++++++++------------- README.md | 4 +-- cmake/HDF5LibraryConfig.cmake | 4 +-- cmake/MPIConfig.cmake | 4 +-- conanfile.py | 6 ++-- doc/source/users_guide/installing.rst | 2 +- h5cpp-config.cmake.in | 6 ++-- src/h5cpp/CMakeLists.txt | 8 ++--- src/h5cpp/core/filesystem.hpp | 2 +- src/h5cpp/core/hdf5_capi.hpp | 2 +- src/h5cpp/core/with_boost.hpp.in | 2 +- src/h5cpp/file/mpi_driver.cpp | 2 +- src/h5cpp/file/mpi_driver.hpp | 2 +- src/h5cpp/property/dataset_transfer.cpp | 2 +- src/h5cpp/property/dataset_transfer.hpp | 4 +-- test/core/object_id_test.cpp | 2 +- test/file/driver_test.cpp | 2 +- test/node/link_target_test.cpp | 2 +- test/property/dataset_transfer_test.cpp | 2 +- 19 files changed, 49 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9077de520..b5920f9cb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,28 +21,28 @@ endif() #============================================================================= # Conan #============================================================================= -set(CONAN "AUTO" CACHE STRING "conan options AUTO (conan must be in path), MANUAL (expects conanbuildinfo.cmake in build directory) or DISABLE") -set(CONAN_PROFILE "default" CACHE STRING "Name of conan profile to use, uses default by default") -set(CONAN_FILE "conanfile_ess.txt" CACHE STRING "The conanfile to use for the build") +set(H5CPP_CONAN "AUTO" CACHE STRING "conan options AUTO (conan must be in path), MANUAL (expects conanbuildinfo.cmake in build directory) or DISABLE") +set(H5CPP_CONAN_PROFILE "default" CACHE STRING "Name of conan profile to use, uses default by default") +set(H5CPP_CONAN_FILE "conanfile_ess.txt" CACHE STRING "The conanfile to use for the build") -if(${CONAN} MATCHES "AUTO") +if(${H5CPP_CONAN} MATCHES "AUTO") include(${EXTRA_MODULES_DIR}/ConanSetup.cmake) - conan_cmake_run(CONANFILE ${CONAN_FILE} - PROFILE ${CONAN_PROFILE} + conan_cmake_run(CONANFILE ${H5CPP_CONAN_FILE} + PROFILE ${H5CPP_CONAN_PROFILE} BASIC_SETUP NO_OUTPUT_DIRS KEEP_RPATHS BUILD_TYPE "None" BUILD outdated) list(PREPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) -elseif(${CONAN} MATCHES "MANUAL") +elseif(${H5CPP_CONAN} MATCHES "MANUAL") if(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") conan_basic_setup(NO_OUTPUT_DIRS KEEP_RPATHS) list(PREPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) else() - message(FATAL_ERROR "CONAN set to MANUAL but no file named conanbuildinfo.cmake found in build directory") + message(FATAL_ERROR "H5CPP_CONAN set to MANUAL but no file named conanbuildinfo.cmake found in build directory") endif() -elseif(NOT ${CONAN} MATCHES "DISABLE") - message(FATAL_ERROR "Unrecognised option for CONAN (${CONAN}), use AUTO, MANUAL or DISABLE") +elseif(NOT ${H5CPP_CONAN} MATCHES "DISABLE") + message(FATAL_ERROR "Unrecognised option for H5CPP_CONAN (${H5CPP_CONAN}), use AUTO, MANUAL or DISABLE") endif() #============================================================================= @@ -63,8 +63,8 @@ include(DoxygenUtilities) #============================================================================= # compiler and library configuration #============================================================================= -set(WITH_BOOST ON CACHE BOOL "enable Boost filesystem support") -if(WITH_BOOST) +option(H5CPP_WITH_BOOST "enable Boost filesystem support" ON) +if(H5CPP_WITH_BOOST) find_package(Boost 1.41 COMPONENTS filesystem system REQUIRED) message(STATUS "Using Boost library for filesystem") else() @@ -79,8 +79,8 @@ include(${EXTRA_MODULES_DIR}/MPIConfig.cmake) include(${EXTRA_MODULES_DIR}/HDF5LibraryConfig.cmake) add_subdirectory(src) -set( BUILD_DOCS ON CACHE BOOL "Build documentation") -if(BUILD_DOCS) +option(H5CPP_BUILD_DOCS "Build documentation" ON) +if(H5CPP_BUILD_DOCS) add_subdirectory(doc) endif() @@ -93,8 +93,8 @@ install(DIRECTORY examples #============================================================================= # unit tests if GTest if present #============================================================================= -set(DISABLE_TESTS False CACHE BOOL "Disable building unit tests") -if(NOT DISABLE_TESTS) +option(H5CPP_DISABLE_TESTS "Disable building unit tests" OFF) +if(NOT H5CPP_DISABLE_TESTS) enable_testing() include(Catch) add_subdirectory(test) @@ -103,11 +103,11 @@ endif() #============================================================================= # create package file #============================================================================= -set(WITH_SWMR OFF CACHE BOOL "enable SWMR support") -set(WITH_VDS OFF CACHE BOOL "enable VDS support") +option(H5CPP_WITH_SWMR "enable SWMR support" OFF) +option(H5CPP_WITH_VDS "enable VDS support" OFF) if(HDF5_VERSION VERSION_GREATER 1.10.0 OR HDF5_VERSION VERSION_EQUAL 1.10.0) - set(WITH_SWMR ON) - set(WITH_VDS ON) + set(H5CPP_WITH_SWMR ON) + set(H5CPP_WITH_VDS ON) endif() # diff --git a/README.md b/README.md index 37c437e85a..9ca0a38399 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ The minimum requirements for building the library are: * a C++ compiler, gcc>=4.8.1 should do well * the HDF5 C library (>=1.8.13 would do but >=1.10.0 is prefered) * cmake >= 3.0 -* _either_ the boost libraries _or_ a compiler with std::filesystem or std::experimental::filesystem (and specify WITH_BOOST=OFF to CMake) +* _either_ the boost libraries _or_ a compiler with std::filesystem or std::experimental::filesystem (and specify H5CPP_WITH_BOOST=OFF to CMake) The external library dependencies can be acquired and built using [Conan](https://conan.io/). Conan can be installed with PyPI: ``` @@ -74,7 +74,7 @@ conan remote add bincrafters https://bincrafters.jfrog.io/artifactory/api/conan/ ``` and that's it, CMake will handle the rest! -Alternatively you can manually install the dependencies to typical system locations. In this case please disable Conan by using the `-DCONAN=DISABLE` option when you run CMake. +Alternatively you can manually install the dependencies to typical system locations. In this case please disable Conan by using the `-DH5CPP_CONAN=DISABLE` option when you run CMake. Building the library is standard cmake & make fare, out of source. For example, in linux shell, you would do the following: diff --git a/cmake/HDF5LibraryConfig.cmake b/cmake/HDF5LibraryConfig.cmake index b064575d7a..99b40560cb 100644 --- a/cmake/HDF5LibraryConfig.cmake +++ b/cmake/HDF5LibraryConfig.cmake @@ -1,4 +1,4 @@ -if(WITH_MPI) +if(H5CPP_WITH_MPI) set(HDF5_PREFER_PARALLEL TRUE) endif() @@ -16,7 +16,7 @@ message(STATUS "Found HDF5 HDF5_IS_PARALLEL = ${HDF5_IS_PARALLEL}") message(STATUS "==============================================================") -if(WITH_MPI) +if(H5CPP_WITH_MPI) if(NOT HDF5_IS_PARALLEL) message(FATAL_ERROR "The HDF5 version found does not support MPI") endif() diff --git a/cmake/MPIConfig.cmake b/cmake/MPIConfig.cmake index d3bda8a6c4..c048e4bbee 100644 --- a/cmake/MPIConfig.cmake +++ b/cmake/MPIConfig.cmake @@ -1,6 +1,6 @@ -option(WITH_MPI "Enable MPI support" OFF) +option(H5CPP_WITH_MPI "Enable MPI support" OFF) -if (WITH_MPI) +if (H5CPP_WITH_MPI) if (CMAKE_SYSTEM_NAME MATCHES Windows) message(FATAL_ERROR "MPI not supported on the Windows platform!") endif () diff --git a/conanfile.py b/conanfile.py index 78ed8029a2..33849e69d6 100644 --- a/conanfile.py +++ b/conanfile.py @@ -39,9 +39,9 @@ def requirements(self): def build(self): cmake = CMake(self, generator="Ninja") cmake.definitions.update({ - "CONAN": "MANUAL", - "WITH_MPI": self.options.get_safe("with_mpi", False), - "WITH_BOOST": self.options.with_boost + "H5CPP_CONAN": "MANUAL", + "H5CPP_WITH_MPI": self.options.get_safe("with_mpi", False), + "H5CPP_WITH_BOOST": self.options.with_boost }) cmake.configure() cmake.build() diff --git a/doc/source/users_guide/installing.rst b/doc/source/users_guide/installing.rst index c6c3a38839..92de70576e 100644 --- a/doc/source/users_guide/installing.rst +++ b/doc/source/users_guide/installing.rst @@ -71,7 +71,7 @@ which should do the job provided that all dependencies are installed in standard locations. We strongly recommend to set the particular build configuration with the :envvar:`CMAKE_BUILD_TYPE` variable. -To attempt to build without Boost, additionally specify `-DWITH_BOOST=OFF`. +To attempt to build without Boost, additionally specify `-DH5CPP_WITH_BOOST=OFF`. This requires a recent compiler, for example gcc >8, with filesystem in the std or std::experimental namespace. diff --git a/h5cpp-config.cmake.in b/h5cpp-config.cmake.in index 19053d587e..2eb2e8d89f 100644 --- a/h5cpp-config.cmake.in +++ b/h5cpp-config.cmake.in @@ -2,10 +2,10 @@ # add some additional information via cached variables # -set(H5CPP_MPI_ENABLED @WITH_MPI@ CACHE BOOL "h5cpp was built with MPI support") +set(H5CPP_MPI_ENABLED @H5CPP_WITH_MPI@ CACHE BOOL "h5cpp was built with MPI support") set(H5CPP_SWMR_ENABLED @WITH_SWMR@ CACHE BOOL "h5cpp was built with SMWR support") set(H5CPP_VDS_ENABLED @WITH_VDS@ CACHE BOOL "h5cpp was built with VDS support") -set(H5CPP_BOOST_ENABLED @WITH_BOOST@ CACHE BOOL "h5cpp was built against boost") +set(H5CPP_BOOST_ENABLED @H5CPP_WITH_BOOST@ CACHE BOOL "h5cpp was built against boost") # # checking for the Boost library @@ -33,7 +33,7 @@ endif() # # checking for hdf5 # -set(HDF5_PREFER_PARALLEL @WITH_MPI@) +set(HDF5_PREFER_PARALLEL @H5CPP_WITH_MPI@) find_package(HDF5 @HDF5_VERSION@ EXACT REQUIRED COMPONENTS C) # diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index 303340eab6..2454678562 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -31,7 +31,7 @@ if (H5CPP_BUILD_SHARED OR BUILD_SHARED_LIBS) endif() set(H5CPP_LINKS ${MPI_CXX_LIBRARIES}) -if(WITH_BOOST) +if(H5CPP_WITH_BOOST) list(APPEND H5CPP_LINKS Boost::filesystem Boost::system) else() # Link stdc++fs or c++experimental to get std::experimental::filesystem when necessary @@ -49,8 +49,8 @@ target_include_directories(h5cpp # # THIS IS BAD # NEED TO GET RID OF THIS -if (WITH_MPI) - target_compile_definitions(h5cpp PUBLIC WITH_MPI) +if (H5CPP_WITH_MPI) + target_compile_definitions(h5cpp PUBLIC H5CPP_WITH_MPI) endif () set_target_properties(h5cpp @@ -123,7 +123,7 @@ function(GET_LIBRARY_NAME LIB) endfunction(GET_LIBRARY_NAME) -if(${CONAN} MATCHES "DISABLE") +if(${H5CPP_CONAN} MATCHES "DISABLE") get_target_property(LIBRARIES h5cpp INTERFACE_LINK_LIBRARIES) get_target_property(DEFINITIONS h5cpp INTERFACE_COMPILE_DEFINITIONS) diff --git a/src/h5cpp/core/filesystem.hpp b/src/h5cpp/core/filesystem.hpp index dcd5ee3c49..f0876e6b1a 100644 --- a/src/h5cpp/core/filesystem.hpp +++ b/src/h5cpp/core/filesystem.hpp @@ -2,7 +2,7 @@ #include -#ifdef WITH_BOOST +#ifdef H5CPP_WITH_BOOST #include namespace fs = boost::filesystem; #else diff --git a/src/h5cpp/core/hdf5_capi.hpp b/src/h5cpp/core/hdf5_capi.hpp index d5c3b97248..e18ac1be93 100644 --- a/src/h5cpp/core/hdf5_capi.hpp +++ b/src/h5cpp/core/hdf5_capi.hpp @@ -29,7 +29,7 @@ // // This hack is necessary to get MPI, HDF5 and C++ build together // -#ifdef WITH_MPI +#ifdef H5CPP_WITH_MPI #include #endif diff --git a/src/h5cpp/core/with_boost.hpp.in b/src/h5cpp/core/with_boost.hpp.in index c9ce1e9166..5615c38dd2 100644 --- a/src/h5cpp/core/with_boost.hpp.in +++ b/src/h5cpp/core/with_boost.hpp.in @@ -1,3 +1,3 @@ #pragma once -#cmakedefine WITH_BOOST +#cmakedefine H5CPP_WITH_BOOST diff --git a/src/h5cpp/file/mpi_driver.cpp b/src/h5cpp/file/mpi_driver.cpp index 6fd24f980d..a439f0bd91 100644 --- a/src/h5cpp/file/mpi_driver.cpp +++ b/src/h5cpp/file/mpi_driver.cpp @@ -31,7 +31,7 @@ namespace hdf5 { namespace file { -#ifdef WITH_MPI +#ifdef H5CPP_WITH_MPI MPIDriver::MPIDriver(MPI_Comm comm,MPI_Info info): comm_(comm), diff --git a/src/h5cpp/file/mpi_driver.hpp b/src/h5cpp/file/mpi_driver.hpp index ebc56c04f6..7b0d47e744 100644 --- a/src/h5cpp/file/mpi_driver.hpp +++ b/src/h5cpp/file/mpi_driver.hpp @@ -30,7 +30,7 @@ namespace hdf5 { namespace file { -#ifdef WITH_MPI +#ifdef H5CPP_WITH_MPI class DLL_EXPORT MPIDriver : public Driver { diff --git a/src/h5cpp/property/dataset_transfer.cpp b/src/h5cpp/property/dataset_transfer.cpp index 2cafec873d..4505c716cb 100644 --- a/src/h5cpp/property/dataset_transfer.cpp +++ b/src/h5cpp/property/dataset_transfer.cpp @@ -48,7 +48,7 @@ DatasetTransferList::DatasetTransferList(ObjectHandle &&handle, bool do_check): } } -#ifdef WITH_MPI +#ifdef H5CPP_WITH_MPI #ifdef __GNUC__ #pragma GCC diagnostic push diff --git a/src/h5cpp/property/dataset_transfer.hpp b/src/h5cpp/property/dataset_transfer.hpp index 9ed899243c..29e64c03f5 100644 --- a/src/h5cpp/property/dataset_transfer.hpp +++ b/src/h5cpp/property/dataset_transfer.hpp @@ -33,7 +33,7 @@ namespace hdf5 { namespace property { -#ifdef WITH_MPI +#ifdef H5CPP_WITH_MPI enum class MPITransferMode : std::underlying_type::type { Independent = H5FD_MPIO_INDEPENDENT, @@ -90,7 +90,7 @@ class DLL_EXPORT DatasetTransferList : public List { return dtpl_; } -#ifdef WITH_MPI +#ifdef H5CPP_WITH_MPI void mpi_transfer_mode(MPITransferMode mode) const; MPITransferMode mpi_transfer_mode() const; diff --git a/test/core/object_id_test.cpp b/test/core/object_id_test.cpp index 01d397b1e8..0ecff4c09c 100644 --- a/test/core/object_id_test.cpp +++ b/test/core/object_id_test.cpp @@ -258,7 +258,7 @@ SCENARIO("checking copies and files of identical structure") { } // create a copy of the first file. -#ifdef WITH_BOOST + #ifdef H5CPP_WITH_BOOST fs::copy_file(path1, path3, fs::copy_option::overwrite_if_exists); #else diff --git a/test/file/driver_test.cpp b/test/file/driver_test.cpp index 14d698bc50..8b406a3909 100644 --- a/test/file/driver_test.cpp +++ b/test/file/driver_test.cpp @@ -125,7 +125,7 @@ SCENARIO("Applying a POSIX file driver", "[h5cpp, file]") { } } -#ifdef WITH_MPI +#ifdef H5CPP_WITH_MPI SCENARIO("Applying the MPI file driver", "[h5cpp,file]") { int flag; diff --git a/test/node/link_target_test.cpp b/test/node/link_target_test.cpp index df131682e3..1239f7e7d2 100644 --- a/test/node/link_target_test.cpp +++ b/test/node/link_target_test.cpp @@ -24,7 +24,7 @@ // Created on: Mar 1, 2018 // #include -#ifdef WITH_BOOST +#ifdef H5CPP_WITH_BOOST #include #else #define BOOST_VERSION 100 diff --git a/test/property/dataset_transfer_test.cpp b/test/property/dataset_transfer_test.cpp index e425f10dd3..0d710668ff 100644 --- a/test/property/dataset_transfer_test.cpp +++ b/test/property/dataset_transfer_test.cpp @@ -55,7 +55,7 @@ SCENARIO("DatasetTransferList creation") { } } -#ifdef WITH_MPI +#ifdef H5CPP_WITH_MPI SCENARIO("testing the MPI transfer mode enumeration") { using r = std::tuple; From 2ca8bc352144c71169cd03a7eb57a9cf61e24a50 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 10 Aug 2021 12:06:49 +0100 Subject: [PATCH 27/78] [cmake] find and link to individual hdf5 components --- cmake/HDF5LibraryConfig.cmake | 2 +- conanfile.py | 1 + h5cpp-config.cmake.in | 4 ++-- src/h5cpp/CMakeLists.txt | 5 +++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/HDF5LibraryConfig.cmake b/cmake/HDF5LibraryConfig.cmake index 99b40560cb..c05fe75fa1 100644 --- a/cmake/HDF5LibraryConfig.cmake +++ b/cmake/HDF5LibraryConfig.cmake @@ -2,7 +2,7 @@ if(H5CPP_WITH_MPI) set(HDF5_PREFER_PARALLEL TRUE) endif() -find_package(HDF5) +find_package(HDF5 REQUIRED COMPONENTS C HL) message(STATUS "==============================================================") message(STATUS "========================Found HDF5============================") message(STATUS "==============================================================") diff --git a/conanfile.py b/conanfile.py index 33849e69d6..c9a55c988b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,6 +15,7 @@ class H5CppConan(ConanFile): "fPIC": True, "with_mpi": False, "with_boost": True, + "hdf5:hl": True, "hdf5:enable_cxx": False } diff --git a/h5cpp-config.cmake.in b/h5cpp-config.cmake.in index 2eb2e8d89f..a0f255f17c 100644 --- a/h5cpp-config.cmake.in +++ b/h5cpp-config.cmake.in @@ -3,8 +3,8 @@ # set(H5CPP_MPI_ENABLED @H5CPP_WITH_MPI@ CACHE BOOL "h5cpp was built with MPI support") -set(H5CPP_SWMR_ENABLED @WITH_SWMR@ CACHE BOOL "h5cpp was built with SMWR support") -set(H5CPP_VDS_ENABLED @WITH_VDS@ CACHE BOOL "h5cpp was built with VDS support") +set(H5CPP_SWMR_ENABLED @HDF5_WITH_SWMR@ CACHE BOOL "h5cpp was built with SMWR support") +set(H5CPP_VDS_ENABLED @HDF5_WITH_VDS@ CACHE BOOL "h5cpp was built with VDS support") set(H5CPP_BOOST_ENABLED @H5CPP_WITH_BOOST@ CACHE BOOL "h5cpp was built against boost") # diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index 2454678562..231b36e293 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -65,9 +65,10 @@ enable_coverage(h5cpp) target_link_libraries(h5cpp PUBLIC - ${H5CPP_LINKS} + ${H5CPP_LINKS} PRIVATE ${COVERAGE_LIBRARIES} - HDF5::HDF5 + hdf5::hdf5 + hdf5::hdf5_hl INTERFACE ${H5CPP_INTERFACE_LIBS}) include(GNUInstallDirs) #Required for CMAKE_INSTALL_XXX From f28198c677b032dc8da4326a0abd2cae538af932 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 10 Aug 2021 12:16:18 +0100 Subject: [PATCH 28/78] [ci] add openmpi configs to linux and macos --- .github/workflows/cmake-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 48a30c0d50..acdada8108 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -11,7 +11,7 @@ jobs: libcxx: [libstdc++11, libc++] shared: [shared, static] boost: [boost, stdfs] - mpi: [serial] + mpi: [mpi, serial] exclude: - image: conanio/gcc11-ubuntu16.04:1.39.0 libcxx: libc++ @@ -126,7 +126,7 @@ jobs: matrix: shared: ["shared", "static"] boost: ["boost", "stdfs"] - mpi: ["serial"] + mpi: ["serial", "mpi"] runs-on: macos-10.15 steps: - uses: actions/checkout@v2 From a37344cb5779d834392b736e691528012247700d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 10 Aug 2021 12:49:15 +0100 Subject: [PATCH 29/78] [ci] use partial lockfiles for cache restore keys --- .github/workflows/cmake-build.yml | 41 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index acdada8108..0dd02aca9c 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -42,19 +42,21 @@ jobs: pip install --upgrade \ conan \ ninja - conan lock create conanfile.py \ - --profile .github/workflows/conan/profiles/${{ matrix.profile }} \ + CONAN_ARGS="--profile .github/workflows/conan/profiles/${{ matrix.profile }} \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ -o shared=${H5CPP_SHARED} \ - -o hdf5:shared=${H5CPP_SHARED} \ - --build missing + -o hdf5:shared=${H5CPP_SHARED}" + conan lock create conanfile.py ${CONAN_ARGS} --base --lockfile-out base.lock + conan lock create conanfile.py ${CONAN_ARGS} --build missing - name: cache conan dependencies uses: actions/cache@v2 with: path: ~/.conan/data - key: conan-${{ hashFiles('conan.lock') }} - restore-keys: conan-${{ matrix.profile }} + key: conan-${{ matrix.profile }}-${{ hashfiles('base.lock') }}-${{ hashFiles('conan.lock') }} + restore-keys: | + conan-${{ matrix.profile }}-${{ hashfiles('base.lock') }} + conan-${{ matrix.profile }} - name: install conan dependencies run: | conan install . \ @@ -91,19 +93,21 @@ jobs: pip install --upgrade \ conan \ ninja - conan lock create conanfile.py \ - --profile .github/workflows/conan/profiles/vs2019 \ + CONAN_ARGS="--profile .github/workflows/conan/profiles/vs2019 \ -o with_boost=${H5CPP_WITH_BOOST} \ -o shared=${H5CPP_SHARED} \ - -o hdf5:shared=${H5CPP_SHARED} \ - --build missing + -o hdf5:shared=${H5CPP_SHARED}" + conan lock create conanfile.py ${CONAN_ARGS} --base --lockfile-out base.lock + conan lock create conanfile.py ${CONAN_ARGS} --build missing shell: bash - name: cache conan dependencies uses: actions/cache@v2 with: path: ~/.conan/data - key: conan-${{ hashFiles('conan.lock') }} - restore-keys: conan-vs2019 + key: conan-vs2019-${{ hashfiles('base.lock') }}-${{ hashFiles('conan.lock') }} + restore-keys: | + conan-vs-2019-${{ hashfiles('base.lock') }} + conan-vs-2019 - name: install conan dependencies run: | conan install . \ @@ -145,18 +149,21 @@ jobs: pip install --upgrade \ conan \ ninja - conan lock create conanfile.py \ - --profile .github/workflows/conan/profiles/apple-clang12 \ + CONAN_ARGS="--profile .github/workflows/conan/profiles/apple-clang12 \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ -o shared=${H5CPP_SHARED} \ - -o hdf5:shared=${H5CPP_SHARED} + -o hdf5:shared=${H5CPP_SHARED}" + conan lock create conanfile.py ${CONAN_ARGS} --base --lockfile-out base.lock + conan lock create conanfile.py ${CONAN_ARGS} --build missing - name: cache conan dependencies uses: actions/cache@v2 with: path: ~/.conan/data - key: conan-${{ hashFiles('conan.lock') }} - restore-keys: conan-apple-clang12 + key: conan-apple-clang12-${{ hashfiles('base.lock') }}-${{ hashFiles('conan.lock') }} + restore-keys: | + conan-apple-clang12-${{ hashfiles('base.lock') }} + conan-apple-clang12 - name: install conan dependencies run: | conan install . \ From 5f45bb7b019f18db7bd3c08a12f9fdde6ca1c322 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 10 Aug 2021 13:46:24 +0100 Subject: [PATCH 30/78] [ci] install ssh on linux containers if using MPI --- .github/workflows/cmake-build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 0dd02aca9c..f59aa5624d 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -36,6 +36,11 @@ jobs: ${{ matrix.shared }} \ ${{ matrix.boost }} \ ${{ matrix.mpi }} + - name: Install MPI prerequisites + if: ${{ matrix.mpi == 'mpi' }} + run: | + apt-get update + apt-get install -y --no-install-recommends ssh - name: Install and configure conan run: | python -m pip install --upgrade pip From ca5cda30cf652a9472d7063bcfeeff4136b380cb Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 10 Aug 2021 13:47:49 +0100 Subject: [PATCH 31/78] [cmake] prefix h5cpp status messages --- CMakeLists.txt | 13 +++++++++++-- cmake/MPIConfig.cmake | 8 ++++---- cmake/utilities.cmake | 7 +++++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5920f9cb5..622fe5060b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,18 +66,27 @@ include(DoxygenUtilities) option(H5CPP_WITH_BOOST "enable Boost filesystem support" ON) if(H5CPP_WITH_BOOST) find_package(Boost 1.41 COMPONENTS filesystem system REQUIRED) - message(STATUS "Using Boost library for filesystem") + h5cpp_message(STATUS "Using Boost library for filesystem") else() # if we do not use Boost we have to ensure a C++ standard of at least 2017 # since we require the std::filesystem API set(CMAKE_CXX_STANDARD 17) - message(STATUS "Using std library for filesystem") + h5cpp_message(STATUS "Using std library for filesystem") endif() include(${EXTRA_MODULES_DIR}/CompilerConfig.cmake) include(${EXTRA_MODULES_DIR}/MPIConfig.cmake) include(${EXTRA_MODULES_DIR}/HDF5LibraryConfig.cmake) +if(H5CPP_BUILD_SHARED) + h5cpp_message(STATUS "Building shared library") +else() + h5cpp_message(STATUS "Building static library") +endif() +if (H5CPP_WITH_MPI) + h5cpp_message(STATUS "Building with MPI support") +endif() + add_subdirectory(src) option(H5CPP_BUILD_DOCS "Build documentation" ON) if(H5CPP_BUILD_DOCS) diff --git a/cmake/MPIConfig.cmake b/cmake/MPIConfig.cmake index c048e4bbee..17a3c87eaf 100644 --- a/cmake/MPIConfig.cmake +++ b/cmake/MPIConfig.cmake @@ -2,11 +2,11 @@ option(H5CPP_WITH_MPI "Enable MPI support" OFF) if (H5CPP_WITH_MPI) if (CMAKE_SYSTEM_NAME MATCHES Windows) - message(FATAL_ERROR "MPI not supported on the Windows platform!") + h5cpp_message(FATAL_ERROR "MPI not supported on the Windows platform!") endif () if (CMAKE_SYSTEM_NAME MATCHES Darwin) - message(FATAL_ERROR "MPI not supported for OSX") + h5cpp_message(FATAL_ERROR "MPI not supported for OSX") endif () if(CMAKE_CXX_COMPILER_ID MATCHES GNU) @@ -14,7 +14,7 @@ if (H5CPP_WITH_MPI) endif() find_package(MPI REQUIRED) - message(STATUS "Found MPI headers in: ${MPI_C_INCLUDE_PATH}") - message(STATUS "Found MPI libraries: ${MPI_C_LIBRARIES}") + h5cpp_message(STATUS "Found MPI headers in: ${MPI_C_INCLUDE_PATH}") + h5cpp_message(STATUS "Found MPI libraries: ${MPI_C_LIBRARIES}") endif () diff --git a/cmake/utilities.cmake b/cmake/utilities.cmake index d53ed05803..f5751ccfb8 100644 --- a/cmake/utilities.cmake +++ b/cmake/utilities.cmake @@ -2,10 +2,13 @@ # some utility functions which make life easier # -function(copy_to_current_build) +function(H5CPP_MESSAGE LEVEL) + message(${LEVEL} "H5CPP: ${ARGN}") +endfunction() +function(copy_to_current_build) foreach(f ${ARGV}) configure_file(${f} ${f} COPYONLY) endforeach() - + endfunction() From a395a0cd43ad88b5b08d82d15bff15d46999460d Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 10 Aug 2021 14:01:42 +0100 Subject: [PATCH 32/78] [cmake] support using MPI on OSX --- .github/workflows/cmake-build.yml | 5 ++++- cmake/MPIConfig.cmake | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index f59aa5624d..f487883e67 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -23,7 +23,7 @@ jobs: profile: clang12-libstdc++ - image: conanio/clang12-ubuntu16.04:1.39.0 libcxx: libc++ - profile: clang12-libc++ + profile: clang12-libc++ runs-on: ubuntu-20.04 container: image: ${{ matrix.image }} @@ -148,6 +148,9 @@ jobs: ${{ matrix.shared }} \ ${{ matrix.boost }} \ ${{ matrix.mpi }} + - name: Install OpenMPI and prerequisites + if: ${{ matrix.mpi == 'mpi' }} + run: brew install open-mpi - name: Install and configure conan run: | python -m pip install --upgrade pip diff --git a/cmake/MPIConfig.cmake b/cmake/MPIConfig.cmake index 17a3c87eaf..d5cd0663bf 100644 --- a/cmake/MPIConfig.cmake +++ b/cmake/MPIConfig.cmake @@ -5,10 +5,6 @@ if (H5CPP_WITH_MPI) h5cpp_message(FATAL_ERROR "MPI not supported on the Windows platform!") endif () - if (CMAKE_SYSTEM_NAME MATCHES Darwin) - h5cpp_message(FATAL_ERROR "MPI not supported for OSX") - endif () - if(CMAKE_CXX_COMPILER_ID MATCHES GNU) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-literal-suffix") endif() From edbdc7ff3977a9eb8d58068d711f2c5945730899 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Tue, 10 Aug 2021 14:11:28 +0100 Subject: [PATCH 33/78] [ci] run workflow prs --- .github/workflows/cmake-build.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index f487883e67..2a0ed0630d 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -1,5 +1,10 @@ name: cmake-build -on: [push] +on: + push: + pull_request: + branches: + - master + jobs: linux-build: strategy: From fc3216e9f08227c30c370a673f389cbd8993f119 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 11 Aug 2021 12:46:42 +0100 Subject: [PATCH 34/78] [ci] use virtualenv to run mac tests --- .github/workflows/cmake-build.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index 2a0ed0630d..d1bb282f28 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -162,11 +162,17 @@ jobs: pip install --upgrade \ conan \ ninja + # there's currently an issue running the MPI tests on OSX with HDF5 compiled + # as a dynamic library. Use static HDF5 for now + HDF5_SHARED=${H5CPP_SHARED} + if [ "${H5CPP_WITH_MPI}" = "True" ]; then + HDF5_SHARED=False + fi CONAN_ARGS="--profile .github/workflows/conan/profiles/apple-clang12 \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ -o shared=${H5CPP_SHARED} \ - -o hdf5:shared=${H5CPP_SHARED}" + -o hdf5:shared=${HDF5_SHARED}" conan lock create conanfile.py ${CONAN_ARGS} --base --lockfile-out base.lock conan lock create conanfile.py ${CONAN_ARGS} --build missing - name: cache conan dependencies @@ -182,11 +188,13 @@ jobs: conan install . \ --install-folder build \ --lockfile conan.lock \ - --build missing + --build missing \ + --generator virtualenv - name: build with cmake run: | conan build . --build-folder build - name: run tests run: | cd build + source activate.sh ctest --extra-verbose From 6dcfd8b6a288ed186ffab7fcfe9b07ff45c8854e Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Wed, 11 Aug 2021 13:31:31 +0100 Subject: [PATCH 35/78] [conan,ci] use conan to satisfy ninja dependency --- .github/workflows/cmake-build.yml | 12 ++---------- conanfile.py | 3 ++- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index d1bb282f28..59e232ac22 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -48,10 +48,6 @@ jobs: apt-get install -y --no-install-recommends ssh - name: Install and configure conan run: | - python -m pip install --upgrade pip - pip install --upgrade \ - conan \ - ninja CONAN_ARGS="--profile .github/workflows/conan/profiles/${{ matrix.profile }} \ -o with_boost=${H5CPP_WITH_BOOST} \ -o with_mpi=${H5CPP_WITH_MPI} \ @@ -100,9 +96,7 @@ jobs: - name: Install and configure conan run: | python -m pip install --upgrade pip - pip install --upgrade \ - conan \ - ninja + pip install --upgrade conan CONAN_ARGS="--profile .github/workflows/conan/profiles/vs2019 \ -o with_boost=${H5CPP_WITH_BOOST} \ -o shared=${H5CPP_SHARED} \ @@ -159,9 +153,7 @@ jobs: - name: Install and configure conan run: | python -m pip install --upgrade pip - pip install --upgrade \ - conan \ - ninja + pip install --upgrade conan # there's currently an issue running the MPI tests on OSX with HDF5 compiled # as a dynamic library. Use static HDF5 for now HDF5_SHARED=${H5CPP_SHARED} diff --git a/conanfile.py b/conanfile.py index c9a55c988b..2ec351de56 100644 --- a/conanfile.py +++ b/conanfile.py @@ -21,6 +21,7 @@ class H5CppConan(ConanFile): def build_requirements(self): self.build_requires("gtest/1.11.0") + self.build_requires("ninja/1.10.2") def config_options(self): if self.settings.os == "Windows": @@ -38,7 +39,7 @@ def requirements(self): self.requires("openmpi/4.1.0") def build(self): - cmake = CMake(self, generator="Ninja") + cmake = CMake(self) cmake.definitions.update({ "H5CPP_CONAN": "MANUAL", "H5CPP_WITH_MPI": self.options.get_safe("with_mpi", False), From 6369e7801b750b3267a07fbbbad215f3a82b9197 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 12 Aug 2021 12:03:03 +0100 Subject: [PATCH 36/78] [cmake] remove the pkgconfig generation --- src/h5cpp/CMakeLists.txt | 95 ---------------------------------------- 1 file changed, 95 deletions(-) diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index 231b36e293..b522265f91 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -84,98 +84,3 @@ install(TARGETS h5cpp install(EXPORT h5cpp_targets DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} COMPONENT development) - -# ============================================================================= -# Build the pkg-config file -# -# basically the target provides all the information required to link against -# it via all the INTERFACE properties. -# ============================================================================= -function(GET_LIBRARY_NAME LIB) - - message(STATUS "Dealing with library ${LIB}") - if(TARGET "${LIB}") - #set(LIBTMP $) - get_property(LIBTMP TARGET ${LIB} PROPERTY IMPORTED_LOCATION) - else() - set(LIBTMP "${LIB}") - endif() - - get_filename_component(LIBNAME "${LIBTMP}" NAME_WE) - get_filename_component(LIBPATH "${LIBTMP}" DIRECTORY) - - string(REPLACE "${CMAKE_SHARED_LIBRARY_PREFIX}" "" LIBNAME "${LIBNAME}") - string(REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}" "" LIBNAME "${LIBNAME}") - message("Found: ${LIBNAME} in ${LIBPATH}") - - if(DEFINED PKG_CONFIG_LIBS) - list(APPEND PKG_CONFIG_LIBS "${LIBNAME}") - set(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} PARENT_SCOPE) - else() - set(PKG_CONFIG_LIBS "${LIBNAME}" PARENT_SCOPE) - endif() - - if(DEFINED PKG_CONFIG_LIBDIRS) - list(APPEND PKG_CONFIG_LIBDIRS "${LIBPATH}") - set(PKG_CONFIG_LIBDIRS ${PKG_CONFIG_LIBDIRS} PARENT_SCOPE) - else() - set(PKG_CONFIG_LIBDIRS "${LIBPATH}" PARENT_SCOPE) - endif() - -endfunction(GET_LIBRARY_NAME) - -if(${H5CPP_CONAN} MATCHES "DISABLE") - - get_target_property(LIBRARIES h5cpp INTERFACE_LINK_LIBRARIES) - get_target_property(DEFINITIONS h5cpp INTERFACE_COMPILE_DEFINITIONS) - get_target_property(INCLUDE_DIRS h5cpp INTERFACE_INCLUDE_DIRECTORIES) - - foreach(LIB ${LIBRARIES}) - GET_LIBRARY_NAME("${LIB}") - endforeach() - - foreach(LIB ${HDF5_LIBRARIES}) - GET_LIBRARY_NAME("${LIB}") - endforeach() - - list(REMOVE_DUPLICATES PKG_CONFIG_LIBS) - list(REMOVE_DUPLICATES PKG_CONFIG_LIBDIRS) - - if(${CMAKE_VERSION} VERSION_LESS "3.13.0") - message("Please consider to switch to CMake 3.13.0") - else() - target_link_directories(h5cpp PUBLIC ${PKG_CONFIG_LIBDIRS}) - endif() - - set(PKG_CONFIG_LINKFLAGS) - foreach(DIR ${PKG_CONFIG_LIBDIRS}) - set(PKG_CONFIG_LINKFLAGS "${PKG_CONFIG_LINKFLAGS} -L${DIR}") - endforeach() - foreach(LIB ${PKG_CONFIG_LIBS}) - set(PKG_CONFIG_LINKFLAGS "${PKG_CONFIG_LINKFLAGS} -l${LIB}") - endforeach() - - set(PKG_CONFIG_CFLAGS) - - foreach(DEF ${DEFINITIONS}) - if(NOT (DEF MATCHES ".*NOTFOUND")) - set(PKG_CONFIG_CFLAGS "${PKG_CONFIG_CFLAGS} -D${DEF}") - endif() - endforeach() - foreach(INCDIR ${INCLUDE_DIRS}) - if(NOT (INCDIR MATCHES "\\$<.*")) - set(PKG_CONFIG_CFLAGS "${PKG_CONFIG_CFLAGS} -I${INCDIR}") - endif() - endforeach() - - - message("Linke libraries: ${PKG_CONFIG_LIBS}") - message("Library paths: ${PKG_CONFIG_LINKFLAGS}") - - - configure_file(h5cpp.pc.in h5cpp.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/h5cpp.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig - COMPONENT development) - -endif() From 6fd137e670d6a4989f058382a6ba144301087801 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Thu, 12 Aug 2021 12:14:14 +0100 Subject: [PATCH 37/78] [cmake] add namespace alias and target --- examples/CMakeLists.txt | 20 ++++++++++---------- examples/attributes/CMakeLists.txt | 6 +++--- examples/mpi/CMakeLists.txt | 6 ++---- examples/swmr/CMakeLists.txt | 4 ++-- examples/useage/CMakeLists.txt | 2 +- src/h5cpp/CMakeLists.txt | 2 ++ 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d685d5574c..4ebe79ecf6 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,35 +5,35 @@ set(CMAKE_CXX_STANDARD 11) find_package(h5cpp REQUIRED) add_executable(basic_files basic_files.cpp) -target_link_libraries(basic_files h5cpp) +target_link_libraries(basic_files PRIVATE h5cpp::h5cpp) add_executable(selecting_datasets selecting_datasets.cpp) -target_link_libraries(selecting_datasets h5cpp) +target_link_libraries(selecting_datasets PRIVATE h5cpp::h5cpp) add_executable(std_vector_io std_vector_io.cpp) -target_link_libraries(std_vector_io h5cpp) +target_link_libraries(std_vector_io PRIVATE h5cpp::h5cpp) add_executable(complex_io complex_io.cpp) -target_link_libraries(complex_io h5cpp) +target_link_libraries(complex_io PRIVATE h5cpp::h5cpp) add_executable(writing_image writing_image.cpp rgbpixel.cpp) -target_link_libraries(writing_image h5cpp) +target_link_libraries(writing_image PRIVATE h5cpp::h5cpp) add_executable(write_single_vector write_single_vector.cpp) -target_link_libraries(write_single_vector h5cpp) +target_link_libraries(write_single_vector PRIVATE h5cpp::h5cpp) add_executable(read_dataset read_dataset.cpp) -target_link_libraries(read_dataset h5cpp) +target_link_libraries(read_dataset PRIVATE h5cpp::h5cpp) add_executable(append_scalar_data append_scalar_data.cpp) -target_link_libraries(append_scalar_data h5cpp) +target_link_libraries(append_scalar_data PRIVATE h5cpp::h5cpp) add_executable(write_vector_list write_vector_list.cpp) -target_link_libraries(write_vector_list h5cpp) +target_link_libraries(write_vector_list PRIVATE h5cpp::h5cpp) add_executable(append_vector_data append_vector_data.cpp) -target_link_libraries(append_vector_data h5cpp) +target_link_libraries(append_vector_data PRIVATE h5cpp::h5cpp) add_custom_target(examples) diff --git a/examples/attributes/CMakeLists.txt b/examples/attributes/CMakeLists.txt index cb7513048f..423f6c97ea 100644 --- a/examples/attributes/CMakeLists.txt +++ b/examples/attributes/CMakeLists.txt @@ -1,8 +1,8 @@ add_executable(attribute_creation attribute_creation.cpp) -target_link_libraries(attribute_creation h5cpp) +target_link_libraries(attribute_creation PRIVATE h5cpp::h5cpp) add_executable(attribute_iteration attribute_iteration.cpp) -target_link_libraries(attribute_iteration h5cpp) +target_link_libraries(attribute_iteration PRIVATE h5cpp::h5cpp) add_executable(attribute_io attribute_io.cpp) -target_link_libraries(attribute_io h5cpp) \ No newline at end of file +target_link_libraries(attribute_io PRIVATE h5cpp::h5cpp) \ No newline at end of file diff --git a/examples/mpi/CMakeLists.txt b/examples/mpi/CMakeLists.txt index 2feb4f9f98..8a79d3b679 100644 --- a/examples/mpi/CMakeLists.txt +++ b/examples/mpi/CMakeLists.txt @@ -1,10 +1,8 @@ - add_executable(writer_simple writer.cpp) -target_link_libraries(writer_simple h5cpp) - +target_link_libraries(writer_simple PRIVATE h5cpp::h5cpp) add_executable(writer_extend writer_extend.cpp) -target_link_libraries(writer_extend h5cpp) +target_link_libraries(writer_extend PRIVATE h5cpp::h5cpp) add_dependencies(examples writer_simple diff --git a/examples/swmr/CMakeLists.txt b/examples/swmr/CMakeLists.txt index 9206432ef6..8c20abac96 100644 --- a/examples/swmr/CMakeLists.txt +++ b/examples/swmr/CMakeLists.txt @@ -1,9 +1,9 @@ set(SWMR_SOURCES swmr_environment.cpp swmr_builder.cpp) add_executable(swmr_write swmr_write.cpp ${SWMR_SOURCES}) -target_link_libraries(swmr_write h5cpp) +target_link_libraries(swmr_write PRIVATE h5cpp::h5cpp) add_executable(swmr_read swmr_reader.cpp ${SWMR_SOURCES}) -target_link_libraries(swmr_read h5cpp) +target_link_libraries(swmr_read PRIVATE h5cpp::h5cpp) add_dependencies(examples swmr_write diff --git a/examples/useage/CMakeLists.txt b/examples/useage/CMakeLists.txt index cb2b1538e0..02df445601 100644 --- a/examples/useage/CMakeLists.txt +++ b/examples/useage/CMakeLists.txt @@ -3,7 +3,7 @@ project("usingh5cpp") find_package(h5cpp REQUIRED) add_library(core SHARED core.cpp) -target_link_libraries(core PUBLIC h5cpp) +target_link_libraries(core PUBLIC h5cpp::h5cpp) add_executable(app app.cpp) target_link_libraries(app PRIVATE core) \ No newline at end of file diff --git a/src/h5cpp/CMakeLists.txt b/src/h5cpp/CMakeLists.txt index b522265f91..972b9e64dd 100644 --- a/src/h5cpp/CMakeLists.txt +++ b/src/h5cpp/CMakeLists.txt @@ -23,6 +23,7 @@ add_library(h5cpp ${h5cpp_sources} ${h5cpp_headers} ) +add_library(h5cpp::h5cpp ALIAS h5cpp) add_doxygen_source_deps(${h5cpp_headers}) @@ -83,4 +84,5 @@ install(TARGETS h5cpp install(EXPORT h5cpp_targets DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} + NAMESPACE h5cpp:: COMPONENT development) From badc103f07f8d384487f68a268400ec53767c219 Mon Sep 17 00:00:00 2001 From: Andrew Marshall Date: Sun, 22 Aug 2021 17:07:26 +0100 Subject: [PATCH 38/78] [conan, catch2] use catch2 from conan instead of subproject --- CMakeLists.txt | 1 - conanfile.py | 2 +- subprojects/catch2/cmake/Catch.cmake | 205 - subprojects/catch2/cmake/CatchAddTests.cmake | 132 - .../catch2/cmake/ParseAndAddCatchTests.cmake | 251 - subprojects/catch2/include/catch2/catch.hpp | 17799 ---------------- test/CMakeLists.txt | 3 +- 7 files changed, 2 insertions(+), 18391 deletions(-) delete mode 100644 subprojects/catch2/cmake/Catch.cmake delete mode 100644 subprojects/catch2/cmake/CatchAddTests.cmake delete mode 100644 subprojects/catch2/cmake/ParseAndAddCatchTests.cmake delete mode 100644 subprojects/catch2/include/catch2/catch.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 622fe5060b..26a4ce7a63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,6 @@ project(h5cpp #============================================================================= set(EXTRA_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake) list(APPEND CMAKE_MODULE_PATH ${EXTRA_MODULES_DIR}) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/subprojects/catch2/cmake) option(H5CPP_BUILD_SHARED "Build h5cpp as a shared library" OFF) if (BUILD_SHARED_LIBS) diff --git a/conanfile.py b/conanfile.py index 2ec351de56..8888a6d586 100644 --- a/conanfile.py +++ b/conanfile.py @@ -20,7 +20,7 @@ class H5CppConan(ConanFile): } def build_requirements(self): - self.build_requires("gtest/1.11.0") + self.build_requires("catch2/2.13.7") self.build_requires("ninja/1.10.2") def config_options(self): diff --git a/subprojects/catch2/cmake/Catch.cmake b/subprojects/catch2/cmake/Catch.cmake deleted file mode 100644 index b3f90a79e8..0000000000 --- a/subprojects/catch2/cmake/Catch.cmake +++ /dev/null @@ -1,205 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -Catch ------ - -This module defines a function to help use the Catch test framework. - -The :command:`catch_discover_tests` discovers tests by asking the compiled test -executable to enumerate its tests. This does not require CMake to be re-run -when tests change. However, it may not work in a cross-compiling environment, -and setting test properties is less convenient. - -This command is intended to replace use of :command:`add_test` to register -tests, and will create a separate CTest test for each Catch test case. Note -that this is in some cases less efficient, as common set-up and tear-down logic -cannot be shared by multiple test cases executing in the same instance. -However, it provides more fine-grained pass/fail information to CTest, which is -usually considered as more beneficial. By default, the CTest test name is the -same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. - -.. command:: catch_discover_tests - - Automatically add tests with CTest by querying the compiled test executable - for available tests:: - - catch_discover_tests(target - [TEST_SPEC arg1...] - [EXTRA_ARGS arg1...] - [WORKING_DIRECTORY dir] - [TEST_PREFIX prefix] - [TEST_SUFFIX suffix] - [PROPERTIES name1 value1...] - [TEST_LIST var] - [REPORTER reporter] - [OUTPUT_DIR dir] - [OUTPUT_PREFIX prefix} - [OUTPUT_SUFFIX suffix] - ) - - ``catch_discover_tests`` sets up a post-build command on the test executable - that generates the list of tests by parsing the output from running the test - with the ``--list-test-names-only`` argument. This ensures that the full - list of tests is obtained. Since test discovery occurs at build time, it is - not necessary to re-run CMake when the list of tests changes. - However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set - in order to function in a cross-compiling environment. - - Additionally, setting properties on tests is somewhat less convenient, since - the tests are not available at CMake time. Additional test properties may be - assigned to the set of tests as a whole using the ``PROPERTIES`` option. If - more fine-grained test control is needed, custom content may be provided - through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES` - directory property. The set of discovered tests is made accessible to such a - script via the ``_TESTS`` variable. - - The options are: - - ``target`` - Specifies the Catch executable, which must be a known CMake executable - target. CMake will substitute the location of the built executable when - running the test. - - ``TEST_SPEC arg1...`` - Specifies test cases, wildcarded test cases, tags and tag expressions to - pass to the Catch executable with the ``--list-test-names-only`` argument. - - ``EXTRA_ARGS arg1...`` - Any extra arguments to pass on the command line to each test case. - - ``WORKING_DIRECTORY dir`` - Specifies the directory in which to run the discovered test cases. If this - option is not provided, the current binary directory is used. - - ``TEST_PREFIX prefix`` - Specifies a ``prefix`` to be prepended to the name of each discovered test - case. This can be useful when the same test executable is being used in - multiple calls to ``catch_discover_tests()`` but with different - ``TEST_SPEC`` or ``EXTRA_ARGS``. - - ``TEST_SUFFIX suffix`` - Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of - every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may - be specified. - - ``PROPERTIES name1 value1...`` - Specifies additional properties to be set on all tests discovered by this - invocation of ``catch_discover_tests``. - - ``TEST_LIST var`` - Make the list of tests available in the variable ``var``, rather than the - default ``_TESTS``. This can be useful when the same test - executable is being used in multiple calls to ``catch_discover_tests()``. - Note that this variable is only available in CTest. - - ``REPORTER reporter`` - Use the specified reporter when running the test case. The reporter will - be passed to the Catch executable as ``--reporter reporter``. - - ``OUTPUT_DIR dir`` - If specified, the parameter is passed along as - ``--out dir/`` to Catch executable. The actual file name is the - same as the test name. This should be used instead of - ``EXTRA_ARGS --out foo`` to avoid race conditions writing the result output - when using parallel test execution. - - ``OUTPUT_PREFIX prefix`` - May be used in conjunction with ``OUTPUT_DIR``. - If specified, ``prefix`` is added to each output file name, like so - ``--out dir/prefix``. - - ``OUTPUT_SUFFIX suffix`` - May be used in conjunction with ``OUTPUT_DIR``. - If specified, ``suffix`` is added to each output file name, like so - ``--out dir/suffix``. This can be used to add a file extension to - the output e.g. ".xml". - -#]=======================================================================] - -#------------------------------------------------------------------------------ -function(catch_discover_tests TARGET) - cmake_parse_arguments( - "" - "" - "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX" - "TEST_SPEC;EXTRA_ARGS;PROPERTIES" - ${ARGN} - ) - - if(NOT _WORKING_DIRECTORY) - set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - endif() - if(NOT _TEST_LIST) - set(_TEST_LIST ${TARGET}_TESTS) - endif() - - ## Generate a unique name based on the extra arguments - string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS} ${_REPORTER} ${_OUTPUT_DIR} ${_OUTPUT_PREFIX} ${_OUTPUT_SUFFIX}") - string(SUBSTRING ${args_hash} 0 7 args_hash) - - # Define rule to generate test list for aforementioned test executable - set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") - set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake") - get_property(crosscompiling_emulator - TARGET ${TARGET} - PROPERTY CROSSCOMPILING_EMULATOR - ) - add_custom_command( - TARGET ${TARGET} POST_BUILD - BYPRODUCTS "${ctest_tests_file}" - COMMAND "${CMAKE_COMMAND}" - -D "TEST_TARGET=${TARGET}" - -D "TEST_EXECUTABLE=$" - -D "TEST_EXECUTOR=${crosscompiling_emulator}" - -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" - -D "TEST_SPEC=${_TEST_SPEC}" - -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" - -D "TEST_PROPERTIES=${_PROPERTIES}" - -D "TEST_PREFIX=${_TEST_PREFIX}" - -D "TEST_SUFFIX=${_TEST_SUFFIX}" - -D "TEST_LIST=${_TEST_LIST}" - -D "TEST_REPORTER=${_REPORTER}" - -D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}" - -D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}" - -D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}" - -D "CTEST_FILE=${ctest_tests_file}" - -P "${_CATCH_DISCOVER_TESTS_SCRIPT}" - VERBATIM - ) - - file(WRITE "${ctest_include_file}" - "if(EXISTS \"${ctest_tests_file}\")\n" - " include(\"${ctest_tests_file}\")\n" - "else()\n" - " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" - "endif()\n" - ) - - if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") - # Add discovered tests to directory TEST_INCLUDE_FILES - set_property(DIRECTORY - APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}" - ) - else() - # Add discovered tests as directory TEST_INCLUDE_FILE if possible - get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET) - if (NOT ${test_include_file_set}) - set_property(DIRECTORY - PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}" - ) - else() - message(FATAL_ERROR - "Cannot set more than one TEST_INCLUDE_FILE" - ) - endif() - endif() - -endfunction() - -############################################################################### - -set(_CATCH_DISCOVER_TESTS_SCRIPT - ${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake -) diff --git a/subprojects/catch2/cmake/CatchAddTests.cmake b/subprojects/catch2/cmake/CatchAddTests.cmake deleted file mode 100644 index 18286b71c7..0000000000 --- a/subprojects/catch2/cmake/CatchAddTests.cmake +++ /dev/null @@ -1,132 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -set(prefix "${TEST_PREFIX}") -set(suffix "${TEST_SUFFIX}") -set(spec ${TEST_SPEC}) -set(extra_args ${TEST_EXTRA_ARGS}) -set(properties ${TEST_PROPERTIES}) -set(reporter ${TEST_REPORTER}) -set(output_dir ${TEST_OUTPUT_DIR}) -set(output_prefix ${TEST_OUTPUT_PREFIX}) -set(output_suffix ${TEST_OUTPUT_SUFFIX}) -set(script) -set(suite) -set(tests) - -function(add_command NAME) - set(_args "") - foreach(_arg ${ARGN}) - if(_arg MATCHES "[^-./:a-zA-Z0-9_]") - set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument - else() - set(_args "${_args} ${_arg}") - endif() - endforeach() - set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE) -endfunction() - -# Run test executable to get list of available tests -if(NOT EXISTS "${TEST_EXECUTABLE}") - message(FATAL_ERROR - "Specified test executable '${TEST_EXECUTABLE}' does not exist" - ) -endif() -execute_process( - COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only - OUTPUT_VARIABLE output - RESULT_VARIABLE result - WORKING_DIRECTORY "${TEST_WORKING_DIR}" -) -# Catch --list-test-names-only reports the number of tests, so 0 is... surprising -if(${result} EQUAL 0) - message(WARNING - "Test executable '${TEST_EXECUTABLE}' contains no tests!\n" - ) -elseif(${result} LESS 0) - message(FATAL_ERROR - "Error running test executable '${TEST_EXECUTABLE}':\n" - " Result: ${result}\n" - " Output: ${output}\n" - ) -endif() - -string(REPLACE "\n" ";" output "${output}") - -# Run test executable to get list of available reporters -execute_process( - COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-reporters - OUTPUT_VARIABLE reporters_output - RESULT_VARIABLE reporters_result - WORKING_DIRECTORY "${TEST_WORKING_DIR}" -) -if(${reporters_result} EQUAL 0) - message(WARNING - "Test executable '${TEST_EXECUTABLE}' contains no reporters!\n" - ) -elseif(${reporters_result} LESS 0) - message(FATAL_ERROR - "Error running test executable '${TEST_EXECUTABLE}':\n" - " Result: ${reporters_result}\n" - " Output: ${reporters_output}\n" - ) -endif() -string(FIND "${reporters_output}" "${reporter}" reporter_is_valid) -if(reporter AND ${reporter_is_valid} EQUAL -1) - message(FATAL_ERROR - "\"${reporter}\" is not a valid reporter!\n" - ) -endif() - -# Prepare reporter -if(reporter) - set(reporter_arg "--reporter ${reporter}") -endif() - -# Prepare output dir -if(output_dir AND NOT IS_ABSOLUTE ${output_dir}) - set(output_dir "${TEST_WORKING_DIR}/${output_dir}") - if(NOT EXISTS ${output_dir}) - file(MAKE_DIRECTORY ${output_dir}) - endif() -endif() - -# Parse output -foreach(line ${output}) - set(test ${line}) - # Escape characters in test case names that would be parsed by Catch2 - set(test_name ${test}) - foreach(char , [ ]) - string(REPLACE ${char} "\\${char}" test_name ${test_name}) - endforeach(char) - # ...add output dir - if(output_dir) - string(REGEX REPLACE "[^A-Za-z0-9_]" "_" test_name_clean ${test_name}) - set(output_dir_arg "--out ${output_dir}/${output_prefix}${test_name_clean}${output_suffix}") - endif() - - # ...and add to script - add_command(add_test - "${prefix}${test}${suffix}" - ${TEST_EXECUTOR} - "${TEST_EXECUTABLE}" - "${test_name}" - ${extra_args} - "${reporter_arg}" - "${output_dir_arg}" - ) - add_command(set_tests_properties - "${prefix}${test}${suffix}" - PROPERTIES - WORKING_DIRECTORY "${TEST_WORKING_DIR}" - ${properties} - ) - list(APPEND tests "${prefix}${test}${suffix}") -endforeach() - -# Create a list of all discovered tests, which users may use to e.g. set -# properties on the tests -add_command(set ${TEST_LIST} ${tests}) - -# Write CTest script -file(WRITE "${CTEST_FILE}" "${script}") diff --git a/subprojects/catch2/cmake/ParseAndAddCatchTests.cmake b/subprojects/catch2/cmake/ParseAndAddCatchTests.cmake deleted file mode 100644 index 3f3da83198..0000000000 --- a/subprojects/catch2/cmake/ParseAndAddCatchTests.cmake +++ /dev/null @@ -1,251 +0,0 @@ -#==================================================================================================# -# supported macros # -# - TEST_CASE, # -# - TEMPLATE_TEST_CASE # -# - SCENARIO, # -# - TEST_CASE_METHOD, # -# - CATCH_TEST_CASE, # -# - CATCH_TEMPLATE_TEST_CASE # -# - CATCH_SCENARIO, # -# - CATCH_TEST_CASE_METHOD. # -# # -# Usage # -# 1. make sure this module is in the path or add this otherwise: # -# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/") # -# 2. make sure that you've enabled testing option for the project by the call: # -# enable_testing() # -# 3. add the lines to the script for testing target (sample CMakeLists.txt): # -# project(testing_target) # -# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/") # -# enable_testing() # -# # -# find_path(CATCH_INCLUDE_DIR "catch.hpp") # -# include_directories(${INCLUDE_DIRECTORIES} ${CATCH_INCLUDE_DIR}) # -# # -# file(GLOB SOURCE_FILES "*.cpp") # -# add_executable(${PROJECT_NAME} ${SOURCE_FILES}) # -# # -# include(ParseAndAddCatchTests) # -# ParseAndAddCatchTests(${PROJECT_NAME}) # -# # -# The following variables affect the behavior of the script: # -# # -# PARSE_CATCH_TESTS_VERBOSE (Default OFF) # -# -- enables debug messages # -# PARSE_CATCH_TESTS_NO_HIDDEN_TESTS (Default OFF) # -# -- excludes tests marked with [!hide], [.] or [.foo] tags # -# PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME (Default ON) # -# -- adds fixture class name to the test name # -# PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME (Default ON) # -# -- adds cmake target name to the test name # -# PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS (Default OFF) # -# -- causes CMake to rerun when file with tests changes so that new tests will be discovered # -# # -# One can also set (locally) the optional variable OptionalCatchTestLauncher to precise the way # -# a test should be run. For instance to use test MPI, one can write # -# set(OptionalCatchTestLauncher ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${NUMPROC}) # -# just before calling this ParseAndAddCatchTests function # -# # -# The AdditionalCatchParameters optional variable can be used to pass extra argument to the test # -# command. For example, to include successful tests in the output, one can write # -# set(AdditionalCatchParameters --success) # -# # -# After the script, the ParseAndAddCatchTests_TESTS property for the target, and for each source # -# file in the target is set, and contains the list of the tests extracted from that target, or # -# from that file. This is useful, for example to add further labels or properties to the tests. # -# # -#==================================================================================================# - -if (CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8) - message(FATAL_ERROR "ParseAndAddCatchTests requires CMake 2.8.8 or newer") -endif() - -option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF) -option(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS "Exclude tests with [!hide], [.] or [.foo] tags" OFF) -option(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME "Add fixture class name to the test name" ON) -option(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME "Add target name to the test name" ON) -option(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS "Add test file to CMAKE_CONFIGURE_DEPENDS property" OFF) - -function(ParseAndAddCatchTests_PrintDebugMessage) - if(PARSE_CATCH_TESTS_VERBOSE) - message(STATUS "ParseAndAddCatchTests: ${ARGV}") - endif() -endfunction() - -# This removes the contents between -# - block comments (i.e. /* ... */) -# - full line comments (i.e. // ... ) -# contents have been read into '${CppCode}'. -# !keep partial line comments -function(ParseAndAddCatchTests_RemoveComments CppCode) - string(ASCII 2 CMakeBeginBlockComment) - string(ASCII 3 CMakeEndBlockComment) - string(REGEX REPLACE "/\\*" "${CMakeBeginBlockComment}" ${CppCode} "${${CppCode}}") - string(REGEX REPLACE "\\*/" "${CMakeEndBlockComment}" ${CppCode} "${${CppCode}}") - string(REGEX REPLACE "${CMakeBeginBlockComment}[^${CMakeEndBlockComment}]*${CMakeEndBlockComment}" "" ${CppCode} "${${CppCode}}") - string(REGEX REPLACE "\n[ \t]*//+[^\n]+" "\n" ${CppCode} "${${CppCode}}") - - set(${CppCode} "${${CppCode}}" PARENT_SCOPE) -endfunction() - -# Worker function -function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget) - # If SourceFile is an object library, do not scan it (as it is not a file). Exit without giving a warning about a missing file. - if(SourceFile MATCHES "\\\$") - ParseAndAddCatchTests_PrintDebugMessage("Detected OBJECT library: ${SourceFile} this will not be scanned for tests.") - return() - endif() - # According to CMake docs EXISTS behavior is well-defined only for full paths. - get_filename_component(SourceFile ${SourceFile} ABSOLUTE) - if(NOT EXISTS ${SourceFile}) - message(WARNING "Cannot find source file: ${SourceFile}") - return() - endif() - ParseAndAddCatchTests_PrintDebugMessage("parsing ${SourceFile}") - file(STRINGS ${SourceFile} Contents NEWLINE_CONSUME) - - # Remove block and fullline comments - ParseAndAddCatchTests_RemoveComments(Contents) - - # Find definition of test names - # https://regex101.com/r/JygOND/1 - string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([ \t\n]*\"[^\"]*\"[ \t\n]*(,[ \t\n]*\"[^\"]*\")?(,[ \t\n]*[^\,\)]*)*\\)[ \t\n]*\{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}") - - if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests) - ParseAndAddCatchTests_PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property") - set_property( - DIRECTORY - APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS ${SourceFile} - ) - endif() - - # check CMP0110 policy for new add_test() behavior - if(POLICY CMP0110) - cmake_policy(GET CMP0110 _cmp0110_value) # new add_test() behavior - else() - # just to be thorough explicitly set the variable - set(_cmp0110_value) - endif() - - foreach(TestName ${Tests}) - # Strip newlines - string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}") - - # Get test type and fixture if applicable - string(REGEX MATCH "(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^,^\"]*" TestTypeAndFixture "${TestName}") - string(REGEX MATCH "(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)" TestType "${TestTypeAndFixture}") - string(REGEX REPLACE "${TestType}\\([ \t]*" "" TestFixture "${TestTypeAndFixture}") - - # Get string parts of test definition - string(REGEX MATCHALL "\"+([^\\^\"]|\\\\\")+\"+" TestStrings "${TestName}") - - # Strip wrapping quotation marks - string(REGEX REPLACE "^\"(.*)\"$" "\\1" TestStrings "${TestStrings}") - string(REPLACE "\";\"" ";" TestStrings "${TestStrings}") - - # Validate that a test name and tags have been provided - list(LENGTH TestStrings TestStringsLength) - if(TestStringsLength GREATER 2 OR TestStringsLength LESS 1) - message(FATAL_ERROR "You must provide a valid test name and tags for all tests in ${SourceFile}") - endif() - - # Assign name and tags - list(GET TestStrings 0 Name) - if("${TestType}" STREQUAL "SCENARIO") - set(Name "Scenario: ${Name}") - endif() - if(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME AND "${TestType}" MATCHES "(CATCH_)?TEST_CASE_METHOD" AND TestFixture ) - set(CTestName "${TestFixture}:${Name}") - else() - set(CTestName "${Name}") - endif() - if(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME) - set(CTestName "${TestTarget}:${CTestName}") - endif() - # add target to labels to enable running all tests added from this target - set(Labels ${TestTarget}) - if(TestStringsLength EQUAL 2) - list(GET TestStrings 1 Tags) - string(TOLOWER "${Tags}" Tags) - # remove target from labels if the test is hidden - if("${Tags}" MATCHES ".*\\[!?(hide|\\.)\\].*") - list(REMOVE_ITEM Labels ${TestTarget}) - endif() - string(REPLACE "]" ";" Tags "${Tags}") - string(REPLACE "[" "" Tags "${Tags}") - else() - # unset tags variable from previous loop - unset(Tags) - endif() - - list(APPEND Labels ${Tags}) - - set(HiddenTagFound OFF) - foreach(label ${Labels}) - string(REGEX MATCH "^!hide|^\\." result ${label}) - if(result) - set(HiddenTagFound ON) - break() - endif(result) - endforeach(label) - if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_LESS "3.9") - ParseAndAddCatchTests_PrintDebugMessage("Skipping test \"${CTestName}\" as it has [!hide], [.] or [.foo] label") - else() - ParseAndAddCatchTests_PrintDebugMessage("Adding test \"${CTestName}\"") - if(Labels) - ParseAndAddCatchTests_PrintDebugMessage("Setting labels to ${Labels}") - endif() - - # Escape commas in the test spec - string(REPLACE "," "\\," Name ${Name}) - - # Work around CMake 3.18.0 change in `add_test()`, before the escaped quotes were neccessary, - # only with CMake 3.18.0 the escaped double quotes confuse the call. This change is reverted in 3.18.1 - # And properly introduced in 3.19 with the CMP0110 policy - if(_cmp0110_value STREQUAL "NEW" OR ${CMAKE_VERSION} VERSION_EQUAL "3.18") - ParseAndAddCatchTests_PrintDebugMessage("CMP0110 set to NEW, no need for add_test(\"\") workaround") - else() - ParseAndAddCatchTests_PrintDebugMessage("CMP0110 set to OLD adding \"\" for add_test() workaround") - set(CTestName "\"${CTestName}\"") - endif() - - # Handle template test cases - if("${TestTypeAndFixture}" MATCHES ".*TEMPLATE_.*") - set(Name "${Name} - *") - endif() - - # Add the test and set its properties - add_test(NAME "${CTestName}" COMMAND ${OptionalCatchTestLauncher} $ ${Name} ${AdditionalCatchParameters}) - # Old CMake versions do not document VERSION_GREATER_EQUAL, so we use VERSION_GREATER with 3.8 instead - if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_GREATER "3.8") - ParseAndAddCatchTests_PrintDebugMessage("Setting DISABLED test property") - set_tests_properties("${CTestName}" PROPERTIES DISABLED ON) - else() - set_tests_properties("${CTestName}" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran" - LABELS "${Labels}") - endif() - set_property( - TARGET ${TestTarget} - APPEND - PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}") - set_property( - SOURCE ${SourceFile} - APPEND - PROPERTY ParseAndAddCatchTests_TESTS "${CTestName}") - endif() - - - endforeach() -endfunction() - -# entry point -function(ParseAndAddCatchTests TestTarget) - ParseAndAddCatchTests_PrintDebugMessage("Started parsing ${TestTarget}") - get_target_property(SourceFiles ${TestTarget} SOURCES) - ParseAndAddCatchTests_PrintDebugMessage("Found the following sources: ${SourceFiles}") - foreach(SourceFile ${SourceFiles}) - ParseAndAddCatchTests_ParseFile(${SourceFile} ${TestTarget}) - endforeach() - ParseAndAddCatchTests_PrintDebugMessage("Finished parsing ${TestTarget}") -endfunction() diff --git a/subprojects/catch2/include/catch2/catch.hpp b/subprojects/catch2/include/catch2/catch.hpp deleted file mode 100644 index cf1fae15aa..0000000000 --- a/subprojects/catch2/include/catch2/catch.hpp +++ /dev/null @@ -1,17799 +0,0 @@ -/* - * Catch v2.13.0 - * Generated: 2020-07-12 20:07:49.015950 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 0 - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ - // Because REQUIREs trigger GCC's -Wparentheses, and because still - // supported version of g++ have only buggy support for _Pragmas, - // Wparentheses have to be suppressed globally. -# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -#ifdef __APPLE__ -# include -# if TARGET_OS_OSX == 1 -# define CATCH_PLATFORM_MAC -# elif TARGET_OS_IPHONE == 1 -# define CATCH_PLATFORM_IPHONE -# endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) -# define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { - unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -#endif - -#if defined(__cpp_lib_uncaught_exceptions) -# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -#endif - -// We have to avoid both ICC and Clang, because they try to mask themselves -// as gcc, and we want only GCC in this block -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) - -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) - -#endif - -#if defined(__clang__) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) - -// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug -// which results in calls to destructors being emitted for each temporary, -// without a matching initialization. In practice, this can result in something -// like `std::string::~string` being called on an uninitialized value. -// -// For example, this code will likely segfault under IBM XL: -// ``` -// REQUIRE(std::string("12") + "34" == "1234") -// ``` -// -// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. -# if !defined(__ibmxl__) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ -# endif - -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ - _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) - -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ - && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -# endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#if defined(_MSC_VER) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) - -# if _MSC_VER >= 1900 // Visual Studio 2015 or newer -# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -# endif - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -# define CATCH_CONFIG_COLOUR_NONE -# else -# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -# endif - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(__clang__) // Handle Clang masquerading for msvc -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif // MSVC_TRADITIONAL -# endif // __clang__ - -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -# define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -# define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) - #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) - #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH - #define CATCH_INTERNAL_CONFIG_NO_ASYNC - #define CATCH_CONFIG_COLOUR_NONE -#endif - -#if !defined(_GLIBCXX_USE_C99_MATH_TR1) -#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Various stdlib support checks that require __has_include -#if defined(__has_include) - // Check if string_view is available and usable - #if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW - #endif - - // Check if optional is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if byte is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_BYTE - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if variant is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 - # include - # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # define CATCH_CONFIG_NO_CPP17_VARIANT - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__clang__) && (__clang_major__ < 8) - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // defined(__has_include) - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) -# define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -# define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) -# define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) -# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -# define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) -# define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) -# define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) -# define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -# define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) -# define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -# define CATCH_CONFIG_USE_ASYNC -#endif - -#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) -# define CATCH_CONFIG_ANDROID_LOGWRITE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) -# define CATCH_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Even if we do not think the compiler has that warning, we still have -// to provide a macro that can be used by the code. -#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -// The goal of this macro is to avoid evaluation of the arguments, but -// still have the compiler warn on problems inside... -#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) -#endif - -#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#elif defined(__clang__) && (__clang_major__ < 5) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); - }; - - struct SourceLineInfo { - - SourceLineInfo() = delete; - SourceLineInfo( char const* _file, std::size_t _line ) noexcept - : file( _file ), - line( _line ) - {} - - SourceLineInfo( SourceLineInfo const& other ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo( SourceLineInfo&& ) noexcept = default; - SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - - bool empty() const noexcept { return file[0] == '\0'; } - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // Bring in operator<< from global namespace into Catch namespace - // This is necessary because the overload of operator<< above makes - // lookup stop at namespace Catch - using ::operator<<; - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() const; - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) - -// end catch_common.h -namespace Catch { - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - - class TestSpec; - - struct ITestInvoker { - virtual void invoke () const = 0; - virtual ~ITestInvoker(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCase const& testCase, IConfig const& config ); - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef const& other ) const noexcept -> bool; - auto operator != (StringRef const& other) const noexcept -> bool { - return !(*this == other); - } - - auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns the current start pointer. If the StringRef is not - // null-terminated, throws std::domain_exception - auto c_str() const -> char const*; - - public: // substrings and searches - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - auto substr( size_type start, size_type length ) const noexcept -> StringRef; - - // Returns the current start pointer. May not be null-terminated. - auto data() const noexcept -> char const*; - - constexpr auto isNullTerminated() const noexcept -> bool { - return m_start[m_size] == '\0'; - } - - public: // iterators - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - }; - - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; - - constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -// end catch_stringref.h -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, -// and passes userdata as the first parameter to each invocation, -// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - template class...> struct TemplateTypeList{};\ - template class...Cs>\ - constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ - template\ - struct append;\ - template\ - struct rewrap;\ - template class, typename...>\ - struct create;\ - template class, typename>\ - struct convert;\ - \ - template \ - struct append { using type = T; };\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ - template< template class L1, typename...E1, typename...Rest>\ - struct append, TypeList, Rest...> { using type = L1; };\ - \ - template< template class Container, template class List, typename...elems>\ - struct rewrap, List> { using type = TypeList>; };\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ - \ - template