Skip to content

Commit 9adacb5

Browse files
committed
Added cmake-format to pre-commit
1 parent bd2469f commit 9adacb5

File tree

5 files changed

+262
-203
lines changed

5 files changed

+262
-203
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ repos:
1313
hooks:
1414
- id: clang-format
1515
files: \.(c|cpp|cc|h|hpp|cxx|hxx)$
16+
17+
- repo: https://github.com/cheshirekow/cmake-format-precommit
18+
rev: v0.6.13
19+
hooks:
20+
- id: cmake-format

CMakeLists.txt

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,50 +48,53 @@ duckdb_add_library(duckdb_target)
4848

4949
# Bundle in INTERFACE library
5050
add_library(_duckdb_dependencies INTERFACE)
51-
target_link_libraries(_duckdb_dependencies INTERFACE
52-
pybind11::pybind11
53-
duckdb_target
54-
)
51+
target_link_libraries(_duckdb_dependencies INTERFACE pybind11::pybind11
52+
duckdb_target)
5553
# Also add include directory
56-
target_include_directories(_duckdb_dependencies INTERFACE
57-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/duckdb_py/include>
54+
target_include_directories(
55+
_duckdb_dependencies
56+
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/duckdb_py/include>
5857
)
5958

6059
# ────────────────────────────────────────────
6160
# Descend into the real DuckDB‑Python sources
6261
# ────────────────────────────────────────────
6362
add_subdirectory(src/duckdb_py)
6463

65-
pybind11_add_module(_duckdb
66-
$<TARGET_OBJECTS:python_src>
67-
$<TARGET_OBJECTS:python_arrow>
68-
$<TARGET_OBJECTS:python_common>
69-
$<TARGET_OBJECTS:python_functional>
70-
$<TARGET_OBJECTS:python_jupyter>
71-
$<TARGET_OBJECTS:python_native>
72-
$<TARGET_OBJECTS:python_numpy>
73-
$<TARGET_OBJECTS:python_pandas>
74-
$<TARGET_OBJECTS:python_pybind11>
75-
$<TARGET_OBJECTS:python_connection>
76-
$<TARGET_OBJECTS:python_expression>
77-
$<TARGET_OBJECTS:python_relation>
78-
$<TARGET_OBJECTS:python_type>
79-
)
64+
pybind11_add_module(
65+
_duckdb
66+
$<TARGET_OBJECTS:python_src>
67+
$<TARGET_OBJECTS:python_arrow>
68+
$<TARGET_OBJECTS:python_common>
69+
$<TARGET_OBJECTS:python_functional>
70+
$<TARGET_OBJECTS:python_jupyter>
71+
$<TARGET_OBJECTS:python_native>
72+
$<TARGET_OBJECTS:python_numpy>
73+
$<TARGET_OBJECTS:python_pandas>
74+
$<TARGET_OBJECTS:python_pybind11>
75+
$<TARGET_OBJECTS:python_connection>
76+
$<TARGET_OBJECTS:python_expression>
77+
$<TARGET_OBJECTS:python_relation>
78+
$<TARGET_OBJECTS:python_type>)
8079
# add _duckdb_dependencies
8180
target_link_libraries(_duckdb PRIVATE _duckdb_dependencies)
8281

8382
# ────────────────────────────────────────────
8483
# Put the object file in the correct place
8584
# ────────────────────────────────────────────
8685

87-
# If we're not building through scikit-build-core then we have to set a different dest dir
86+
# If we're not building through scikit-build-core then we have to set a
87+
# different dest dir
8888
include(GNUInstallDirs)
8989
if(DEFINED SKBUILD_PLATLIB_DIR)
9090
set(_DUCKDB_PY_INSTALL_DIR "${SKBUILD_PLATLIB_DIR}")
9191
elseif(DEFINED Python_SITEARCH)
9292
set(_DUCKDB_PY_INSTALL_DIR "${Python_SITEARCH}")
9393
else()
94-
message(WARNING "Could not determine Python install dir. Falling back to CMAKE_INSTALL_LIBDIR.")
94+
message(
95+
WARNING
96+
"Could not determine Python install dir. Falling back to CMAKE_INSTALL_LIBDIR."
97+
)
9598
set(_DUCKDB_PY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
9699
endif()
97100

cmake/compiler_launcher.cmake

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@ include(CMakeParseArguments)
88
# Function to look for ccache and sccache to speed up builds, if available
99
# ────────────────────────────────────────────
1010
function(setup_compiler_launcher_if_available)
11-
if(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER AND NOT DEFINED ENV{CMAKE_C_COMPILER_LAUNCHER})
12-
find_program(COMPILER_LAUNCHER NAMES ccache sccache)
13-
if(COMPILER_LAUNCHER)
14-
message(STATUS "Using ${COMPILER_LAUNCHER} as C compiler launcher")
15-
set(CMAKE_C_COMPILER_LAUNCHER "${COMPILER_LAUNCHER}" CACHE STRING "" FORCE)
16-
endif()
11+
if(NOT DEFINED CMAKE_C_COMPILER_LAUNCHER AND NOT DEFINED
12+
ENV{CMAKE_C_COMPILER_LAUNCHER})
13+
find_program(COMPILER_LAUNCHER NAMES ccache sccache)
14+
if(COMPILER_LAUNCHER)
15+
message(STATUS "Using ${COMPILER_LAUNCHER} as C compiler launcher")
16+
set(CMAKE_C_COMPILER_LAUNCHER
17+
"${COMPILER_LAUNCHER}"
18+
CACHE STRING "" FORCE)
1719
endif()
20+
endif()
1821

19-
if(NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER AND NOT DEFINED ENV{CMAKE_CXX_COMPILER_LAUNCHER})
20-
find_program(COMPILER_LAUNCHER NAMES ccache sccache)
21-
if(COMPILER_LAUNCHER)
22-
message(STATUS "Using ${COMPILER_LAUNCHER} as C++ compiler launcher")
23-
set(CMAKE_CXX_COMPILER_LAUNCHER "${COMPILER_LAUNCHER}" CACHE STRING "" FORCE)
24-
endif()
22+
if(NOT DEFINED CMAKE_CXX_COMPILER_LAUNCHER
23+
AND NOT DEFINED ENV{CMAKE_CXX_COMPILER_LAUNCHER})
24+
find_program(COMPILER_LAUNCHER NAMES ccache sccache)
25+
if(COMPILER_LAUNCHER)
26+
message(STATUS "Using ${COMPILER_LAUNCHER} as C++ compiler launcher")
27+
set(CMAKE_CXX_COMPILER_LAUNCHER
28+
"${COMPILER_LAUNCHER}"
29+
CACHE STRING "" FORCE)
2530
endif()
31+
endif()
2632
endfunction()

0 commit comments

Comments
 (0)