Skip to content

Commit

Permalink
chore: cleanup CMake a bit (#902)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii authored Nov 29, 2023
1 parent a6efa1c commit cfea242
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
17 changes: 17 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

<details><summary>Updating dependencies (click to expand)</summary>
Expand Down
31 changes: 3 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit cfea242

Please sign in to comment.