commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 03/03: cmake: modtool: update Modules to GR


From: git
Subject: [Commit-gnuradio] [gnuradio] 03/03: cmake: modtool: update Modules to GR master
Date: Mon, 13 Oct 2014 21:00:48 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit c3a55f7e867951f23fef1b1943b6447540381ff9
Author: Michael Dickens <address@hidden>
Date:   Sun Oct 12 21:36:30 2014 -0400

    cmake: modtool: update Modules to GR master
---
 .../gr-newmod/cmake/Modules/FindCppUnit.cmake      |   3 +
 .../gr-newmod/cmake/Modules/GrMiscUtils.cmake      | 321 ++++++++++++++++++++-
 .../gr-newmod/cmake/Modules/GrPlatform.cmake       |  10 +-
 .../modtool/gr-newmod/cmake/Modules/GrPython.cmake |  25 +-
 .../modtool/gr-newmod/cmake/Modules/GrSwig.cmake   |  50 +++-
 .../modtool/gr-newmod/cmake/Modules/GrTest.cmake   |  22 +-
 6 files changed, 402 insertions(+), 29 deletions(-)

diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/FindCppUnit.cmake 
b/gr-utils/python/modtool/gr-newmod/cmake/Modules/FindCppUnit.cmake
index 9af308f..f93ade3 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/FindCppUnit.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/FindCppUnit.cmake
@@ -15,6 +15,7 @@ PKG_CHECK_MODULES(PC_CPPUNIT "cppunit")
 FIND_PATH(CPPUNIT_INCLUDE_DIRS
     NAMES cppunit/TestCase.h
     HINTS ${PC_CPPUNIT_INCLUDE_DIR}
+    ${CMAKE_INSTALL_PREFIX}/include
     PATHS
     /usr/local/include
     /usr/include
@@ -23,6 +24,8 @@ FIND_PATH(CPPUNIT_INCLUDE_DIRS
 FIND_LIBRARY(CPPUNIT_LIBRARIES
     NAMES cppunit
     HINTS ${PC_CPPUNIT_LIBDIR}
+    ${CMAKE_INSTALL_PREFIX}/lib
+    ${CMAKE_INSTALL_PREFIX}/lib64
     PATHS
     ${CPPUNIT_INCLUDE_DIRS}/../lib
     /usr/local/lib
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake 
b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
index 9331d5d..188c404 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrMiscUtils.cmake
@@ -1,4 +1,4 @@
-# Copyright 2010-2011 Free Software Foundation, Inc.
+# Copyright 2010-2011,2014 Free Software Foundation, Inc.
 #
 # This file is part of GNU Radio
 #
@@ -94,7 +94,13 @@ macro(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have)
     include(CheckCXXCompilerFlag)
     CHECK_CXX_COMPILER_FLAG(${flag} ${have})
     if(${have})
-        add_definitions(${flag})
+      if(${CMAKE_VERSION} VERSION_GREATER "2.8.4")
+        STRING(FIND "${CMAKE_CXX_FLAGS}" "${flag}" flag_dup)
+        if(${flag_dup} EQUAL -1)
+          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+          set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
+        endif(${flag_dup} EQUAL -1)
+      endif(${CMAKE_VERSION} VERSION_GREATER "2.8.4")
     endif(${have})
 endmacro(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE)
 
@@ -155,7 +161,7 @@ function(GR_LIBRARY_FOO target)
         GR_LIBTOOL(TARGET ${target} DESTINATION ${GR_LIBRARY_DIR})
 
         #give the library a special name with ultra-zero soversion
-        set_target_properties(${target} PROPERTIES LIBRARY_OUTPUT_NAME 
${target}-${LIBVER} SOVERSION "0.0.0")
+        set_target_properties(${target} PROPERTIES OUTPUT_NAME 
${target}-${LIBVER} SOVERSION "0.0.0")
         set(target_name lib${target}-${LIBVER}.so.0.0.0)
 
         #custom command to generate symlinks
@@ -208,3 +214,312 @@ function(GR_GEN_TARGET_DEPS name var)
         set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE)
     endif()
 endfunction(GR_GEN_TARGET_DEPS)
+
+########################################################################
+# Control use of gr_logger
+# Usage:
+#   GR_LOGGING()
+#
+# Will set ENABLE_GR_LOG to 1 by default.
+# Can manually set with -DENABLE_GR_LOG=0|1
+########################################################################
+function(GR_LOGGING)
+  find_package(Log4cpp)
+
+  OPTION(ENABLE_GR_LOG "Use gr_logger" ON)
+  if(ENABLE_GR_LOG)
+    # If gr_logger is enabled, make it usable
+    add_definitions( -DENABLE_GR_LOG )
+
+    # also test LOG4CPP; if we have it, use this version of the logger
+    # otherwise, default to the stdout/stderr model.
+    if(LOG4CPP_FOUND)
+      SET(HAVE_LOG4CPP True CACHE INTERNAL "" FORCE)
+      add_definitions( -DHAVE_LOG4CPP )
+    else(not LOG4CPP_FOUND)
+      SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE)
+      SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE)
+      SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE)
+      SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE)
+    endif(LOG4CPP_FOUND)
+
+    SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE)
+
+  else(ENABLE_GR_LOG)
+    SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE)
+    SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE)
+    SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE)
+    SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE)
+  endif(ENABLE_GR_LOG)
+
+  message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.")
+  message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.")
+  message(STATUS "LOG4CPP_LIBRARIES set to ${LOG4CPP_LIBRARIES}.")
+
+endfunction(GR_LOGGING)
+
+########################################################################
+# Run GRCC to compile .grc files into .py files.
+#
+# Usage: GRCC(filename, directory)
+#    - filenames: List of file name of .grc file
+#    - directory: directory of built .py file - usually in
+#                 ${CMAKE_CURRENT_BINARY_DIR}
+#    - Sets PYFILES: output converted GRC file names to Python files.
+########################################################################
+function(GRCC)
+  # Extract directory from list of args, remove it for the list of filenames.
+  list(GET ARGV -1 directory)
+  list(REMOVE_AT ARGV -1)
+  set(filenames ${ARGV})
+  file(MAKE_DIRECTORY ${directory})
+
+  SET(GRCC_COMMAND ${CMAKE_SOURCE_DIR}/gr-utils/python/grcc)
+
+  # GRCC uses some stuff in grc and gnuradio-runtime, so we force
+  # the known paths here
+  list(APPEND PYTHONPATHS
+    ${CMAKE_SOURCE_DIR}
+    ${CMAKE_SOURCE_DIR}/gnuradio-runtime/python
+    ${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/swig
+    ${CMAKE_BINARY_DIR}/gnuradio-runtime/lib/swig
+    )
+
+  if(WIN32)
+    #SWIG generates the python library files into a subdirectory.
+    #Therefore, we must append this subdirectory into PYTHONPATH.
+    #Only do this for the python directories matching the following:
+    foreach(pydir ${PYTHONPATHS})
+      get_filename_component(name ${pydir} NAME)
+      if(name MATCHES "^(swig|lib|src)$")
+        list(APPEND PYTHONPATHS ${pydir}/${CMAKE_BUILD_TYPE})
+      endif()
+    endforeach(pydir)
+  endif(WIN32)
+
+  file(TO_NATIVE_PATH "${PYTHONPATHS}" pypath)
+
+  if(UNIX)
+    list(APPEND pypath "$PYTHONPATH")
+    string(REPLACE ";" ":" pypath "${pypath}")
+    set(ENV{PYTHONPATH} ${pypath})
+  endif(UNIX)
+
+  if(WIN32)
+    list(APPEND pypath "%PYTHONPATH%")
+    string(REPLACE ";" "\\;" pypath "${pypath}")
+    #list(APPEND environs "PYTHONPATH=${pypath}")
+    set(ENV{PYTHONPATH} ${pypath})
+  endif(WIN32)
+
+  foreach(f ${filenames})
+    execute_process(
+      COMMAND ${GRCC_COMMAND} -d ${directory} ${f}
+      )
+    string(REPLACE ".grc" ".py" pyfile "${f}")
+    string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" 
pyfile "${pyfile}")
+    list(APPEND pyfiles ${pyfile})
+  endforeach(f)
+
+  set(PYFILES ${pyfiles} PARENT_SCOPE)
+endfunction(GRCC)
+
+########################################################################
+# Check if HAVE_PTHREAD_SETSCHEDPARAM and HAVE_SCHED_SETSCHEDULER
+#  should be defined
+########################################################################
+macro(GR_CHECK_LINUX_SCHED_AVAIL)
+set(CMAKE_REQUIRED_LIBRARIES -lpthread)
+    CHECK_CXX_SOURCE_COMPILES("
+        #include <pthread.h>
+        int main(){
+            pthread_t pthread;
+            pthread_setschedparam(pthread,  0, 0);
+            return 0;
+        } " HAVE_PTHREAD_SETSCHEDPARAM
+    )
+    GR_ADD_COND_DEF(HAVE_PTHREAD_SETSCHEDPARAM)
+
+    CHECK_CXX_SOURCE_COMPILES("
+        #include <sched.h>
+        int main(){
+            pid_t pid;
+            sched_setscheduler(pid, 0, 0);
+            return 0;
+        } " HAVE_SCHED_SETSCHEDULER
+    )
+    GR_ADD_COND_DEF(HAVE_SCHED_SETSCHEDULER)
+endmacro(GR_CHECK_LINUX_SCHED_AVAIL)
+
+########################################################################
+# Macros to generate source and header files from template
+########################################################################
+macro(GR_EXPAND_X_H component root)
+
+  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_dict2(name, sig, '${component}')
+        build_utils.expand_template(d, inp)
+")
+
+  #make a list of all the generated headers
+  unset(expanded_files_h)
+  foreach(sig ${ARGN})
+    string(REGEX REPLACE "X+" ${sig} name ${root})
+    list(APPEND expanded_files_h ${CMAKE_CURRENT_BINARY_DIR}/${name}.h)
+  endforeach(sig)
+  unset(name)
+
+  #create a command to generate the headers
+  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}
+  )
+
+  #install rules for the generated headers
+  list(APPEND generated_includes ${expanded_files_h})
+
+endmacro(GR_EXPAND_X_H)
+
+macro(GR_EXPAND_X_CC_H component root)
+
+  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, '${component}')
+        build_utils.expand_template(d, inp)
+")
+
+  #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)
+  unset(name)
+
+  #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 files
+  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 files
+  list(APPEND generated_sources ${expanded_files_cc})
+  list(APPEND generated_headers ${expanded_files_h})
+
+endmacro(GR_EXPAND_X_CC_H)
+
+macro(GR_EXPAND_X_CC_H_IMPL component root)
+
+  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_dict(name, sig, '${component}')
+        build_utils.expand_template(d, inp, '_impl')
+")
+
+  #make a list of all the generated files
+  unset(expanded_files_cc_impl)
+  unset(expanded_files_h_impl)
+  unset(expanded_files_h)
+  foreach(sig ${ARGN})
+    string(REGEX REPLACE "X+" ${sig} name ${root})
+    list(APPEND expanded_files_cc_impl 
${CMAKE_CURRENT_BINARY_DIR}/${name}_impl.cc)
+    list(APPEND expanded_files_h_impl 
${CMAKE_CURRENT_BINARY_DIR}/${name}_impl.h)
+    list(APPEND expanded_files_h 
${CMAKE_CURRENT_BINARY_DIR}/../include/gnuradio/${component}/${name}.h)
+  endforeach(sig)
+  unset(name)
+
+  #create a command to generate the _impl.cc files
+  add_custom_command(
+    OUTPUT ${expanded_files_cc_impl}
+    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}_impl.cc.t
+    COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+    ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
+    ${root} ${root}_impl.cc.t ${ARGN}
+  )
+
+  #create a command to generate the _impl.h files
+  add_custom_command(
+    OUTPUT ${expanded_files_h_impl}
+    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${root}_impl.h.t
+    COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
+    ${CMAKE_CURRENT_BINARY_DIR}/generate_helper.py
+    ${root} ${root}_impl.h.t ${ARGN}
+  )
+
+  #make _impl.cc source files depend on _impl.h to force generation
+  set_source_files_properties(${expanded_files_cc_impl}
+    PROPERTIES OBJECT_DEPENDS "${expanded_files_h_impl}"
+  )
+
+  #make _impl.h source files depend on headers to force generation
+  set_source_files_properties(${expanded_files_h_impl}
+    PROPERTIES OBJECT_DEPENDS "${expanded_files_h}"
+  )
+
+  #install rules for the generated files
+  list(APPEND generated_sources ${expanded_files_cc_impl})
+  list(APPEND generated_headers ${expanded_files_h_impl})
+
+endmacro(GR_EXPAND_X_CC_H_IMPL)
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPlatform.cmake 
b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPlatform.cmake
index a2e4f3b..5b7e886 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPlatform.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPlatform.cmake
@@ -37,10 +37,18 @@ if(LINUX AND EXISTS "/etc/redhat-release")
     set(REDHAT TRUE)
 endif()
 
