From 46c8c982fb06f1ec10517266b74023894553dffc Mon Sep 17 00:00:00 2001 From: Vlad Gheorghiu Date: Mon, 29 Jul 2024 16:56:15 -0400 Subject: [PATCH] Improvements (#176) * WIP * Simplified MATLAB detection * Update CHANGES.md * Formatting * Minor update POSIX-compliance Signed-off-by: Vlad Gheorghiu * Update Signed-off-by: Vlad Gheorghiu * add .txt extension VERSION conflicts with cpp20 on macOS, hence renamed to VERSION.txt Signed-off-by: Vlad Gheorghiu * Update Signed-off-by: Vlad Gheorghiu * Update Signed-off-by: Vlad Gheorghiu * fix Signed-off-by: Vlad Gheorghiu * Minor update Signed-off-by: Vlad Gheorghiu * improve performance of multiidx2n (#173) * improve performance of multiidx2n * minor cleanup * minor fix * CCNOT example (#175) * add toffoli example * fix typo * Updated CCNOT example Signed-off-by: Vlad Gheorghiu * Minor typos Signed-off-by: Vlad Gheorghiu --------- Signed-off-by: Vlad Gheorghiu Co-authored-by: Saman <100295082+enum-class@users.noreply.github.com> --- .github/workflows/cmake.yml | 13 ++++- CHANGES.md | 14 +++-- CMakeLists.txt | 8 +-- INSTALL.md | 40 ++++--------- LICENSE => LICENSE.txt | 0 README.md | 4 +- VERSION => VERSION.txt | 0 cmake/examples.cmake | 2 +- cmake/qpp_MATLAB.cmake | 106 ++-------------------------------- cmake/qpp_dependencies.cmake | 2 +- cmake/qpp_uninstall.cmake.in | 14 ++--- examples/toffoli.cpp | 77 ++++++++++++++++++++++++ include/qpp/input_output.hpp | 2 +- include/qpp/instruments.hpp | 2 - include/qpp/internal/util.hpp | 10 +--- include/qpp/qpp.h | 12 ++-- prettyprint.sh | 10 ++-- stress_tests/CMakeLists.txt | 2 +- unit_tests/CMakeLists.txt | 2 +- 19 files changed, 146 insertions(+), 174 deletions(-) rename LICENSE => LICENSE.txt (100%) rename VERSION => VERSION.txt (100%) create mode 100644 examples/toffoli.cpp diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 9ddef8357..3fe4b4949 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -17,7 +17,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Configure Quantum++ run: cmake -B build @@ -55,7 +55,7 @@ jobs: - name: Run unit tests run: ctest --test-dir build -E qpp_Timer - - name: Uninstall + - name: Uninstall Quantum++ shell: bash run: | if [ "$RUNNER_OS" == "Windows" ]; then @@ -65,5 +65,12 @@ jobs: fi - name: Install pyqpp + shell: bash run: | - pip3 install --user . + python3 -m venv venv + if [ "$RUNNER_OS" == "Windows" ]; then + venv/Scripts/activate + else + . venv/bin/activate + fi + pip3 install . diff --git a/CHANGES.md b/CHANGES.md index 363394606..af5636e6b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# Pre-release + +- Simplified MATLAB detection via CMake `find_package()` function. Users should + only use `-DQPP_MATLAB=ON` when building with MATLAB support, all other + MATLAB-related CMake flags have been removed. + # Version 5.1 - 1 March 2024 - Replaced ["CHANGES"] by ["CHANGES.md"], @@ -308,7 +314,7 @@ attribute `[[qpp::parallel]]`. Since C++17, unknown attributes are supposed to be ignored by the compiler (and one can use this technique to define custom attributes). Warnings are explicitly disabled for - clang/gcc/MSVC/icc. If your compiler emits a warning, please disable it + Clang/GCC/MSVC/Intel. If your compiler emits a warning, please disable it with the corresponding `#pragma` directive at the beginning of ["qpp.h"] - Added from-string constructor for `qpp::Bit_circuit` and `qpp::Dynamic_bitset` @@ -911,13 +917,13 @@ as using traits over-complicated the design and it was not worth it. - Marked final all classes that are not intended to be used as base classes. - Modified the `CMakeLists.txt`, which now: - - supports only GNU gcc and LLVM/Apple clang; otherwise, emits an error - during the CMake running phase + - supports only GCC and LLVM/Apple clang; otherwise, emits an error during + the CMake running phase - adds `-D_NO_THREAD_LOCAL` definition for conditional compiling the source code without support for `std::thread_local` (if using e.g., LLVM/Apple clang with libc++, as libc++ does not yet support `std::thread_local`) - - uses OpenMP only if the compiler is detected as GNU gcc + - uses OpenMP only if the compiler is detected as GCC # Version 0.7 - 22 April 2015 diff --git a/CMakeLists.txt b/CMakeLists.txt index a8de16fbf..7e14d3c6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,21 +52,21 @@ if(${Python3_FOUND}) endif() # BEGIN LOCAL stuff, you don't need those in standalone projects -option(SANITIZE "Enable code sanitizing (only for gcc/clang)" OFF) +option(SANITIZE "Enable code sanitizing (only for GCC/Clang)" OFF) # Dependencies, do not modify unless you know what you're doing include(cmake/qpp_eigen3.cmake) # Dependencies, do not modify unless you know what you're doing -include(cmake/qpp_dependencies.cmake) +include(cmake/qpp_MATLAB.cmake) # Dependencies, do not modify unless you know what you're doing -include(cmake/qpp_MATLAB.cmake) +include(cmake/qpp_dependencies.cmake) # Unit testing add_subdirectory(${CMAKE_SOURCE_DIR}/unit_tests/ EXCLUDE_FROM_ALL SYSTEM) -# Enable all warnings for GNU gcc and Clang/AppleClang +# Enable all warnings for GCC and Clang/AppleClang if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") add_compile_options("-pedantic" "-Wall" "-Wextra" "-Weffc++") diff --git a/INSTALL.md b/INSTALL.md index 38bc9c3ff..ddeaefce5 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,19 +1,18 @@ # Installation instructions **Quantum++** is a header-only library that uses [CMake](https://cmake.org/) as -its build/install system. **Quantum++** is platform-independent, -supporting [UNIX](https://www.opengroup.org/membership/forums/platform/unix) -(including -[macOS](https://www.apple.com/macos/)) and UNIX-like operating systems -(e.g., [Linux](https://www.linux.org)), as well -as [Windows](https://www.microsoft.com/en-us/windows). +its build/install system. **Quantum++** is platform-independent, supporting +[UNIX](https://www.opengroup.org/membership/forums/platform/unix) (including +[macOS](https://www.apple.com/macos/)) and UNIX-like operating systems (e.g., +[Linux](https://www.linux.org)), as well as +[Windows](https://www.microsoft.com/en-us/windows). --- ## Pre-requisites -- C++17 compliant compiler, e.g., [gcc](https://gcc.gnu.org/) - , [clang](https://clang.llvm.org) +- C++17 compliant compiler, e.g., [GCC](https://gcc.gnu.org/) + , [Clang](https://clang.llvm.org) , [MSVC](https://visualstudio.microsoft.com/vs/) etc. - [CMake](https://cmake.org/) - [Eigen 3](https://eigen.tuxfamily.org) linear algebra library. If missing, it @@ -25,13 +24,8 @@ as [Windows](https://www.microsoft.com/en-us/windows). Python 3 wrapper - [MATLAB](https://www.mathworks.com/products/matlab/) compiler shared libraries and include header files, in case you want to enable - interoperability with MATLAB. If enabled, allows applications build with + interoperability with MATLAB. If enabled, allows applications built with **Quantum++** to save/load **Quantum++** matrices and vectors to/from MATLAB. - The locations of the MATLAB compiler shared libraries and header files are - platform-specific, e.g., under Linux, they may be located under - `/usr/local/MATLAB/R2021a/bin/glnxa64` and - `/usr/local/MATLAB/R2021a/extern/include`, respectively. On your platform the - locations may of course differ. --- @@ -103,19 +97,7 @@ their corresponding `CMakeLists.txt` via `findpackage(qpp ...)`. | `QPP_FP` | `default`, etc. [`default` by default] | Floating-point type (`qpp::realT`) | | `QPP_IDX` | `default`, etc. [`default` by default] | Integer index type (`qpp::idx`) | | | | | -| `SANITIZE` | `ON/OFF` [`OFF` by default] | Enable code sanitizing (only for gcc/clang) | - -If `QPP_MATLAB=ON` and the system could not detect your MATLAB installation, -you can manually specify the path to MATLAB's installation directory via the -additional CMake argument - - MATLAB_INSTALL_DIR=/path/to/MATLAB - -If you are still receiving errors, you can manually specify the path to -MATLAB's required libraries and header files via the additional arguments - - MATLAB_LIB_DIR=/path/to/MATLAB/libs - MATLAB_INCLUDE_DIR=/path/to/MATLAB/headers +| `SANITIZE` | `ON/OFF` [`OFF` by default] | Enable code sanitizing (only for GCC/Clang) | --- @@ -273,8 +255,8 @@ If building under Windows with [MATLAB](https://www.mathworks.com/products/matlab/) support, please add the location of -`libmx.dll` and `libmat.dll` (the `.dll` **and not** the `.lib` files) to -your `PATH` environment variable. In our case they are located +`libmx.dll` and `libmat.dll` (the `.dll` **and not** the `.lib` files) to your +`PATH` environment variable. For example, on our platform they are located under `C:\Program Files\MATLAB\R2021a\bin\win64`. --- diff --git a/LICENSE b/LICENSE.txt similarity index 100% rename from LICENSE rename to LICENSE.txt diff --git a/README.md b/README.md index 427ddd623..799a5216c 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,8 @@ Copyright (c) 2017 - 2024 softwareQ Inc. All rights reserved. [Quantum++](https://github.com/softwareQinc/qpp) is distributed under the MIT license. Please see the -[`LICENSE`](https://github.com/softwareQinc/qpp/blob/main/LICENSE) file for -more details. +[`LICENSE.txt`](https://github.com/softwareQinc/qpp/blob/main/LICENSE.txt) +file for more details. --- diff --git a/VERSION b/VERSION.txt similarity index 100% rename from VERSION rename to VERSION.txt diff --git a/cmake/examples.cmake b/cmake/examples.cmake index 174009d10..3e1e92418 100644 --- a/cmake/examples.cmake +++ b/cmake/examples.cmake @@ -8,7 +8,7 @@ add_custom_target(examples COMMENT "Examples") foreach(file ${EXAMPLE_FILES}) get_filename_component(TARGET_NAME ${file} NAME_WE) # Do not build "examples/matlab_io.cpp" if there's no MATLAB support - if(${TARGET_NAME} STREQUAL "matlab_io" AND NOT BUILD_WITH_MATLAB) + if(${TARGET_NAME} STREQUAL "matlab_io" AND NOT MATLAB_FOUND) continue() endif() add_executable(${TARGET_NAME} EXCLUDE_FROM_ALL ${file}) diff --git a/cmake/qpp_MATLAB.cmake b/cmake/qpp_MATLAB.cmake index aeebee58f..f04de2732 100644 --- a/cmake/qpp_MATLAB.cmake +++ b/cmake/qpp_MATLAB.cmake @@ -1,107 +1,13 @@ # MATLAB support, disabled by default option(QPP_MATLAB "MATLAB support" OFF) if(${QPP_MATLAB}) - message(STATUS "Detecting MATLAB") - # Try to find it automatically - find_package( - Matlab - OPTIONAL_COMPONENTS MX_LIBRARY MAT_LIBRARY - QUIET) + message(STATUS "Detecting MATLAB...") + find_package(Matlab REQUIRED COMPONENTS MX_LIBRARY MAT_LIBRARY) if(MATLAB_FOUND) - message(STATUS "Detecting MATLAB - done (in ${Matlab_ROOT_DIR})") include_directories(SYSTEM ${Matlab_INCLUDE_DIRS}) - if(WIN32) - if(MSVC) - set(MATLAB_LIB_DIR - "${Matlab_ROOT_DIR}/extern/lib/win64/microsoft" - CACHE PATH "Custom path to MATLAB lib directory") - elseif(MINGW) - set(MATLAB_LIB_DIR - "${Matlab_ROOT_DIR}/extern/lib/win64/mingw64" - CACHE PATH "Custom path to MATLAB lib directory") - else() - message(FATAL_ERROR "Platform not supported, aborting.") - endif() - elseif(UNIX AND NOT APPLE) - set(MATLAB_LIB_DIR - "${Matlab_ROOT_DIR}/bin/glnxa64" - CACHE PATH "Custom path to MATLAB lib directory") - elseif(APPLE) - if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "arm64") - message( - FATAL_ERROR - "arm64 architecture is not (yet) supported by MATLAB, aborting.") - endif() - set(MATLAB_LIB_DIR - "${Matlab_ROOT_DIR}/bin/maci64" - CACHE PATH "Custom path to MATLAB lib directory") - else() - message(FATAL_ERROR "Platform not supported, aborting.") - endif() - link_directories(${MATLAB_LIB_DIR}) - add_compile_definitions(QPP_MATLAB) - set(BUILD_WITH_MATLAB TRUE) - else() # Location manually specified - set(MATLAB_INSTALL_DIR - "" - CACHE PATH "Custom path to MATLAB installation") - if(IS_DIRECTORY ${MATLAB_INSTALL_DIR}) - # MATLAB include files - set(MATLAB_INCLUDE_DIR - "${MATLAB_INSTALL_DIR}/extern/include" - CACHE PATH "Custom path to MATLAB include directory") - if(IS_DIRECTORY ${MATLAB_INCLUDE_DIR}) - include_directories(SYSTEM ${MATLAB_INCLUDE_DIR}) - else() - message(FATAL_ERROR "Possibly corrupted MATLAB include headers") - endif() - # MATLAB linker files - if(WIN32) - if(MSVC) - set(MATLAB_LIB_DIR - "${MATLAB_INSTALL_DIR}/extern/lib/win64/microsoft" - CACHE PATH "Custom path to MATLAB lib directory") - elseif(MINGW64) - set(MATLAB_LIB_DIR - "${MATLAB_INSTALL_DIR}/extern/lib/win64/mingw64" - CACHE PATH "Custom path to MATLAB lib directory") - else() - message(FATAL_ERROR "Platform not supported, aborting.") - endif() - elseif(UNIX AND NOT APPLE) - set(MATLAB_LIB_DIR - "${MATLAB_INSTALL_DIR}/bin/glnxa64" - CACHE PATH "Custom path to MATLAB lib directory") - elseif(APPLE) - set(MATLAB_LIB_DIR - "${MATLAB_INSTALL_DIR}/bin/maci64" - CACHE PATH "Custom path to MATLAB lib directory") - else() - message(FATAL_ERROR "Platform not supported, aborting.") - endif() - if(IS_DIRECTORY ${MATLAB_LIB_DIR}) - link_directories(${MATLAB_LIB_DIR}) - else() - message(FATAL_ERROR "Possibly corrupted MATLAB compiler libraries") - endif() - # Everything is OK, inject definition (as #define) in the source - message(STATUS "Detecting MATLAB - done (in ${MATLAB_INSTALL_DIR})") - add_compile_definitions(QPP_MATLAB) - set(BUILD_WITH_MATLAB TRUE) - else() - message(FATAL_ERROR "Could not detect MATLAB, aborting") - endif() - endif() - # MATLAB linking dependencies to be injected in the main CMakeLists.txt - if(${BUILD_WITH_MATLAB}) - if(WIN32) - if(MSVC) - set(QPP_MATLAB_LINK_DEPS libmx libmat) - elseif(MINGW) - set(QPP_MATLAB_LINK_DEPS mx mat) - endif() - else() - set(QPP_MATLAB_LINK_DEPS mx mat) - endif() + set(QPP_MATLAB_LINK_DEPS Matlab::mat Matlab::mx) + message(STATUS "Detected MATLAB in: ${Matlab_ROOT_DIR}") + else() + message(FATAL_ERROR "Could not detect MATLAB, aborting") endif() endif() diff --git a/cmake/qpp_dependencies.cmake b/cmake/qpp_dependencies.cmake index 83601daf8..f5b4fd386 100644 --- a/cmake/qpp_dependencies.cmake +++ b/cmake/qpp_dependencies.cmake @@ -152,7 +152,7 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") add_compile_options(-stdlib=libc++) endif() -# GNU gcc additional debug settings +# GCC additional debug settings if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") # if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ## use the "no-weak" debugging # flag only when debugging under OS X, ## as gdb cannot step in template diff --git a/cmake/qpp_uninstall.cmake.in b/cmake/qpp_uninstall.cmake.in index f6017d480..514346ec3 100644 --- a/cmake/qpp_uninstall.cmake.in +++ b/cmake/qpp_uninstall.cmake.in @@ -7,17 +7,17 @@ endif() file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") foreach(file ${files}) - message(STATUS "Uninstalling $ENV{DESTDIR}${file}") - if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "Uninstalling ${file}") + if(IS_SYMLINK "${file}" OR EXISTS "${file}") execute_process( - COMMAND @CMAKE_COMMAND@ -E rm $ENV{DESTDIR}${file} + COMMAND @CMAKE_COMMAND@ -E rm -f "${file}" OUTPUT_VARIABLE rm_out RESULT_VARIABLE rm_retval) - if(NOT "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + if(${rm_retval}) + message(FATAL_ERROR "Problem when removing ${file}") endif() - else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + else() + message(STATUS "File ${file} does not exist.") endif() endforeach() diff --git a/examples/toffoli.cpp b/examples/toffoli.cpp new file mode 100644 index 000000000..b39555288 --- /dev/null +++ b/examples/toffoli.cpp @@ -0,0 +1,77 @@ +// Toffoli gate simulation +// Source: ./examples/toffoli.cpp + +#include + +#include "qpp/qpp.h" + +int main() { + using namespace qpp; + + std::cout << ">> Toffoli gate simulation\n\n"; + + ket psi_in = randket(8); + std::cout << ">> Input state:\n"; + std::cout << disp(dirac(psi_in)) << "\n\n"; + + /** + * Toffoli gate (control control not) + * + * ---+--- + * | + * ---+--- + * | + * ---X--- + */ + ket result = apply(psi_in, gt.TOF, {0, 1, 2}); + std::cout << ">> Toffoli gate output state:\n"; + std::cout << disp(dirac(result)) << "\n\n"; + + /** + * Toffoli with T and CNOT + * + * -------------+-------------+-----+---T---+-- + * | | | | + * -----+-------------+----------T--X--T_d--X-- + * | | | | + * --H--X--T_d--X--T--X--T_d--X--T--H---------- + */ + result = apply(psi_in, gt.H, {2}); + result = applyCTRL(result, gt.X, {1}, {2}); + result = apply(result, adjoint(gt.T), {2}); + result = applyCTRL(result, gt.X, {0}, {2}); + result = apply(result, gt.T, {2}); + result = applyCTRL(result, gt.X, {1}, {2}); + result = apply(result, adjoint(gt.T), {2}); + result = applyCTRL(result, gt.X, {0}, {2}); + result = apply(result, gt.T, {1}); + result = apply(result, gt.T, {2}); + result = applyCTRL(result, gt.X, {0}, {1}); + result = apply(result, gt.T, {0}); + result = apply(result, adjoint(gt.T), {1}); + result = apply(result, gt.H, {2}); + result = applyCTRL(result, gt.X, {0}, {1}); + std::cout << ">> Toffoli with T and CNOT output state:\n"; + std::cout << disp(dirac(result)) << "\n\n"; + + /** + * Sleator Weinfurter construction + * V * V = X + * + * -----+-------+---+--- + * | | | + * --+--X---+---X------- + * | | | + * --V-----V_d------V--- + */ + cmat sqrtx{cmat::Zero(2, 2)}; + sqrtx << 0.5 + 0.5 * 1_i, 0.5 - 0.5 * 1_i, 0.5 - 0.5 * 1_i, 0.5 + 0.5 * 1_i; + result = applyCTRL(psi_in, sqrtx, {1}, {2}); + result = applyCTRL(result, gt.X, {0}, {1}); + result = applyCTRL(result, adjoint(sqrtx), {1}, {2}); + result = applyCTRL(result, gt.X, {0}, {1}); + result = applyCTRL(result, sqrtx, {0}, {2}); + std::cout + << ">> Barenco et. al. [quant-ph/9503016] construction output state:\n"; + std::cout << disp(dirac(result)) << "\n\n"; +} diff --git a/include/qpp/input_output.hpp b/include/qpp/input_output.hpp index 74d7e6265..6e2057019 100644 --- a/include/qpp/input_output.hpp +++ b/include/qpp/input_output.hpp @@ -63,7 +63,7 @@ template disp(Scalar scalar, IOManipScalarOpts opts = {}) { return internal::IOManipScalar{scalar, opts}; -}; +} /** * \brief Complex number std::ostream manipulator diff --git a/include/qpp/instruments.hpp b/include/qpp/instruments.hpp index c1373245a..be6492d5f 100644 --- a/include/qpp/instruments.hpp +++ b/include/qpp/instruments.hpp @@ -36,8 +36,6 @@ #include -// #include - #include "qpp/functions.hpp" #include "qpp/operations.hpp" #include "qpp/types.hpp" diff --git a/include/qpp/internal/util.hpp b/include/qpp/internal/util.hpp index d1fd1a372..867a5fe47 100644 --- a/include/qpp/internal/util.hpp +++ b/include/qpp/internal/util.hpp @@ -105,15 +105,11 @@ template #endif // no error checks in release version to improve speed - // static allocation for speed! - // allocate twice the size for matrices reshaped as vectors - T part_prod[2 * internal::maxn]; - + T part_prod = 1; T result = 0; - part_prod[numdims - 1] = 1; for (std::size_t i = 1; i < numdims; ++i) { - part_prod[numdims - i - 1] = part_prod[numdims - i] * dims[numdims - i]; - result += midx[numdims - i - 1] * part_prod[numdims - i - 1]; + part_prod *= dims[numdims - i]; + result += midx[numdims - i - 1] * part_prod; } return result + midx[numdims - 1]; diff --git a/include/qpp/qpp.h b/include/qpp/qpp.h index ffa3b1351..518738a24 100644 --- a/include/qpp/qpp.h +++ b/include/qpp/qpp.h @@ -39,19 +39,19 @@ #ifndef QPP_QPP_H_ #define QPP_QPP_H_ -// ignore warnings for unknown C++17 attributes (we use such "custom" attributes -// internally, the compiler is supposed to ignore them according to the C++17 -// standard) +// Ignore warnings for unknown C++17 attributes (we use such "custom" +// attributes internally, the compiler is supposed to ignore them according to +// the C++17 standard) -// Intel icc +// Intel #if defined(__INTEL_COMPILER) #pragma warning(disable : 3924) -// clang +// Clang #elif defined(__clang__) #pragma clang diagnostic ignored "-Wunknown-attributes" -// gcc +// GCC #elif defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) #pragma GCC diagnostic ignored "-Wattributes" diff --git a/prettyprint.sh b/prettyprint.sh index a14ac3a55..8c7fad534 100755 --- a/prettyprint.sh +++ b/prettyprint.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # $@ - List of directories @@ -14,11 +14,11 @@ else echo "Error: $CLANG_FORMAT executable not found." >&2 exit 1 fi - echo "Code formatting with '$CLANG_FORMAT' the folders:" + echo "Code formatting with '$CLANG_FORMAT' the directories:" fi -for folder in "$@"; do - echo "$folder" - find "$folder" \( -iname '*.cpp' -o -iname '*.c' -o -iname '*.h' \ +for directory in "$@"; do + echo "$directory" + find "$directory" \( -iname '*.cpp' -o -iname '*.c' -o -iname '*.h' \ -o -iname '*.hpp' \) -exec "$CLANG_FORMAT" -style=file -i {} + done diff --git a/stress_tests/CMakeLists.txt b/stress_tests/CMakeLists.txt index 4d7f37ba4..9a330d9b3 100644 --- a/stress_tests/CMakeLists.txt +++ b/stress_tests/CMakeLists.txt @@ -31,7 +31,7 @@ include(../cmake/qpp_eigen3.cmake) # Dependencies, do not modify unless you know what you're doing include(../cmake/qpp_dependencies.cmake) -# Enable all warnings for GNU gcc and Clang/AppleClang +# Enable all warnings for GCC and Clang/AppleClang if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") add_compile_options("-pedantic" "-Wall" "-Wextra" "-Weffc++") diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 251736b45..cceac3c51 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -34,7 +34,7 @@ cmake_policy(SET CMP0076 NEW) # Build all tests in ${TEST_FILES} foreach(file ${TEST_FILES}) # Do not build "tests/MATLAB/matlab.cpp" if there's no MATLAB support - if(${file} STREQUAL "tests/MATLAB/matlab.cpp" AND NOT BUILD_WITH_MATLAB) + if(${file} STREQUAL "tests/MATLAB/matlab.cpp" AND NOT MATLAB_FOUND) continue() endif() target_sources(${TARGET_NAME} PUBLIC ${file})