From 3314cbe41004718907fb8f4d38fe470e49ea1fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Fri, 8 Sep 2023 10:19:11 +0200 Subject: [PATCH 01/14] Updated the library dependencies: xxHash-0.8.2, doctest-2.8.11, boost-1.83.0 --- .github/workflows/build.yml | 7 +- CMakeLists.txt | 30 +---- cmake/clang-tidy.cmake | 26 ++-- cmake/sanitizer.cmake | 99 +++++++++++++++ cmake/toolchain/i686-linux.cmake | 18 +++ cmake/toolchain/i686-w64-mingw32.cmake | 19 +++ cmake/toolchain/x86_64-linux.cmake | 18 +++ .../toolchain/x86_64-w64-mingw32.cmake | 0 cmake/xxhash.cmake | 65 ++++++++++ compile.sh | 74 ++++++++++++ getlibs.sh | 113 ++++++++++++------ src/CMakeLists.txt | 4 +- src/print.cpp | 24 ++-- 13 files changed, 392 insertions(+), 105 deletions(-) create mode 100644 cmake/sanitizer.cmake create mode 100644 cmake/toolchain/i686-linux.cmake create mode 100644 cmake/toolchain/i686-w64-mingw32.cmake create mode 100644 cmake/toolchain/x86_64-linux.cmake rename toolchains/mingw.cmake => cmake/toolchain/x86_64-w64-mingw32.cmake (100%) create mode 100644 cmake/xxhash.cmake create mode 100755 compile.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ec95f9..db44b31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: - name: Set mingw environment variables if: matrix.target == 'mingw' run: | - echo "CMAKE_TOOLCHAIN_FILE=$(pwd)/toolchains/mingw.cmake" >> "$GITHUB_ENV" + echo "CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/x86_64-w64-mingw32.cmake" >> "$GITHUB_ENV" echo "STATIC=ON" >> "$GITHUB_ENV" - name: Get ubuntu dependencies if: matrix.target == 'ubuntu' @@ -64,10 +64,9 @@ jobs: bash ./getlibs.sh - name: Build and test run: | - cmake -DCMAKE_BUILD_TYPE=Release -DUDBM_WITH_TESTS=ON "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DCMAKE_PREFIX_PATH=$(pwd)/local -B build -S . + cmake -DCMAKE_BUILD_TYPE=Release -DUDBM_WITH_TESTS=ON "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DCMAKE_PREFIX_PATH=$PWD/local/x86_64-w64-mingw32 -B build -S . cmake --build build --config Release - cd build - ctest --output-on-failure -C Release + (cd build ; ctest --output-on-failure -C Release) build-macos: runs-on: macos-latest strategy: diff --git a/CMakeLists.txt b/CMakeLists.txt index 34d077e..869720d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,6 @@ include(GNUInstallDirs) option(UDBM_WITH_TESTS "UDBM Unit tests" OFF) option(UDBM_STATIC "Static linking" OFF) -option(SSP "Stack-Smashing Protector" OFF) -option(UBSAN "Undefined Behavior Sanitizer" OFF) -option(ASAN "Address Sanitizer" OFF) cmake_policy(SET CMP0048 NEW) # project() command manages VERSION variables set(CMAKE_CXX_STANDARD 17) @@ -16,32 +13,11 @@ set(UDBM_VERSION "${PACKAGE_VERSION}") set(ENABLE_STORE_MINGRAPH 1) CONFIGURE_FILE("src/config.h.cmake" "include/dbm/config.h") +include(cmake/sanitizer.cmake) include(cmake/clang-tidy.cmake) include(cmake/doctest.cmake) - -find_package(xxHash 0.8.0 CONFIG REQUIRED) -find_package(UUtils 1.1.1 REQUIRED COMPONENTS base hash debug) - -if (SSP) - message(STATUS "Enabled Stack Smashing Protector") - add_compile_options(-fstack-protector) - add_link_options(-fstack-protector) -endif(SSP) - -if (UBSAN OR ASAN) - add_compile_options(-fno-omit-frame-pointer) - add_link_options(-fno-omit-frame-pointer) -endif() -if (UBSAN) - message(STATUS "Enabled Undefined Behavior Sanitizer") - add_compile_options(-fsanitize=undefined) - add_link_options(-fsanitize=undefined) -endif(UBSAN) -if (ASAN) - message(STATUS "Enabled Address Sanitizer") - add_compile_options(-fsanitize=address) - add_link_options(-fsanitize=address) -endif(ASAN) +include(cmake/xxhash.cmake) +find_package(UUtils 2.0.0 REQUIRED COMPONENTS base hash debug) if(UDBM_STATIC) set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lwsock32 -lws2_32 ${CMAKE_CXX_STANDARD_LIBRARIES}") diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake index 5b31189..9b7b2ea 100644 --- a/cmake/clang-tidy.cmake +++ b/cmake/clang-tidy.cmake @@ -1,30 +1,20 @@ find_program(CLANG_TIDY_PROGRAM clang-tidy-14 clang-tidy) if(CLANG_TIDY_PROGRAM) - # Here we add checks that we know are good, and produce a minimal amount of false positives - # One or two false positives can be dealt with using // NOLINT - - set(CLANG_TIDY_WERROR "") - if(WERROR) - set(CLANG_TIDY_WERROR "--warnings-as-errors=*") - endif(WERROR) - execute_process(COMMAND ${CLANG_TIDY_PROGRAM} --version OUTPUT_VARIABLE CLANG_TIDY_VERSION_STRING) - string(FIND ${CLANG_TIDY_VERSION_STRING} "LLVM version" startloc) - string(SUBSTRING ${CLANG_TIDY_VERSION_STRING} ${startloc} -1 withoutstart) - string(FIND ${withoutstart} "\n" endloc) - string(SUBSTRING ${withoutstart} 13 ${endloc} TIDY_VERSION) - - string(FIND ${TIDY_VERSION} "." major_end) - string(SUBSTRING ${TIDY_VERSION} 0 ${major_end} TIDY_MAJOR_VERSION) + string(REGEX MATCH "LLVM version ([0-9A-Za-z]+)\\.([0-9A-Za-z\\.]+)" TIDY_VERSION "${CLANG_TIDY_VERSION_STRING}") + set(TIDY_MAJOR_VERSION "${CMAKE_MATCH_1}") + set(TIDY_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}") # We use NOLINTBEGIN and NOLINTEND to preserve some macros # This was only introduced in version 14 if (TIDY_MAJOR_VERSION GREATER_EQUAL 14) - message(STATUS "Found clang-tidy version ${TIDY_VERSION}") + # Add good checks which produce a minimal amount of false positives + # One or two false positives can be dealt with using // NOLINT set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PROGRAM} -checks=-*,cppcoreguidelines-macro-usage,hicpp-deprecated-headers,modernize-deprecated-headers,hicpp-use-override,hicpp-use-emplace,modernize-use-emplace,hicpp-use-auto,readability-container-size-empty,readability-implicit-bool-conversion,readability-redundant-smartptr-get,readability-qualified-auto,performance-unnecessary-value-param,modernize-make-unique,modernize-make-shared,misc-unused-using-decls,performance-move-const-arg,modernize-use-using,modernize-use-nullptr,modernize-deprecated-headers,modernize-loop-convert,misc-unused-using-decls,misc-static-assert,misc-redundant-expression,modernize-use-bool-literals,readability-delete-null-pointer,readability-redundant-member-init --warnings-as-errors=*) + message(STATUS "Enabled clang-tidy ${TIDY_VERSION}: ${CLANG_TIDY_PROGRAM}") else() - message(WARNING "Found clang-tidy version ${TIDY_VERSION}, but 14 or higher is required. Disabling clang-tidy") + message(WARNING "Found clang-tidy ${TIDY_VERSION}, but >=14 is required, thus disabled.") endif() else(CLANG_TIDY_PROGRAM) - message(WARNING "Failed to find clang-tidy >=14. Some checks are not enabled") + message(WARNING "No clang-tidy found. Some checks are not enabled") endif(CLANG_TIDY_PROGRAM) diff --git a/cmake/sanitizer.cmake b/cmake/sanitizer.cmake new file mode 100644 index 0000000..2ebe277 --- /dev/null +++ b/cmake/sanitizer.cmake @@ -0,0 +1,99 @@ +# Various sanitizers (runtime checks) for debugging +option(SSP "Stack Smashing Protector (GCC/Clang/ApplClang on Unix)" OFF + )# Available on Windows too +option(UBSAN "Undefined Behavior Sanitizer (GCC/Clang/AppleClang on Unix)" OFF) +option(ASAN "Address Sanitizer (GCC/Clang/AppleClang on Unix, MSVC on Windows)" + OFF) +option(TSAN "Thread Sanitizer (GCC/Clang/AppleClang on Unix)" OFF) +option(RTC_C "Runtime Checks for Conversions (MSVC on Windows)" OFF) +option(RTC_S "Runtime Checks for Stack (MSVC on Windows)" OFF) +option(RTC_U "Runtime Checks for Uninitialized (MSVC on Windows)" OFF) + +if(SSP) + add_compile_options(-fstack-protector) + add_link_options(-fstack-protector) + message(STATUS "Enable Stack Smashing Protector") +endif(SSP) + +if(ASAN + OR UBSAN + OR TSAN) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + + else() + add_compile_options(-fno-omit-frame-pointer) + add_link_options(-fno-omit-frame-pointer) + endif() +endif() + +if(UBSAN) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/fsanitize=undefined) + message( + STATUS + "Please see if MSVC supports undefined behavior sanitizer: https://learn.microsoft.com/en-us/cpp/sanitizers/asan" + ) + else() + add_compile_options(-fsanitize=undefined) + add_link_options(-fsanitize=undefined) + endif() + message(STATUS "Enabled Undefined Behavior Sanitizer") +endif(UBSAN) + +if(ASAN) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/fsanitize=address) + else() + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) + endif() + message(STATUS "Enabled Address Sanitizer") +endif(ASAN) + +if(TSAN) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/fsanitize=thread) + message( + STATUS + "Please see if MSVC supports thread sanitizer: https://learn.microsoft.com/en-us/cpp/sanitizers/asan" + ) + else() + add_compile_options(-fsanitize=thread) + add_link_options(-fsanitize=thread) + endif() + message(STATUS "Enabled Thread Sanitizer") +endif(TSAN) + +if(RTC_C) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/RTCc) + add_compile_definitions(_ALLOW_RTCc_IN_STL) + message(STATUS "Enabled Runtime Check Conversions") + else() + message( + WARNING + "Runtime Check Conversions is not enabled for ${CMAKE_CXX_COMPILER_ID}") + endif() +endif(RTC_C) + +if(RTC_S) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/RTCs) + message(STATUS "Enabled Runtime Check Stack") + else() + message( + WARNING "Runtime Check Stack is not enabled for ${CMAKE_CXX_COMPILER_ID}") + endif() +endif(RTC_S) + +if(RTC_U) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + add_compile_options(/RTCu) + message(STATUS "Enabled Runtime Check Uninitialized") + else() + message( + WARNING + "Runtime Check Uninitialized is not enabled for ${CMAKE_CXX_COMPILER_ID}" + ) + endif() +endif(RTC_U) diff --git a/cmake/toolchain/i686-linux.cmake b/cmake/toolchain/i686-linux.cmake new file mode 100644 index 0000000..6ea4aae --- /dev/null +++ b/cmake/toolchain/i686-linux.cmake @@ -0,0 +1,18 @@ +# the name of the target operating system +set(CMAKE_SYSTEM_NAME Linux) + +# which compilers to use for C and C++ +set(CMAKE_C_COMPILER cc) +set(CMAKE_C_FLAGS -m32) +set(CMAKE_CXX_COMPILER c++) +set(CMAKE_CXX_FLAGS -m32) + +# here is the target environment located +set(CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in both target and host environments +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchain/i686-w64-mingw32.cmake b/cmake/toolchain/i686-w64-mingw32.cmake new file mode 100644 index 0000000..1d762b8 --- /dev/null +++ b/cmake/toolchain/i686-w64-mingw32.cmake @@ -0,0 +1,19 @@ +# the name of the target operating system +set(CMAKE_SYSTEM_NAME Windows) +set(CMAKE_CROSSCOMPILING ON) +set(CMAKE_CROSSCOMPILING_EMULATOR wine) + +# which compilers to use for C and C++ +set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) +set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) + +# where is the target environment located +set(CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") + +# adjust the default behavior of the FIND_XXX() commands: +# search programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) + +# search headers and libraries in the target environment +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchain/x86_64-linux.cmake b/cmake/toolchain/x86_64-linux.cmake new file mode 100644 index 0000000..8eb85f5 --- /dev/null +++ b/cmake/toolchain/x86_64-linux.cmake @@ -0,0 +1,18 @@ +# the name of the target operating system +set(CMAKE_SYSTEM_NAME Linux) + +# which compilers to use for C and C++ +set(CMAKE_C_COMPILER cc) +set(CMAKE_C_FLAGS -m64) +set(CMAKE_CXX_COMPILER c++) +set(CMAKE_CXX_FLAGS -m64) + +# here is the target environment located +set(CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in both target and host environments +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/toolchains/mingw.cmake b/cmake/toolchain/x86_64-w64-mingw32.cmake similarity index 100% rename from toolchains/mingw.cmake rename to cmake/toolchain/x86_64-w64-mingw32.cmake diff --git a/cmake/xxhash.cmake b/cmake/xxhash.cmake new file mode 100644 index 0000000..d026cad --- /dev/null +++ b/cmake/xxhash.cmake @@ -0,0 +1,65 @@ +#find_package(xxHash 0.8.0 CONFIG QUIET) +set(XXHASH_VERSION_MINIMUM 0.8.0) +find_file(XXHASH_PATH xxhash.h) +if (XXHASH_PATH) + cmake_path(GET XXHASH_PATH PARENT_PATH xxHash_DIR) + file(READ "${XXHASH_PATH}" XXHASH_H) + string(REGEX MATCH "#define XXH_VERSION_MAJOR([ \t])*([0-9])*" _ ${XXHASH_H}) + set(XXHASH_VERSION_MAJOR ${CMAKE_MATCH_2}) + string(REGEX MATCH "#define XXH_VERSION_MINOR([ \t])*([0-9])*" _ ${XXHASH_H}) + set(XXHASH_VERSION_MINOR ${CMAKE_MATCH_2}) + string(REGEX MATCH "#define XXH_VERSION_RELEASE([ \t])*([0-9])*" _ ${XXHASH_H}) + set(XXHASH_VERSION_PATCH ${CMAKE_MATCH_2}) + set(XXHASH_VERSION "${XXHASH_VERSION_MAJOR}.${XXHASH_VERSION_MINOR}.${XXHASH_VERSION_PATCH}") + if (XXHASH_VERSION VERSION_GREATER_EQUAL ${XXHASH_VERSION_MINIMUM}) + set(xxHash_FOUND TRUE) + cmake_path(GET XXHASH_PATH PARENT_PATH XXHASH_INCLUDE_DIR) + add_library(xxHash INTERFACE) + target_compile_definitions(xxHash INTERFACE XXH_INLINE_ALL) + target_include_directories(xxHash INTERFACE ${XXHASH_INCLUDE_DIR}) + else() + message(STATUS "Found xxHash-${XXHASH_VERSION} is too old, need at lease ${XXHASH_VERSION_MINIMUM}") + endif() +endif(XXHASH_PATH) + +if (xxHash_FOUND) + message(STATUS "Found xxHash-${XXHASH_VERSION}: ${XXHASH_PATH}") +else(xxHash_FOUND) + message(STATUS "Failed to find xxHash, going to compile from source.") + if (FIND_FATAL) + message(FATAL_ERROR "Failed to find with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") + endif(FIND_FATAL) + include(ExternalProject) + set(XXHASH_BUILD_ENABLE_INLINE_API ON CACHE BOOL "adds xxhash.c for the -DXXH_INLINE_ALL api. Default ON") + set(XXHASH_BUILD_XXHSUM OFF CACHE BOOL "build the command line binary. Default ON") + set(BUILD_SHARED_LIBS OFF CACHE BOOL "build dynamic library. Default ON") + # set(DISPATCH OFF CACHE BOOL "enable dispatch mode. Default OFF") + FetchContent_Declare( + xxHash + GIT_REPOSITORY https://github.com/Cyan4973/xxHash + GIT_TAG v0.8.2 + GIT_SHALLOW TRUE # get only the last commit version + GIT_PROGRESS TRUE # show progress of download + SOURCE_SUBDIR cmake_unofficial # CMakeLists.txt is not in the main folder + FIND_PACKAGE_ARGS NAMES xxHash COMPONENTS xxhash # for future when xxhash supports cmake + USES_TERMINAL_DOWNLOAD TRUE # show progress in ninja generator + USES_TERMINAL_CONFIGURE ON + USES_TERMINAL_BUILD ON + USES_TERMINAL_INSTALL ON + ) + FetchContent_MakeAvailable(xxHash) + if (xxHash_SOURCE_DIR) + cmake_path(GET xxHash_SOURCE_DIR PARENT_PATH XXHASH_INCLUDE_DIR) # drop "cmake_unofficial" +# add_library(xxHash ALIAS xxHash::xxhash) + add_library(xxHash INTERFACE) +# set_property(TARGET xxHash APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${XXHASH_INCLUDE_DIR}) + target_compile_definitions(xxHash INTERFACE XXH_INLINE_ALL) + target_include_directories(xxHash INTERFACE ${XXHASH_INCLUDE_DIR}) +# target_link_libraries(xxHash INTERFACE xxHash::xhash) + set(xxHash_FOUND TRUE) + message(STATUS "Got xxHash: ${XXHASH_INCLUDE_DIR}") + else(xxHash_SOURCE_DIR) + message(FATAL_ERROR "Failed to fetch xxHash") + endif (xxHash_SOURCE_DIR) + # Custom config: https://github.com/untrioctium/refrakt/blob/main/CMakeLists.txt +endif(xxHash_FOUND) diff --git a/compile.sh b/compile.sh new file mode 100755 index 0000000..d86ade5 --- /dev/null +++ b/compile.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +set -eo pipefail + +PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +if [ $# -eq 0 ]; then + targets="x86_64-linux-ubsan-asan-debug x86_64-linux-release x86_64-w64-mingw32-debug x86_64-w64-mingw32-release" +else + targets="$@" +fi + +for target in $targets ; do + unset BUILD_EXTRA + unset CMAKE_BUILD_TYPE + case $target in + x86_64-linux-*) + PLATFORM=x86_64-linux + ;; + i686-linux-*) + PLATFORM=i686-linux + ;; + x86_64-w64-mingw32-*) + PLATFORM=x86_64-w64-mingw32 + ;; + i686-w64-mingw32-*) + PLATFORM=i686-w64-mingw32 + ;; + *) + echo "Unrecognized target platform: $target" + exit 1 + esac + export CMAKE_TOOLCHAIN_FILE="$PROJECT_DIR/cmake/toolchain/$PLATFORM.cmake" + export CMAKE_PREFIX_PATH="$PROJECT_DIR/local/$PLATFORM" + BUILD_DIR="build-$PLATFORM" + + case $target in + *-ubsan-*) + BUILD_EXTRA="$BUILD_EXTRA -DUBSAN=ON" + BUILD_DIR="${BUILD_DIR}-ubsan" + ;; + esac + case $target in + *-lsan-*) + BUILD_EXTRA="$BUILD_EXTRA -DLSAN=ON" + BUILD_DIR="${BUILD_DIR}-lsan" + ;; + esac + case $target in + *-asan-*) + BUILD_EXTRA="$BUILD_EXTRA -DASAN=ON" + BUILD_DIR="${BUILD_DIR}-asan" + ;; + esac + case $target in + *-debug) + export CMAKE_BUILD_TYPE=Debug + BUILD_DIR="${BUILD_DIR}-debug" + ;; + *-release) + export CMAKE_BUILD_TYPE=Release + BUILD_DIR="${BUILD_DIR}-release" + ;; + *) + export CMAKE_BUILD_TYPE=Release + BUILD_DIR="${BUILD_DIR}-release" + echo "Unrecognized build type: $target, assuming $CMAKE_BUILD_TYPE" + esac + echo "Building $target with $BUILD_EXTRA into $BUILD_DIR" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + cmake -S "$PROJECT_DIR" -B "$BUILD_DIR" $BUILD_EXTRA + cmake --build "$BUILD_DIR" --config $CMAKE_BUILD_TYPE + (cd "$BUILD_DIR" ; ctest -C $CMAKE_BUILD_TYPE --output-on-failure) +done diff --git a/getlibs.sh b/getlibs.sh index 35ec1c1..f282ce3 100755 --- a/getlibs.sh +++ b/getlibs.sh @@ -1,52 +1,91 @@ #!/usr/bin/env bash -set -euxo pipefail +set -eo pipefail -SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -PREFIX="$SOURCE_DIR/local" -SOURCES="$SOURCE_DIR/local/sources" -mkdir -p "$SOURCES" - -CMAKE_PREFIX_PATH="$PREFIX" - -CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH -DCMAKE_INSTALL_PREFIX=$PREFIX" -if [ -z ${CMAKE_TOOLCHAIN_FILE+x} ]; then - echo "Not using a custom toolchain"; +if [ -z "$CMAKE_TOOLCHAIN_FILE" ]; then + TARGET=$(uname --machine)-$(uname --kernel-name) + TARGET="${TARGET,,}" else - echo "Using toolchain $CMAKE_TOOLCHAIN_FILE"; - CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE"; + TARGET=$(basename $CMAKE_TOOLCHAIN_FILE) + TARGET=${TARGET%%.*} fi -# doctest for unit testing +PREFIX="$PROJECT_DIR/local/$TARGET" +SOURCES="$PROJECT_DIR/local/sources" + +[ -n "$CMAKE_BUILD_TYPE" ] || export CMAKE_BUILD_TYPE=Release +[ -n "$CMAKE_PREFIX_PATH" ] || export CMAKE_PREFIX_PATH="$PREFIX" +[ -n "$CMAKE_INSTALL_PREFIX" ] || export CMAKE_INSTALL_PREFIX="$PREFIX" + +echo " TARGET=$TARGET" +echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" +echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" +echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" + +mkdir -p "$SOURCES" cd "$SOURCES" -curl -L https://github.com/doctest/doctest/archive/refs/tags/v2.4.8.tar.gz -o doctest-2.4.8.tar.gz -tar -xf doctest-2.4.8.tar.gz -SOURCE_DIR="$SOURCES/doctest-2.4.8" -BUILD_DIR="$SOURCE_DIR/build" -mkdir -p "$BUILD_DIR" -cmake $CMAKE_ARGS -DDOCTEST_WITH_TESTS=OFF -B "$BUILD_DIR" "$SOURCE_DIR" + +# doctest for unit testing +PACKAGE=doctest +VERSION=2.4.11 +ARCHIVE="$PACKAGE-$VERSION.tar.gz" +SOURCE_DIR="$PACKAGE-$VERSION" +BUILD_DIR="build-${SOURCE_DIR}-$TARGET" +[ -r "$ARCHIVE" ] || curl -sL "https://github.com/doctest/doctest/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" +[ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DDOCTEST_WITH_TESTS=OFF \ + -DDOCTEST_WITH_MAIN_IN_STATIC_LIB=ON -DDOCTEST_USE_STD_HEADERS=OFF cmake --build "$BUILD_DIR" --config Release -cmake --install "$BUILD_DIR" --config Release +cmake --install "$BUILD_DIR" --config Release --prefix "$CMAKE_INSTALL_PREFIX" +rm -Rf "$BUILD_DIR" +rm -Rf "$SOURCE_DIR" # xxHash for fast high quality hashing -cd "$SOURCES" -curl -L https://github.com/Cyan4973/xxHash/archive/refs/tags/v0.8.0.tar.gz -o xxHash-0.8.0.tar.gz -tar -xf xxHash-0.8.0.tar.gz -SOURCE_DIR="$SOURCES/xxHash-0.8.0" -BUILD_DIR="$SOURCE_DIR/build" -mkdir -p "$BUILD_DIR" -cmake $CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF -B "$BUILD_DIR" "$SOURCE_DIR/cmake_unofficial" +PACKAGE=xxHash +VERSION=0.8.2 +ARCHIVE="$PACKAGE-$VERSION.tar.gz" +SOURCE_DIR="$PACKAGE-$VERSION" +BUILD_DIR="build-${SOURCE_DIR}-$TARGET" +[ -r "$ARCHIVE" ] || curl -sL "https://github.com/Cyan4973/xxHash/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" +[ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" +echo "Building $SOURCE_DIR" +cmake -S "$SOURCE_DIR/cmake_unofficial" -B "$BUILD_DIR" -DBUILD_SHARED_LIBS=OFF cmake --build "$BUILD_DIR" --config Release -cmake --install "$BUILD_DIR" --config Release +cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" +rm -Rf "$BUILD_DIR" +rm -Rf "$SOURCE_DIR" + +# Boost +PACKAGE=boost +VERSION=1.83.0 +ARCHIVE="$PACKAGE-$VERSION.tar.xz" +SOURCE_DIR="$PACKAGE-$VERSION" +BUILD_DIR="build-${SOURCE_DIR}-$TARGET" +[ -r "$ARCHIVE" ] || curl -sL "https://github.com/boostorg/boost/releases/download/${SOURCE_DIR}/${ARCHIVE}" -o "$ARCHIVE" +[ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" +echo "Building $SOURCE_DIR" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DBOOST_ENABLE_CMAKE=ON -DBUILD_SHARED_LIBS=OFF \ + -DBOOST_INCLUDE_LIBRARIES="headers;math" -DBOOST_ENABLE_MPI=OFF -DBOOST_ENABLE_PYTHON=OFF \ + -DBOOST_RUNTIME_LINK=static -DBUILD_TESTING=OFF -DBOOST_USE_STATIC_LIBS=ON -DBOOST_USE_DEBUG_LIBS=ON \ + -DBOOST_USE_RELEASE_LIBS=ON -DBOOST_USE_STATIC_RUNTIME=ON -DBOOST_INSTALL_LAYOUT=system +cmake --build "$BUILD_DIR" --config Release +cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" +rm -Rf "$BUILD_DIR" +rm -Rf "$SOURCE_DIR" # UUtils various low level Uppaal utilities #git clone https://github.com/UPPAALModelChecker/UUtils "$SOURCE_DIR/libs/sources/UUtils"; -cd "$SOURCES" -curl -L https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v1.1.1.tar.gz -o UUtils-1.1.1.tar.gz -tar -xf UUtils-1.1.1.tar.gz -SOURCE_DIR="$SOURCES/UUtils-1.1.1" -BUILD_DIR="$SOURCE_DIR/build" -mkdir -p "$BUILD_DIR" -cmake $CMAKE_ARGS -B "$BUILD_DIR" "$SOURCE_DIR" +PACKAGE=UUtils +VERSION=2.0.0 +ARCHIVE="$PACKAGE-$VERSION.tar.gz" +SOURCE_DIR="$PACKAGE-$VERSION" +BUILD_DIR="build-${SOURCE_DIR}-$TARGET" +[ -r "$ARCHIVE" ] || curl -sL "https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" +[ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" +echo "Building $SOURCE_DIR" +cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DUUtils_WITH_TESTS=OFF -DUUtils_WITH_BENCHMARKS=OFF cmake --build "$BUILD_DIR" --config Release -cmake --install "$BUILD_DIR" --config Release +cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" +rm -Rf "$BUILD_DIR" +rm -Rf "$SOURCE_DIR" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 95478ac..13f75bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,9 @@ -add_library(UDBM DBMAllocator.cpp dbm.c fed_dbm.cpp mingraph.c mingraph_read.c partition.cpp print.cpp gen.c +add_library(UDBM STATIC DBMAllocator.cpp dbm.c fed_dbm.cpp mingraph.c mingraph_read.c partition.cpp print.cpp gen.c mingraph_cache.cpp mingraph_relation.c pfed.cpp fed.cpp infimum.cpp mingraph_equal.c mingraph_write.c priced.cpp valuation.cpp) set_property(TARGET UDBM PROPERTY C_VISIBILITY_PRESET hidden) set_property(TARGET UDBM PROPERTY VISIBILITY_INLINES_HIDDEN ON) -target_link_libraries(UDBM UUtils::base UUtils::udebug UUtils::hash) +target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash xxHash) target_include_directories(UDBM PRIVATE diff --git a/src/print.cpp b/src/print.cpp index b503201..581c2a2 100644 --- a/src/print.cpp +++ b/src/print.cpp @@ -15,19 +15,11 @@ #include "dbm/dbm.h" #include "dbm/fed.h" -#include "io/FileStreamBuffer.h" -#include "base/bitstring.h" -/** For easy conversion FILE* to ostream */ -class file_ostream -{ - io::FileStreamBuffer buffer; - std::ostream os; +#include +#include -public: - file_ostream(FILE* file): buffer{file}, os{&buffer} {} - operator std::ostream&() { return os; } -}; +using base::file_ostream; static const char* _print_prefix = ""; static bool _ruby_format = false; @@ -109,10 +101,8 @@ std::ostream& dbm_cppPrint(std::ostream& os, dbm::reader dbm) } void dbm_print(FILE* file, const raw_t* dbm, cindex_t dim) { - if (dbm != nullptr) { - auto fos = file_ostream{file}; - dbm_cppPrint(fos, {dbm, dim}); - } + if (dbm != nullptr) + dbm_cppPrint(file_ostream{file}, {dbm, dim}); } /* Shortcuts to print the difference highlight @@ -216,9 +206,9 @@ void dbm_printCloseDiff(FILE* file, const raw_t* dbm, cindex_t dim) /* check for infinity values * before printing. */ -std::ostream& dbm_cppPrintRaw(std::ostream& out, raw_t c) +std::ostream& dbm_cppPrintRaw(std::ostream& os, raw_t c) { - return dbm_cppPrintBound(out << (dbm_rawIsWeak(c) ? "<=" : "<"), dbm_raw2bound(c)); + return dbm_cppPrintBound(os << (dbm_rawIsWeak(c) ? "<=" : "<"), dbm_raw2bound(c)); } void dbm_printRaw(FILE* file, raw_t c) { dbm_cppPrintRaw(file_ostream{file}, c); } From 2849686269dfbe1fcde43edf0b263eff2058f995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Fri, 8 Sep 2023 12:01:03 +0200 Subject: [PATCH 02/14] Fixed header inclusion of external libraries --- .clang-format | 97 +------------------- CMakeLists.txt | 13 ++- cmake/doctest.cmake | 53 ++++++++--- compile.sh | 12 +-- getlibs.sh | 168 +++++++++++++++++++--------------- include/dbm/constraints.h | 4 +- include/dbm/dbm.h | 7 +- include/dbm/mingraph.h | 5 +- src/CMakeLists.txt | 2 +- src/dbm.c | 11 +-- src/fed.cpp | 5 +- src/fed_dbm.cpp | 6 +- src/gen.c | 8 +- src/infimum.cpp | 5 +- src/infimum.h | 2 +- src/mingraph.c | 4 +- src/mingraph_cache.cpp | 15 ++- src/mingraph_cache.h | 2 +- src/mingraph_coding.h | 3 +- src/mingraph_equal.c | 6 +- src/mingraph_read.c | 5 +- src/mingraph_relation.c | 5 +- src/mingraph_write.c | 5 +- src/priced.cpp | 3 +- test/CMakeLists.txt | 9 +- test/doctest_main.cpp | 2 - test/test_constraint.cpp | 4 +- test/test_dbm.c | 5 +- test/test_ext.c | 5 +- test/test_extrapolation.c | 3 +- test/test_fed.cpp | 7 +- test/test_fp_intersection.cpp | 4 +- test/test_mingraph.c | 5 +- test/test_valuation.cpp | 4 +- 34 files changed, 230 insertions(+), 264 deletions(-) delete mode 100644 test/doctest_main.cpp diff --git a/.clang-format b/.clang-format index 22ad72c..6df5d3f 100644 --- a/.clang-format +++ b/.clang-format @@ -66,101 +66,6 @@ ForEachMacros: - Q_FOREACH - BOOST_FOREACH IncludeBlocks: Regroup -IncludeCategories: - - Regex: '^"[a-zA-Z0-9_]*\.' - Priority: 1 - SortPriority: 1 - - Regex: '^"testutils/' - Priority: 2 - SortPriority: 2 - - Regex: '^"tron/' - Priority: 2 - SortPriority: 3 - - Regex: '^"fmi/' - Priority: 2 - SortPriority: 4 - - Regex: '^"verifier/' - Priority: 2 - SortPriority: 5 - - Regex: '^"cora/' - Priority: 2 - SortPriority: 6 - - Regex: '^"tiga/' - Priority: 2 - SortPriority: 7 - - Regex: '^"statmc/' - Priority: 2 - SortPriority: 8 - - Regex: '^"xmltrace/' - Priority: 2 - SortPriority: 9 - - Regex: '^"pipeline/' - Priority: 2 - SortPriority: 10 - - Regex: '^"protocol/' - Priority: 2 - SortPriority: 11 - - Regex: '^"storage/' - Priority: 2 - SortPriority: 12 - - Regex: '^"system/' - Priority: 2 - SortPriority: 13 - - Regex: '^"dbm/' - Priority: 2 - SortPriority: 14 - - Regex: '^"cdd/' - Priority: 2 - SortPriority: 15 - - Regex: '^"polyhedra/' - Priority: 2 - SortPriority: 16 - - Regex: '^"tracer/' - Priority: 2 - SortPriority: 17 - - Regex: '^"utap/' - Priority: 2 - SortPriority: 18 - - Regex: '^"io/' - Priority: 2 - SortPriority: 19 - - Regex: '^"formats/' - Priority: 2 - SortPriority: 20 - - Regex: '^"base/' - Priority: 2 - SortPriority: 21 - - Regex: '^"hash/' - Priority: 2 - SortPriority: 22 - - Regex: '^"debug/' - Priority: 2 - SortPriority: 23 - - Regex: '^$' - Priority: 4 - SortPriority: 30 - - Regex: '^/dev/null 2>&1 && pwd )" -if [ -z "$CMAKE_TOOLCHAIN_FILE" ]; then - TARGET=$(uname --machine)-$(uname --kernel-name) - TARGET="${TARGET,,}" +if [ $# -eq 0 ]; then + targets=$(uname --machine)-$(uname --kernel-name) + targets="${targets,,}" + echo "No targets specified on command line, assuming: $targets" else - TARGET=$(basename $CMAKE_TOOLCHAIN_FILE) - TARGET=${TARGET%%.*} + targets="$@" fi -PREFIX="$PROJECT_DIR/local/$TARGET" SOURCES="$PROJECT_DIR/local/sources" +mkdir -p "$SOURCES" +cd "$SOURCES" [ -n "$CMAKE_BUILD_TYPE" ] || export CMAKE_BUILD_TYPE=Release -[ -n "$CMAKE_PREFIX_PATH" ] || export CMAKE_PREFIX_PATH="$PREFIX" -[ -n "$CMAKE_INSTALL_PREFIX" ] || export CMAKE_INSTALL_PREFIX="$PREFIX" -echo " TARGET=$TARGET" -echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" -echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" -echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" +for target in $targets ; do + PREFIX="$PROJECT_DIR/local/$target" -mkdir -p "$SOURCES" -cd "$SOURCES" + export CMAKE_TOOLCHAIN_FILE="$PROJECT_DIR/cmake/toolchain/$target.cmake" + export CMAKE_PREFIX_PATH="$PREFIX" + export CMAKE_INSTALL_PREFIX="$PREFIX" -# doctest for unit testing -PACKAGE=doctest -VERSION=2.4.11 -ARCHIVE="$PACKAGE-$VERSION.tar.gz" -SOURCE_DIR="$PACKAGE-$VERSION" -BUILD_DIR="build-${SOURCE_DIR}-$TARGET" -[ -r "$ARCHIVE" ] || curl -sL "https://github.com/doctest/doctest/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" -[ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" -cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DDOCTEST_WITH_TESTS=OFF \ - -DDOCTEST_WITH_MAIN_IN_STATIC_LIB=ON -DDOCTEST_USE_STD_HEADERS=OFF -cmake --build "$BUILD_DIR" --config Release -cmake --install "$BUILD_DIR" --config Release --prefix "$CMAKE_INSTALL_PREFIX" -rm -Rf "$BUILD_DIR" -rm -Rf "$SOURCE_DIR" + # doctest for unit testing + PACKAGE=doctest + VERSION=2.4.11 + ARCHIVE="$PACKAGE-$VERSION.tar.gz" + SOURCE_DIR="$PACKAGE-$VERSION" + BUILD_DIR="build-${SOURCE_DIR}-$target" + [ -r "$ARCHIVE" ] || curl -sL "https://github.com/doctest/doctest/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" + [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" + echo "Building $SOURCE_DIR" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" + echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" + cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DDOCTEST_WITH_TESTS=OFF \ + -DDOCTEST_WITH_MAIN_IN_STATIC_LIB=ON -DDOCTEST_USE_STD_HEADERS=OFF + cmake --build "$BUILD_DIR" --config Release + cmake --install "$BUILD_DIR" --config Release --prefix "$CMAKE_INSTALL_PREFIX" + rm -Rf "$BUILD_DIR" + rm -Rf "$SOURCE_DIR" -# xxHash for fast high quality hashing -PACKAGE=xxHash -VERSION=0.8.2 -ARCHIVE="$PACKAGE-$VERSION.tar.gz" -SOURCE_DIR="$PACKAGE-$VERSION" -BUILD_DIR="build-${SOURCE_DIR}-$TARGET" -[ -r "$ARCHIVE" ] || curl -sL "https://github.com/Cyan4973/xxHash/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" -[ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" -echo "Building $SOURCE_DIR" -cmake -S "$SOURCE_DIR/cmake_unofficial" -B "$BUILD_DIR" -DBUILD_SHARED_LIBS=OFF -cmake --build "$BUILD_DIR" --config Release -cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" -rm -Rf "$BUILD_DIR" -rm -Rf "$SOURCE_DIR" + # xxHash for fast high quality hashing + PACKAGE=xxHash + VERSION=0.8.2 + ARCHIVE="$PACKAGE-$VERSION.tar.gz" + SOURCE_DIR="$PACKAGE-$VERSION" + BUILD_DIR="build-${SOURCE_DIR}-$target" + [ -r "$ARCHIVE" ] || curl -sL "https://github.com/Cyan4973/xxHash/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" + [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" + echo "Building $SOURCE_DIR" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" + echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" + cmake -S "$SOURCE_DIR/cmake_unofficial" -B "$BUILD_DIR" -DBUILD_SHARED_LIBS=OFF + cmake --build "$BUILD_DIR" --config Release + cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" + #rm -Rf "$BUILD_DIR" + #rm -Rf "$SOURCE_DIR" -# Boost -PACKAGE=boost -VERSION=1.83.0 -ARCHIVE="$PACKAGE-$VERSION.tar.xz" -SOURCE_DIR="$PACKAGE-$VERSION" -BUILD_DIR="build-${SOURCE_DIR}-$TARGET" -[ -r "$ARCHIVE" ] || curl -sL "https://github.com/boostorg/boost/releases/download/${SOURCE_DIR}/${ARCHIVE}" -o "$ARCHIVE" -[ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" -echo "Building $SOURCE_DIR" -cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DBOOST_ENABLE_CMAKE=ON -DBUILD_SHARED_LIBS=OFF \ - -DBOOST_INCLUDE_LIBRARIES="headers;math" -DBOOST_ENABLE_MPI=OFF -DBOOST_ENABLE_PYTHON=OFF \ - -DBOOST_RUNTIME_LINK=static -DBUILD_TESTING=OFF -DBOOST_USE_STATIC_LIBS=ON -DBOOST_USE_DEBUG_LIBS=ON \ - -DBOOST_USE_RELEASE_LIBS=ON -DBOOST_USE_STATIC_RUNTIME=ON -DBOOST_INSTALL_LAYOUT=system -cmake --build "$BUILD_DIR" --config Release -cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" -rm -Rf "$BUILD_DIR" -rm -Rf "$SOURCE_DIR" + # Boost + PACKAGE=boost + VERSION=1.83.0 + ARCHIVE="$PACKAGE-$VERSION.tar.xz" + SOURCE_DIR="$PACKAGE-$VERSION" + BUILD_DIR="build-${SOURCE_DIR}-$target" + [ -r "$ARCHIVE" ] || curl -sL "https://github.com/boostorg/boost/releases/download/${SOURCE_DIR}/${ARCHIVE}" -o "$ARCHIVE" + [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" + echo "Building $SOURCE_DIR" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" + echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" + cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DBOOST_ENABLE_CMAKE=ON -DBUILD_SHARED_LIBS=OFF \ + -DBOOST_INCLUDE_LIBRARIES="headers;math" -DBOOST_ENABLE_MPI=OFF -DBOOST_ENABLE_PYTHON=OFF \ + -DBOOST_RUNTIME_LINK=static -DBUILD_TESTING=OFF -DBOOST_USE_STATIC_LIBS=ON -DBOOST_USE_DEBUG_LIBS=ON \ + -DBOOST_USE_RELEASE_LIBS=ON -DBOOST_USE_STATIC_RUNTIME=ON -DBOOST_INSTALL_LAYOUT=system + cmake --build "$BUILD_DIR" --config Release + cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" + rm -Rf "$BUILD_DIR" + rm -Rf "$SOURCE_DIR" -# UUtils various low level Uppaal utilities -#git clone https://github.com/UPPAALModelChecker/UUtils "$SOURCE_DIR/libs/sources/UUtils"; -PACKAGE=UUtils -VERSION=2.0.0 -ARCHIVE="$PACKAGE-$VERSION.tar.gz" -SOURCE_DIR="$PACKAGE-$VERSION" -BUILD_DIR="build-${SOURCE_DIR}-$TARGET" -[ -r "$ARCHIVE" ] || curl -sL "https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" -[ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" -echo "Building $SOURCE_DIR" -cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DUUtils_WITH_TESTS=OFF -DUUtils_WITH_BENCHMARKS=OFF -cmake --build "$BUILD_DIR" --config Release -cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" -rm -Rf "$BUILD_DIR" -rm -Rf "$SOURCE_DIR" + # UUtils various low level Uppaal utilities + #git clone https://github.com/UPPAALModelChecker/UUtils "$SOURCE_DIR/libs/sources/UUtils"; + PACKAGE=UUtils + VERSION=2.0.0 + ARCHIVE="$PACKAGE-$VERSION.tar.gz" + SOURCE_DIR="$PACKAGE-$VERSION" + BUILD_DIR="build-${SOURCE_DIR}-$target" + [ -r "$ARCHIVE" ] || curl -sL "https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" + [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" + echo "Building $SOURCE_DIR" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" + echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" + cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DUUtils_WITH_TESTS=OFF -DUUtils_WITH_BENCHMARKS=OFF + cmake --build "$BUILD_DIR" --config Release + cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" + rm -Rf "$BUILD_DIR" + rm -Rf "$SOURCE_DIR" +done diff --git a/include/dbm/constraints.h b/include/dbm/constraints.h index 652b708..fe7bfdf 100644 --- a/include/dbm/constraints.h +++ b/include/dbm/constraints.h @@ -18,11 +18,11 @@ #ifndef INCLUDE_DBM_CONSTRAINTS_H #define INCLUDE_DBM_CONSTRAINTS_H +#include + #include #include -#include - #ifdef __cplusplus extern "C" { #endif // C++ diff --git a/include/dbm/dbm.h b/include/dbm/dbm.h index 493056a..99402d9 100644 --- a/include/dbm/dbm.h +++ b/include/dbm/dbm.h @@ -19,9 +19,10 @@ #define INCLUDE_DBM_DBM_H #include "dbm/constraints.h" -#include "base/intutils.h" -#include "base/relation.h" -#include "hash/compute.h" + +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/include/dbm/mingraph.h b/include/dbm/mingraph.h index 15f2426..eb5b66b 100644 --- a/include/dbm/mingraph.h +++ b/include/dbm/mingraph.h @@ -18,8 +18,9 @@ #define INCLUDE_DBM_MINGRAPH_H #include "dbm/dbm.h" -#include "base/c_allocator.h" -#include "base/intutils.h" + +#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 13f75bc..03ef32f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,7 @@ add_library(UDBM STATIC DBMAllocator.cpp dbm.c fed_dbm.cpp mingraph.c mingraph_r priced.cpp valuation.cpp) set_property(TARGET UDBM PROPERTY C_VISIBILITY_PRESET hidden) set_property(TARGET UDBM PROPERTY VISIBILITY_INLINES_HIDDEN ON) -target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash xxHash) +target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash xxhash) target_include_directories(UDBM PRIVATE diff --git a/src/dbm.c b/src/dbm.c index 03f2d95..9b27a1e 100644 --- a/src/dbm.c +++ b/src/dbm.c @@ -19,14 +19,13 @@ #define VECTORIZE_FLOYD #endif -#include "dbm/dbm.h" - #include "dbm.h" - +#include "dbm/dbm.h" #include "dbm/print.h" -#include "base/bitstring.h" -#include "base/doubles.h" -#include "debug/macros.h" + +#include +#include +#include #include diff --git a/src/fed.cpp b/src/fed.cpp index c4bb13f..7d7d5a1 100644 --- a/src/fed.cpp +++ b/src/fed.cpp @@ -18,8 +18,9 @@ #include "dbm/config.h" #include "dbm/mingraph.h" #include "dbm/print.h" -#include "base/bitstring.h" -#include "base/doubles.h" + +#include +#include #include // find_if #include diff --git a/src/fed_dbm.cpp b/src/fed_dbm.cpp index d1148a4..013c985 100644 --- a/src/fed_dbm.cpp +++ b/src/fed_dbm.cpp @@ -13,10 +13,10 @@ #include "DBMAllocator.h" #include "dbm.h" - #include "dbm/config.h" -#include "base/bitstring.h" -#include "base/doubles.h" + +#include +#include #include #include diff --git a/src/gen.c b/src/gen.c index a065882..f3134b8 100644 --- a/src/gen.c +++ b/src/gen.c @@ -15,12 +15,12 @@ *********************************************************************/ #include "dbm/gen.h" - #include "dbm/dbm.h" #include "dbm/print.h" -#include "base/bitstring.h" -#include "base/doubles.h" -#include "debug/macros.h" + +#include +#include +#include #include diff --git a/src/infimum.cpp b/src/infimum.cpp index e5ea9b6..b95eb55 100644 --- a/src/infimum.cpp +++ b/src/infimum.cpp @@ -4,8 +4,9 @@ #include "dbm/dbm_raw.hpp" #include "dbm/mingraph.h" -#include "base/bitstring.h" -#include "debug/macros.h" + +#include +#include #include #include diff --git a/src/infimum.h b/src/infimum.h index 126e720..7d4c67b 100644 --- a/src/infimum.h +++ b/src/infimum.h @@ -15,4 +15,4 @@ int32_t pdbm_infimum(const raw_t* dbm, uint32_t dim, uint32_t offsetCost, const int32_t* rates); void pdbm_infimum(const raw_t* dbm, uint32_t dim, uint32_t offsetCost, const int32_t* rates, int32_t* valuation); -#endif +#endif /* DBM_INFIMUM_H */ diff --git a/src/mingraph.c b/src/mingraph.c index 8d8fd34..b864179 100644 --- a/src/mingraph.c +++ b/src/mingraph.c @@ -18,8 +18,8 @@ #include "mingraph_coding.h" -#include "base/bitstring.h" -#include "debug/macros.h" +#include +#include /** * @file diff --git a/src/mingraph_cache.cpp b/src/mingraph_cache.cpp index dbbaddc..9d1ebbf 100644 --- a/src/mingraph_cache.cpp +++ b/src/mingraph_cache.cpp @@ -15,15 +15,14 @@ #include "mingraph_cache.h" -#include "base/intutils.h" -#include "base/stats.h" -#include "debug/macros.h" - -#include - +#include +#include #ifndef NDEBUG -#include "base/bitstring.h" +#include #endif +#include + +#include /* Default size for the cache, can redefined to anything > 0 */ /* Choose your favorite prime among http://primes.utm.edu/lists/small/1000.txt. */ @@ -100,4 +99,4 @@ void mingraph_putCachedResult(const raw_t* dbm, cindex_t dim, const uint32_t* bi assert(base_countBitsN(&entry->data[dim2], bits2intsize(dim2)) == entry->cnt); } -#endif +#endif /* ENABLE_MINGRAPH_CACHE */ diff --git a/src/mingraph_cache.h b/src/mingraph_cache.h index 45ee692..760594d 100644 --- a/src/mingraph_cache.h +++ b/src/mingraph_cache.h @@ -44,4 +44,4 @@ void mingraph_putCachedResult(const raw_t* dbm, cindex_t dim, const uint32_t* bi #endif #endif /* DBM_MINGRAPH_CACHE_H */ -#endif +#endif /* ENABLE_MINGRAPH_CACHE */ diff --git a/src/mingraph_coding.h b/src/mingraph_coding.h index 1dcc7f2..91b735d 100644 --- a/src/mingraph_coding.h +++ b/src/mingraph_coding.h @@ -16,7 +16,8 @@ #include "dbm/config.h" #include "dbm/constraints.h" // bit_t -#include "base/bitstring.h" // bit_t + +#include // bit_t #include diff --git a/src/mingraph_equal.c b/src/mingraph_equal.c index 46bd778..28489fd 100644 --- a/src/mingraph_equal.c +++ b/src/mingraph_equal.c @@ -12,10 +12,10 @@ *********************************************************************/ #include "mingraph_coding.h" - #include "dbm/mingraph.h" -#include "base/bitstring.h" -#include "debug/macros.h" + +#include +#include #include #include diff --git a/src/mingraph_read.c b/src/mingraph_read.c index 78fbd5e..b3259c0 100644 --- a/src/mingraph_read.c +++ b/src/mingraph_read.c @@ -14,8 +14,9 @@ #include "mingraph_coding.h" #include "dbm/mingraph.h" -#include "base/bitstring.h" -#include "debug/macros.h" + +#include +#include #include #include diff --git a/src/mingraph_relation.c b/src/mingraph_relation.c index b15e70e..c13acc0 100644 --- a/src/mingraph_relation.c +++ b/src/mingraph_relation.c @@ -14,8 +14,9 @@ #include "mingraph_coding.h" #include "dbm/mingraph.h" -#include "base/bitstring.h" -#include "debug/macros.h" + +#include +#include #include #include diff --git a/src/mingraph_write.c b/src/mingraph_write.c index f77ed87..b33f434 100644 --- a/src/mingraph_write.c +++ b/src/mingraph_write.c @@ -18,8 +18,9 @@ #endif #include "dbm/mingraph.h" -#include "base/bitstring.h" -#include "debug/macros.h" + +#include +#include /** * @file diff --git a/src/priced.cpp b/src/priced.cpp index 7daf045..021a040 100644 --- a/src/priced.cpp +++ b/src/priced.cpp @@ -15,7 +15,8 @@ #include "dbm/dbm_raw.hpp" #include "dbm/print.h" -#include "debug/macros.h" + +#include #include #include diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cff7d96..21e063b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,11 +1,6 @@ # dbm tests... -set(libs UDBM UUtils::udebug UUtils::base UUtils::hash) - -include(../cmake/doctest.cmake) - -add_library(doctest_main OBJECT doctest_main.cpp) -target_link_libraries(doctest_main PRIVATE doctest::doctest) +set(libs UDBM xxHash) file(GLOB test_c_sources "test_*.c" "test_allocation.cpp") foreach(source ${test_c_sources}) @@ -18,7 +13,7 @@ file(GLOB test_cpp_sources test_fed.cpp test_fed_dbm.cpp test_fp_intersection.cp foreach(source ${test_cpp_sources}) get_filename_component(test_target ${source} NAME_WE) add_executable(${test_target} ${source}) - target_link_libraries(${test_target} ${libs} doctest_main) + target_link_libraries(${test_target} ${libs} doctest_with_main) endforeach() # comments contain expected time of Linux debug build, YMMV, whereas timeouts diff --git a/test/doctest_main.cpp b/test/doctest_main.cpp deleted file mode 100644 index 0a3f254..0000000 --- a/test/doctest_main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include diff --git a/test/test_constraint.cpp b/test/test_constraint.cpp index 657bdde..8266232 100644 --- a/test/test_constraint.cpp +++ b/test/test_constraint.cpp @@ -1,11 +1,11 @@ #include "dbm/constraints.h" +#include + #include #include #include -#include - TEST_CASE("Constraint operators") { const auto vec = std::vector{{2, 1, 2}, {1, 2, -2}, {1, 0, 1}, {0, 1, -2}}; diff --git a/test/test_dbm.c b/test/test_dbm.c index 6eb03e3..5d9bf9d 100644 --- a/test/test_dbm.c +++ b/test/test_dbm.c @@ -22,8 +22,9 @@ #include "dbm/dbm.h" #include "dbm/gen.h" #include "dbm/print.h" -#include "base/bitstring.h" -#include "debug/macros.h" + +#include +#include #include #include diff --git a/test/test_ext.c b/test/test_ext.c index 1a2b291..dc68387 100644 --- a/test/test_ext.c +++ b/test/test_ext.c @@ -20,8 +20,9 @@ #include "dbm/dbm.h" #include "dbm/gen.h" #include "dbm/print.h" -#include "base/bitstring.h" -#include "debug/macros.h" + +#include +#include #include #include diff --git a/test/test_extrapolation.c b/test/test_extrapolation.c index 9bd235f..fea462d 100644 --- a/test/test_extrapolation.c +++ b/test/test_extrapolation.c @@ -24,7 +24,8 @@ #include "dbm/dbm.h" #include "dbm/gen.h" #include "dbm/print.h" -#include "debug/macros.h" + +#include #include #include diff --git a/test/test_fed.cpp b/test/test_fed.cpp index b4a97be..0158a5c 100644 --- a/test/test_fed.cpp +++ b/test/test_fed.cpp @@ -18,15 +18,16 @@ #include "dbm/fed.h" #include "dbm/gen.h" #include "dbm/print.h" -#include "debug/utils.h" + +#include + +#include #include // sort #include #include #include -#include - using namespace std; using namespace dbm; diff --git a/test/test_fp_intersection.cpp b/test/test_fp_intersection.cpp index 33eea24..166fd44 100644 --- a/test/test_fp_intersection.cpp +++ b/test/test_fp_intersection.cpp @@ -2,13 +2,13 @@ #include "dbm/print.h" #include "base/doubles.h" +#include + #include #include #include #include -#include - void printConstraint(const raw_t raw, const double i, const double j) { std::cout << i << (dbm_rawIsStrict(raw) ? "<" : "<=") << j << "+" << dbm_raw2bound(raw) << std::endl; diff --git a/test/test_mingraph.c b/test/test_mingraph.c index 6308d6b..9597935 100644 --- a/test/test_mingraph.c +++ b/test/test_mingraph.c @@ -23,8 +23,9 @@ #include "dbm/gen.h" #include "dbm/mingraph.h" #include "dbm/print.h" -#include "base/bitstring.h" -#include "debug/macros.h" + +#include +#include #include #include diff --git a/test/test_valuation.cpp b/test/test_valuation.cpp index dc0b2e3..0d2f6be 100644 --- a/test/test_valuation.cpp +++ b/test/test_valuation.cpp @@ -12,10 +12,10 @@ #include "dbm/valuation.h" -#include - #include +#include + using namespace std; using namespace dbm; From 4f8141c15045cf2545fad10464cfd65511ceb5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Mon, 11 Sep 2023 13:39:35 +0200 Subject: [PATCH 03/14] In the middle of updating the libraries --- CMakeLists.txt | 11 ++++++----- cmake/UUtils.cmake | 38 ++++++++++++++++++++++++++++++++++++++ cmake/clang-tidy.cmake | 2 +- cmake/doctest.cmake | 20 +++++++++++--------- cmake/xxhash.cmake | 34 +++++++++++++++++++--------------- getlibs.sh | 25 +------------------------ src/CMakeLists.txt | 3 ++- test/CMakeLists.txt | 4 ++-- 8 files changed, 80 insertions(+), 57 deletions(-) create mode 100644 cmake/UUtils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ae3404d..87d757f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if (UDBM_WITH_TESTS) include(cmake/doctest.cmake) endif (UDBM_WITH_TESTS) include(cmake/xxhash.cmake) -find_package(UUtils 2.0.0 REQUIRED COMPONENTS base hash debug) +include(cmake/UUtils.cmake) if(UDBM_STATIC) set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ -lwsock32 -lws2_32 ${CMAKE_CXX_STANDARD_LIBRARIES}") @@ -35,14 +35,15 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") add_compile_options(/W4) endif() -add_definitions(-DXXHASH_INLINE_ALL=1) -add_compile_definitions(XXHASH_INLINE_ALL) # workaround for xxHash::xxhash -include_directories(${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include ${XXHASH_INCLUDE_DIR}) +if(UDBM_WITH_TESTS) + enable_testing() +endif(UDBM_WITH_TESTS) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include) add_subdirectory("src") if(UDBM_WITH_TESTS) - enable_testing() add_subdirectory(test) endif(UDBM_WITH_TESTS) diff --git a/cmake/UUtils.cmake b/cmake/UUtils.cmake new file mode 100644 index 0000000..84473f4 --- /dev/null +++ b/cmake/UUtils.cmake @@ -0,0 +1,38 @@ +message(STATUS "LOOKING FOR UUTILS") +find_package(UUtils 2.0.2 COMPONENTS base hash debug QUIET) + +if (UUtils_FOUND) + message(STATUS "Found UUtils: ${uutils_DIR}") +else(UUtils_FOUND) + message(STATUS "Failed to find doctest, going to compile from source.") + if (FIND_FATAL) + message(FATAL_ERROR "Failed to find doctest with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") + endif(FIND_FATAL) + include(FetchContent) + set(UUtils_WITH_TESTS OFF CACHE BOOL "UUtils tests") + set(UUtils_WITH_BENCHMARKS OFF CACHE BOOL "UUtils benchmarks") + FetchContent_Declare( + UUtils + GIT_REPOSITORY https://github.com/mikucionisaau/UUtils.git + GIT_TAG cmake-alias + #GIT_REPOSITORY https://github.com/UPPAALModelChecker/UUtils.git + #GIT_TAG v2.0.2 + GIT_SHALLOW TRUE # get only the last commit version + GIT_PROGRESS TRUE # show progress of download + # FIND_PACKAGE_ARGS NAMES doctest + USES_TERMINAL_DOWNLOAD TRUE # show progress in ninja generator + USES_TERMINAL_CONFIGURE ON + USES_TERMINAL_BUILD ON + USES_TERMINAL_INSTALL ON + ) +# FetchContent_MakeAvailable(UUtils) + FetchContent_GetProperties(UUtils) + if (uutils_POPULATED) + message(STATUS "Found populated UUtils: ${uutils_SOURCE_DIR}") + else (uutils_POPULATED) + FetchContent_Populate(UUtils) + add_subdirectory(${uutils_SOURCE_DIR} ${uutils_BINARY_DIR} EXCLUDE_FROM_ALL) + message(STATUS "Got UUtils: ${uutils_SOURCE_DIR}") + endif (uutils_POPULATED) +endif(UUtils_FOUND) +message(STATUS "STOPPED LOOKING FOR UUTILS") \ No newline at end of file diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake index 9b7b2ea..da70137 100644 --- a/cmake/clang-tidy.cmake +++ b/cmake/clang-tidy.cmake @@ -10,7 +10,7 @@ if(CLANG_TIDY_PROGRAM) if (TIDY_MAJOR_VERSION GREATER_EQUAL 14) # Add good checks which produce a minimal amount of false positives # One or two false positives can be dealt with using // NOLINT - set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PROGRAM} -checks=-*,cppcoreguidelines-macro-usage,hicpp-deprecated-headers,modernize-deprecated-headers,hicpp-use-override,hicpp-use-emplace,modernize-use-emplace,hicpp-use-auto,readability-container-size-empty,readability-implicit-bool-conversion,readability-redundant-smartptr-get,readability-qualified-auto,performance-unnecessary-value-param,modernize-make-unique,modernize-make-shared,misc-unused-using-decls,performance-move-const-arg,modernize-use-using,modernize-use-nullptr,modernize-deprecated-headers,modernize-loop-convert,misc-unused-using-decls,misc-static-assert,misc-redundant-expression,modernize-use-bool-literals,readability-delete-null-pointer,readability-redundant-member-init --warnings-as-errors=*) + set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PROGRAM} -checks=-*,cppcoreguidelines-macro-usage,hicpp-deprecated-headers,modernize-deprecated-headers,hicpp-use-override,hicpp-use-emplace,modernize-use-emplace,hicpp-use-auto,readability-container-size-empty,readability-implicit-bool-conversion,readability-redundant-smartptr-get,readability-qualified-auto,performance-unnecessary-value-param,modernize-make-unique,modernize-make-shared,misc-unused-using-decls,performance-move-const-arg,modernize-use-using,modernize-use-nullptr,modernize-deprecated-headers,modernize-loop-convert,misc-unused-using-decls,misc-static-assert,misc-redundant-expression,modernize-use-bool-literals,readability-delete-null-pointer,readability-redundant-member-init) message(STATUS "Enabled clang-tidy ${TIDY_VERSION}: ${CLANG_TIDY_PROGRAM}") else() message(WARNING "Found clang-tidy ${TIDY_VERSION}, but >=14 is required, thus disabled.") diff --git a/cmake/doctest.cmake b/cmake/doctest.cmake index b40da3d..24e7f0a 100644 --- a/cmake/doctest.cmake +++ b/cmake/doctest.cmake @@ -15,12 +15,13 @@ if (doctest_FOUND) else(doctest_FOUND) message(STATUS "Failed to find doctest, going to compile from source.") if (FIND_FATAL) - message(FATAL_ERROR "Failed to find ${FIND_FATAL} with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") + message(FATAL_ERROR "Failed to find doctest with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") endif(FIND_FATAL) + include(FetchContent) set(DOCTEST_WITH_TESTS OFF CACHE BOOL "doctest tests and examples") set(DOCTEST_WITH_MAIN_IN_STATIC_LIB ON CACHE BOOL "static lib (cmake target) with a default main entry point") - #set(DOCTEST_NO_INSTALL OFF CACHE BOOL "Skip the installation process") - #set(DOCTEST_USE_STD_HEADERS OFF CACHE BOOL "Use std headers") + set(DOCTEST_NO_INSTALL ON CACHE BOOL "Skip the installation process") + set(DOCTEST_USE_STD_HEADERS OFF CACHE BOOL "Use std headers") FetchContent_Declare( doctest GIT_REPOSITORY https://github.com/doctest/doctest @@ -33,11 +34,12 @@ else(doctest_FOUND) USES_TERMINAL_BUILD ON USES_TERMINAL_INSTALL ON ) - FetchContent_MakeAvailable(doctest) - if (doctest_SOURCE_DIR) - set(doctest_FOUND TRUE) + FetchContent_GetProperties(doctest) + if (doctest_POPULATED) + message(STATUS "Found populated doctest: ${doctest_SOURCE_DIR}") + else (doctest_POPULATED) + FetchContent_Populate(doctest) + add_subdirectory(${doctest_SOURCE_DIR} ${doctest_BINARY_DIR} EXCLUDE_FROM_ALL) message(STATUS "Got doctest: ${doctest_SOURCE_DIR}") - else (doctest_SOURCE_DIR) - message(FATAL_ERROR "Failed to fetch doctest") - endif (doctest_SOURCE_DIR) + endif (doctest_POPULATED) endif(doctest_FOUND) diff --git a/cmake/xxhash.cmake b/cmake/xxhash.cmake index d026cad..f577755 100644 --- a/cmake/xxhash.cmake +++ b/cmake/xxhash.cmake @@ -16,7 +16,11 @@ if (XXHASH_PATH) cmake_path(GET XXHASH_PATH PARENT_PATH XXHASH_INCLUDE_DIR) add_library(xxHash INTERFACE) target_compile_definitions(xxHash INTERFACE XXH_INLINE_ALL) - target_include_directories(xxHash INTERFACE ${XXHASH_INCLUDE_DIR}) + target_include_directories(xxHash + INTERFACE + $ + $ + ) else() message(STATUS "Found xxHash-${XXHASH_VERSION} is too old, need at lease ${XXHASH_VERSION_MINIMUM}") endif() @@ -27,7 +31,7 @@ if (xxHash_FOUND) else(xxHash_FOUND) message(STATUS "Failed to find xxHash, going to compile from source.") if (FIND_FATAL) - message(FATAL_ERROR "Failed to find with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") + message(FATAL_ERROR "Failed to find xxHash with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") endif(FIND_FATAL) include(ExternalProject) set(XXHASH_BUILD_ENABLE_INLINE_API ON CACHE BOOL "adds xxhash.c for the -DXXH_INLINE_ALL api. Default ON") @@ -47,19 +51,19 @@ else(xxHash_FOUND) USES_TERMINAL_BUILD ON USES_TERMINAL_INSTALL ON ) - FetchContent_MakeAvailable(xxHash) - if (xxHash_SOURCE_DIR) - cmake_path(GET xxHash_SOURCE_DIR PARENT_PATH XXHASH_INCLUDE_DIR) # drop "cmake_unofficial" -# add_library(xxHash ALIAS xxHash::xxhash) + FetchContent_GetProperties(xxHash) + if (xxhash_POPULATED) + message(STATUS "Found populated xxHash: ${xxhash_SOURCE_DIR}") + else (xxhash_POPULATED) + FetchContent_Populate(xxHash) + add_subdirectory(${xxhash_SOURCE_DIR}/cmake_unofficial ${xxhash_BINARY_DIR} EXCLUDE_FROM_ALL) add_library(xxHash INTERFACE) -# set_property(TARGET xxHash APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${XXHASH_INCLUDE_DIR}) target_compile_definitions(xxHash INTERFACE XXH_INLINE_ALL) - target_include_directories(xxHash INTERFACE ${XXHASH_INCLUDE_DIR}) -# target_link_libraries(xxHash INTERFACE xxHash::xhash) - set(xxHash_FOUND TRUE) - message(STATUS "Got xxHash: ${XXHASH_INCLUDE_DIR}") - else(xxHash_SOURCE_DIR) - message(FATAL_ERROR "Failed to fetch xxHash") - endif (xxHash_SOURCE_DIR) - # Custom config: https://github.com/untrioctium/refrakt/blob/main/CMakeLists.txt + target_include_directories(xxHash + INTERFACE + $ + $ + ) + message(STATUS "Got xxHash: ${xxhash_SOURCE_DIR}") + endif (xxhash_POPULATED) endif(xxHash_FOUND) diff --git a/getlibs.sh b/getlibs.sh index 471399a..194690a 100755 --- a/getlibs.sh +++ b/getlibs.sh @@ -62,36 +62,13 @@ for target in $targets ; do cmake -S "$SOURCE_DIR/cmake_unofficial" -B "$BUILD_DIR" -DBUILD_SHARED_LIBS=OFF cmake --build "$BUILD_DIR" --config Release cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" - #rm -Rf "$BUILD_DIR" - #rm -Rf "$SOURCE_DIR" - - # Boost - PACKAGE=boost - VERSION=1.83.0 - ARCHIVE="$PACKAGE-$VERSION.tar.xz" - SOURCE_DIR="$PACKAGE-$VERSION" - BUILD_DIR="build-${SOURCE_DIR}-$target" - [ -r "$ARCHIVE" ] || curl -sL "https://github.com/boostorg/boost/releases/download/${SOURCE_DIR}/${ARCHIVE}" -o "$ARCHIVE" - [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" - echo "Building $SOURCE_DIR" - echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" - echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" - echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" - echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" - echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" - cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DBOOST_ENABLE_CMAKE=ON -DBUILD_SHARED_LIBS=OFF \ - -DBOOST_INCLUDE_LIBRARIES="headers;math" -DBOOST_ENABLE_MPI=OFF -DBOOST_ENABLE_PYTHON=OFF \ - -DBOOST_RUNTIME_LINK=static -DBUILD_TESTING=OFF -DBOOST_USE_STATIC_LIBS=ON -DBOOST_USE_DEBUG_LIBS=ON \ - -DBOOST_USE_RELEASE_LIBS=ON -DBOOST_USE_STATIC_RUNTIME=ON -DBOOST_INSTALL_LAYOUT=system - cmake --build "$BUILD_DIR" --config Release - cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" rm -Rf "$BUILD_DIR" rm -Rf "$SOURCE_DIR" # UUtils various low level Uppaal utilities #git clone https://github.com/UPPAALModelChecker/UUtils "$SOURCE_DIR/libs/sources/UUtils"; PACKAGE=UUtils - VERSION=2.0.0 + VERSION=2.0.2 ARCHIVE="$PACKAGE-$VERSION.tar.gz" SOURCE_DIR="$PACKAGE-$VERSION" BUILD_DIR="build-${SOURCE_DIR}-$target" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 03ef32f..f4a7fc6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,8 @@ add_library(UDBM STATIC DBMAllocator.cpp dbm.c fed_dbm.cpp mingraph.c mingraph_r priced.cpp valuation.cpp) set_property(TARGET UDBM PROPERTY C_VISIBILITY_PRESET hidden) set_property(TARGET UDBM PROPERTY VISIBILITY_INLINES_HIDDEN ON) -target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash xxhash) +target_compile_definitions(UDBM INTERFACE XXHASH_INLINE_ALL) +target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash) target_include_directories(UDBM PRIVATE diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 21e063b..b94ef87 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ # dbm tests... -set(libs UDBM xxHash) +set(libs UDBM base xxHash) file(GLOB test_c_sources "test_*.c" "test_allocation.cpp") foreach(source ${test_c_sources}) @@ -9,7 +9,7 @@ foreach(source ${test_c_sources}) target_link_libraries(${test_target} ${libs}) endforeach() -file(GLOB test_cpp_sources test_fed.cpp test_fed_dbm.cpp test_fp_intersection.cpp test_valuation.cpp test_constraint.cpp) +file(GLOB test_cpp_sources test_fed.cpp test_fed_dbm.cpp test_fp_intersection.cpp test_valuation.cpp test_constraint.cpp test_hash.cpp) foreach(source ${test_cpp_sources}) get_filename_component(test_target ${source} NAME_WE) add_executable(${test_target} ${source}) From 25a23aeb28188c02bd160f61d687c0c705c8f639 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Mon, 11 Sep 2023 13:50:01 +0200 Subject: [PATCH 04/14] Fixed cmake message copy-paste mistake --- cmake/UUtils.cmake | 3 +-- cmake/clang-tidy.cmake | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/UUtils.cmake b/cmake/UUtils.cmake index 84473f4..f8a7092 100644 --- a/cmake/UUtils.cmake +++ b/cmake/UUtils.cmake @@ -4,7 +4,7 @@ find_package(UUtils 2.0.2 COMPONENTS base hash debug QUIET) if (UUtils_FOUND) message(STATUS "Found UUtils: ${uutils_DIR}") else(UUtils_FOUND) - message(STATUS "Failed to find doctest, going to compile from source.") + message(STATUS "Failed to find UUtils, going to compile from source.") if (FIND_FATAL) message(FATAL_ERROR "Failed to find doctest with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") endif(FIND_FATAL) @@ -25,7 +25,6 @@ else(UUtils_FOUND) USES_TERMINAL_BUILD ON USES_TERMINAL_INSTALL ON ) -# FetchContent_MakeAvailable(UUtils) FetchContent_GetProperties(UUtils) if (uutils_POPULATED) message(STATUS "Found populated UUtils: ${uutils_SOURCE_DIR}") diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake index da70137..a769943 100644 --- a/cmake/clang-tidy.cmake +++ b/cmake/clang-tidy.cmake @@ -10,7 +10,7 @@ if(CLANG_TIDY_PROGRAM) if (TIDY_MAJOR_VERSION GREATER_EQUAL 14) # Add good checks which produce a minimal amount of false positives # One or two false positives can be dealt with using // NOLINT - set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PROGRAM} -checks=-*,cppcoreguidelines-macro-usage,hicpp-deprecated-headers,modernize-deprecated-headers,hicpp-use-override,hicpp-use-emplace,modernize-use-emplace,hicpp-use-auto,readability-container-size-empty,readability-implicit-bool-conversion,readability-redundant-smartptr-get,readability-qualified-auto,performance-unnecessary-value-param,modernize-make-unique,modernize-make-shared,misc-unused-using-decls,performance-move-const-arg,modernize-use-using,modernize-use-nullptr,modernize-deprecated-headers,modernize-loop-convert,misc-unused-using-decls,misc-static-assert,misc-redundant-expression,modernize-use-bool-literals,readability-delete-null-pointer,readability-redundant-member-init) + set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PROGRAM} -checks=-*,cppcoreguidelines-macro-usage,hicpp-deprecated-headers,modernize-deprecated-headers,hicpp-use-override,hicpp-use-emplace,modernize-use-emplace,hicpp-use-auto,readability-container-size-empty,readability-implicit-bool-conversion,readability-redundant-smartptr-get,readability-qualified-auto,performance-unnecessary-value-param,modernize-make-unique,modernize-make-shared,misc-unused-using-decls,performance-move-const-arg,modernize-use-using,modernize-use-nullptr,modernize-deprecated-headers,modernize-loop-convert,misc-unused-using-decls,misc-static-assert,misc-redundant-expression,modernize-use-bool-literals,readability-delete-null-pointer,readability-redundant-member-init,-warnings-as-errors) message(STATUS "Enabled clang-tidy ${TIDY_VERSION}: ${CLANG_TIDY_PROGRAM}") else() message(WARNING "Found clang-tidy ${TIDY_VERSION}, but >=14 is required, thus disabled.") From 59efc5fe39efe7d61a71f6f2ef051c844aeb92c1 Mon Sep 17 00:00:00 2001 From: Thorulf Neustrup Date: Mon, 11 Sep 2023 15:34:18 +0200 Subject: [PATCH 05/14] merge --- cmake/clang-tidy.cmake | 2 +- src/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/clang-tidy.cmake b/cmake/clang-tidy.cmake index a769943..b93e6f8 100644 --- a/cmake/clang-tidy.cmake +++ b/cmake/clang-tidy.cmake @@ -10,7 +10,7 @@ if(CLANG_TIDY_PROGRAM) if (TIDY_MAJOR_VERSION GREATER_EQUAL 14) # Add good checks which produce a minimal amount of false positives # One or two false positives can be dealt with using // NOLINT - set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_PROGRAM} -checks=-*,cppcoreguidelines-macro-usage,hicpp-deprecated-headers,modernize-deprecated-headers,hicpp-use-override,hicpp-use-emplace,modernize-use-emplace,hicpp-use-auto,readability-container-size-empty,readability-implicit-bool-conversion,readability-redundant-smartptr-get,readability-qualified-auto,performance-unnecessary-value-param,modernize-make-unique,modernize-make-shared,misc-unused-using-decls,performance-move-const-arg,modernize-use-using,modernize-use-nullptr,modernize-deprecated-headers,modernize-loop-convert,misc-unused-using-decls,misc-static-assert,misc-redundant-expression,modernize-use-bool-literals,readability-delete-null-pointer,readability-redundant-member-init,-warnings-as-errors) + set(CLANG_TIDY_COMMAND ${CLANG_TIDY_PROGRAM} -checks=-*,cppcoreguidelines-macro-usage,hicpp-deprecated-headers,modernize-deprecated-headers,hicpp-use-override,hicpp-use-emplace,modernize-use-emplace,hicpp-use-auto,readability-container-size-empty,readability-implicit-bool-conversion,readability-redundant-smartptr-get,readability-qualified-auto,performance-unnecessary-value-param,modernize-make-unique,modernize-make-shared,misc-unused-using-decls,performance-move-const-arg,modernize-use-using,modernize-use-nullptr,modernize-deprecated-headers,modernize-loop-convert,misc-unused-using-decls,misc-static-assert,misc-redundant-expression,modernize-use-bool-literals,readability-delete-null-pointer,readability-redundant-member-init) message(STATUS "Enabled clang-tidy ${TIDY_VERSION}: ${CLANG_TIDY_PROGRAM}") else() message(WARNING "Found clang-tidy ${TIDY_VERSION}, but >=14 is required, thus disabled.") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4a7fc6..a361529 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ add_library(UDBM STATIC DBMAllocator.cpp dbm.c fed_dbm.cpp mingraph.c mingraph_r priced.cpp valuation.cpp) set_property(TARGET UDBM PROPERTY C_VISIBILITY_PRESET hidden) set_property(TARGET UDBM PROPERTY VISIBILITY_INLINES_HIDDEN ON) +set_target_properties(UDBM PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") target_compile_definitions(UDBM INTERFACE XXHASH_INLINE_ALL) target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash) From ba1309067d0c454d76f364691e923b90efc34e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Tue, 12 Sep 2023 14:38:36 +0200 Subject: [PATCH 06/14] Updated UUtils to 2.0.3 and simplified getlibs --- CMakeLists.txt | 1 - cmake/UUtils.cmake | 16 +++++++--------- getlibs.sh | 23 ++--------------------- src/CMakeLists.txt | 9 ++++----- test/CMakeLists.txt | 6 +++--- 5 files changed, 16 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87d757f..9705e53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,6 @@ include(cmake/clang-tidy.cmake) if (UDBM_WITH_TESTS) include(cmake/doctest.cmake) endif (UDBM_WITH_TESTS) -include(cmake/xxhash.cmake) include(cmake/UUtils.cmake) if(UDBM_STATIC) diff --git a/cmake/UUtils.cmake b/cmake/UUtils.cmake index f8a7092..2da53ce 100644 --- a/cmake/UUtils.cmake +++ b/cmake/UUtils.cmake @@ -1,23 +1,22 @@ -message(STATUS "LOOKING FOR UUTILS") find_package(UUtils 2.0.2 COMPONENTS base hash debug QUIET) if (UUtils_FOUND) - message(STATUS "Found UUtils: ${uutils_DIR}") + message(STATUS "Found UUtils: ${UUtils_DIR}") else(UUtils_FOUND) message(STATUS "Failed to find UUtils, going to compile from source.") if (FIND_FATAL) - message(FATAL_ERROR "Failed to find doctest with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") + message(FATAL_ERROR "Failed to find UUtils with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") endif(FIND_FATAL) include(FetchContent) set(UUtils_WITH_TESTS OFF CACHE BOOL "UUtils tests") set(UUtils_WITH_BENCHMARKS OFF CACHE BOOL "UUtils benchmarks") FetchContent_Declare( UUtils - GIT_REPOSITORY https://github.com/mikucionisaau/UUtils.git - GIT_TAG cmake-alias - #GIT_REPOSITORY https://github.com/UPPAALModelChecker/UUtils.git - #GIT_TAG v2.0.2 - GIT_SHALLOW TRUE # get only the last commit version + #GIT_REPOSITORY https://github.com/mikucionisaau/UUtils.git + #GIT_TAG cmake-alias + GIT_REPOSITORY https://github.com/UPPAALModelChecker/UUtils.git + GIT_TAG v2.0.3 + GIT_SHALLOW TRtliUE # get only the last commit version GIT_PROGRESS TRUE # show progress of download # FIND_PACKAGE_ARGS NAMES doctest USES_TERMINAL_DOWNLOAD TRUE # show progress in ninja generator @@ -34,4 +33,3 @@ else(UUtils_FOUND) message(STATUS "Got UUtils: ${uutils_SOURCE_DIR}") endif (uutils_POPULATED) endif(UUtils_FOUND) -message(STATUS "STOPPED LOOKING FOR UUTILS") \ No newline at end of file diff --git a/getlibs.sh b/getlibs.sh index 194690a..fcc7f51 100755 --- a/getlibs.sh +++ b/getlibs.sh @@ -45,35 +45,16 @@ for target in $targets ; do rm -Rf "$BUILD_DIR" rm -Rf "$SOURCE_DIR" - # xxHash for fast high quality hashing - PACKAGE=xxHash - VERSION=0.8.2 - ARCHIVE="$PACKAGE-$VERSION.tar.gz" - SOURCE_DIR="$PACKAGE-$VERSION" - BUILD_DIR="build-${SOURCE_DIR}-$target" - [ -r "$ARCHIVE" ] || curl -sL "https://github.com/Cyan4973/xxHash/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" - [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" - echo "Building $SOURCE_DIR" - echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" - echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" - echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" - echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" - echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" - cmake -S "$SOURCE_DIR/cmake_unofficial" -B "$BUILD_DIR" -DBUILD_SHARED_LIBS=OFF - cmake --build "$BUILD_DIR" --config Release - cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" - rm -Rf "$BUILD_DIR" - rm -Rf "$SOURCE_DIR" - # UUtils various low level Uppaal utilities #git clone https://github.com/UPPAALModelChecker/UUtils "$SOURCE_DIR/libs/sources/UUtils"; PACKAGE=UUtils - VERSION=2.0.2 + VERSION=2.0.3 ARCHIVE="$PACKAGE-$VERSION.tar.gz" SOURCE_DIR="$PACKAGE-$VERSION" BUILD_DIR="build-${SOURCE_DIR}-$target" [ -r "$ARCHIVE" ] || curl -sL "https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" +# git clone -b cmake-alias --single-branch --depth 1 https://github.com/mikucionisaau/UUtils.git "$SOURCE_DIR" echo "Building $SOURCE_DIR" echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a361529..25400b4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,18 +4,17 @@ add_library(UDBM STATIC DBMAllocator.cpp dbm.c fed_dbm.cpp mingraph.c mingraph_r set_property(TARGET UDBM PROPERTY C_VISIBILITY_PRESET hidden) set_property(TARGET UDBM PROPERTY VISIBILITY_INLINES_HIDDEN ON) set_target_properties(UDBM PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") -target_compile_definitions(UDBM INTERFACE XXHASH_INLINE_ALL) target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash) target_include_directories(UDBM PRIVATE # where the library itself will look for its internal headers - ${CMAKE_CURRENT_BINARY_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../include + ${PROJECT_BINARY_DIR}/include + ${PROJECT_SOURCE_DIR}/include PUBLIC # where top-level project will look for the library's public headers - $ - $ + $ + $ # where external projects will look for the library's public headers $ ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b94ef87..7dc05ec 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,15 +1,15 @@ # dbm tests... -set(libs UDBM base xxHash) +set(libs UDBM UUtils::base) file(GLOB test_c_sources "test_*.c" "test_allocation.cpp") foreach(source ${test_c_sources}) get_filename_component(test_target ${source} NAME_WE) add_executable(${test_target} ${source}) - target_link_libraries(${test_target} ${libs}) + target_link_libraries(${test_target} PRIVATE ${libs}) endforeach() -file(GLOB test_cpp_sources test_fed.cpp test_fed_dbm.cpp test_fp_intersection.cpp test_valuation.cpp test_constraint.cpp test_hash.cpp) +file(GLOB test_cpp_sources test_fed.cpp test_fed_dbm.cpp test_fp_intersection.cpp test_valuation.cpp test_constraint.cpp) foreach(source ${test_cpp_sources}) get_filename_component(test_target ${source} NAME_WE) add_executable(${test_target} ${source}) From 03b5895fc8c29743a418b089b36de87f7e1e4a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 13 Sep 2023 08:45:57 +0200 Subject: [PATCH 07/14] Refactored the build scripts --- .github/workflows/build.yml | 153 +++++++++++++++------------- cmake/UUtils.cmake | 2 +- cmake/toolchain/i686-linux.cmake | 1 + cmake/toolchain/x86_64-darwin.cmake | 19 ++++ cmake/toolchain/x86_64-linux.cmake | 1 + compile.sh | 25 +++-- getlibs.sh | 87 +++++++++------- src/CMakeLists.txt | 4 +- 8 files changed, 175 insertions(+), 117 deletions(-) create mode 100644 cmake/toolchain/x86_64-darwin.cmake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db44b31..f00cb75 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,3 +1,4 @@ +--- name: Build and Test on: @@ -7,106 +8,118 @@ on: branches: [ main ] jobs: - format: + formatting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Format - run: find src include test -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\)$' | xargs clang-format -n -Werror - build-linux-win: + - uses: actions/checkout@v2 + - name: Formatting + run: find src include test -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\)$' | xargs clang-format -n -Werror + build-win64: strategy: fail-fast: false matrix: - target: [mingw, ubuntu] + target: [x86_64-w64-mingw32, x86_64-linux] sanitizers: [ON, OFF] newdbm: [ON, OFF] exclude: - - target: mingw + - target: x86_64-w64-mingw32 sanitizers: ON runs-on: ubuntu-latest + env: + CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/{{ matrix.target }}.cmake + CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/{{ matrix.target }} + CMAKE_BUILD_TYPE: Release + CTEST_OUTPUT_ON_FAILURE: 1 + STATIC: ON steps: - - uses: actions/checkout@v2 - - name: Set default environment variables - run: echo "STATIC=OFF" >> "$GITHUB_ENV" - - name: Set mingw environment variables - if: matrix.target == 'mingw' - run: | - echo "CMAKE_TOOLCHAIN_FILE=$PWD/cmake/toolchain/x86_64-w64-mingw32.cmake" >> "$GITHUB_ENV" - echo "STATIC=ON" >> "$GITHUB_ENV" - - name: Get ubuntu dependencies - if: matrix.target == 'ubuntu' - run: | - sudo apt-get update - sudo apt-get install libboost-all-dev doctest-dev - - name: Get mingw dependencies - if: matrix.target == 'mingw' - run: | - sudo apt-get update - sudo apt-get install cmake make g++-mingw-w64-x86-64 mingw-w64-x86-64-dev mingw-w64-tools wine wine-binfmt + - uses: actions/checkout@v2 + - name: Set default environment variables + run: echo "STATIC=OFF" >> "$GITHUB_ENV" + - name: Get MinGW64 dependencies + if: matrix.target == 'mingw' + run: | + sudo apt-get -qqy update + sudo apt-get -qqy install cmake make g++-mingw-w64-x86-64 mingw-w64-x86-64-dev mingw-w64-tools wine wine-binfmt sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - - name: Getlibs - run: ./getlibs.sh - - name: Build and test - run: | - export CTEST_OUTPUT_ON_FAILURE=1 - cmake -DUDBM_WITH_TESTS=ON -DUDBM_STATIC=$STATIC -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} -DCMAKE_BUILD_TYPE=Release -DENABLE_DBM_NEW=${{ matrix.newdbm }} -DCMAKE_PREFIX_PATH=$(pwd)/local -B build -S . - cmake --build build - (cd build ; ctest) - build-win-native: + - name: Getlibs + run: ./getlibs.sh {{ matrix.target }} + - name: Build and test + run: | + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + cmake -S . -B build -DUDBM_WITH_TESTS=ON -DUDBM_STATIC=$STATIC -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} -DENABLE_DBM_NEW=${{ matrix.newdbm }} + cmake --build build --config $CMAKE_BUILD_TYPE + (cd build ; ctest -C $CMAKE_BUILD_TYPE) + build-win64-native: runs-on: windows-latest + env: + CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake + CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/x86_64-w64-mingw32 + CMAKE_BUILD_TYPE: Release + STATIC: ON + CTEST_OUTPUT_ON_FAILURE: 1 steps: - - uses: actions/checkout@v2 - - name: Get dependencies - run: | + - uses: actions/checkout@v2 + - name: Get dependencies + run: | vcpkg integrate install vcpkg install doctest --triplet x64-windows - bash ./getlibs.sh - - name: Build and test - run: | - cmake -DCMAKE_BUILD_TYPE=Release -DUDBM_WITH_TESTS=ON "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" -DCMAKE_PREFIX_PATH=$PWD/local/x86_64-w64-mingw32 -B build -S . - cmake --build build --config Release - (cd build ; ctest --output-on-failure -C Release) + bash ./getlibs.sh x86_64-w64-mingw32 + - name: Build and test + run: | + cmake -S . -B build -DUDBM_WITH_TESTS=ON + cmake --build build --config %CMAKE_BUILD_TYPE% + (cd build ; ctest -C %CMAKE_BUILD_TYPE%) build-macos: runs-on: macos-latest + env: + CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/x86_64-darwin.cmake + CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/x86_64-darwin + CMAKE_BUILD_TYPE: Release + STATIC: ON + CTEST_OUTPUT_ON_FAILURE: 1 strategy: fail-fast: false matrix: sanitizers: [ON, OFF] steps: - - uses: actions/checkout@v2 - - name: Get dependencies - run: brew install boost doctest && ./getlibs.sh - - name: Build and test - run: | - export CTEST_OUTPUT_ON_FAILURE=1 - cmake -DUDBM_WITH_TESTS=ON -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$(pwd)/local -B build -S . - cmake --build build - (cd build ; ctest) + - uses: actions/checkout@v2 + - name: Get dependencies + run: brew install boost doctest && ./getlibs.sh + - name: Build and test + run: | + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + cmake -S . -B build -DUDBM_WITH_TESTS=ON -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} + cmake --build build --config $CMAKE_BUILD_TYPE + (cd build ; ctest -C $CMAKE_BUILD_TYPE) build-nix: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v15 - with: - nix_path: nixpkgs=channel:nixos-unstable - - name: Build and test - run: nix build -L + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Build and test + run: nix build -L build-nix-mac: runs-on: macos-latest steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v15 - with: - nix_path: nixpkgs=channel:nixos-unstable - - name: Build and test - run: nix build -L + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Build and test + run: nix build -L build-nix-cross: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v15 - with: - nix_path: nixpkgs=channel:nixos-unstable - - name: Build and test - run: nix build -L .\#packages.crossPackage.x86_64-linux + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Build and test + run: nix build -L .\#packages.crossPackage.x86_64-linux diff --git a/cmake/UUtils.cmake b/cmake/UUtils.cmake index 2da53ce..b64049d 100644 --- a/cmake/UUtils.cmake +++ b/cmake/UUtils.cmake @@ -16,7 +16,7 @@ else(UUtils_FOUND) #GIT_TAG cmake-alias GIT_REPOSITORY https://github.com/UPPAALModelChecker/UUtils.git GIT_TAG v2.0.3 - GIT_SHALLOW TRtliUE # get only the last commit version + GIT_SHALLOW TRUE # get only the last commit version GIT_PROGRESS TRUE # show progress of download # FIND_PACKAGE_ARGS NAMES doctest USES_TERMINAL_DOWNLOAD TRUE # show progress in ninja generator diff --git a/cmake/toolchain/i686-linux.cmake b/cmake/toolchain/i686-linux.cmake index 6ea4aae..6fabd4b 100644 --- a/cmake/toolchain/i686-linux.cmake +++ b/cmake/toolchain/i686-linux.cmake @@ -6,6 +6,7 @@ set(CMAKE_C_COMPILER cc) set(CMAKE_C_FLAGS -m32) set(CMAKE_CXX_COMPILER c++) set(CMAKE_CXX_FLAGS -m32) +set(CMAKE_ASM_FLAGS -m32) # here is the target environment located set(CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") diff --git a/cmake/toolchain/x86_64-darwin.cmake b/cmake/toolchain/x86_64-darwin.cmake new file mode 100644 index 0000000..e05a733 --- /dev/null +++ b/cmake/toolchain/x86_64-darwin.cmake @@ -0,0 +1,19 @@ +# the name of the target operating system +set(CMAKE_SYSTEM_NAME Darwin) + +# which compilers to use for C and C++ +set(CMAKE_C_COMPILER cc) +set(CMAKE_C_FLAGS -m64) +set(CMAKE_CXX_COMPILER c++) +set(CMAKE_CXX_FLAGS -m64) +set(CMAKE_ASM_FLAGS -m64) + +# here is the target environment located +set(CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, +# search programs in both target and host environments +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) diff --git a/cmake/toolchain/x86_64-linux.cmake b/cmake/toolchain/x86_64-linux.cmake index 8eb85f5..5e686bc 100644 --- a/cmake/toolchain/x86_64-linux.cmake +++ b/cmake/toolchain/x86_64-linux.cmake @@ -6,6 +6,7 @@ set(CMAKE_C_COMPILER cc) set(CMAKE_C_FLAGS -m64) set(CMAKE_CXX_COMPILER c++) set(CMAKE_CXX_FLAGS -m64) +set(CMAKE_ASM_FLAGS -m64) # here is the target environment located set(CMAKE_FIND_ROOT_PATH "${CMAKE_PREFIX_PATH}") diff --git a/compile.sh b/compile.sh index 2aa5d0b..8c8f4cc 100755 --- a/compile.sh +++ b/compile.sh @@ -4,7 +4,7 @@ set -eo pipefail PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" if [ $# -eq 0 ]; then - targets="x86_64-linux-ubsan-asan-debug x86_64-linux-release x86_64-w64-mingw32-debug x86_64-w64-mingw32-release" + targets="x86_64-linux-libs-release x86_64-w64-mingw32-libs-release" else targets="$@" fi @@ -13,26 +13,36 @@ for target in $targets ; do unset BUILD_EXTRA unset CMAKE_BUILD_TYPE case $target in - x86_64-linux*|linux64*) + linux64*|x86_64-linux*) PLATFORM=x86_64-linux ;; - i686-linux*|linux32*) + linux32*|i686-linux*) PLATFORM=i686-linux ;; - x86_64-w64-mingw32*|win64*) + win64*|x86_64-w64-mingw32*) PLATFORM=x86_64-w64-mingw32 ;; - i686-w64-mingw32*|win32*) + win32*|i686-w64-mingw32*) PLATFORM=i686-w64-mingw32 ;; + macos*|x86_64-darwin*) + PLATFORM=x86_64-darwin + ;; *) echo "Unrecognized target platform: $target" exit 1 esac export CMAKE_TOOLCHAIN_FILE="$PROJECT_DIR/cmake/toolchain/$PLATFORM.cmake" - export CMAKE_PREFIX_PATH="$PROJECT_DIR/local/$PLATFORM" BUILD_DIR="build-$PLATFORM" + case $target in + *-lib*) + CMAKE_BUILD_TYPE=Release ./getlibs.sh $PLATFORM + BUILD_EXTRA="$BUILD_EXTRA -DFIND_FATAL=ON" + export CMAKE_PREFIX_PATH="$PROJECT_DIR/local/$PLATFORM" + ;; + esac + case $target in *-ubsan-*) BUILD_EXTRA="$BUILD_EXTRA -DUBSAN=ON" @@ -68,7 +78,8 @@ for target in $targets ; do echo "Building $target${BUILD_EXTRA:+ with$BUILD_EXTRA} into $BUILD_DIR" echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" - cmake -S "$PROJECT_DIR" -B "$BUILD_DIR" $BUILD_EXTRA -DFIND_FATAL=ON + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + cmake -S "$PROJECT_DIR" -B "$BUILD_DIR" $BUILD_EXTRA cmake --build "$BUILD_DIR" --config $CMAKE_BUILD_TYPE (cd "$BUILD_DIR" ; ctest -C $CMAKE_BUILD_TYPE --output-on-failure) done diff --git a/getlibs.sh b/getlibs.sh index fcc7f51..d937072 100755 --- a/getlibs.sh +++ b/getlibs.sh @@ -13,57 +13,68 @@ fi SOURCES="$PROJECT_DIR/local/sources" mkdir -p "$SOURCES" -cd "$SOURCES" [ -n "$CMAKE_BUILD_TYPE" ] || export CMAKE_BUILD_TYPE=Release for target in $targets ; do PREFIX="$PROJECT_DIR/local/$target" - export CMAKE_TOOLCHAIN_FILE="$PROJECT_DIR/cmake/toolchain/$target.cmake" export CMAKE_PREFIX_PATH="$PREFIX" export CMAKE_INSTALL_PREFIX="$PREFIX" # doctest for unit testing - PACKAGE=doctest + NAME=doctest VERSION=2.4.11 - ARCHIVE="$PACKAGE-$VERSION.tar.gz" - SOURCE_DIR="$PACKAGE-$VERSION" - BUILD_DIR="build-${SOURCE_DIR}-$target" - [ -r "$ARCHIVE" ] || curl -sL "https://github.com/doctest/doctest/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" - [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" - echo "Building $SOURCE_DIR" - echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" - echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" - echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" - echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" - echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" - cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DDOCTEST_WITH_TESTS=OFF \ + LIBRARY="${NAME}-${VERSION}" + if [ -r "$PREFIX/include/doctest/doctest.h" ] ; then + echo "$LIBRARY is already installed in $PREFIX" + else + ARCHIVE="${LIBRARY}.tar.gz" + SOURCE="${SOURCES}/${LIBRARY}" + BUILD="${PREFIX}/build-${LIBRARY}" + pushd "$SOURCES" + [ -r "$ARCHIVE" ] || curl -sL "https://github.com/doctest/doctest/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" + [ -d "$SOURCE" ] || tar -xf "$ARCHIVE" + popd + echo "Building $LIBRARY in $BUILD" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" + echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" + cmake -S "$SOURCE" -B "$BUILD" -DDOCTEST_WITH_TESTS=OFF \ -DDOCTEST_WITH_MAIN_IN_STATIC_LIB=ON -DDOCTEST_USE_STD_HEADERS=OFF - cmake --build "$BUILD_DIR" --config Release - cmake --install "$BUILD_DIR" --config Release --prefix "$CMAKE_INSTALL_PREFIX" - rm -Rf "$BUILD_DIR" - rm -Rf "$SOURCE_DIR" + cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE + cmake --install "$BUILD" --config $CMAKE_BUILD_TYPE --prefix "$CMAKE_INSTALL_PREFIX" + rm -Rf "$BUILD" + rm -Rf "$SOURCE" + fi # UUtils various low level Uppaal utilities - #git clone https://github.com/UPPAALModelChecker/UUtils "$SOURCE_DIR/libs/sources/UUtils"; - PACKAGE=UUtils + NAME=UUtils VERSION=2.0.3 - ARCHIVE="$PACKAGE-$VERSION.tar.gz" - SOURCE_DIR="$PACKAGE-$VERSION" - BUILD_DIR="build-${SOURCE_DIR}-$target" - [ -r "$ARCHIVE" ] || curl -sL "https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" - [ -d "$SOURCE_DIR" ] || tar -xf "$ARCHIVE" -# git clone -b cmake-alias --single-branch --depth 1 https://github.com/mikucionisaau/UUtils.git "$SOURCE_DIR" - echo "Building $SOURCE_DIR" - echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" - echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" - echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" - echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" - echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" - cmake -S "$SOURCE_DIR" -B "$BUILD_DIR" -DUUtils_WITH_TESTS=OFF -DUUtils_WITH_BENCHMARKS=OFF - cmake --build "$BUILD_DIR" --config Release - cmake --install "$BUILD_DIR" --config Release --prefix="$CMAKE_INSTALL_PREFIX" - rm -Rf "$BUILD_DIR" - rm -Rf "$SOURCE_DIR" + LIBRARY="${NAME}-${VERSION}" + if [ -r "$PREFIX/include/base/Enumerator.h" ]; then + echo "$LIBRARY is already installed in $PREFIX" + else + ARCHIVE="${LIBRARY}.tar.gz" + SOURCE="${SOURCES}/${LIBRARY}" + BUILD="${PREFIX}/build-${LIBRARY}" + pushd "$SOURCES" + [ -r "$ARCHIVE" ] || curl -sL "https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" + [ -d "$SOURCE" ] || tar -xf "$ARCHIVE" + popd + # git clone -b cmake-alias --single-branch --depth 1 https://github.com/mikucionisaau/UUtils.git "$SOURCE_DIR" + echo "Building $LIBRARY in $BUILD" + echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" + echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" + echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" + echo " CMAKE_INSTALL_PREFIX=$CMAKE_INSTALL_PREFIX" + echo " CMAKE_GENERATOR=$CMAKE_GENERATOR" + cmake -S "$SOURCE" -B "$BUILD" -DUUtils_WITH_TESTS=OFF -DUUtils_WITH_BENCHMARKS=OFF + cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE + cmake --install "$BUILD" --config $CMAKE_BUILD_TYPE --prefix="$CMAKE_INSTALL_PREFIX" + rm -Rf "$BUILD" + rm -Rf "$SOURCE" + fi done diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 25400b4..815f15f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,9 @@ add_library(UDBM STATIC DBMAllocator.cpp dbm.c fed_dbm.cpp mingraph.c mingraph_r priced.cpp valuation.cpp) set_property(TARGET UDBM PROPERTY C_VISIBILITY_PRESET hidden) set_property(TARGET UDBM PROPERTY VISIBILITY_INLINES_HIDDEN ON) -set_target_properties(UDBM PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") +if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) # unknown argument: '-fno-keep-inline-dllexport' + set_target_properties(UDBM PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}") +endif() target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash) target_include_directories(UDBM From 35f28456d632504a4f868a1c4461b9b6d9bc2171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 13 Sep 2023 09:01:50 +0200 Subject: [PATCH 08/14] Fixes to GH CI build script --- .github/workflows/build.yml | 20 +++++++++----------- getlibs.sh | 11 +++++++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f00cb75..b4c7778 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v2 - name: Formatting run: find src include test -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\)$' | xargs clang-format -n -Werror - build-win64: + build-linux: strategy: fail-fast: false matrix: @@ -26,24 +26,22 @@ jobs: sanitizers: ON runs-on: ubuntu-latest env: - CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/{{ matrix.target }}.cmake - CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/{{ matrix.target }} + CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/${{ matrix.target }}.cmake + CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/${{ matrix.target }} CMAKE_BUILD_TYPE: Release CTEST_OUTPUT_ON_FAILURE: 1 - STATIC: ON + STATIC: OFF steps: - uses: actions/checkout@v2 - - name: Set default environment variables - run: echo "STATIC=OFF" >> "$GITHUB_ENV" - - name: Get MinGW64 dependencies - if: matrix.target == 'mingw' + - name: Install MinGW64 cross-compiler and wine + if: matrix.target == 'x86_64-w64-mingw32' run: | sudo apt-get -qqy update sudo apt-get -qqy install cmake make g++-mingw-w64-x86-64 mingw-w64-x86-64-dev mingw-w64-tools wine wine-binfmt sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix - name: Getlibs - run: ./getlibs.sh {{ matrix.target }} + run: ./getlibs.sh ${{ matrix.target }} - name: Build and test run: | echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" @@ -52,7 +50,7 @@ jobs: cmake -S . -B build -DUDBM_WITH_TESTS=ON -DUDBM_STATIC=$STATIC -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} -DENABLE_DBM_NEW=${{ matrix.newdbm }} cmake --build build --config $CMAKE_BUILD_TYPE (cd build ; ctest -C $CMAKE_BUILD_TYPE) - build-win64-native: + build-windows: runs-on: windows-latest env: CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake @@ -87,7 +85,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Get dependencies - run: brew install boost doctest && ./getlibs.sh + run: ./getlibs.sh x86_64-darwin - name: Build and test run: | echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" diff --git a/getlibs.sh b/getlibs.sh index d937072..8cbe589 100755 --- a/getlibs.sh +++ b/getlibs.sh @@ -4,11 +4,14 @@ set -eo pipefail PROJECT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" if [ $# -eq 0 ]; then - targets=$(uname --machine)-$(uname --kernel-name) - targets="${targets,,}" - echo "No targets specified on command line, assuming: $targets" + echo "Script $0 fetches, compiles and installs dependent libraries." + machine=$(uname --machine) + kernel=$(uname --kernel-name) + targets=${machine,,}-${kernel,,} + echo "Expects targets as arguments, for example: $targets" + exit 1 else - targets="$@" + targets="$@" fi SOURCES="$PROJECT_DIR/local/sources" From 13a021ec26b813767bf8d5a3d7cc21c804dbe1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 13 Sep 2023 09:21:43 +0200 Subject: [PATCH 09/14] Separated NIX into separate CI script and added WINEPATH for mingw64 --- .github/workflows/build-nix.yml | 34 ++++++++++++++++++++++++ .github/workflows/build.yml | 30 +++------------------ winepath-for | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/build-nix.yml create mode 100755 winepath-for diff --git a/.github/workflows/build-nix.yml b/.github/workflows/build-nix.yml new file mode 100644 index 0000000..83f5ef2 --- /dev/null +++ b/.github/workflows/build-nix.yml @@ -0,0 +1,34 @@ +--- +name: Build on NIX + +on: + workflow_dispatch: + +jobs: + build-nix: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Build and test + run: nix build -L + build-nix-mac: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Build and test + run: nix build -L + build-nix-cross: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: cachix/install-nix-action@v15 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Build and test + run: nix build -L .\#packages.crossPackage.x86_64-linux diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b4c7778..1e205fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,6 +40,9 @@ jobs: sudo apt-get -qqy install cmake make g++-mingw-w64-x86-64 mingw-w64-x86-64-dev mingw-w64-tools wine wine-binfmt sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix + WINEPATH=$($PWD/winepath-for ${{ matrix.target }}) + echo "WINEPATH=$WINEPATH" >> $GITHUB_ENV + echo "WINARCH=win64" >> $GITHUB_ENV - name: Getlibs run: ./getlibs.sh ${{ matrix.target }} - name: Build and test @@ -94,30 +97,3 @@ jobs: cmake -S . -B build -DUDBM_WITH_TESTS=ON -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} cmake --build build --config $CMAKE_BUILD_TYPE (cd build ; ctest -C $CMAKE_BUILD_TYPE) - build-nix: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v15 - with: - nix_path: nixpkgs=channel:nixos-unstable - - name: Build and test - run: nix build -L - build-nix-mac: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v15 - with: - nix_path: nixpkgs=channel:nixos-unstable - - name: Build and test - run: nix build -L - build-nix-cross: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v15 - with: - nix_path: nixpkgs=channel:nixos-unstable - - name: Build and test - run: nix build -L .\#packages.crossPackage.x86_64-linux diff --git a/winepath-for b/winepath-for new file mode 100755 index 0000000..5a0fac5 --- /dev/null +++ b/winepath-for @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -e + +if [ $# -eq 0 ]; then + echo "Script $0 prints WINEPATH to include MINGW and GCC runtime environments," + echo "so that libwinpthread-1.dll, libgcc_s_seh-1.dll etc are available everywhere." + echo "Takes the toolchain as an argument. For example:" + echo " x86_64-w64-mingw32 - for 64bit Windows binaries" + echo " i686-w64-mingw32 - for 32bit Windows binaries" + exit 1 +else + toolchain="$1" +fi + +CXX="${toolchain}-g++" + +if [ -z "$(command -v $CXX)" ]; then + echo "Failed to find a cross-compiler $CXX" + case $toolchain in + x86_64-w64-mingw32) + echo "Please install mingw-w64-x86-64-dev" + ;; + i686-w64-mingw32) + echo "Please install mingw-w64-i686-dev" + ;; + esac + exit 1 +fi + +if [ -z "$(command -v winepath)" ]; then + echo "Failed to find a winepath" + echo "Please install wine with winepath" + exit 1 +fi + +GCC_S_FILE=$($CXX --print-file-name libgcc_s.a) +GCC_S_FILE=$(realpath "$GCC_S_FILE") +GCC_RUNTIME_PATH=$(dirname "$GCC_S_FILE") +GCC_RUNTIME_WINEPATH=$(winepath --windows "$GCC_RUNTIME_PATH") + +WINPTHREAD_FILE=$($CXX --print-file-name libwinpthread-1.dll) +WINPTHREAD_FILE=$(realpath "$WINPTHREAD_FILE") +MINGW_RUNTIME_PATH=$(dirname "$WINPTHREAD_FILE") +MINGW_RUNTIME_WINEPATH=$(winepath --windows "$MINGW_RUNTIME_PATH") + +echo "${GCC_RUNTIME_WINEPATH};${MINGW_RUNTIME_WINEPATH}" From ca8f2217093c0136c61e4168a5ee0ee6d6e0b536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 13 Sep 2023 13:28:45 +0200 Subject: [PATCH 10/14] Updated UUtils-2.0.4, refactored build scripts --- .github/workflows/build.yml | 101 +++++++++++++++++++++--------------- cmake/UUtils.cmake | 4 +- getlibs.sh | 10 ++-- 3 files changed, 68 insertions(+), 47 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e205fc..11883c4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,5 @@ --- -name: Build and Test +name: Build on: push: @@ -11,7 +11,7 @@ jobs: formatting: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Formatting run: find src include test -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\)$' | xargs clang-format -n -Werror build-linux: @@ -27,12 +27,12 @@ jobs: runs-on: ubuntu-latest env: CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/${{ matrix.target }}.cmake - CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/${{ matrix.target }} CMAKE_BUILD_TYPE: Release CTEST_OUTPUT_ON_FAILURE: 1 + CTEST_TEST_TIMEOUT: 20 STATIC: OFF steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install MinGW64 cross-compiler and wine if: matrix.target == 'x86_64-w64-mingw32' run: | @@ -43,57 +43,74 @@ jobs: WINEPATH=$($PWD/winepath-for ${{ matrix.target }}) echo "WINEPATH=$WINEPATH" >> $GITHUB_ENV echo "WINARCH=win64" >> $GITHUB_ENV + - name: Build without getlibs + run: | + BUILD="build-${{ matrix.target }}-${CMAKE_BUILD_TYPE,,}" + cmake -S . -B "$BUILD" -DUDBM_STATIC=$STATIC -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} -DENABLE_DBM_NEW=${{ matrix.newdbm }} + cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE + (cd "$BUILD" ; ctest -C $CMAKE_BUILD_TYPE) - name: Getlibs run: ./getlibs.sh ${{ matrix.target }} - - name: Build and test + - name: Build with getlibs + run: | + BUILD="build-${{ matrix.target }}-libs-${CMAKE_BUILD_TYPE,,}" + cmake -S . -B "$BUILD" -DCMAKE_PREFIX_PATH="${{ github.workspace }}/local/${{ matrix.target }}" -DUDBM_STATIC=$STATIC -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} -DENABLE_DBM_NEW=${{ matrix.newdbm }} + cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE + (cd "$BUILD" ; ctest -C $CMAKE_BUILD_TYPE) + build-macos: + runs-on: macos-latest + env: + CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/x86_64-darwin.cmake + CMAKE_BUILD_TYPE: Debug + CTEST_OUTPUT_ON_FAILURE: 1 + CTEST_TEST_TIMEOUT: 20 + STATIC: ON + strategy: + fail-fast: false + matrix: + sanitizers: [ON, OFF] + steps: + - uses: actions/checkout@v3 + - name: Build without getlibs + run: | + BUILD=build-x86_64-darwin-$CMAKE_BUILD_TYPE + cmake -S . -B "$BUILD" -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} + cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE + (cd "$BUILD" ; ctest -C $CMAKE_BUILD_TYPE) + - name: Get dependencies + run: CMAKE_BUILD_TYPE=Release ./getlibs.sh x86_64-darwin + - name: Build with getlibs run: | - echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" - echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" - echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" - cmake -S . -B build -DUDBM_WITH_TESTS=ON -DUDBM_STATIC=$STATIC -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} -DENABLE_DBM_NEW=${{ matrix.newdbm }} - cmake --build build --config $CMAKE_BUILD_TYPE - (cd build ; ctest -C $CMAKE_BUILD_TYPE) + BUILD=build-x86_64-darwin-libs-$CMAKE_BUILD_TYPE + cmake -S . -B "$BUILD" -DCMAKE_PREFIX_PATH="${{ github.workspace }}/local/x86_64-darwin" -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} + cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE + (cd "$BUILD" ; ctest -C $CMAKE_BUILD_TYPE) build-windows: runs-on: windows-latest env: CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake - CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/x86_64-w64-mingw32 CMAKE_BUILD_TYPE: Release STATIC: ON CTEST_OUTPUT_ON_FAILURE: 1 + CTEST_TEST_TIMEOUT: 20 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 + - name: Build without getlibs + run: | + $env:BUILD='build-x86_64-windows' + cmake -S . -B $env:BUILD + cmake --build $env:BUILD --config $env:CMAKE_BUILD_TYPE + cd $env:BUILD + ctest -C $env:CMAKE_BUILD_TYPE - name: Get dependencies run: | vcpkg integrate install vcpkg install doctest --triplet x64-windows - bash ./getlibs.sh x86_64-w64-mingw32 - - name: Build and test - run: | - cmake -S . -B build -DUDBM_WITH_TESTS=ON - cmake --build build --config %CMAKE_BUILD_TYPE% - (cd build ; ctest -C %CMAKE_BUILD_TYPE%) - build-macos: - runs-on: macos-latest - env: - CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/x86_64-darwin.cmake - CMAKE_PREFIX_PATH: ${{ github.workspace }}/local/x86_64-darwin - CMAKE_BUILD_TYPE: Release - STATIC: ON - CTEST_OUTPUT_ON_FAILURE: 1 - strategy: - fail-fast: false - matrix: - sanitizers: [ON, OFF] - steps: - - uses: actions/checkout@v2 - - name: Get dependencies - run: ./getlibs.sh x86_64-darwin - - name: Build and test + pwsh -Command { $env:CMAKE_BUILD_TYPE=Release ; bash ./getlibs.sh x86_64-w64-mingw32 } + - name: Build with getlibs run: | - echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" - echo " CMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH" - echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" - cmake -S . -B build -DUDBM_WITH_TESTS=ON -DASAN=${{ matrix.sanitizers }} -DUBSAN=${{ matrix.sanitizers }} - cmake --build build --config $CMAKE_BUILD_TYPE - (cd build ; ctest -C $CMAKE_BUILD_TYPE) + $env:BUILD='build-x86_64-windows-libs' + cmake -S . -B $env:BUILD -DCMAKE_PREFIX_PATH="${{ github.workspace }}/local/x86_64-w64-mingw32" + cmake --build $env:BUILD --config $env:CMAKE_BUILD_TYPE + cd $env:BUILD + ctest -C $env:CMAKE_BUILD_TYPE diff --git a/cmake/UUtils.cmake b/cmake/UUtils.cmake index b64049d..9986609 100644 --- a/cmake/UUtils.cmake +++ b/cmake/UUtils.cmake @@ -1,4 +1,4 @@ -find_package(UUtils 2.0.2 COMPONENTS base hash debug QUIET) +find_package(UUtils 2.0.4 COMPONENTS base hash debug QUIET) if (UUtils_FOUND) message(STATUS "Found UUtils: ${UUtils_DIR}") @@ -15,7 +15,7 @@ else(UUtils_FOUND) #GIT_REPOSITORY https://github.com/mikucionisaau/UUtils.git #GIT_TAG cmake-alias GIT_REPOSITORY https://github.com/UPPAALModelChecker/UUtils.git - GIT_TAG v2.0.3 + GIT_TAG v2.0.4 GIT_SHALLOW TRUE # get only the last commit version GIT_PROGRESS TRUE # show progress of download # FIND_PACKAGE_ARGS NAMES doctest diff --git a/getlibs.sh b/getlibs.sh index 8cbe589..cd27808 100755 --- a/getlibs.sh +++ b/getlibs.sh @@ -17,7 +17,11 @@ fi SOURCES="$PROJECT_DIR/local/sources" mkdir -p "$SOURCES" -[ -n "$CMAKE_BUILD_TYPE" ] || export CMAKE_BUILD_TYPE=Release +if [ -z "${CMAKE_BUILD_TYPE+x}" ]; then + export CMAKE_BUILD_TYPE=Release +elif [ "$CMAKE_BUILD_TYPE" != Release ]; then + echo "WARNING: building libs with CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" +fi for target in $targets ; do PREFIX="$PROJECT_DIR/local/$target" @@ -55,7 +59,7 @@ for target in $targets ; do # UUtils various low level Uppaal utilities NAME=UUtils - VERSION=2.0.3 + VERSION=2.0.4 LIBRARY="${NAME}-${VERSION}" if [ -r "$PREFIX/include/base/Enumerator.h" ]; then echo "$LIBRARY is already installed in $PREFIX" @@ -66,8 +70,8 @@ for target in $targets ; do pushd "$SOURCES" [ -r "$ARCHIVE" ] || curl -sL "https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" [ -d "$SOURCE" ] || tar -xf "$ARCHIVE" + #git clone -b native-windows --single-branch --depth 1 https://github.com/mikucionisaau/UUtils.git "$LIBRARY" popd - # git clone -b cmake-alias --single-branch --depth 1 https://github.com/mikucionisaau/UUtils.git "$SOURCE_DIR" echo "Building $LIBRARY in $BUILD" echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" echo " CMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE" From 6b2006b4a0bd19b5a633bf889f641ecb1d9964b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 13 Sep 2023 14:05:18 +0200 Subject: [PATCH 11/14] Added missing header for MSVC --- .github/workflows/build.yml | 2 +- src/priced.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11883c4..78f801a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -89,7 +89,7 @@ jobs: runs-on: windows-latest env: CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake - CMAKE_BUILD_TYPE: Release + CMAKE_BUILD_TYPE: Debug STATIC: ON CTEST_OUTPUT_ON_FAILURE: 1 CTEST_TEST_TIMEOUT: 20 diff --git a/src/priced.cpp b/src/priced.cpp index 021a040..00b590e 100644 --- a/src/priced.cpp +++ b/src/priced.cpp @@ -18,6 +18,7 @@ #include +#include // transform #include #include #include From a573d79feaf69fb1d4a8f8500f9a265eca0c59b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Wed, 13 Sep 2023 14:08:36 +0200 Subject: [PATCH 12/14] Switch CI to release builds as tests are taking too long --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78f801a..dd61aba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,7 +61,7 @@ jobs: runs-on: macos-latest env: CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/x86_64-darwin.cmake - CMAKE_BUILD_TYPE: Debug + CMAKE_BUILD_TYPE: Release CTEST_OUTPUT_ON_FAILURE: 1 CTEST_TEST_TIMEOUT: 20 STATIC: ON @@ -89,7 +89,7 @@ jobs: runs-on: windows-latest env: CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake - CMAKE_BUILD_TYPE: Debug + CMAKE_BUILD_TYPE: Release STATIC: ON CTEST_OUTPUT_ON_FAILURE: 1 CTEST_TEST_TIMEOUT: 20 From aa17d96fe96d8ddd9ae2679a4fde16f4b632567f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Thu, 14 Sep 2023 13:26:50 +0200 Subject: [PATCH 13/14] Added SHA256 checking in getlibs and cleaned up some comment out script code --- CMakeLists.txt | 3 +-- cmake/UUtils.cmake | 6 ++---- getlibs.sh | 8 ++++++-- src/CMakeLists.txt | 6 +----- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9705e53..ce17a13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ include(GNUInstallDirs) option(UDBM_WITH_TESTS "UDBM Unit tests" ON) option(UDBM_STATIC "Static linking" OFF) +option(FIND_FATAL "Stop upon find_package errors" OFF) cmake_policy(SET CMP0048 NEW) # project() command manages VERSION variables set(CMAKE_CXX_STANDARD 17) @@ -38,8 +39,6 @@ if(UDBM_WITH_TESTS) enable_testing() endif(UDBM_WITH_TESTS) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include) - add_subdirectory("src") if(UDBM_WITH_TESTS) diff --git a/cmake/UUtils.cmake b/cmake/UUtils.cmake index 9986609..c9379b5 100644 --- a/cmake/UUtils.cmake +++ b/cmake/UUtils.cmake @@ -1,4 +1,4 @@ -find_package(UUtils 2.0.4 COMPONENTS base hash debug QUIET) +find_package(UUtils 2.0.5 COMPONENTS base hash debug QUIET) if (UUtils_FOUND) message(STATUS "Found UUtils: ${UUtils_DIR}") @@ -12,10 +12,8 @@ else(UUtils_FOUND) set(UUtils_WITH_BENCHMARKS OFF CACHE BOOL "UUtils benchmarks") FetchContent_Declare( UUtils - #GIT_REPOSITORY https://github.com/mikucionisaau/UUtils.git - #GIT_TAG cmake-alias GIT_REPOSITORY https://github.com/UPPAALModelChecker/UUtils.git - GIT_TAG v2.0.4 + GIT_TAG v2.0.5 GIT_SHALLOW TRUE # get only the last commit version GIT_PROGRESS TRUE # show progress of download # FIND_PACKAGE_ARGS NAMES doctest diff --git a/getlibs.sh b/getlibs.sh index cd27808..7c8b4f1 100755 --- a/getlibs.sh +++ b/getlibs.sh @@ -37,10 +37,12 @@ for target in $targets ; do echo "$LIBRARY is already installed in $PREFIX" else ARCHIVE="${LIBRARY}.tar.gz" + SHA256=632ed2c05a7f53fa961381497bf8069093f0d6628c5f26286161fbd32a560186 SOURCE="${SOURCES}/${LIBRARY}" BUILD="${PREFIX}/build-${LIBRARY}" pushd "$SOURCES" [ -r "$ARCHIVE" ] || curl -sL "https://github.com/doctest/doctest/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" + if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi [ -d "$SOURCE" ] || tar -xf "$ARCHIVE" popd echo "Building $LIBRARY in $BUILD" @@ -59,18 +61,20 @@ for target in $targets ; do # UUtils various low level Uppaal utilities NAME=UUtils - VERSION=2.0.4 + VERSION=2.0.5 LIBRARY="${NAME}-${VERSION}" if [ -r "$PREFIX/include/base/Enumerator.h" ]; then echo "$LIBRARY is already installed in $PREFIX" else ARCHIVE="${LIBRARY}.tar.gz" + SHA256=e213f936af73344de071a7794233a328028045c08df58ac9c637a0e6a2ad7b3f SOURCE="${SOURCES}/${LIBRARY}" BUILD="${PREFIX}/build-${LIBRARY}" pushd "$SOURCES" + #git clone -b dev-branch --single-branch --depth 1 https://github.com/UPPAALModelChecker/UUtils.git "$LIBRARY" [ -r "$ARCHIVE" ] || curl -sL "https://github.com/UPPAALModelChecker/UUtils/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE" + if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi [ -d "$SOURCE" ] || tar -xf "$ARCHIVE" - #git clone -b native-windows --single-branch --depth 1 https://github.com/mikucionisaau/UUtils.git "$LIBRARY" popd echo "Building $LIBRARY in $BUILD" echo " CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 815f15f..711f7cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,13 +9,9 @@ endif() target_link_libraries(UDBM PRIVATE UUtils::base UUtils::udebug UUtils::hash) target_include_directories(UDBM - PRIVATE - # where the library itself will look for its internal headers - ${PROJECT_BINARY_DIR}/include - ${PROJECT_SOURCE_DIR}/include PUBLIC # where top-level project will look for the library's public headers - $ + $ # dbm/config.h $ # where external projects will look for the library's public headers $ From a8f6185b60bce14a627eb81d68d413d538d3d0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Miku=C4=8Dionis?= Date: Thu, 14 Sep 2023 13:29:25 +0200 Subject: [PATCH 14/14] Version increment to 2.0.13 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce17a13..cfda5d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.16) -project(UDBM VERSION 2.0.11 LANGUAGES CXX C) +project(UDBM VERSION 2.0.13 LANGUAGES CXX C) include(CMakePackageConfigHelpers) include(GNUInstallDirs)