summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Preiner <mathias.preiner@gmail.com>2021-04-07 06:21:29 -0700
committerGitHub <noreply@github.com>2021-04-07 08:21:29 -0500
commit5059658ee0d6fc65e4cb1652c605895d016cd274 (patch)
treeb4d20341b5760be73c93904d81224933c18bc442 /src
parent1fb3561da22565b92a5d31db6ce5d91877c897a1 (diff)
cmake: Do not always regenerate cvc4kinds.{pxi,pxd}. (#6300)
Only regenerate files if dependencies changed. This avoids unnecessary rebuilds of the Cython code.
Diffstat (limited to 'src')
-rw-r--r--src/api/python/CMakeLists.txt40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/api/python/CMakeLists.txt b/src/api/python/CMakeLists.txt
index 2311b63f4..da28fc328 100644
--- a/src/api/python/CMakeLists.txt
+++ b/src/api/python/CMakeLists.txt
@@ -17,19 +17,17 @@ endif()
find_package(PythonExtensions REQUIRED)
find_package(Cython 0.29 REQUIRED)
-include_directories(${PYTHON_INCLUDE_DIRS})
-include_directories(${CMAKE_CURRENT_LIST_DIR}) # cvc4kinds.pxd
-include_directories(${PROJECT_SOURCE_DIR}/src)
-include_directories(${PROJECT_SOURCE_DIR}/src/include)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-# TEMP: Only needed while expr/kind.h is public in the C++ api
-include_directories("${CMAKE_BINARY_DIR}/src/")
-
# Generate cvc4kinds.{pxd,pyx}
configure_file(genkinds.py.in genkinds.py)
-add_custom_target(
- gen-pycvc4-kinds
- ALL
+set(GENERATED_FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/cvc4kinds.pxd"
+ "${CMAKE_CURRENT_BINARY_DIR}/cvc4kinds.pxi"
+)
+add_custom_command(
+ OUTPUT
+ ${GENERATED_FILES}
+ BYPRODUCTS
+ ${GENERATED_FILES}
COMMAND
"${PYTHON_EXECUTABLE}"
"${CMAKE_CURRENT_BINARY_DIR}/genkinds.py"
@@ -37,15 +35,25 @@ add_custom_target(
--kinds-file-prefix "${CMAKE_CURRENT_BINARY_DIR}/cvc4kinds"
DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/genkinds.py"
- COMMENT
- "Generate cvc4kinds.{pxd,pyx}"
+ "${PROJECT_SOURCE_DIR}/src/api/cpp/cvc5_kind.h"
)
+add_custom_target(cvc4kinds DEPENDS ${GENERATED_FILES})
+
+include_directories(${CMAKE_CURRENT_BINARY_DIR}) # for cvc4kinds.pxi
add_cython_target(pycvc4 CXX)
add_library(pycvc4
MODULE
${pycvc4})
+add_dependencies(pycvc4 cvc4kinds)
+
+target_include_directories(pycvc4
+ PRIVATE
+ ${PYTHON_INCLUDE_DIRS}
+ ${PROJECT_SOURCE_DIR}/src # for API headers in src/api/cpp
+ ${CMAKE_BINARY_DIR}/src # for cvc4_export.h
+)
target_link_libraries(pycvc4 cvc4 ${PYTHON_LIBRARIES})
@@ -86,7 +94,8 @@ execute_process(OUTPUT_VARIABLE IN_VIRTUALENV
"from __future__ import print_function; import os;
print('YES' if 'VIRTUAL_ENV' in os.environ else 'NO', end='')")
-set(INSTALL_CMD "${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install")
+set(INSTALL_CMD
+ "${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install")
# if we're in a virtualenv, we install it in the virtualenv lib location
if ("${IN_VIRTUALENV}" STREQUAL "NO")
set(INSTALL_CMD "${INSTALL_CMD} --prefix=${CMAKE_INSTALL_PREFIX}")
@@ -94,4 +103,5 @@ endif()
message("Python bindings install command: ${INSTALL_CMD}")
-install(CODE "execute_process(COMMAND ${INSTALL_CMD})" FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
+install(CODE "execute_process(COMMAND ${INSTALL_CMD})"
+ FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback