Skip to content

Commit

Permalink
refactor: Use __cpp_concepts directly (#2626)
Browse files Browse the repository at this point in the history
This replaces the custom C++20 concepts detection mechanism at CMake level with the corresponding feature preprocessor define.
  • Loading branch information
paulgessinger authored Nov 3, 2023
1 parent 4571a6b commit 882fff7
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 32 deletions.
4 changes: 0 additions & 4 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/ChargeConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <any>
#include <type_traits>

#if defined(ACTS_CONCEPTS_SUPPORTED)
#if defined(__cpp_concepts)
#include <concepts>

namespace Acts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <any>
#include <type_traits>

#if defined(ACTS_CONCEPTS_SUPPORTED)
#if defined(__cpp_concepts)
#include <concepts>

namespace Acts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <any>
#include <type_traits>

#if defined(ACTS_CONCEPTS_SUPPORTED)
#if defined(__cpp_concepts)
#include <concepts>

namespace Acts {
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/EventData/TrackStateProxyConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <utility>

#if defined(ACTS_CONCEPTS_SUPPORTED)
#if defined(__cpp_concepts)
#include <concepts>

namespace Acts {
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Geometry/SurfaceVisitorConcept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "Acts/Surfaces/Surface.hpp"

#if defined(ACTS_CONCEPTS_SUPPORTED)
#if defined(__cpp_concepts)
#include <concepts>

namespace Acts {
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/Utilities/Concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions cmake/ActsCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 <concepts>\n"
"template<class T, class U>\n"
"concept Derived = std::is_base_of<U, T>::value;\n"
"struct A {}; struct B : public A {};"
"int main() { static_assert(Derived<B, A>, \"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()

0 comments on commit 882fff7

Please sign in to comment.