+if(LINUX AND EXISTS "/etc/slackware-version")
+    set(SLACKWARE TRUE)
+endif()
+
 ########################################################################
 # when the library suffix should be 64 (applies to redhat linux family)
 ########################################################################
-if(NOT DEFINED LIB_SUFFIX AND REDHAT AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$")
+if (REDHAT OR SLACKWARE)
+    set(LIB64_CONVENTION TRUE)
+endif()
+
+if(NOT DEFINED LIB_SUFFIX AND LIB64_CONVENTION AND CMAKE_SYSTEM_PROCESSOR 
MATCHES "64$")
     set(LIB_SUFFIX 64)
 endif()
 set(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix")
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake 
b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
index 68ca58e..395faff 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrPython.cmake
@@ -48,8 +48,15 @@ else(PYTHON_EXECUTABLE)
 
 endif(PYTHON_EXECUTABLE)
 
+if (CMAKE_CROSSCOMPILING)
+    set(QA_PYTHON_EXECUTABLE "/usr/bin/python")
+else (CMAKE_CROSSCOMPILING)
+    set(QA_PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
+endif(CMAKE_CROSSCOMPILING)
+
 #make the path to the executable appear in the cmake gui
 set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter")
+set(QA_PYTHON_EXECUTABLE ${QA_PYTHON_EXECUTABLE} CACHE FILEPATH "python 
interpreter for QA tests")
 
 #make sure we can use -B with python (introduced in 2.6)
 if(PYTHON_EXECUTABLE)
@@ -76,10 +83,11 @@ macro(GR_PYTHON_CHECK_MODULE desc mod cmd have)
     execute_process(
         COMMAND ${PYTHON_EXECUTABLE} -c "
 #########################################
-try: import ${mod}
-except: exit(-1)
-try: assert ${cmd}
-except: exit(-1)
+try:
+    import ${mod}
+    assert ${cmd}
+except ImportError, AssertionError: exit(-1)
+except: pass
 #########################################"
         RESULT_VARIABLE ${have}
     )
@@ -95,11 +103,13 @@ endmacro(GR_PYTHON_CHECK_MODULE)
 ########################################################################
 # Sets the python installation directory GR_PYTHON_DIR
 ########################################################################
+if(NOT DEFINED GR_PYTHON_DIR)
 execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
 from distutils import sysconfig
 print sysconfig.get_python_lib(plat_specific=True, prefix='')
 " OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
 )
+endif()
 file(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR)
 
 ########################################################################
@@ -181,6 +191,10 @@ function(GR_PYTHON_INSTALL)
     ####################################################################
         file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native)
 
+        if (CMAKE_CROSSCOMPILING)
+           set(pyexe_native "/usr/bin/env python")
+        endif()
+
         foreach(pyfile ${GR_PYTHON_INSTALL_PROGRAMS})
             get_filename_component(pyfile_name ${pyfile} NAME)
             get_filename_component(pyfile ${pyfile} ABSOLUTE)
@@ -193,8 +207,9 @@ function(GR_PYTHON_INSTALL)
             add_custom_command(
                 OUTPUT ${pyexefile} DEPENDS ${pyfile}
                 COMMAND ${PYTHON_EXECUTABLE} -c
-                \"open('${pyexefile}', 
'w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())\"
+                
"open('${pyexefile}','w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())"
                 COMMENT "Shebangin ${pyfile_name}"
+                VERBATIM
             )
 
             #on windows, python files need an extension to execute
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake 
b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
index 569667b..abf4dc4 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrSwig.cmake
@@ -33,14 +33,13 @@ include(GrPython)
 #   - GR_SWIG_DOCS_TARGET_DEPS
 ########################################################################
 function(GR_SWIG_MAKE_DOCS output_file)
-    find_package(Doxygen)
-    if(DOXYGEN_FOUND)
+    if(ENABLE_DOXYGEN)
 
         #setup the input files variable list, quote formated
         set(input_files)
         unset(INPUT_PATHS)
         foreach(input_path ${ARGN})
-            if (IS_DIRECTORY ${input_path}) #when input path is a directory
+            if(IS_DIRECTORY ${input_path}) #when input path is a directory
                 file(GLOB input_path_h_files ${input_path}/*.h)
             else() #otherwise its just a file, no glob
                 set(input_path_h_files ${input_path})
@@ -76,17 +75,18 @@ function(GR_SWIG_MAKE_DOCS output_file)
         #call the swig_doc script on the xml files
         add_custom_command(
             OUTPUT ${output_file}
-            DEPENDS ${input_files} ${OUTPUT_DIRECTORY}/xml/index.xml
+            DEPENDS ${input_files} ${stamp-file} 
${OUTPUT_DIRECTORY}/xml/index.xml
             COMMAND ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B}
                 ${CMAKE_SOURCE_DIR}/docs/doxygen/swig_doc.py
                 ${OUTPUT_DIRECTORY}/xml
                 ${output_file}
+            COMMENT "Generating python docstrings for ${name}"
             WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/docs/doxygen
         )
 
-    else(DOXYGEN_FOUND)
+    else(ENABLE_DOXYGEN)
         file(WRITE ${output_file} "\n") #no doxygen -> empty file
-    endif(DOXYGEN_FOUND)
+    endif(ENABLE_DOXYGEN)
 endfunction(GR_SWIG_MAKE_DOCS)
 
 ########################################################################
@@ -105,20 +105,35 @@ endfunction(GR_SWIG_MAKE_DOCS)
 macro(GR_SWIG_MAKE name)
     set(ifiles ${ARGN})
 
+    # Shimming this in here to take care of a SWIG bug with handling
+    # vector<size_t> and vector<unsigned int> (on 32-bit machines) and
+    # vector<long unsigned int> (on 64-bit machines). Use this to test
+    # the size of size_t, then set SIZE_T_32 if it's a 32-bit machine
+    # or not if it's 64-bit. The logic in gr_type.i handles the rest.
+    INCLUDE(CheckTypeSize)
+    CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T)
+    CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT)
+    if(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT})
+      list(APPEND GR_SWIG_FLAGS -DSIZE_T_32)
+    endif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT})
+
     #do swig doc generation if specified
-    if (GR_SWIG_DOC_FILE)
+    if(GR_SWIG_DOC_FILE)
         set(GR_SWIG_DOCS_SOURCE_DEPS ${GR_SWIG_SOURCE_DEPS})
-        set(GR_SWIG_DOCS_TAREGT_DEPS ${GR_SWIG_TARGET_DEPS})
+        list(APPEND GR_SWIG_DOCS_TARGET_DEPS ${GR_SWIG_TARGET_DEPS})
         GR_SWIG_MAKE_DOCS(${GR_SWIG_DOC_FILE} ${GR_SWIG_DOC_DIRS})
-        list(APPEND GR_SWIG_SOURCE_DEPS ${GR_SWIG_DOC_FILE})
+        add_custom_target(${name}_swig_doc DEPENDS ${GR_SWIG_DOC_FILE})
+        list(APPEND GR_SWIG_TARGET_DEPS ${name}_swig_doc 
${GR_RUNTIME_SWIG_DOC_FILE})
     endif()
 
     #append additional include directories
     find_package(PythonLibs 2)
     list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) #deprecated name 
(now dirs)
     list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
-    list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
-    list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR})
+
+    #prepend local swig directories
+    list(INSERT GR_SWIG_INCLUDE_DIRS 0 ${CMAKE_CURRENT_SOURCE_DIR})
+    list(INSERT GR_SWIG_INCLUDE_DIRS 0 ${CMAKE_CURRENT_BINARY_DIR})
 
     #determine include dependencies for swig file
     execute_process(
@@ -157,6 +172,9 @@ macro(GR_SWIG_MAKE name)
     include(UseSWIG)
     SWIG_ADD_MODULE(${name} python ${ifiles})
     SWIG_LINK_LIBRARIES(${name} ${PYTHON_LIBRARIES} ${GR_SWIG_LIBRARIES})
+    if(${name} STREQUAL "runtime_swig")
+        SET_TARGET_PROPERTIES(${SWIG_MODULE_runtime_swig_REAL_NAME} PROPERTIES 
DEFINE_SYMBOL "gnuradio_runtime_EXPORTS")
+    endif(${name} STREQUAL "runtime_swig")
 
 endmacro(GR_SWIG_MAKE)
 
@@ -204,21 +222,25 @@ file(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py "
 
 import os, sys, re
 
-include_matcher = re.compile('[#|%]include\\s*[<|\"](.*)[>|\"]')
+i_include_matcher = re.compile('%(include|import)\\s*[<|\"](.*)[>|\"]')
+h_include_matcher = re.compile('#(include)\\s*[<|\"](.*)[>|\"]')
 include_dirs = sys.argv[2].split(';')
 
 def get_swig_incs(file_path):
+    if file_path.endswith('.i'): matcher = i_include_matcher
+    else: matcher = h_include_matcher
     file_contents = open(file_path, 'r').read()
-    return include_matcher.findall(file_contents, re.MULTILINE)
+    return matcher.findall(file_contents, re.MULTILINE)
 
 def get_swig_deps(file_path, level):
     deps = [file_path]
     if level == 0: return deps
-    for inc_file in get_swig_incs(file_path):
+    for keyword, inc_file in get_swig_incs(file_path):
         for inc_dir in include_dirs:
             inc_path = os.path.join(inc_dir, inc_file)
             if not os.path.exists(inc_path): continue
             deps.extend(get_swig_deps(inc_path, level-1))
+            break #found, we dont search in lower prio inc dirs
     return deps
 
 if __name__ == '__main__':
diff --git a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrTest.cmake 
b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrTest.cmake
index 6174c03..62caab4 100644
--- a/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrTest.cmake
+++ b/gr-utils/python/modtool/gr-newmod/cmake/Modules/GrTest.cmake
@@ -30,10 +30,10 @@ set(__INCLUDED_GR_TEST_CMAKE TRUE)
 # GR_TEST_TARGET_DEPS  - built targets for the library path
 # GR_TEST_LIBRARY_DIRS - directories for the library path
 # GR_TEST_PYTHON_DIRS  - directories for the python path
+# GR_TEST_ENVIRONS  - other environment key/value pairs
 ########################################################################
 function(GR_ADD_TEST test_name)
 
-    if(WIN32)
         #Ensure that the build exe also appears in the PATH.
         list(APPEND GR_TEST_TARGET_DEPS ${ARGN})
 
@@ -50,6 +50,7 @@ function(GR_ADD_TEST test_name)
             endif(location)
         endforeach(target)
 
+    if(WIN32)
         #SWIG generates the python library files into a subdirectory.
         #Therefore, we must append this subdirectory into PYTHONPATH.
         #Only do this for the python directories matching the following:
@@ -65,7 +66,8 @@ function(GR_ADD_TEST test_name)
     file(TO_NATIVE_PATH "${GR_TEST_LIBRARY_DIRS}" libpath) #ok to use on dir 
list?
     file(TO_NATIVE_PATH "${GR_TEST_PYTHON_DIRS}" pypath) #ok to use on dir 
list?
 
-    set(environs "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}")
+    set(environs "VOLK_GENERIC=1" "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}")
+    list(APPEND environs ${GR_TEST_ENVIRONS})
 
     #http://www.cmake.org/pipermail/cmake/2009-May/029464.html
     #Replaced this add test + set environs code with the shell script 
generation.
@@ -74,18 +76,26 @@ function(GR_ADD_TEST test_name)
     #SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}")
 
     if(UNIX)
+        set(LD_PATH_VAR "LD_LIBRARY_PATH")
+        if(APPLE)
+            set(LD_PATH_VAR "DYLD_LIBRARY_PATH")
+        endif()
+
         set(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH")
-        #set both LD and DYLD paths to cover multiple UNIX OS library paths
-        list(APPEND libpath "$LD_LIBRARY_PATH" "$DYLD_LIBRARY_PATH")
+        list(APPEND libpath "$${LD_PATH_VAR}")
         list(APPEND pypath "$PYTHONPATH")
 
         #replace list separator with the path separator
         string(REPLACE ";" ":" libpath "${libpath}")
         string(REPLACE ";" ":" pypath "${pypath}")
-        list(APPEND environs "PATH=${binpath}" "LD_LIBRARY_PATH=${libpath}" 
"DYLD_LIBRARY_PATH=${libpath}" "PYTHONPATH=${pypath}")
+        list(APPEND environs "PATH=${binpath}" "${LD_PATH_VAR}=${libpath}" 
"PYTHONPATH=${pypath}")
 
         #generate a bat file that sets the environment and runs the test
-        find_program(SHELL sh)
+       if (CMAKE_CROSSCOMPILING)
+                set(SHELL "/bin/sh")
+        else(CMAKE_CROSSCOMPILING)
+                find_program(SHELL sh)
+        endif(CMAKE_CROSSCOMPILING)
         set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh)
         file(WRITE ${sh_file} "#!${SHELL}\n")
         #each line sets an environment variable



reply via email to

[Prev in Thread] Current Thread [Next in Thread]