blob: 4589fd489f494e965f6f74cf9e611ad9d14daf1a [file] [log] [blame]
Piotr Krysikf00936d2018-06-18 14:59:18 +02001# Author (C) 2018 by Piotr Krysik <ptrkrysik@gmail.com>
2# Author (C) 2018 by Vasil Velichkov <vvvelichkov@gmail.com>
3#
4# This file is part of GNU Radio
5#
6# GNU Radio is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 3, or (at your option)
9# any later version.
10#
11# GNU Radio is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with GNU Radio; see the file COPYING. If not, write to
18# the Free Software Foundation, Inc., 51 Franklin Street,
19# Boston, MA 02110-1301, USA.
20
21SET(PYTHONPATH
22 ${CMAKE_SOURCE_DIR}/python
23 ${CMAKE_SOURCE_DIR}/python/misc_utils
24 ${CMAKE_SOURCE_DIR}/python/demapping
25 ${CMAKE_SOURCE_DIR}/python/receiver
26 ${CMAKE_SOURCE_DIR}/python/transmitter
27 ${CMAKE_SOURCE_DIR}/python/trx
28 ${CMAKE_BINARY_DIR}/swig
29 $ENV{PYTHONPATH}
30 )
31string(REPLACE ";" ":" PYTHONPATH "${PYTHONPATH}")
32
Vasil Velichkov1789ae22019-08-13 20:32:05 +000033find_program(GRCC grcc
34 PATHS ${CMAKE_INSTALL_PREFIX}/${GR_RUNTIME_DIR}
35 )
36
Piotr Krysikf00936d2018-06-18 14:59:18 +020037macro(GRCC_COMPILE file_name)
Vasil Velichkov1789ae22019-08-13 20:32:05 +000038 ADD_CUSTOM_COMMAND(
39 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file_name}
40 COMMAND "${CMAKE_COMMAND}"
41 -E env PYTHONPATH="${PYTHONPATH}" GRC_BLOCKS_PATH=${CMAKE_SOURCE_DIR}/grc
42 ${GRCC} -o ${CMAKE_CURRENT_BINARY_DIR}
43 ${CMAKE_CURRENT_SOURCE_DIR}/${file_name}.grc
44 COMMAND "${CMAKE_COMMAND}" -E rename ${CMAKE_CURRENT_BINARY_DIR}/${file_name}.py ${CMAKE_CURRENT_BINARY_DIR}/${file_name}
45 DEPENDS ${file_name}.grc
Piotr Krysikf00936d2018-06-18 14:59:18 +020046 )
Piotr Krysikf00936d2018-06-18 14:59:18 +020047endmacro(GRCC_COMPILE)
48
49########################################################################
50# Override the GR_UNIQUE_TARGET function to not append a hash
51# to the `target` name, because we need a known name in order
52# to add an explicit dependency that's needed for the parallel build
53#
54# The original code segment (taken from GrPython.cmake) is
55#
56# execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib
57#unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5]
58#print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))"
59# OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE)
60#
61########################################################################
62function(GR_UNIQUE_TARGET desc)
63 file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
64 execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib
65print(re.sub('\\W', '_', '${desc} ${reldir}'))"
66 OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE)
67 add_custom_target(${_target} ALL DEPENDS ${ARGN})
68endfunction(GR_UNIQUE_TARGET)