Skip to content

Commit dc8b603

Browse files
committed
[Cmake] support using system provided pybind11
1 parent 64ee762 commit dc8b603

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,16 @@ set(PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" CACHE INTERNAL "")
234234

235235
add_subdirectory(external)
236236

237-
if(USE_SYSTEM_FMTLIB)
237+
if(SHAMROCK_EXTERNAL_FMTLIB)
238238
message(STATUS "Using system fmtlib")
239239
find_package(fmt REQUIRED)
240240
endif()
241241

242+
if(SHAMROCK_EXTERNAL_PYBIND11)
243+
message(STATUS "Using system pybind11")
244+
find_package(pybind11 REQUIRED)
245+
endif()
246+
242247
include_directories(external/plf_nanotimer)
243248

244249
message("-- Shamrock config : ")

external/CMakeLists.txt

+41-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## -------------------------------------------------------
2+
##
3+
## SHAMROCK code for hydrodynamics
4+
## Copyright (c) 2021-2024 Timothée David--Cléris <[email protected]>
5+
## SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6+
## Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7+
##
8+
## -------------------------------------------------------
9+
10+
###############################################################################
11+
### test git submodules
12+
###############################################################################
13+
114
function(_git_submod_is_empty directory)
215
file(GLOB files RELATIVE "${directory}" "${directory}/*")
316
if(NOT files)
@@ -13,11 +26,29 @@ endfunction()
1326

1427
_git_submod_is_empty(${CMAKE_CURRENT_SOURCE_DIR}/pybind11)
1528

16-
add_subdirectory(pybind11)
1729

18-
option(USE_SYSTEM_FMTLIB "use fmt lib from the host system" Off)
30+
###############################################################################
31+
### pybind11
32+
###############################################################################
33+
option(SHAMROCK_EXTERNAL_PYBIND11 "use pybind11 lib from the host system" Off)
34+
35+
if(NOT SHAMROCK_EXTERNAL_PYBIND11)
36+
message(STATUS "Using git submodule pybind11")
37+
add_subdirectory(pybind11)
38+
endif()
39+
40+
###############################################################################
41+
### fmt
42+
###############################################################################
1943

20-
if(NOT USE_SYSTEM_FMTLIB)
44+
option(SHAMROCK_EXTERNAL_FMTLIB "use fmt lib from the host system" Off)
45+
46+
# LEGACY variable
47+
if(DEFINED USE_SYSTEM_FMTLIB)
48+
set(SHAMROCK_EXTERNAL_FMTLIB ${USE_SYSTEM_FMTLIB})
49+
endif()
50+
51+
if(NOT SHAMROCK_EXTERNAL_FMTLIB)
2152
message(STATUS "Using git submodule fmtlib")
2253

2354
option(USE_MANUAL_FMTLIB "Bypass fmt cmake integration" Off)
@@ -42,11 +73,18 @@ if(NOT USE_SYSTEM_FMTLIB)
4273
endif()
4374
endif()
4475

76+
###############################################################################
77+
### NVTX
78+
###############################################################################
79+
4580
if(SHAMROCK_USE_NVTX)
4681
#include(NVTX/c/nvtxImportedTargets.cmake)
4782
add_subdirectory(NVTX/c)
4883
endif()
4984

85+
###############################################################################
86+
### nlohmann_json
87+
###############################################################################
5088

5189
if(SHAMROCK_EXTERNAL_JSON)
5290
find_package(nlohmann_json 3.11.3 REQUIRED)

0 commit comments

Comments
 (0)