summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CTestCustom.cmake5
-rw-r--r--cmake/detect_cxx_version.cmake45
-rw-r--r--cmake/sed.cmake12
-rw-r--r--cmake/sed.script.cmake18
4 files changed, 80 insertions, 0 deletions
diff --git a/cmake/CTestCustom.cmake b/cmake/CTestCustom.cmake
new file mode 100644
index 0000000..d6ddbcf
--- /dev/null
+++ b/cmake/CTestCustom.cmake
@@ -0,0 +1,5 @@
+set(CTEST_CUSTOM_COVERAGE_EXCLUDE
+ ".*examples.*"
+ ".*tests.*"
+ ".*benchmark.*"
+ ".*c[+][+].*")
diff --git a/cmake/detect_cxx_version.cmake b/cmake/detect_cxx_version.cmake
new file mode 100644
index 0000000..2021650
--- /dev/null
+++ b/cmake/detect_cxx_version.cmake
@@ -0,0 +1,45 @@
+set(cxx17_minimum_msvc_version 19.14)
+set(cxx17_minimum_gcc_version 7.0)
+set(cxx17_minimum_clang_version 4.0)
+set(cxx17_minimum_appleclang_version 6.0)
+
+set(cxx20_minimum_msvc_version 19.22)
+set(cxx20_minimum_gcc_version 9.0)
+set(cxx20_minimum_clang_version 7.0)
+set(cxx20_minimum_appleclang_version 10.0)
+
+set(cxx_17_supported OFF)
+
+if(MSVC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx17_minimum_msvc_version})
+ set(cxx_17_supported ON)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx17_minimum_gcc_version})
+ set(cxx_17_supported ON)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx17_minimum_clang_version})
+ set(cxx_17_supported ON)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx17_minimum_appleclang_version})
+ set(cxx_17_supported ON)
+endif()
+
+set(cxx_20_supported OFF)
+
+if(MSVC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx20_minimum_msvc_version})
+ set(cxx_20_supported ON)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx20_minimum_gcc_version})
+ set(cxx_20_supported ON)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx20_minimum_clang_version})
+ set(cxx_20_supported ON)
+endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${cxx20_minimum_appleclang_version})
+ set(cxx_20_supported ON)
+endif()
diff --git a/cmake/sed.cmake b/cmake/sed.cmake
new file mode 100644
index 0000000..feb0f1e
--- /dev/null
+++ b/cmake/sed.cmake
@@ -0,0 +1,12 @@
+set(SED_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/sed.script.cmake"
+ CACHE INTERNAL "path to sed script")
+
+function(sed input_file output_file)
+ add_custom_command(OUTPUT "${output_file}"
+ COMMAND ${CMAKE_COMMAND}
+ -Dinput_file="${input_file}"
+ -Doutput_file="${output_file}"
+ -Dreplacement_pairs="${ARGN}"
+ -P ${SED_SCRIPT}
+ DEPENDS "${input_file}")
+endfunction()
diff --git a/cmake/sed.script.cmake b/cmake/sed.script.cmake
new file mode 100644
index 0000000..a596736
--- /dev/null
+++ b/cmake/sed.script.cmake
@@ -0,0 +1,18 @@
+string(REPLACE " " ";" replacement_pairs ${replacement_pairs})
+
+file(READ "${input_file}" text)
+
+list(LENGTH replacement_pairs length)
+math(EXPR last_index "${length} - 1")
+
+foreach(regex_index RANGE 0 ${last_index} 2)
+ math(EXPR replacement_index "${regex_index} + 1")
+ LIST(GET replacement_pairs ${regex_index} regex_expression)
+ LIST(GET replacement_pairs ${replacement_index} replacement_expression)
+ string(REPLACE
+ "${regex_expression}"
+ "${replacement_expression}"
+ text "${text}")
+endforeach()
+
+file(WRITE ${output_file} "${text}")