From 882fff7ca8998bc98d7dae039eeb35293cbfb8fc Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 3 Nov 2023 23:45:47 +0100 Subject: [PATCH] refactor: Use `__cpp_concepts` directly (#2626) This replaces the custom C++20 concepts detection mechanism at CMake level with the corresponding feature preprocessor define. --- Core/CMakeLists.txt | 4 ---- Core/include/Acts/EventData/ChargeConcept.hpp | 2 +- .../MultiTrajectoryBackendConcept.hpp | 2 +- .../TrackContainerBackendConcept.hpp | 2 +- .../Acts/EventData/TrackStateProxyConcept.hpp | 2 +- .../Acts/Geometry/SurfaceVisitorConcept.hpp | 2 +- Core/include/Acts/Utilities/Concepts.hpp | 2 +- cmake/ActsCompilerOptions.cmake | 22 ------------------- 8 files changed, 6 insertions(+), 32 deletions(-) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 3cff9ffbf7c..128e378c322 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -15,10 +15,6 @@ target_compile_features( ActsCore PUBLIC ${ACTS_CXX_STANDARD_FEATURE}) -if(ACTS_CONCEPTS_SUPPORTED) - target_compile_definitions(ActsCore PUBLIC ACTS_CONCEPTS_SUPPORTED) -endif() - target_include_directories( ActsCore PUBLIC diff --git a/Core/include/Acts/EventData/ChargeConcept.hpp b/Core/include/Acts/EventData/ChargeConcept.hpp index 9837247971b..d9e295ba25e 100644 --- a/Core/include/Acts/EventData/ChargeConcept.hpp +++ b/Core/include/Acts/EventData/ChargeConcept.hpp @@ -16,7 +16,7 @@ #include #include -#if defined(ACTS_CONCEPTS_SUPPORTED) +#if defined(__cpp_concepts) #include namespace Acts { diff --git a/Core/include/Acts/EventData/MultiTrajectoryBackendConcept.hpp b/Core/include/Acts/EventData/MultiTrajectoryBackendConcept.hpp index 51834c37ecd..dc4b465d985 100644 --- a/Core/include/Acts/EventData/MultiTrajectoryBackendConcept.hpp +++ b/Core/include/Acts/EventData/MultiTrajectoryBackendConcept.hpp @@ -19,7 +19,7 @@ #include #include -#if defined(ACTS_CONCEPTS_SUPPORTED) +#if defined(__cpp_concepts) #include namespace Acts { diff --git a/Core/include/Acts/EventData/TrackContainerBackendConcept.hpp b/Core/include/Acts/EventData/TrackContainerBackendConcept.hpp index fb29081a5c7..07c4ed0a7dc 100644 --- a/Core/include/Acts/EventData/TrackContainerBackendConcept.hpp +++ b/Core/include/Acts/EventData/TrackContainerBackendConcept.hpp @@ -16,7 +16,7 @@ #include #include -#if defined(ACTS_CONCEPTS_SUPPORTED) +#if defined(__cpp_concepts) #include namespace Acts { diff --git a/Core/include/Acts/EventData/TrackStateProxyConcept.hpp b/Core/include/Acts/EventData/TrackStateProxyConcept.hpp index bb25c8fe3c9..b6f240f26a3 100644 --- a/Core/include/Acts/EventData/TrackStateProxyConcept.hpp +++ b/Core/include/Acts/EventData/TrackStateProxyConcept.hpp @@ -20,7 +20,7 @@ #include -#if defined(ACTS_CONCEPTS_SUPPORTED) +#if defined(__cpp_concepts) #include namespace Acts { diff --git a/Core/include/Acts/Geometry/SurfaceVisitorConcept.hpp b/Core/include/Acts/Geometry/SurfaceVisitorConcept.hpp index fbb773f2a1e..d37255e2f4e 100644 --- a/Core/include/Acts/Geometry/SurfaceVisitorConcept.hpp +++ b/Core/include/Acts/Geometry/SurfaceVisitorConcept.hpp @@ -10,7 +10,7 @@ #include "Acts/Surfaces/Surface.hpp" -#if defined(ACTS_CONCEPTS_SUPPORTED) +#if defined(__cpp_concepts) #include namespace Acts { diff --git a/Core/include/Acts/Utilities/Concepts.hpp b/Core/include/Acts/Utilities/Concepts.hpp index df401ccc897..b8b36ad1ee2 100644 --- a/Core/include/Acts/Utilities/Concepts.hpp +++ b/Core/include/Acts/Utilities/Concepts.hpp @@ -8,7 +8,7 @@ #pragma once -#if defined(ACTS_CONCEPTS_SUPPORTED) +#if defined(__cpp_concepts) #define ACTS_REQUIRES(x) requires(x) #define ACTS_CONCEPT(x) x diff --git a/cmake/ActsCompilerOptions.cmake b/cmake/ActsCompilerOptions.cmake index 2c892c4e554..67d82fbf962 100644 --- a/cmake/ActsCompilerOptions.cmake +++ b/cmake/ActsCompilerOptions.cmake @@ -55,25 +55,3 @@ set(CMAKE_MACOSX_RPATH 1) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # set relative library path for ACTS libraries set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") - -if(${ACTS_CXX_STANDARD} GREATER_EQUAL 20) - file(WRITE - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/concepts.cpp" - "#include \n" - "template\n" - "concept Derived = std::is_base_of::value;\n" - "struct A {}; struct B : public A {};" - "int main() { static_assert(Derived, \"works\"); }\n" ) - - message(CHECK_START "Are C++20 concepts supported") - try_compile(ACTS_CONCEPTS_SUPPORTED "${CMAKE_BINARY_DIR}" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/concepts.cpp" - CXX_STANDARD 20 - OUTPUT_VARIABLE __OUTPUT) - - if(ACTS_CONCEPTS_SUPPORTED) - message(CHECK_PASS "yes") - else() - message(CHECK_FAIL "no") - endif() -endif()