forked from sdr/gr-osmosdr
update cmake modules from gnuradio master
This commit is contained in:
parent
b74aeb108e
commit
dc28f6c4c8
|
@ -155,7 +155,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 +208,70 @@ function(GR_GEN_TARGET_DEPS name var)
|
|||
set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction(GR_GEN_TARGET_DEPS)
|
||||
|
||||
|
||||
########################################################################
|
||||
# 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/src/python/grcc)
|
||||
|
||||
# GRCC uses some stuff in grc and gnuradio-core, so we force
|
||||
# the known paths here
|
||||
list(APPEND PYTHONPATHS
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/gnuradio-core/src/python
|
||||
${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/swig
|
||||
${CMAKE_BINARY_DIR}/gnuradio-core/src/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)
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -76,10 +76,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 +96,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 +184,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)
|
||||
|
|
|
@ -33,8 +33,7 @@ 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)
|
||||
|
@ -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)
|
||||
|
||||
########################################################################
|
||||
|
@ -108,9 +108,10 @@ macro(GR_SWIG_MAKE name)
|
|||
#do swig doc generation if specified
|
||||
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})
|
||||
set(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)
|
||||
endif()
|
||||
|
||||
#append additional include directories
|
||||
|
@ -204,21 +205,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__':
|
||||
|
|
|
@ -33,7 +33,6 @@ set(__INCLUDED_GR_TEST_CMAKE TRUE)
|
|||
########################################################################
|
||||
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 +49,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:
|
||||
|
@ -74,15 +74,19 @@ 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)
|
||||
|
|
|
@ -48,24 +48,24 @@ endif()
|
|||
# Use the logic below to set the version constants
|
||||
########################################################################
|
||||
if("${MINOR_VERSION}" STREQUAL "git")
|
||||
# VERSION: 3.6git-xxx-gxxxxxxxx
|
||||
# DOCVER: 3.6git
|
||||
# LIBVER: 3.6git
|
||||
# VERSION: 3.3git-xxx-gxxxxxxxx
|
||||
# DOCVER: 3.3git
|
||||
# LIBVER: 3.3git
|
||||
set(VERSION "${GIT_DESCRIBE}")
|
||||
set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}")
|
||||
set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}")
|
||||
elseif("${MAINT_VERSION}" STREQUAL "git")
|
||||
# VERSION: 3.6.1git-xxx-gxxxxxxxx
|
||||
# DOCVER: 3.6.1git
|
||||
# LIBVER: 3.6.1git
|
||||
# VERSION: 3.3.1git-xxx-gxxxxxxxx
|
||||
# DOCVER: 3.3.1git
|
||||
# LIBVER: 3.3.1git
|
||||
set(VERSION "${GIT_DESCRIBE}")
|
||||
set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}")
|
||||
set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}")
|
||||
else()
|
||||
# This is a numbered release.
|
||||
# VERSION: 3.6.1{.x}
|
||||
# DOCVER: 3.6.1{.x}
|
||||
# LIBVER: 3.6.1{.x}
|
||||
# VERSION: 3.3.1{.x}
|
||||
# DOCVER: 3.3.1{.x}
|
||||
# LIBVER: 3.3.1{.x}
|
||||
if("${MAINT_VERSION}" STREQUAL "0")
|
||||
set(VERSION "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}")
|
||||
else()
|
||||
|
|
Loading…
Reference in New Issue