Skip to content

Commit

Permalink
Merge branch 'main' into feat/install_runtimes_for_3rd_party
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims committed Oct 5, 2024
2 parents 9ccd37f + bd2be71 commit 7462a2a
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 80 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ jobs:
vcpkg: true
conan: 2.6.0
cppcheck: true
clangtidy: true
cmakelang: true
clang-tidy: true
task: true
doxygen: true
python: true
Expand All @@ -80,5 +81,4 @@ jobs:

- name: Lint
run: |
pipx install cmakelang[YAML]
task lint
22 changes: 11 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: docs
on:
push:
branches:
- main
tags:
- "*"
workflow_dispatch:

jobs:
Test:
Expand Down Expand Up @@ -36,12 +37,11 @@ jobs:
git checkout main
task docs
# TODO Automatic deploys fail
# - name: Deploy Documentation
# uses: Cecilapp/GitHub-Pages-deploy@v3
# with:
# build_dir: docs/build/html/
# branch: gh-pages
# email: [email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy Documentation
uses: Cecilapp/GitHub-Pages-deploy@v3
with:
build_dir: docs/build/
branch: gh-pages
email: ${{ github.actor }}@users.noreply.github.com
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ endif()
# Add project_options from https://github.com/aminya/project_options
# Change the version in the following URL to update the package (watch the releases of the repository for future updates)
set(PROJECT_OPTIONS_VERSION "v0.36.4")
set(PROJECT_OPTIONS_VERSION "v0.36.5")
FetchContent_Declare(
_project_options
URL https://github.com/aminya/project_options/archive/refs/tags/${PROJECT_OPTIONS_VERSION}.zip)
Expand All @@ -77,7 +77,7 @@ include(${_project_options_SOURCE_DIR}/Index.cmake)
# install vcpkg dependencies: - should be called before defining project()
run_vcpkg(
VCPKG_URL "https://github.com/microsoft/vcpkg.git"
VCPKG_REV "10e052511428d6b0c7fcc63a139e8024bb146032"
VCPKG_REV "86a181505ac6460f98496a79abdee6a0f49905ec"
)
# Install conan dependencies: - should be called before defining project()
run_conan()
Expand All @@ -101,7 +101,7 @@ if(FEATURE_TESTS)
set(ENABLE_COVERAGE "ENABLE_COVERAGE")
set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS")
set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR")
set(ENABLE_SANITIZER_UNDEFINED "ENABLE_SANITIZER_UNDEFINED")
endif()
# Enable doxgen for the docs
Expand All @@ -123,7 +123,7 @@ project_options(
${ENABLE_DOXYGEN}
${ENABLE_COVERAGE}
${ENABLE_SANITIZER_ADDRESS}
${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR}
${ENABLE_SANITIZER_UNDEFINED}
# ${ENABLE_SANITIZER_THREAD}
# ${ENABLE_SANITIZER_MEMORY}
# ENABLE_SANITIZER_POINTER_COMPARE
Expand Down
1 change: 1 addition & 0 deletions docs/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tasks:
- cmake -S ./ -B ./build -G "Ninja Multi-Config" -DCMAKE_BUILD_TYPE=Release
- cmake --build ./build --config Release
- touch ./build/.nojekyll
- rm -rf ./build/*.ninja ./build/*log ./build/*.py ./build/CMakeFiles ./build/CMakeCache.txt ./build/*.cmake

docs.preview:
deps:
Expand Down
9 changes: 4 additions & 5 deletions docs/src/project_options_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endif()
# Add project_options from https://github.com/aminya/project_options
# Change the version in the following URL to update the package (watch the releases of the repository for future updates)
set(PROJECT_OPTIONS_VERSION "v0.36.4")
set(PROJECT_OPTIONS_VERSION "v0.36.5")
FetchContent_Declare(
_project_options
URL https://github.com/aminya/project_options/archive/refs/tags/${PROJECT_OPTIONS_VERSION}.zip)
Expand All @@ -30,8 +30,7 @@ include(${_project_options_SOURCE_DIR}/Index.cmake)
# install vcpkg dependencies: - should be called before defining project()
run_vcpkg(
VCPKG_URL "https://github.com/microsoft/vcpkg.git"
VCPKG_REV "10e052511428d6b0c7fcc63a139e8024bb146032"
ENABLE_VCPKG_UPDATE
VCPKG_REV "86a181505ac6460f98496a79abdee6a0f49905ec"
)
# Install conan dependencies: - should be called before defining project()
run_conan()
Expand All @@ -55,7 +54,7 @@ if(FEATURE_TESTS)
set(ENABLE_COVERAGE "ENABLE_COVERAGE")
set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS")
set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR")
set(ENABLE_SANITIZER_UNDEFINED "ENABLE_SANITIZER_UNDEFINED")
endif()
# Enable doxgen for the docs
Expand All @@ -77,7 +76,7 @@ project_options(
${ENABLE_DOXYGEN}
${ENABLE_COVERAGE}
${ENABLE_SANITIZER_ADDRESS}
${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR}
${ENABLE_SANITIZER_UNDEFINED}
# ${ENABLE_SANITIZER_THREAD}
# ${ENABLE_SANITIZER_MEMORY}
# ENABLE_SANITIZER_POINTER_COMPARE
Expand Down
39 changes: 15 additions & 24 deletions src/DynamicProjectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Here is an example of how to use ``dynamic_project_options``:

# Add project_options from https://github.com/aminya/project_options
# Change the version in the following URL to update the package (watch the releases of the repository for future updates)
set(PROJECT_OPTIONS_VERSION "v0.36.4")
set(PROJECT_OPTIONS_VERSION "v0.36.5")
FetchContent_Declare(
_project_options
URL https://github.com/aminya/project_options/archive/refs/tags/${PROJECT_OPTIONS_VERSION}.zip)
Expand Down Expand Up @@ -103,27 +103,18 @@ macro(dynamic_project_options)
)
endif()

check_sanitizers_support(
ENABLE_SANITIZER_ADDRESS
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_THREAD
ENABLE_SANITIZER_MEMORY
ENABLE_SANITIZER_POINTER_COMPARE
ENABLE_SANITIZER_POINTER_SUBTRACT
)

if(ENABLE_SANITIZER_ADDRESS)
set(SUPPORTS_ASAN ON)
else()
set(SUPPORTS_ASAN OFF)
endif()
# Fallback for ENABLE_SANITIZER_UNDEFINED_BEHAVIOR option
foreach(default_type IN ITEMS DEFAULT DEVELOPER_DEFAULT USER_DEFAULT)
if(DEFINED ENABLE_SANITIZER_UNDEFINED_BEHAVIOR_${default_type})
if(DEFINED ENABLE_SANITIZER_UNDEFINED_${default_type})
message(WARNING "Don't set both ENABLE_SANITIZER_UNDEFINED_BEHAVIOR_${default_type} and ENABLE_SANITIZER_UNDEFINED_${default_type}. Use ENABLE_SANITIZER_UNDEFINED_${default_type} only.")
else()
message(DEPRECATION "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR_${default_type} is deprecated. Use ENABLE_SANITIZER_UNDEFINED_${default_type} instead.")
endif()

if(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR)
set(SUPPORTS_UBSAN ON)
else()
set(SUPPORTS_UBSAN OFF)
endif()
set(ENABLE_SANITIZER_UNDEFINED_${default_type} ${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR_${default_type}})
endif()
endforeach()

# ccache, clang-tidy, cppcheck are only supported with Ninja and Makefile based generators
# note that it is possible to use Ninja with cl, so this still allows clang-tidy on Windows
Expand Down Expand Up @@ -163,9 +154,9 @@ macro(dynamic_project_options)
"0\;DISABLE_RTTI\;OFF\;OFF\;Disable RTTI (no-rtti flag)"
"0\;ENABLE_BUILD_WITH_TIME_TRACE\;OFF\;OFF\;Generates report of where compile-time is spent"
"0\;ENABLE_UNITY\;OFF\;OFF\;Merge C++ files into larger C++ files, can speed up compilation sometimes"
"0\;ENABLE_SANITIZER_ADDRESS\;OFF\;${SUPPORTS_ASAN}\;Make memory errors into hard runtime errors (windows/linux/macos)"
"0\;ENABLE_SANITIZER_ADDRESS\;OFF\;ON\;Make memory errors into hard runtime errors (windows/linux/macos)"
"0\;ENABLE_SANITIZER_LEAK\;OFF\;OFF\;Make memory leaks into hard runtime errors"
"0\;ENABLE_SANITIZER_UNDEFINED_BEHAVIOR\;OFF\;${SUPPORTS_UBSAN}\;Make certain types (numeric mostly) of undefined behavior into runtime errors"
"0\;ENABLE_SANITIZER_UNDEFINED\;OFF\;ON\;Make certain types (numeric mostly) of undefined behavior into runtime errors"
"0\;ENABLE_SANITIZER_THREAD\;OFF\;OFF\;Make thread race conditions into hard runtime errors"
"0\;ENABLE_SANITIZER_MEMORY\;OFF\;OFF\;Make other memory errors into runtime errors"
"0\;ENABLE_CONTROL_FLOW_PROTECTION\;OFF\;OFF\;Enable control flow protection instrumentation"
Expand Down Expand Up @@ -277,7 +268,7 @@ macro(dynamic_project_options)
${ENABLE_UNITY_VALUE}
${ENABLE_SANITIZER_ADDRESS_VALUE}
${ENABLE_SANITIZER_LEAK_VALUE}
${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR_VALUE}
${ENABLE_SANITIZER_UNDEFINED_VALUE}
${ENABLE_SANITIZER_THREAD_VALUE}
${ENABLE_SANITIZER_MEMORY_VALUE}
${ENABLE_CONTROL_FLOW_PROTECTION_VALUE}
Expand Down
15 changes: 7 additions & 8 deletions src/Git.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,16 @@ function(git_add_remote)

find_program(GIT_EXECUTABLE "git" REQUIRED)

# ensure that the given repository's remote is the current remote
# Get the list of the remotes
execute_process(
COMMAND "${GIT_EXECUTABLE}" "remote" "-v" WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}"
COMMAND_ERROR_IS_FATAL LAST
OUTPUT_VARIABLE _remote_output
)
string(FIND "${_remote_output}" "${_fun_REMOTE_URL}" _find_index)
# Remove .git from the URL
string(REGEX REPLACE "^(.*)\.git$" "\\1" _fun_REMOTE_URL_no_git "${_fun_REMOTE_URL}")
# Check if the given remote already exists in the remote list
string(FIND "${_remote_output}" "${_fun_REMOTE_URL_no_git}" _find_index)

# Add the given remote if it doesn't exist
if(${_find_index} EQUAL -1)
Expand All @@ -343,12 +346,8 @@ function(git_add_remote)
endif()

execute_process(
COMMAND "${GIT_EXECUTABLE}" "remote" "add" "${_fun_REMOTE_NAME}" "${_fun_REMOTE_URL}"
WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}" COMMAND_ERROR_IS_FATAL LAST
)
execute_process(
COMMAND "${GIT_EXECUTABLE}" "fetch" "${_fun_REMOTE_NAME}" WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}"
COMMAND_ERROR_IS_FATAL LAST
COMMAND "${GIT_EXECUTABLE}" "remote" "add" "--fetch" "${_fun_REMOTE_NAME}" "${_fun_REMOTE_URL}"
WORKING_DIRECTORY "${_fun_REPOSITORY_PATH}"
)
endif()
endfunction()
Expand Down
18 changes: 15 additions & 3 deletions src/Index.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ include("${ProjectOptions_SRC_DIR}/Vcpkg.cmake")
those.
- ``ENABLE_SANITIZER_ADDRESS``: Enable address sanitizer
- ``ENABLE_SANITIZER_LEAK``: Enable leak sanitizer
- ``ENABLE_SANITIZER_UNDEFINED_BEHAVIOR``: Enable undefined behavior
- ``ENABLE_SANITIZER_UNDEFINED``: Enable undefined behavior
sanitizer
- ``ENABLE_SANITIZER_THREAD``: Enable thread sanitizer
- ``ENABLE_SANITIZER_MEMORY``: Enable memory sanitizer
Expand Down Expand Up @@ -148,7 +148,8 @@ macro(project_options)
ENABLE_UNITY
ENABLE_SANITIZER_ADDRESS
ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
ENABLE_SANITIZER_UNDEFINED
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR # deprecated, ENABLE_SANITIZER_UNDEFINED
ENABLE_SANITIZER_THREAD
ENABLE_SANITIZER_MEMORY
ENABLE_SANITIZER_POINTER_COMPARE
Expand Down Expand Up @@ -260,12 +261,23 @@ macro(project_options)
enable_coverage(${_options_target})
endif()

# Fallback for deprecated ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
if(ProjectOptions_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR)
if(ProjectOptions_ENABLE_SANITIZER_UNDEFINED)
message(WARNING "Don't switch on both ENABLE_SANITIZER_UNDEFINED_BEHAVIOR and ENABLE_SANITIZER_UNDEFINED. Use ENABLE_SANITIZER_UNDEFINED only.")
else()
message(DEPRECATION "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR is deprecated. Use ENABLE_SANITIZER_UNDEFINED instead.")
endif()

set(ProjectOptions_ENABLE_SANITIZER_UNDEFINED ${ProjectOptions_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR})
endif()

# sanitizer options if supported by compiler
enable_sanitizers(
${_options_target}
${ProjectOptions_ENABLE_SANITIZER_ADDRESS}
${ProjectOptions_ENABLE_SANITIZER_LEAK}
${ProjectOptions_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR}
${ProjectOptions_ENABLE_SANITIZER_UNDEFINED}
${ProjectOptions_ENABLE_SANITIZER_THREAD}
${ProjectOptions_ENABLE_SANITIZER_MEMORY}
${ProjectOptions_ENABLE_SANITIZER_POINTER_COMPARE}
Expand Down
17 changes: 10 additions & 7 deletions src/Sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function(
_project_name
ENABLE_SANITIZER_ADDRESS
ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
ENABLE_SANITIZER_UNDEFINED
ENABLE_SANITIZER_THREAD
ENABLE_SANITIZER_MEMORY
ENABLE_SANITIZER_POINTER_COMPARE
Expand All @@ -18,7 +18,7 @@ function(
# check if the sanitizers are supported
check_sanitizers_support(
SUPPORTS_SANITIZER_ADDRESS
SUPPORTS_SANITIZER_UNDEFINED_BEHAVIOR
SUPPORTS_SANITIZER_UNDEFINED
SUPPORTS_SANITIZER_LEAK
SUPPORTS_SANITIZER_THREAD
SUPPORTS_SANITIZER_MEMORY
Expand All @@ -38,8 +38,11 @@ function(
"pointer-compare"
"pointer-subtract"
)
if(${ENABLE_SANITIZER_${SANITIZER}})
if(${SUPPORTS_SANITIZER_${SANITIZER}})
set(SANITIZER_UPPERCASE "${SANITIZER}")
string(TOUPPER ${SANITIZER} SANITIZER_UPPERCASE)

if(${ENABLE_SANITIZER_${SANITIZER_UPPERCASE}})
if(${SUPPORTS_SANITIZER_${SANITIZER_UPPERCASE}})
list(APPEND SANITIZERS ${SANITIZER})
else()
# do not enable the sanitizer if it is not supported
Expand Down Expand Up @@ -134,7 +137,7 @@ Note that some sanitizers cannot be enabled together, and this function doesn't
Output variables:

- ``ENABLE_SANITIZER_ADDRESS``: Address sanitizer is supported
- ``ENABLE_SANITIZER_UNDEFINED_BEHAVIOR``: Undefined behavior sanitizer is supported
- ``ENABLE_SANITIZER_UNDEFINED``: Undefined behavior sanitizer is supported
- ``ENABLE_SANITIZER_LEAK``: Leak sanitizer is supported
- ``ENABLE_SANITIZER_THREAD``: Thread sanitizer is supported
- ``ENABLE_SANITIZER_MEMORY``: Memory sanitizer is supported
Expand All @@ -145,7 +148,7 @@ Output variables:
.. code:: cmake

check_sanitizers_support(ENABLE_SANITIZER_ADDRESS
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
ENABLE_SANITIZER_UNDEFINED
ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_THREAD
ENABLE_SANITIZER_MEMORY
Expand All @@ -158,7 +161,7 @@ Output variables:
function(
check_sanitizers_support
ENABLE_SANITIZER_ADDRESS
ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
ENABLE_SANITIZER_UNDEFINED
ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_THREAD
ENABLE_SANITIZER_MEMORY
Expand Down
2 changes: 1 addition & 1 deletion src/Vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Or by specifying the options

run_vcpkg(
VCPKG_URL "https://github.com/microsoft/vcpkg.git"
VCPKG_REV "10e052511428d6b0c7fcc63a139e8024bb146032"
VCPKG_REV "86a181505ac6460f98496a79abdee6a0f49905ec"
ENABLE_VCPKG_UPDATE
)

Expand Down
4 changes: 2 additions & 2 deletions tests/install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ project(anotherproj VERSION 0.1.0 LANGUAGES CXX C)
option(FEATURE_TESTS "Enable the tests" ON)
if(FEATURE_TESTS)
set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS")
set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR")
set(ENABLE_SANITIZER_UNDEFINED "ENABLE_SANITIZER_UNDEFINED")
endif()

# Initialize project_options
Expand All @@ -33,7 +33,7 @@ project_options(
# ENABLE_BUILD_WITH_TIME_TRACE
# ENABLE_UNITY
${ENABLE_SANITIZER_ADDRESS}
${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR}
${ENABLE_SANITIZER_UNDEFINED}
# ${ENABLE_SANITIZER_LEAK}
# ${ENABLE_SANITIZER_THREAD}
# ${ENABLE_SANITIZER_MEMORY}
Expand Down
2 changes: 1 addition & 1 deletion tests/install/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "another-project",
"version-string": "0.1.0",
"builtin-baseline": "10e052511428d6b0c7fcc63a139e8024bb146032",
"builtin-baseline": "86a181505ac6460f98496a79abdee6a0f49905ec",
"dependencies": [
{
"name": "eigen3",
Expand Down
4 changes: 2 additions & 2 deletions tests/minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if(ENABLE_TESTING)
if(NOT DISABLE_SANITIZER)
if(NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS")
set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "ENABLE_SANITIZER_UNDEFINED_BEHAVIOR")
set(ENABLE_SANITIZER_UNDEFINED "ENABLE_SANITIZER_UNDEFINED")
else()
# or it is MSVC and has run vcvarsall
string(FIND "$ENV{PATH}" "$ENV{VSINSTALLDIR}" index_of_vs_install_dir)
Expand All @@ -64,7 +64,7 @@ project_options(
ENABLE_VS_ANALYSIS
${ENABLE_COVERAGE}
${ENABLE_SANITIZER_ADDRESS}
${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR}
${ENABLE_SANITIZER_UNDEFINED}
# DISABLE_EXCEPTIONS
# DISABLE_RTTI
# Note: PCH is disabled by default in developer mode because these headers become globally included and they can mask other errors
Expand Down
Loading

0 comments on commit 7462a2a

Please sign in to comment.