diff options
author | Sebastian Koslowski <koslowski@kit.edu> | 2017-01-12 15:58:38 +0100 |
---|---|---|
committer | Sebastian Koslowski <koslowski@kit.edu> | 2017-01-19 14:09:14 +0100 |
commit | 98806de9e5b623b8301426f648e097f408369316 (patch) | |
tree | ff88f98d2315467f95840c13d5c6db62b2c71a20 | |
parent | c33862a14467b1c999d3c4247425c4f7106ae663 (diff) |
cmake: add DIRECTORY support to GR_PYTHON_INSTALL and use it for grc
-rw-r--r-- | cmake/Modules/GrPython.cmake | 78 | ||||
-rw-r--r-- | grc/CMakeLists.txt | 18 | ||||
-rw-r--r-- | grc/core/CMakeLists.txt | 35 | ||||
-rw-r--r-- | grc/core/generator/CMakeLists.txt | 30 | ||||
-rw-r--r-- | grc/core/utils/CMakeLists.txt | 25 | ||||
-rw-r--r-- | grc/gui/CMakeLists.txt | 27 | ||||
-rw-r--r-- | grc/gui/canvas/CMakeLists.txt | 25 |
7 files changed, 86 insertions, 152 deletions
diff --git a/cmake/Modules/GrPython.cmake b/cmake/Modules/GrPython.cmake index 0bfa92db8d..49461e5319 100644 --- a/cmake/Modules/GrPython.cmake +++ b/cmake/Modules/GrPython.cmake @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2011,2016 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -130,7 +130,7 @@ endfunction(GR_UNIQUE_TARGET) ######################################################################## function(GR_PYTHON_INSTALL) include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(GR_PYTHON_INSTALL "" "DESTINATION" "FILES;PROGRAMS" ${ARGN}) + CMAKE_PARSE_ARGUMENTS(GR_PYTHON_INSTALL "" "DESTINATION" "FILES;PROGRAMS;DIRECTORY" ${ARGN}) #################################################################### if(GR_PYTHON_INSTALL_FILES) @@ -185,6 +185,80 @@ function(GR_PYTHON_INSTALL) ) #################################################################### + elseif(GR_PYTHON_INSTALL_DIRECTORY) + #################################################################### + install(${ARGN}) #installs regular python files + + # collect all python files in given directories + # ############################################# + unset(pysrcfiles) + foreach(pydir ${GR_PYTHON_INSTALL_DIRECTORY}) + file(GLOB_RECURSE pysrcfiles_tmp "${pydir}/*.py") + list(APPEND pysrcfiles ${pysrcfiles_tmp}) + endforeach(pydir) + + # build target lists + # ################## + unset(pycfiles) # pyc targets + unset(pyofiles) # pyo targets + unset(pygen_paths) # all paths of py[oc] targets + foreach(pyfile ${pysrcfiles}) + # determine if this file is in the source or binary directory + file(RELATIVE_PATH source_rel_path ${CMAKE_CURRENT_SOURCE_DIR} ${pyfile}) + string(LENGTH "${source_rel_path}" source_rel_path_len) + file(RELATIVE_PATH binary_rel_path ${CMAKE_CURRENT_BINARY_DIR} ${pyfile}) + string(LENGTH "${binary_rel_path}" binary_rel_path_len) + + # and set the generated path appropriately + if(${source_rel_path_len} GREATER ${binary_rel_path_len}) + set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${binary_rel_path}) + else() + set(pygenfile ${CMAKE_CURRENT_BINARY_DIR}/${source_rel_path}) + endif() + list(APPEND pycfiles "${pygenfile}c") + list(APPEND pyofiles "${pygenfile}o") + + get_filename_component(pygen_path "${pygenfile}" DIRECTORY) + list(APPEND pygen_paths "${pygen_path}") + file(MAKE_DIRECTORY "${pygen_path}") + endforeach(pyfile) + list(REMOVE_DUPLICATES pygen_paths) + list(SORT pygen_paths) + + # generate the py[oc] files + # ######################### + add_custom_command( + DEPENDS ${pysrcfiles} OUTPUT ${pycfiles} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/python_compile_helper.py ${pysrcfiles} ${pycfiles} + ) + add_custom_command( + DEPENDS ${pysrcfiles} OUTPUT ${pyofiles} + COMMAND ${PYTHON_EXECUTABLE} -O ${CMAKE_BINARY_DIR}/python_compile_helper.py ${pysrcfiles} ${pyofiles} + ) + set(python_install_gen_targets ${pycfiles} ${pyofiles}) + + # per-directory install rules + # ########################### + foreach(pygen_path ${pygen_paths}) + # find all targets in that directory (no "list(FILTER ...)") + unset(pygen_path_targets) + foreach(pyget_target ${python_install_gen_targets}) + get_filename_component(pyget_target_path "${pyget_target}" PATH) + if(pygen_path STREQUAL pyget_target_path) + list(APPEND pygen_path_targets "${pyget_target}") + endif() + endforeach(pyget_target) + + # install relative to current binary dir + file(RELATIVE_PATH pygen_path_rel "${CMAKE_CURRENT_BINARY_DIR}" "${pygen_path}") + list(SORT pygen_path_targets) + install( + FILES ${pygen_path_targets} + DESTINATION "${GR_PYTHON_INSTALL_DESTINATION}/${pygen_path_rel}" + ) + endforeach(pygen_path) + + #################################################################### elseif(GR_PYTHON_INSTALL_PROGRAMS) #################################################################### file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native) diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index eed5202657..3aa05e912a 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -48,9 +48,6 @@ GR_REGISTER_COMPONENT("gnuradio-companion" ENABLE_GRC ${grc_python_deps} ) -######################################################################## -# Begin conditional configuration -######################################################################## if(ENABLE_GRC) ######################################################################## @@ -85,15 +82,22 @@ install( DESTINATION ${GR_PREFSDIR} ) +######################################################################## +# Install (+ compile) python sources and data files +######################################################################## file(GLOB py_files "*.py") - GR_PYTHON_INSTALL( FILES ${py_files} - DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc + DESTINATION "${GR_PYTHON_DIR}/gnuradio/grc" ) +GR_PYTHON_INSTALL( + DIRECTORY core gui + DESTINATION "${GR_PYTHON_DIR}/gnuradio/grc" + FILES_MATCHING REGEX "\\.(py|dtd|grc|tmpl)$" +) ######################################################################## -# Appens NSIS commands to set environment variables +# Append NSIS commands to set environment variables ######################################################################## if(WIN32) @@ -112,8 +116,6 @@ endif(WIN32) # Add subdirectories ######################################################################## add_subdirectory(blocks) -add_subdirectory(gui) -add_subdirectory(core) add_subdirectory(scripts) endif(ENABLE_GRC) diff --git a/grc/core/CMakeLists.txt b/grc/core/CMakeLists.txt deleted file mode 100644 index f340127873..0000000000 --- a/grc/core/CMakeLists.txt +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -file(GLOB py_files "*.py") - -GR_PYTHON_INSTALL( - FILES ${py_files} - DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core -) - -file(GLOB dtd_files "*.dtd") - -install( - FILES ${dtd_files} default_flow_graph.grc - DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core -) - -add_subdirectory(generator) -add_subdirectory(utils) diff --git a/grc/core/generator/CMakeLists.txt b/grc/core/generator/CMakeLists.txt deleted file mode 100644 index 492ad7c4ad..0000000000 --- a/grc/core/generator/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -file(GLOB py_files "*.py") - -GR_PYTHON_INSTALL( - FILES ${py_files} - DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core/generator -) - -install(FILES - flow_graph.tmpl - DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core/generator -) diff --git a/grc/core/utils/CMakeLists.txt b/grc/core/utils/CMakeLists.txt deleted file mode 100644 index 3ba65258a5..0000000000 --- a/grc/core/utils/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2015 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -file(GLOB py_files "*.py") - -GR_PYTHON_INSTALL( - FILES ${py_files} - DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core/utils -) diff --git a/grc/gui/CMakeLists.txt b/grc/gui/CMakeLists.txt deleted file mode 100644 index f4c624288a..0000000000 --- a/grc/gui/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -file(GLOB py_files "*.py") - -GR_PYTHON_INSTALL( - FILES ${py_files} - DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/gui -) - -add_subdirectory(canvas) diff --git a/grc/gui/canvas/CMakeLists.txt b/grc/gui/canvas/CMakeLists.txt deleted file mode 100644 index e24e8c2d56..0000000000 --- a/grc/gui/canvas/CMakeLists.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2016 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -file(GLOB py_files "*.py") - -GR_PYTHON_INSTALL( - FILES ${py_files} - DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core/utils -) |