2018-04-24 14:51:18 +02:00
|
|
|
# EVMC: Ethereum Client-VM Connector API.
|
2019-04-24 16:12:13 +02:00
|
|
|
# Copyright 2018-2019 The EVMC Authors.
|
2019-01-18 13:49:54 +01:00
|
|
|
# Licensed under the Apache License, Version 2.0.
|
2018-04-24 14:51:18 +02:00
|
|
|
|
2019-01-18 13:49:54 +01:00
|
|
|
# This CMake script creates multiple additional targets to test the compilation of public headers
|
|
|
|
# with different C and C++ standards.
|
2018-04-24 14:51:18 +02:00
|
|
|
|
2019-03-11 12:31:12 +01:00
|
|
|
set(standards c_std_90;c_std_99;c_std_11;cxx_std_11;cxx_std_14)
|
|
|
|
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL Clang OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.8.1)
|
|
|
|
list(APPEND standards cxx_std_17)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
list(APPEND all_features ${CMAKE_CXX_COMPILE_FEATURES})
|
|
|
|
list(APPEND all_features ${CMAKE_C_COMPILE_FEATURES})
|
|
|
|
|
2019-01-18 13:49:54 +01:00
|
|
|
macro(create_compilation_test STANDARD)
|
2019-03-11 12:31:12 +01:00
|
|
|
if (${STANDARD} MATCHES "^(c|cxx)_std_([0-9]+)$")
|
2019-01-18 13:49:54 +01:00
|
|
|
set(lang ${CMAKE_MATCH_1})
|
|
|
|
set(num ${CMAKE_MATCH_2})
|
|
|
|
else()
|
2019-03-11 12:31:12 +01:00
|
|
|
message(FATAL_ERROR "Unknown standard: ${STANDARD}")
|
2019-01-18 13:49:54 +01:00
|
|
|
endif()
|
2018-08-27 22:13:33 +02:00
|
|
|
|
2019-03-11 12:31:12 +01:00
|
|
|
if(${STANDARD} IN_LIST all_features)
|
|
|
|
set(target test-compile-${STANDARD})
|
|
|
|
add_library(${target} OBJECT compilation_test.${lang})
|
|
|
|
target_compile_features(${target} PRIVATE ${STANDARD})
|
|
|
|
target_include_directories(${target} PRIVATE ${include_dir})
|
2019-01-18 13:49:54 +01:00
|
|
|
else()
|
2019-03-11 12:31:12 +01:00
|
|
|
message(STATUS "Compilation test SKIPPED: ${STANDARD}")
|
2019-01-18 13:49:54 +01:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2019-03-11 12:31:12 +01:00
|
|
|
foreach(standard ${standards})
|
2019-01-18 13:49:54 +01:00
|
|
|
create_compilation_test(${standard})
|
|
|
|
endforeach()
|