From cfea2429d733f09a3bf50fcfabc12807241669d2 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 29 Nov 2023 15:54:41 -0500 Subject: [PATCH] chore: cleanup CMake a bit (#902) Signed-off-by: Henry Schreiner --- .github/CONTRIBUTING.md | 17 +++++++++++++++++ CMakeLists.txt | 31 +++---------------------------- tests/CMakeLists.txt | 3 --- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 86d5ae94..ab3d4764 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -225,6 +225,23 @@ cmake -S . -B build-iwyu -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=$(which include-what-y cmake --build build ``` +## Timing steps + +Make time/memory taken can be set +`CMAKE_CXX_COMPILER_LAUNCHER`/`CMAKE_CXX_LINKER_LANCHER`. Some examples: + +``` +# Linux: +# "time" +# "time;-v" +# "time;-f;'%U user %S system %E elapsed %P CPU %M KB'" +# macOS: +# "time" +# macOS with brew install gnu-time: +# "gtime;-f;'%U user %S system %E elapsed %P CPU %M KB'" +# +``` + ## Common tasks
Updating dependencies (click to expand) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3478fc29..7391d15b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,31 +13,6 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Adding folders to keep the structure a bit nicer in IDE's set_property(GLOBAL PROPERTY USE_FOLDERS ON) -# Make time/memory taken to compile/link available as a setting -# -# Useful settings: -# Linux: -# "time" -# "time -v" -# "time -f '%U user %S system %E elapsed %P CPU %M KB'" -# macOS: -# "time -l" -# macOS with brew install gnu-time: -# "gtime -f '%U user %S system %E elapsed %P CPU %M KB'" -# -set(BH_RULE_LAUNCH_COMPILE - "" - CACHE STRING [=[Use a command, like "time" to wrap the compile]=]) -if(NOT BH_RULE_LAUNCH_COMPILE STREQUAL "") - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${BH_RULE_LAUNCH_COMPILE}") -endif() -set(BH_RULE_LAUNCH_LINK - "" - CACHE STRING [=[Use a command, like "time" to wrap the link]=]) -if(NOT BH_RULE_LAUNCH_LINK STREQUAL "") - set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK "${BH_RULE_LAUNCH_LINK}") -endif() - # This will force color output at build time if this env variable is set _at # configure time_. This is useful for CI. if($ENV{FORCE_COLOR}) @@ -49,11 +24,11 @@ if($ENV{FORCE_COLOR}) endif() # This is a standard recipe for setting a default build type -set(default_build_type "Debug") +set(_default_build_type "Debug") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to '${default_build_type}' as none was specified.") + message(STATUS "Setting build type to '${_default_build_type}' as none was specified.") set(CMAKE_BUILD_TYPE - "${default_build_type}" + "${_default_build_type}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6b66b9f5..9ad27a86 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,9 +1,6 @@ pybind11_find_import(numpy) pybind11_find_import(pytest) pybind11_find_import(pytest-benchmark) -if(PYTHON_VERSION VERSION_LESS 3.5) - pybind11_find_import(typing) -endif() # Support for running from build directory file(WRITE "${PROJECT_BINARY_DIR}/pytest.ini" "[pytest]\n" "addopts = --benchmark-disable\n"