Skip to content

Commit e7e5050

Browse files
committed
Do not set target_compile_features
1 parent d462d55 commit e7e5050

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

CMakeLists.txt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44
# cmake-format: on
55

6-
set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE)
7-
86
cmake_minimum_required(VERSION 3.25...3.31)
97

108
project(
@@ -19,6 +17,23 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
1917
message(FATAL_ERROR "In-source builds are not allowed!")
2018
endif()
2119

20+
# Require C++20, but let a parent project ask for something higher
21+
if(DEFINED CMAKE_CXX_STANDARD)
22+
if(CMAKE_CXX_STANDARD EQUAL 98 OR CMAKE_CXX_STANDARD LESS 20)
23+
message(FATAL_ERROR "This project requires at least C++23")
24+
endif()
25+
else()
26+
set(CMAKE_CXX_STANDARD 23)
27+
endif()
28+
29+
# Always enforce the language constraint
30+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
31+
32+
# We don't need compiler extensions, but let a parent ask for them
33+
if(NOT DEFINED CMAKE_CXX_EXTENSIONS)
34+
set(CMAKE_CXX_EXTENSIONS OFF)
35+
endif()
36+
2237
# [CMAKE.SKIP_EXAMPLES]
2338
option(
2439
BEMAN_EXEMPLAR_BUILD_EXAMPLES
@@ -55,7 +70,6 @@ set_target_properties(
5570
beman.inplace_vector
5671
PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON
5772
)
58-
target_compile_features(beman.inplace_vector INTERFACE cxx_std_23)
5973

6074
set(TARGET_PACKAGE_NAME ${PROJECT_NAME}-config)
6175
set(TARGETS_EXPORT_NAME ${PROJECT_NAME}-targets)

0 commit comments

Comments
 (0)