Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable all examples #56

Merged
merged 8 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ project(
LANGUAGES CXX
)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(CTest)
include(FetchContent)
include(CompilerFeatureTest)
beman_check_range_support(COMPILER_SUPPORTS_RANGES)

if(BUILD_TESTING)
enable_testing()
Expand Down
25 changes: 25 additions & 0 deletions cmake/CompilerFeatureTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Functions that determine compiler capabilities

include(CheckCXXSourceCompiles)

# Determines if the selected C++ compiler has ranges support.
# Sets 'result_var' to whether support is detected.
function(beman_check_range_support result_var)
# Check if the C++ standard is at least C++20 or later.
if(CMAKE_CXX_STANDARD LESS 20)
set(${result_var} FALSE PARENT_SCOPE)
return()
endif()
wusatosi marked this conversation as resolved.
Show resolved Hide resolved

check_cxx_source_compiles(
"
#include <ranges> // C++20 ranges; note that __cpp_lib_ranges is not defined for all compilers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What compiler doesn't define it?

BTW, when searching for __cpp_lib_ranges using GitHub code search I found this alternative way to check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have adopted this in my latest contribution.

int main(){ return 0; }
"
_HAVE_RANGE_SUPPORT
)

set(${result_var} ${_HAVE_RANGE_SUPPORT} PARENT_SCOPE)
endfunction()
12 changes: 9 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

set(ALL_EXAMPLES # identity_as_default_projection
identity_direct_usage
)
set(ALL_EXAMPLES identity_direct_usage)
if(COMPILER_SUPPORTS_RANGES)
list(APPEND ALL_EXAMPLES identity_as_default_projection)
else()
message(
WARNING
"Missing range support! Skip: identity_as_default_projection"
)
endif()

foreach(example ${ALL_EXAMPLES})
add_executable(beman.exemplar.examples.${example})
Expand Down
Loading