Skip to content

Commit

Permalink
cmake: work around CMake UseSwig behavior change
Browse files Browse the repository at this point in the history
CMake 3.11 included a change which made the dependency directly on the
files not work in Makefile-based generators. Instead, depend on the
custom target provided in that case.

Fixes: boatbod#25
  • Loading branch information
mathstuf committed Feb 15, 2020
1 parent 1be5c53 commit ce01555
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion cmake/Modules/GrPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ endfunction(GR_UNIQUE_TARGET)
########################################################################
# Install python sources (also builds and installs byte-compiled python)
########################################################################
function(GR_PYTHON_INSTALL)
function(GR_PYTHON_INSTALL name)
include(CMakeParseArgumentsCopy)
CMAKE_PARSE_ARGUMENTS(GR_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN})

Expand Down Expand Up @@ -156,6 +156,15 @@ function(GR_PYTHON_INSTALL)

endforeach(pyfile)

# XXX(cmake): This can be relaxed once CMake Issue #20067 is fixed.
# https://gitlab.kitware.com/cmake/cmake/issues/20067
if (CMAKE_VERSION VERSION_LESS "3.11" OR
NOT CMAKE_GENERATOR MATCHES "Makefiles")
set(depends_files ${pysrcfiles})
else ()
set(depends_files ${name}_swig_compilation)
endif ()

#the command to generate the pyc files
add_custom_command(
DEPENDS ${pysrcfiles} OUTPUT ${pycfiles}
Expand Down
3 changes: 2 additions & 1 deletion cmake/Modules/GrSwig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ macro(GR_SWIG_INSTALL)
)

include(GrPython)
GR_PYTHON_INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.py
GR_PYTHON_INSTALL(${name}
FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.py
DESTINATION ${GR_SWIG_INSTALL_DESTINATION}
COMPONENT ${GR_SWIG_INSTALL_COMPONENT}
)
Expand Down

0 comments on commit ce01555

Please sign in to comment.