PageRenderTime 36ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/gnuradio-3.6.1/gnuradio-core/src/lib/gengen/CMakeLists.txt

#
CMake | 174 lines | 111 code | 22 blank | 41 comment | 5 complexity | 0c31d0633fb1475e561f88f6dc0aaa09 MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause
  1. # Copyright 2010-2011 Free Software Foundation, Inc.
  2. #
  3. # This file is part of GNU Radio
  4. #
  5. # GNU Radio is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3, or (at your option)
  8. # any later version.
  9. #
  10. # GNU Radio is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with GNU Radio; see the file COPYING. If not, write to
  17. # the Free Software Foundation, Inc., 51 Franklin Street,
  18. # Boston, MA 02110-1301, USA.
  19. ########################################################################
  20. # This file included, use CMake directory variables
  21. ########################################################################
  22. include(GrPython)
  23. ########################################################################
  24. # generate the python helper script which calls into the build utils
  25. ########################################################################
  26. file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py "
  27. #!${PYTHON_EXECUTABLE}
  28. import sys, os, re
  29. sys.path.append('${GR_CORE_PYTHONPATH}')
  30. os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'
  31. os.chdir('${CMAKE_CURRENT_BINARY_DIR}')
  32. if __name__ == '__main__':
  33. import build_utils
  34. root, inp = sys.argv[1:3]
  35. for sig in sys.argv[3:]:
  36. name = re.sub ('X+', sig, root)
  37. d = build_utils.standard_dict(name, sig)
  38. build_utils.expand_template(d, inp)
  39. ")
  40. ########################################################################
  41. # generation helper macro to generate various files from template
  42. ########################################################################
  43. macro(expand_h_cc_i root)
  44. foreach(ext h cc i)
  45. #make a list of all the generated files
  46. unset(expanded_files_${ext})
  47. foreach(sig ${ARGN})
  48. string(REGEX REPLACE "X+" ${sig} name ${root})
  49. list(APPEND expanded_files_${ext} ${CMAKE_CURRENT_BINARY_DIR}/${name}.${ext})
  50. endforeach(sig)
  51. #create a command to generate the files
  52. add_custom_command(
  53. OUTPUT ${expanded_files_${ext}}
  54. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.${ext}.t
  55. COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
  56. ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
  57. ${root} ${root}.${ext}.t ${ARGN}
  58. )
  59. endforeach(ext)
  60. #make source files depends on headers to force generation
  61. set_source_files_properties(${expanded_files_cc}
  62. PROPERTIES OBJECT_DEPENDS "${expanded_files_h}"
  63. )
  64. #install rules for the generated cc, h, and i files
  65. list(APPEND generated_gengen_sources ${expanded_files_cc})
  66. list(APPEND generated_gengen_includes ${expanded_files_h})
  67. list(APPEND generated_gengen_swigs ${expanded_files_i})
  68. endmacro(expand_h_cc_i)
  69. ########################################################################
  70. # Invoke macro to generate various sources
  71. ########################################################################
  72. expand_h_cc_i(gr_vector_source_X b s i f c)
  73. expand_h_cc_i(gr_vector_insert_X b)
  74. expand_h_cc_i(gr_vector_sink_X b s i f c)
  75. expand_h_cc_i(gr_noise_source_X s i f c)
  76. expand_h_cc_i(gr_sig_source_X s i f c)
  77. expand_h_cc_i(gr_probe_signal_X b s i f c)
  78. expand_h_cc_i(gr_probe_signal_vX b s i f c)
  79. expand_h_cc_i(gr_add_const_XX ss ii ff cc sf)
  80. expand_h_cc_i(gr_multiply_const_XX ss ii)
  81. expand_h_cc_i(gr_add_XX ss ii cc)
  82. expand_h_cc_i(gr_sub_XX ss ii ff cc)
  83. expand_h_cc_i(gr_multiply_XX ss ii)
  84. expand_h_cc_i(gr_divide_XX ss ii ff cc)
  85. expand_h_cc_i(gr_mute_XX ss ii ff cc)
  86. expand_h_cc_i(gr_add_const_vXX ss ii ff cc)
  87. expand_h_cc_i(gr_multiply_const_vXX ss ii ff cc)
  88. expand_h_cc_i(gr_integrate_XX ss ii ff cc)
  89. expand_h_cc_i(gr_moving_average_XX ss ii ff cc)
  90. expand_h_cc_i(gr_chunks_to_symbols_XX bf bc sf sc if ic)
  91. expand_h_cc_i(gr_unpacked_to_packed_XX bb ss ii)
  92. expand_h_cc_i(gr_packed_to_unpacked_XX bb ss ii)
  93. expand_h_cc_i(gr_xor_XX bb ss ii)
  94. expand_h_cc_i(gr_and_XX bb ss ii)
  95. expand_h_cc_i(gr_and_const_XX bb ss ii)
  96. expand_h_cc_i(gr_or_XX bb ss ii)
  97. expand_h_cc_i(gr_not_XX bb ss ii)
  98. expand_h_cc_i(gr_sample_and_hold_XX bb ss ii ff)
  99. expand_h_cc_i(gr_argmax_XX fs is ss)
  100. expand_h_cc_i(gr_max_XX ff ii ss)
  101. expand_h_cc_i(gr_peak_detector_XX fb ib sb)
  102. add_custom_target(gengen_generated DEPENDS
  103. ${generated_gengen_includes}
  104. ${generated_gengen_swigs}
  105. )
  106. ########################################################################
  107. # Create the master gengen swig include files
  108. ########################################################################
  109. set(generated_index ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i.in)
  110. file(WRITE ${generated_index} "
  111. //
  112. // This file is machine generated. All edits will be overwritten
  113. //
  114. ")
  115. file(APPEND ${generated_index} "%{\n")
  116. foreach(swig_file ${generated_gengen_swigs})
  117. get_filename_component(name ${swig_file} NAME_WE)
  118. file(APPEND ${generated_index} "#include<${name}.h>\n")
  119. endforeach(swig_file)
  120. file(APPEND ${generated_index} "%}\n")
  121. foreach(swig_file ${generated_gengen_swigs})
  122. get_filename_component(name ${swig_file} NAME)
  123. file(APPEND ${generated_index} "%include<${name}>\n")
  124. endforeach(swig_file)
  125. execute_process(
  126. COMMAND ${CMAKE_COMMAND} -E copy_if_different
  127. ${generated_index} ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i
  128. )
  129. ########################################################################
  130. # Handle the generated sources + a few non-generated ones
  131. ########################################################################
  132. list(APPEND gnuradio_core_sources
  133. ${generated_gengen_sources}
  134. )
  135. install(FILES
  136. ${generated_gengen_includes}
  137. ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.h
  138. ${CMAKE_CURRENT_SOURCE_DIR}/gr_noise_type.h
  139. ${CMAKE_CURRENT_SOURCE_DIR}/gr_sig_source_waveform.h
  140. DESTINATION ${GR_INCLUDE_DIR}/gnuradio
  141. COMPONENT "core_devel"
  142. )
  143. if(ENABLE_PYTHON)
  144. install(FILES
  145. ${generated_gengen_swigs}
  146. ${CMAKE_CURRENT_SOURCE_DIR}/gr_endianness.i
  147. ${CMAKE_CURRENT_SOURCE_DIR}/gengen.i
  148. ${CMAKE_CURRENT_BINARY_DIR}/gengen_generated.i
  149. DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
  150. COMPONENT "core_swig"
  151. )
  152. endif(ENABLE_PYTHON)