diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index d93f3e5..6055db5 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,15 +1,11 @@ +ARG VARIANT=debian-11 # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.205.2/containers/python-3/.devcontainer/base.Dockerfile - -# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster -ARG VARIANT="3.10-bullseye" -FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} - -# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 -ARG NODE_VERSION="none" -RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi +FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT} RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install lsb-release wget software-properties-common \ + && apt-get -y install lsb-release wget software-properties-common + +RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install build-essential ninja-build valgrind gdb lcov doxygen graphviz # Install latest cmake 3.22 so we have support for cmake presets and a better integration in IDEs @@ -25,12 +21,6 @@ RUN add-apt-repository 'deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullsey RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install clang-14 clangd-14 lldb-14 llvm-14 clang-format-14 clang-tidy-14 -# Install ccache -RUN apt-get -y install ccache - -# Clean-up -RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* - RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 100 RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-14 100 RUN update-alternatives --install /usr/bin/clang-apply-replacements clang-apply-replacements /usr/bin/clang-apply-replacements-14 100 @@ -43,25 +33,8 @@ RUN update-alternatives --install /usr/bin/scan-view scan-view /usr/bin/scan-vie RUN update-alternatives --install /usr/bin/llvm-cov llvm-cov /usr/bin/llvm-cov-14 100 RUN update-alternatives --install /usr/bin/llvm-profdata llvm-profdata /usr/bin/llvm-profdata-14 100 -# Our pip requirements rarely change, add them to the image. -COPY requirements.txt /tmp/pip-tmp/ -RUN if [ -f "/tmp/pip-tmp/requirements.txt" ]; then \ - pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ - && rm -rf /tmp/pip-tmp; \ - fi - -# Install global node packages and enable husky. -RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g husky standard-version @commitlint/cli @commitlint/config-conventional " 2>&1 +# Install ccache +RUN apt-get -y install ccache -# Setup oh-my-zsh and plugins for user vscode -ARG USERNAME=vscode -ARG USER_UID=1000 -ARG USER_GID=$USER_UID -COPY --chown=$USER_UID:$USER_GID .devcontainer/.zshrc /home/$USERNAME -RUN chmod 644 /home/$USERNAME/.zshrc -# the user we're applying this too (otherwise it most likely install for root) -USER $USERNAME -RUN git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/custom/themes/powerlevel10k -RUN git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions -RUN git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting -ENV SHELL=/bin/zsh +# Clean-up +RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ba99ba3..836ae1a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,9 +9,21 @@ // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 // Append -bullseye or -buster to pin to an OS version. // Use -bullseye variants on local on arm64/Apple Silicon. - "VARIANT": "3.10-bullseye", - // Options - "NODE_VERSION": "16" + "VARIANT": "debian-11" + } + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:1": { + "configureZshAsDefaultShell": true, + "userName": "vscode", + "uid": "1000", + "gid": "1000" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "16" + }, + "ghcr.io/devcontainers/features/python:1": { + "version": "os-provided" } }, // Set *default* container specific settings.json values on container create. @@ -28,10 +40,7 @@ "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint", - "python.experiments.optInto": [ - "pythonDeprecatePythonPath" - ], - "clangd.path": "/usr/bin/clangd-14", + "clangd.path": "/usr/bin/clangd-14" }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ @@ -52,8 +61,12 @@ ], // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "npx husky install < /dev/null", // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" -} + "remoteUser": "vscode", + "postCreateCommand": { + "git_dubious_fix": "git config --global --add safe.directory ${containerWorkspaceFolder}", + "commit_tools": "npm install -g husky standard-version @commitlint/cli @commitlint/config-conventional", + "enable_husky": "npx husky install < /dev/null", + "update_python_modules": "pip --disable-pip-version-check --no-cache-dir install -r requirements.txt" + } +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 4783ab0..ae39248 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { - "esbonio.sphinx.confDir": "doc", + "esbonio.sphinx.confDir": "${workspaceFolder}/doc", + "esbonio.sphinx.buildDir": "${workspaceFolder}/out/html", "editor.rulers": [ 80, 100 @@ -292,4 +293,4 @@ "files.exclude": { "**/.sphinx": true }, -} +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1faf9fc..40ea99d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,66 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [4.6.3](http://github.com/abdes/asap/compare/v4.6.2...v4.6.3) (2023-03-25) + +### Enhancements + +* Simplify `devcontainer` setup by using features and additional container + lifecycle commands. + +### Bug Fixes + +* enable profiling for test coverage for MSVC ([7348d0a](http://github.com/abdes/asap/commit/7348d0a36b05b2f2e9c517e5b981f2c218bd511e)), closes [#22](http://github.com/abdes/asap/issues/22) + +## [4.6.2](http://github.com/abdes/asap/compare/v4.6.1...v4.6.2) (2022-11-28) + +### Features + +* increase ccache hit rate ([a22a912](http://github.com/abdes/asap/commit/a22a91226060851fe9fc7e5bc0e51973df94d95c)) +* more robust handling of contract checking mode ([304e9ae](http://github.com/abdes/asap/commit/304e9aee1e8fb265be78163578c45ae22569e52b)) + + When linking against the contract checking and enforcement library + `asap-contract` (https://github.com/asap-projects/asap-contract), it is + possible to control the contract checking mode by passing a value for the + `CONTRACTS` option when adding any type of target with `asap_add_xxx` + API (e.g. asap_add_library. asap_add_test, etc): + + * CONTRACTS OFF : set contract checking mode to OFF + * CONTRACTS AUDIT : set contract checking mode to AUDIT + * CONTRACTS DEFAULT : set contract checking mode to DEFAULT + + * CONTRACTS AUTO : set contract checking mode using as a first priority the + value passed in the cmake option `OPTION_CONTRACT_MODE`. If none is present, + automatically set the mode based on the build configuration. For Debug -> + AUDIT, For Release and RelMinSize -> OFF, and for RelWithDebInfo -> DEFAULT. + + * CONTRACTS TESTING : indicates that contracts are being testing and the + target needs to have full control on the contract checking mode. Nothing + will be done here. + + The default setting is AUTO. + +### Bug Fixes + +* **build:** [#21](http://github.com/abdes/asap/issues/21) target option `WARNING` not propagated properly ([432cdaf](http://github.com/abdes/asap/commit/432cdaff1e5c8775d0d5c533dd0abe5eac229bd7)) + + By default, for every target we build, a compiler option will be added + to treat warnings as errors, unless the target is added with `WARNING` as + an option. + + When that option is used, we now properly propagate it to set the + corresponding compiler option to **NOT** treat warnings as errors. + + This is useful when 3rd party dependencies have include files that + generate warnings. + +## [4.6.1](http://github.com/abdes/asap/compare/v4.6.0...v4.6.1) (2022-09-20) + +### Bug Fixes + +* always add code coverage 'all' targets ([d7309a0](http://github.com/abdes/asap/commit/d7309a0806e11a46c73b700f12bccb424c62839b)) +* version-info test was added even when ASAP_BUILD_TESTS is OFF ([b566e7b](http://github.com/abdes/asap/commit/b566e7b555ffb40f8ab1eea43d9a965c5724ccf1)) + ## [4.6.0](http://github.com/abdes/asap/compare/v4.5.2...v4.6.0) (2022-09-20) ### Features diff --git a/CMakeLists.txt b/CMakeLists.txt index e491290..7900a90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,10 @@ endif() # project hierarchy include(LogHelpers) +# Setup our override file, in which we may cleanup cmake's default compiler +# options, based on what we are doing. +set(CMAKE_USER_MAKE_RULES_OVERRIDE "ResetInitialCompilerOptions") + # ------------------------------------------------------------------------------ # Project description and (meta) information # ------------------------------------------------------------------------------ diff --git a/cmake/AsapTargets.cmake b/cmake/AsapTargets.cmake index 6c605bf..a96fd3c 100644 --- a/cmake/AsapTargets.cmake +++ b/cmake/AsapTargets.cmake @@ -110,8 +110,32 @@ endfunction() # Target creation helpers # ------------------------------------------------------------------------------ +macro(_add_common_compiler_options target warnings) + # Set some common compiler options, and forward the 'WARNING' option if it was + # provided + if(warnings) + asap_set_compile_options(${target} WARNING) + else() + asap_set_compile_options(${target}) + endif() +endmacro() + function(asap_add_library target) - swift_add_library("${target}" ${ARGN}) + set(argOption EXCEPTIONS RTTI WARNING) + set(argSingle CONTRACTS) + set(argMulti) + + cmake_parse_arguments(x "${argOption}" "${argSingle}" "${argMulti}" ${ARGN}) + + if(x_WARNING) + set(warning_flag "WARNING") + else() + set(warning_flag) + endif() + + # Contrarily to swift default, we enable exceptions and RTTI for all targets + swift_add_library("${target}" EXCEPTIONS RTTI ${warning_flag} + ${x_UNPARSED_ARGUMENTS}) # We can refer to this target either with its standalone target name or with a # project scoped name (::) which we will alias to the target @@ -120,9 +144,9 @@ function(asap_add_library target) get_target_property(type ${target} TYPE) if(NOT ${type} STREQUAL "INTERFACE_LIBRARY") # Set some common private compiler defines - asap_set_compile_definitions(${target}) - # Set some common compiler options - asap_set_compile_options(${target}) + asap_set_compile_definitions(${target} CONTRACTS ${x_CONTRACTS}) + # Set common compiler options + asap_set_compile_options(${target} ${warning_flag}) # Generate export headers for the library asap_generate_export_headers(${target} ${META_MODULE_NAME}) @@ -138,33 +162,34 @@ function(asap_add_library target) endfunction() function(asap_add_executable target) - swift_add_executable("${target}" ${ARGN}) + set(argOption EXCEPTIONS RTTI WARNING) + set(argSingle CONTRACTS) + set(argMulti) + + cmake_parse_arguments(x "${argOption}" "${argSingle}" "${argMulti}" ${ARGN}) + + if(x_WARNING) + set(warning_flag "WARNING") + else() + set(warning_flag) + endif() + + # Contrarily to swift default, we enable exceptions and RTTI for all targets + swift_add_executable("${target}" EXCEPTIONS RTTI ${warning_flag} + ${x_UNPARSED_ARGUMENTS}) # Set some common private compiler defines - asap_set_compile_definitions(${target}) - # Set some common compiler options - asap_set_compile_options(${target}) + asap_set_compile_definitions(${target} CONTRACTS ${x_CONTRACTS}) + # Set common compiler options + asap_set_compile_options(${target} ${warning_flag}) set_target_properties(${target} PROPERTIES FOLDER "Executables") endfunction() function(asap_add_tool target) - swift_add_tool("${target}" ${ARGN}) - # Set some common private compiler defines - asap_set_compile_definitions(${target}) - # Set some common compiler options - asap_set_compile_options(${target}) + asap_add_executable(${target} ${ARGN}) set_target_properties(${target} PROPERTIES FOLDER "Tools") endfunction() function(asap_add_tool_library target) - swift_add_tool_library("${target}" ${ARGN}) - # Set some common private compiler defines - asap_set_compile_definitions(${target}) - # Set some common compiler options - asap_set_compile_options(${target}) - set_target_properties( - ${target} - PROPERTIES FOLDER "Tool Libraries" - VERSION ${META_MODULE_VERSION} - SOVERSION ${META_MODULE_VERSION_MAJOR} - DEBUG_POSTFIX "d") + asap_add_library(${target} ${ARGN}) + set_target_properties(${target} PROPERTIES FOLDER "Tool Libraries") endfunction() diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 8302129..659e6e3 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -7,8 +7,8 @@ # Do this only once for the project by checking if we already have loaded CPM # which will define the CURRENT_CPM_VERSION, and if that version is what we want # to have here. -if(NOT CURRENT_CPM_VERSION VERSION_EQUAL 0.35.6) - set(CPM_DOWNLOAD_VERSION 0.35.6) +if(NOT CURRENT_CPM_VERSION VERSION_EQUAL 0.38.1) + set(CPM_DOWNLOAD_VERSION 0.38.1) if(CPM_SOURCE_CACHE) # Expand relative path. This is important if the provided path contains a diff --git a/cmake/CompileDefinitions.cmake b/cmake/CompileDefinitions.cmake index 8f35cfd..0087236 100644 --- a/cmake/CompileDefinitions.cmake +++ b/cmake/CompileDefinitions.cmake @@ -7,64 +7,112 @@ include_guard(GLOBAL) # ------------------------------------------------------------------------------ -# Set a common set of compile definitions +# Set a common set of compile definitions. +# +# Compile definitions can be removed from the default set by passing REMOVE +# followed by a list of symbols, eg: +# +# asap_set_compile_definitions(sample-target REMOVE _CRT_SECURE_NO_WARNINGS) +# +# will prevent `_CRT_SECURE_NO_WARNINGS` from being passed to the compiler as a +# defined symbol for sample-target only. +# +# Similarly extra definitions can be added by passing ADD followed by a list of +# symbols (or definitions in the form of symbol=value), eg: +# +# asap_set_compile_definitions(sample-target ADD SUPER HERO=2) +# +# will pass SUPER and HERO=2 to the compiler as definitions for sample-target +# only. +# +# When linking against the contract checking and enforcement library +# `asap-contract` (https://github.com/asap-projects/asap-contract), it is +# possible to control the contract checking mode by passing a value for the +# `CONTRACTS` option to this function as follows: +# +# * CONTRACTS OFF : set contract checking mode to OFF +# * CONTRACTS AUDIT : set contract checking mode to AUDIT +# * CONTRACTS DEFAULT : set contract checking mode to DEFAULT +# +# * CONTRACTS AUTO : set contract checking mode using as a first priority the +# value passed in the cmake option `OPTION_CONTRACT_MODE`. If none is present, +# automatically set the mode based on the build configuration. For Debug -> +# AUDIT, For Release and RelMinSize -> OFF, and for RelWithDebInfo -> DEFAULT. +# +# * CONTRACTS TESTING : indicates that contracts are being testing and the +# target needs to have full control on the contract checking mode. Nothing +# will be done here. +# +# The default setting is AUTO. # ------------------------------------------------------------------------------ function(asap_set_compile_definitions target) - set(argOption "NO_CONTRACT") - set(argSingle "") + set(argOption "") + set(argSingle "CONTRACTS") set(argMulti "ADD" "REMOVE") - unset(x_WARNING) + unset(x_CONTRACTS) unset(x_ADD) unset(x_REMOVE) cmake_parse_arguments(x "${argOption}" "${argSingle}" "${argMulti}" ${ARGN}) + if(NOT DEFINED x_CONTRACTS OR x_CONTRACTS STREQUAL "") + set(x_CONTRACTS "AUTO") + endif() - set(all_flags) + set(all_definitions) # Provide a way to distinguish between debug and release builds via # preprocessor define - list(APPEND all_flags "$<$:ASAP_IS_DEBUG_BUILD>") + list(APPEND all_definitions "$<$:ASAP_IS_DEBUG_BUILD>") if(MSVC) - list(APPEND all_flags "NOMINMAX" "WIN32_LEAN_AND_MEAN=1" + list(APPEND all_definitions "NOMINMAX" "WIN32_LEAN_AND_MEAN=1" "_WIN32_WINNT=0x0600") # Disabling warning for not using "secure-but-not-standard" STL algos - list(APPEND all_flags "_CRT_SECURE_NO_WARNINGS" "_SCL_SECURE_NO_WARNINGS") + list(APPEND all_definitions "_CRT_SECURE_NO_WARNINGS" + "_SCL_SECURE_NO_WARNINGS") endif() if(x_REMOVE) - foreach(flag ${x_REMOVE}) - list(FIND all_flags ${flag} found) + foreach(definition ${x_REMOVE}) + list(FIND all_definitions ${definition} found) if(found EQUAL -1) message( FATAL_ERROR - "Compiler flag '${flag}' specified for removal is not part of the set of common - compiler flags") + "Compiler definition '${definition}' specified for removal is not " + "part of the set of common compiler definitions.") endif() endforeach() - list(REMOVE_ITEM all_flags ${x_REMOVE}) + list(REMOVE_ITEM all_definitions ${x_REMOVE}) endif() - list(APPEND all_flags ${x_ADD}) - target_compile_definitions(${target} PRIVATE ${all_flags}) + list(APPEND all_definitions ${x_ADD}) + + target_compile_definitions(${target} PRIVATE ${all_definitions}) - # If linking against asap_contract, set the contract mode based on the build - # type. Use generator expressions only, do not check for CMAKE_BUILD_TYPE - # which is not friendly with multi-config generators. - # - # Do not add this definition if we are testing asap-_contract - if(TARGET asap_contract AND NOT ASAP_CONTRACT_TESTING) - if(NOT DEFINED OPTION_CONTRACT_MODE) - target_compile_definitions( - ${target} - PRIVATE $<$:ASAP_CONTRACT_AUDIT> - $<$:ASAP_CONTRACT_DEFAULT> - $<$:ASAP_CONTRACT_OFF>) + # If linking against asap_contract, set the contract checking mode. Use + # generator expressions only, do not check for CMAKE_BUILD_TYPE which is not + # friendly with multi-config generators. + if(NOT x_CONTRACTS STREQUAL "TESTING") + if(x_CONTRACTS MATCHES "OFF|AUDIT|DEFAULT") + target_compile_definitions(${target} + PRIVATE "ASAP_CONTRACT_${x_CONTRACTS}") + elseif(x_CONTRACTS STREQUAL "AUTO") + if(NOT DEFINED OPTION_CONTRACT_MODE) + target_compile_definitions( + ${target} + PRIVATE $<$:ASAP_CONTRACT_AUDIT> + $<$:ASAP_CONTRACT_DEFAULT> + $<$:ASAP_CONTRACT_OFF>) + else() + target_compile_definitions( + ${target} PRIVATE "ASAP_CONTRACT_${OPTION_CONTRACT_MODE}") + endif() else() - target_compile_definitions( - ${target} PRIVATE "ASAP_CONTRACT_${OPTION_CONTRACT_MODE}") + message( + FATAL_ERROR "Contract mode '${x_CONTRACTS}' is not valid." + "Valid values are: OFF, DEFAULT, AUDIT, AUTO and TESTING.") endif() endif() endfunction() diff --git a/cmake/CompileOptions.cmake b/cmake/CompileOptions.cmake index c29a760..0f5e8bd 100644 --- a/cmake/CompileOptions.cmake +++ b/cmake/CompileOptions.cmake @@ -16,8 +16,6 @@ # RTTI. By default, both are enabled. function(asap_set_compile_options) - swift_set_compile_options(EXCEPTIONS RTTI ${ARGV}) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # using Clang swift_set_compile_options( @@ -46,13 +44,22 @@ function(asap_set_compile_options) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # using Visual Studio C++ - set(argOption "WARNING" "NO_EXCEPTIONS" "EXCEPTIONS" "NO_RTTI" "RTTI") + set(argOption "WARNING") set(argSingle "") - set(argMulti "ADD" "REMOVE" "EXTRA_FLAGS") + set(argMulti "") + cmake_parse_arguments(x "${argOption}" "${argSingle}" "${argMulti}" ${ARGN}) + set(targets ${x_UNPARSED_ARGUMENTS}) + foreach(target ${targets}) target_compile_options(${target} PRIVATE /EHsc /MP /W4) + if(NOT x_WARNING) + target_compile_options(${target} PRIVATE /WX) + endif() + # Enable coverage profiling in Debug builds + # (see https://github.com/abdes/asap/issues/22) + target_link_options(${target} PRIVATE $<$:/PROFILE>) endforeach() endif() diff --git a/cmake/ResetInitialCompilerOptions.cmake b/cmake/ResetInitialCompilerOptions.cmake new file mode 100644 index 0000000..97ba6fb --- /dev/null +++ b/cmake/ResetInitialCompilerOptions.cmake @@ -0,0 +1,35 @@ +# ===-----------------------------------------------------------------------===# +# Distributed under the 3-Clause BSD License. See accompanying file LICENSE or +# copy at https://opensource.org/licenses/BSD-3-Clause). +# SPDX-License-Identifier: BSD-3-Clause +# ===-----------------------------------------------------------------------===# + +# This module is loaded by `cmake` while enabling support for each language from +# either the project() or enable_language() commands. It is loaded after CMake's +# builtin compiler and platform information modules have been loaded but before +# the information is used. The file may set platform information variables to +# override CMake's defaults. +# +# To load this module, set the variable `CMAKE_USER_MAKE_RULES_OVERRIDE` before +# you declare the project or enable a language: +# ~~~ +# set(CMAKE_USER_MAKE_RULES_OVERRIDE "ResetInitialCompilerOptions") +# ~~~ + +# We use this module to strip compiler options that are not really needed but +# will cause compatibility issues with `ccache`. +if(MSVC AND USE_CCACHE) + # As of ccache 4.6, /Zi option automatically added by cmake is unsupported. + # Given that we are doing ccache only in development environments (USE_CCACHE + # controls if ccache is enabled), we can just strip that option. + macro(strip_unwanted_options_from cmake_flags) + if(${cmake_flags} MATCHES "/Zi") + string(REPLACE "/Zi" "/Z7" ${cmake_flags} ${${cmake_flags}}) + endif() + endmacro() + strip_unwanted_options_from(CMAKE_CXX_FLAGS_DEBUG_INIT) + strip_unwanted_options_from(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT) + strip_unwanted_options_from(CMAKE_C_FLAGS_DEBUG_INIT) + strip_unwanted_options_from(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT) + set(first_time FALSE) +endif() diff --git a/cmake/TestTargets.cmake b/cmake/TestTargets.cmake index 27ee346..73214ef 100644 --- a/cmake/TestTargets.cmake +++ b/cmake/TestTargets.cmake @@ -7,10 +7,17 @@ include(common/TestTargets) macro(asap_add_test target) - swift_add_test("${target}" ${ARGN}) + set(argOption) + set(argSingle CONTRACTS) + set(argMulti) + + cmake_parse_arguments(x "${argOption}" "${argSingle}" "${argMulti}" ${ARGN}) + + # Contrarily to swift default, we enable exceptions and RTTI for all targets + swift_add_test("${target}" ${warning_flag} ${x_UNPARSED_ARGUMENTS}) # Set some common private compiler defines - asap_set_compile_definitions(${target}) - # Set some common compiler options + asap_set_compile_definitions(${target} CONTRACTS ${x_CONTRACTS}) + # Set common compiler options asap_set_compile_options(${target}) if(TARGET gtest AND BUILD_SHARED_LIBS) target_compile_definitions(${target} PRIVATE GTEST_LINKED_AS_SHARED_LIBRARY) @@ -31,9 +38,16 @@ macro(asap_add_test_runner target) endmacro() function(asap_add_test_library target) - swift_add_test_library("${target}" ${ARGN}) + set(argOption) + set(argSingle CONTRACTS) + set(argMulti) + + cmake_parse_arguments(x "${argOption}" "${argSingle}" "${argMulti}" ${ARGN}) + + # Contrarily to swift default, we enable exceptions and RTTI for all targets + swift_add_test_library("${target}" ${x_UNPARSED_ARGUMENTS}) # Set some common private compiler defines - asap_set_compile_definitions(${target}) + asap_set_compile_definitions(${target} CONTRACTS ${x_CONTRACTS}) # Set some common compiler options asap_set_compile_options(${target}) set_target_properties( diff --git a/cmake/common b/cmake/common index 8ac5ddd..d7a20ec 160000 --- a/cmake/common +++ b/cmake/common @@ -1 +1 @@ -Subproject commit 8ac5ddda00cfe959ea63cd9b0fb6e2282e062bb6 +Subproject commit d7a20ec514ef83525d734d8ee39e03c712adbedc diff --git a/contract-ut/doc/conf.py.in b/contract-ut/doc/conf.py.in index 3ba5708..43500e5 100644 --- a/contract-ut/doc/conf.py.in +++ b/contract-ut/doc/conf.py.in @@ -88,7 +88,7 @@ master_doc = 'index' # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' @@ -120,7 +120,7 @@ html_theme_options = { "use_fullscreen_button": True, # We don't want the default navigation bar footer to be displayed on every # page. Mention of the book theme will be added in the home page. - "extra_navbar": "" + "extra_footer": "" } # -- Extension configuration ------------------------------------------------- diff --git a/contract-ut/test/CMakeLists.txt b/contract-ut/test/CMakeLists.txt index 15468e0..170ccec 100644 --- a/contract-ut/test/CMakeLists.txt +++ b/contract-ut/test/CMakeLists.txt @@ -16,9 +16,6 @@ if(ASAP_WITH_GOOGLE_ASAN return() endif() -# Set this to ON to inhibit adding compiler definitions for contract modes -set(ASAP_CONTRACT_TESTING ON) - # ------------------------------------------------------------------------------ # Unit Test Macros # ------------------------------------------------------------------------------ @@ -28,6 +25,8 @@ set(target_name ${MODULE_TARGET_NAME}_contract_ut_test) asap_add_test( ${target_name} UNIT_TEST + CONTRACTS + DEFAULT VALGRIND_MEMCHECK SRCS # headers @@ -44,6 +43,4 @@ asap_add_test( COMMENT "Contract unit test macros tests") -target_compile_definitions(${target_name} PRIVATE ASAP_CONTRACT_DEFAULT) - gtest_discover_tests(${target_name}) diff --git a/contract/doc/conf.py.in b/contract/doc/conf.py.in index a90beb0..8f1a086 100644 --- a/contract/doc/conf.py.in +++ b/contract/doc/conf.py.in @@ -88,7 +88,7 @@ master_doc = 'index' # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = "en" # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' @@ -120,7 +120,7 @@ html_theme_options = { "use_fullscreen_button": True, # We don't want the default navigation bar footer to be displayed on every # page. Mention of the book theme will be added in the home page. - "extra_navbar": "" + "extra_footer": "" } # -- Extension configuration ------------------------------------------------- diff --git a/contract/test/CMakeLists.txt b/contract/test/CMakeLists.txt index 0e08ec9..32a87a8 100644 --- a/contract/test/CMakeLists.txt +++ b/contract/test/CMakeLists.txt @@ -16,9 +16,6 @@ if(ASAP_WITH_GOOGLE_ASAN return() endif() -# Set this to ON to inhibit adding compiler definitions for contract modes -set(ASAP_CONTRACT_TESTING ON) - # ------------------------------------------------------------------------------ # Default mode tests # ------------------------------------------------------------------------------ @@ -27,6 +24,8 @@ set(target_name ${MODULE_TARGET_NAME}_contract_default_test) asap_add_test( ${target_name} + CONTRACTS + DEFAULT UNIT_TEST VALGRIND_MEMCHECK SRCS @@ -46,8 +45,6 @@ asap_add_test( COMMENT "Contract unit tests in DEFAULT build mode") -target_compile_definitions(${target_name} PRIVATE ASAP_CONTRACT_DEFAULT) - gtest_discover_tests(${target_name}) # ------------------------------------------------------------------------------ @@ -59,6 +56,8 @@ set(target_name ${MODULE_TARGET_NAME}_contract_off_test) asap_add_test( ${target_name} UNIT_TEST + CONTRACTS + OFF VALGRIND_MEMCHECK SRCS # headers @@ -76,8 +75,6 @@ asap_add_test( COMMENT "Contract unit tests in OFF build mode") -target_compile_definitions(${target_name} PRIVATE ASAP_CONTRACT_OFF) - gtest_discover_tests(${target_name}) # ------------------------------------------------------------------------------ @@ -89,6 +86,8 @@ set(target_name ${MODULE_TARGET_NAME}_contract_audit_test) asap_add_test( ${target_name} UNIT_TEST + CONTRACTS + AUDIT VALGRIND_MEMCHECK SRCS # headers @@ -106,6 +105,4 @@ asap_add_test( COMMENT "Contract unit tests in AUDIT build mode") -target_compile_definitions(${target_name} PRIVATE ASAP_CONTRACT_AUDIT) - gtest_discover_tests(${target_name}) diff --git a/doc/conf.py.in b/doc/conf.py.in index 6b361fa..320dd64 100644 --- a/doc/conf.py.in +++ b/doc/conf.py.in @@ -84,7 +84,7 @@ master_doc = 'index' # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' @@ -115,7 +115,7 @@ html_theme_options = { "use_fullscreen_button": True, # We don't want the default navigation bar footer to be displayed on every # page. Mention of the book theme will be added in the home page. - "extra_navbar": "" + "extra_footer": "" } # -- Extension configuration ------------------------------------------------- diff --git a/doc/index.rst b/doc/index.rst index 06b404e..7464f93 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -60,7 +60,7 @@ use the project artifacts.* Acknowledgements ================ -.. figure:: https://executablebooks.org/en/latest/_static/logo-wide.png +.. figure:: https://executablebooks.org/en/latest/_static/logo-wide.svg :figclass: margin :alt: Executable Books Project :name: executable_book_logo diff --git a/doxygen/doxygen-awesome-css b/doxygen/doxygen-awesome-css index a3c119b..245c7c9 160000 --- a/doxygen/doxygen-awesome-css +++ b/doxygen/doxygen-awesome-css @@ -1 +1 @@ -Subproject commit a3c119b4797be2039761ec1fa0731f038e3026f6 +Subproject commit 245c7c94c20eac22730ef89035967f78b77bf405