From 20530e6f7161c5ebd43c2344f411be5d05e9eafa Mon Sep 17 00:00:00 2001
From: Michael Dickens <mlk@alum.mit.edu>
Date: Thu, 24 Jul 2014 15:14:30 -0400
Subject: cmake: coalesce EXPAND macros into 3 common macros, and switch to
 using those; simplifies code and makes maintenance easier.

---
 gr-digital/lib/CMakeLists.txt | 67 ++-----------------------------------------
 1 file changed, 3 insertions(+), 64 deletions(-)

(limited to 'gr-digital/lib/CMakeLists.txt')

diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt
index a59120e48a..f9830fbbf2 100644
--- a/gr-digital/lib/CMakeLists.txt
+++ b/gr-digital/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011-2013 Free Software Foundation, Inc.
+# Copyright 2011-2014 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -41,71 +41,11 @@ if(ENABLE_GR_CTRLPORT)
   include_directories(${ICE_INCLUDE_DIR})
 endif(ENABLE_GR_CTRLPORT)
 
-########################################################################
-# generate helper scripts to expand templated files
-########################################################################
-include(GrPython)
-
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py "
-#!${PYTHON_EXECUTABLE}
-
-import sys, os, re
-sys.path.append('${GR_RUNTIME_PYTHONPATH}')
-os.environ['srcdir'] = '${CMAKE_CURRENT_SOURCE_DIR}'
-os.chdir('${CMAKE_CURRENT_BINARY_DIR}')
-
-if __name__ == '__main__':
-    import build_utils
-    root, inp = sys.argv[1:3]
-    for sig in sys.argv[3:]:
-        name = re.sub ('X+', sig, root)
-        d = build_utils.standard_impl_dict2(name, sig, 'digital')
-        build_utils.expand_template(d, inp)
-")
-
-macro(expand_cc root)
-  #make a list of all the generated files
-  unset(expanded_files_cc)
-  unset(expanded_files_h)
-  foreach(sig ${ARGN})
-    string(REGEX REPLACE "X+" ${sig} name ${root})
-    list(APPEND expanded_files_cc ${CMAKE_CURRENT_BINARY_DIR}/${name}.cc)
-    list(APPEND expanded_files_h  ${CMAKE_CURRENT_BINARY_DIR}/${name}.h)
-  endforeach(sig)
-
-  #create a command to generate the source files
-  add_custom_command(
-    OUTPUT ${expanded_files_cc}
-    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.cc.t
-    COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
-    ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
-    ${root} ${root}.cc.t ${ARGN}
-  )
-
-  #create a command to generate the header file
-  add_custom_command(
-    OUTPUT ${expanded_files_h}
-    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}.h.t
-    COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
-    ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
-    ${root} ${root}.h.t ${ARGN}
-  )
-
-  #make source files depends on headers to force generation
-  set_source_files_properties(${expanded_files_cc}
-    PROPERTIES OBJECT_DEPENDS "${expanded_files_h}"
-  )
-
-  #install rules for the generated cc files
-  list(APPEND generated_sources ${expanded_files_cc})
-  list(APPEND generated_headers ${expanded_files_h})
-endmacro(expand_cc)
-
-
 ########################################################################
 # Invoke macro to generate various sources
 ########################################################################
-expand_cc(chunks_to_symbols_XX_impl     bf bc sf sc if ic)
+include(GrMiscUtils)
+GR_EXPAND_X_CC_H(digital chunks_to_symbols_XX_impl     bf bc sf sc if ic)
 
 ########################################################################
 # Setup library
@@ -202,7 +142,6 @@ list(APPEND digital_libs
     ${LOG4CPP_LIBRARIES}
 )
 
-
 add_library(gnuradio-digital SHARED ${digital_sources})
 target_link_libraries(gnuradio-digital ${digital_libs})
 GR_LIBRARY_FOO(gnuradio-digital RUNTIME_COMPONENT "digital_runtime" DEVEL_COMPONENT "digital_devel")
-- 
cgit v1.2.3