Skip to content

Commit 2844974

Browse files
authored
Add option for building python bindings (default to ON for back compat) (#177)
* Add option for building python bindings (default to ON for back compat) * Fix some stragglers for the python target
1 parent b6c49ce commit 2844974

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

.github/workflows/build-c-libraries.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
env:
8888
BUILD_VDF_CLIENT: "N"
8989
run: |
90-
cmake . -DBUILD_CHIAVDFC=ON
90+
cmake . -DBUILD_CHIAVDFC=ON -DBUILD_PYTHON=OFF
9191
cmake --build .
9292
9393
- name: Upload artifacts

src/CMakeLists.txt

+18-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CMAKE_MINIMUM_REQUIRED(VERSION 3.14 FATAL_ERROR)
22
option(BUILD_CHIAVDFC "Build the chiavdfc shared library" OFF)
3+
option(BUILD_PYTHON "Build the python bindings for chiavdf" ON)
34

45
set(CMAKE_CXX_STANDARD 17)
56
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -52,28 +53,32 @@ endif()
5253
# CMake 3.14+
5354
include(FetchContent)
5455

55-
FetchContent_Declare(
56-
pybind11-src
57-
GIT_REPOSITORY https://github.com/pybind/pybind11.git
58-
GIT_TAG v2.11.1
59-
)
60-
FetchContent_MakeAvailable(pybind11-src)
56+
if(BUILD_PYTHON)
57+
FetchContent_Declare(
58+
pybind11-src
59+
GIT_REPOSITORY https://github.com/pybind/pybind11.git
60+
GIT_TAG v2.11.1
61+
)
62+
FetchContent_MakeAvailable(pybind11-src)
6163

62-
pybind11_add_module(chiavdf
63-
${CMAKE_CURRENT_SOURCE_DIR}/python_bindings/fastvdf.cpp
64-
${CMAKE_CURRENT_SOURCE_DIR}/refcode/lzcnt.c
65-
)
64+
pybind11_add_module(chiavdf
65+
${CMAKE_CURRENT_SOURCE_DIR}/python_bindings/fastvdf.cpp
66+
${CMAKE_CURRENT_SOURCE_DIR}/refcode/lzcnt.c
67+
)
68+
69+
target_link_libraries(chiavdf PRIVATE ${GMP_LIBRARIES} ${GMPXX_LIBRARIES})
70+
if(UNIX)
71+
target_link_libraries(chiavdf PRIVATE -pthread)
72+
endif()
73+
endif()
6674

6775
add_executable(verifier_test
6876
${CMAKE_CURRENT_SOURCE_DIR}/verifier_test.cpp
6977
${CMAKE_CURRENT_SOURCE_DIR}/refcode/lzcnt.c
7078
)
71-
72-
target_link_libraries(chiavdf PRIVATE ${GMP_LIBRARIES} ${GMPXX_LIBRARIES})
7379
target_link_libraries(verifier_test PRIVATE ${GMP_LIBRARIES} ${GMPXX_LIBRARIES})
7480

7581
if(UNIX)
76-
target_link_libraries(chiavdf PRIVATE -pthread)
7782
target_link_libraries(verifier_test PRIVATE -pthread)
7883
endif()
7984

0 commit comments

Comments
 (0)