summaryrefslogtreecommitdiff
path: root/gr-howto-write-a-block-cmake/cmake/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'gr-howto-write-a-block-cmake/cmake/Modules')
-rw-r--r--gr-howto-write-a-block-cmake/cmake/Modules/GrPlatform.cmake34
-rw-r--r--gr-howto-write-a-block-cmake/cmake/Modules/GrPython.cmake134
-rw-r--r--gr-howto-write-a-block-cmake/cmake/Modules/GrSwig.cmake60
-rw-r--r--gr-howto-write-a-block-cmake/cmake/Modules/GrTest.cmake128
4 files changed, 178 insertions, 178 deletions
diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/GrPlatform.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/GrPlatform.cmake
index 85f318618..ce2e15fef 100644
--- a/gr-howto-write-a-block-cmake/cmake/Modules/GrPlatform.cmake
+++ b/gr-howto-write-a-block-cmake/cmake/Modules/GrPlatform.cmake
@@ -17,30 +17,30 @@
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
-IF(DEFINED __INCLUDED_GR_PLATFORM_CMAKE)
- RETURN()
-ENDIF()
-SET(__INCLUDED_GR_PLATFORM_CMAKE TRUE)
+if(DEFINED __INCLUDED_GR_PLATFORM_CMAKE)
+ return()
+endif()
+set(__INCLUDED_GR_PLATFORM_CMAKE TRUE)
########################################################################
# Setup additional defines for OS types
########################################################################
-IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
- SET(LINUX TRUE)
-ENDIF()
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(LINUX TRUE)
+endif()
-IF(LINUX AND EXISTS "/etc/debian_version")
- SET(DEBIAN TRUE)
-ENDIF()
+if(LINUX AND EXISTS "/etc/debian_version")
+ set(DEBIAN TRUE)
+endif()
-IF(LINUX AND EXISTS "/etc/redhat-release")
- SET(REDHAT TRUE)
-ENDIF()
+if(LINUX AND EXISTS "/etc/redhat-release")
+ set(REDHAT 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$")
- SET(LIB_SUFFIX 64)
-ENDIF()
-SET(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix")
+if(NOT DEFINED LIB_SUFFIX AND REDHAT 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-howto-write-a-block-cmake/cmake/Modules/GrPython.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/GrPython.cmake
index f54dbc9ba..da0590d42 100644
--- a/gr-howto-write-a-block-cmake/cmake/Modules/GrPython.cmake
+++ b/gr-howto-write-a-block-cmake/cmake/Modules/GrPython.cmake
@@ -17,10 +17,10 @@
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
-IF(DEFINED __INCLUDED_GR_PYTHON_CMAKE)
- RETURN()
-ENDIF()
-SET(__INCLUDED_GR_PYTHON_CMAKE TRUE)
+if(DEFINED __INCLUDED_GR_PYTHON_CMAKE)
+ return()
+endif()
+set(__INCLUDED_GR_PYTHON_CMAKE TRUE)
########################################################################
# Setup the python interpreter:
@@ -28,28 +28,28 @@ SET(__INCLUDED_GR_PYTHON_CMAKE TRUE)
# or finds the interpreter via the built-in cmake module.
########################################################################
#this allows the user to override PYTHON_EXECUTABLE
-IF(PYTHON_EXECUTABLE)
+if(PYTHON_EXECUTABLE)
- SET(PYTHONINTERP_FOUND TRUE)
+ set(PYTHONINTERP_FOUND TRUE)
#otherwise if not set, try to automatically find it
-ELSE(PYTHON_EXECUTABLE)
+else(PYTHON_EXECUTABLE)
#use the built-in find script
- FIND_PACKAGE(PythonInterp)
+ find_package(PythonInterp)
#and if that fails use the find program routine
- IF(NOT PYTHONINTERP_FOUND)
- FIND_PROGRAM(PYTHON_EXECUTABLE NAMES python python2.7 python2.6 python2.5)
- IF(PYTHON_EXECUTABLE)
- SET(PYTHONINTERP_FOUND TRUE)
- ENDIF(PYTHON_EXECUTABLE)
- ENDIF(NOT PYTHONINTERP_FOUND)
+ if(NOT PYTHONINTERP_FOUND)
+ find_program(PYTHON_EXECUTABLE NAMES python python2.7 python2.6 python2.5)
+ if(PYTHON_EXECUTABLE)
+ set(PYTHONINTERP_FOUND TRUE)
+ endif(PYTHON_EXECUTABLE)
+ endif(NOT PYTHONINTERP_FOUND)
-ENDIF(PYTHON_EXECUTABLE)
+endif(PYTHON_EXECUTABLE)
#make the path to the executable appear in the cmake gui
-SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter")
+set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter")
########################################################################
# Check for the existence of a python module:
@@ -58,10 +58,10 @@ SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter")
# - cmd an additional command to run
# - have the result variable to set
########################################################################
-MACRO(GR_PYTHON_CHECK_MODULE desc mod cmd have)
- MESSAGE(STATUS "")
- MESSAGE(STATUS "Python checking for ${desc}")
- EXECUTE_PROCESS(
+macro(GR_PYTHON_CHECK_MODULE desc mod cmd have)
+ message(STATUS "")
+ message(STATUS "Python checking for ${desc}")
+ execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "
#########################################
try: import ${mod}
@@ -71,87 +71,87 @@ except: exit(-1)
#########################################"
RESULT_VARIABLE ${have}
)
- IF(${have} EQUAL 0)
- MESSAGE(STATUS "Python checking for ${desc} - found")
- SET(${have} TRUE)
- ELSE(${have} EQUAL 0)
- MESSAGE(STATUS "Python checking for ${desc} - not found")
- SET(${have} FALSE)
- ENDIF(${have} EQUAL 0)
-ENDMACRO(GR_PYTHON_CHECK_MODULE)
+ if(${have} EQUAL 0)
+ message(STATUS "Python checking for ${desc} - found")
+ set(${have} TRUE)
+ else(${have} EQUAL 0)
+ message(STATUS "Python checking for ${desc} - not found")
+ set(${have} FALSE)
+ endif(${have} EQUAL 0)
+endmacro(GR_PYTHON_CHECK_MODULE)
########################################################################
# Sets the python installation directory GR_PYTHON_DIR
########################################################################
-EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "
+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
)
-FILE(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR)
+file(TO_CMAKE_PATH ${GR_PYTHON_DIR} GR_PYTHON_DIR)
########################################################################
# Create an always-built target with a unique name
# Usage: GR_UNIQUE_TARGET(<description> <dependencies list>)
########################################################################
-FUNCTION(GR_UNIQUE_TARGET desc)
- FILE(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
- EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib
+function(GR_UNIQUE_TARGET desc)
+ file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+ execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib
unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5]
print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))"
OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE)
- ADD_CUSTOM_TARGET(${_target} ALL DEPENDS ${ARGN})
-ENDFUNCTION(GR_UNIQUE_TARGET)
+ add_custom_target(${_target} ALL DEPENDS ${ARGN})
+endfunction(GR_UNIQUE_TARGET)
########################################################################
# Install python sources (also builds and installs byte-compiled python)
########################################################################
-FUNCTION(GR_PYTHON_INSTALL)
- INCLUDE(CMakeParseArgumentsCopy)
+function(GR_PYTHON_INSTALL)
+ include(CMakeParseArgumentsCopy)
CMAKE_PARSE_ARGUMENTS(GR_PYTHON_INSTALL "" "DESTINATION;COMPONENT" "FILES;PROGRAMS" ${ARGN})
####################################################################
- IF(GR_PYTHON_INSTALL_FILES)
+ if(GR_PYTHON_INSTALL_FILES)
####################################################################
- INSTALL(${ARGN}) #installs regular python files
+ install(${ARGN}) #installs regular python files
- FOREACH(pyfile ${GR_PYTHON_INSTALL_FILES})
- GET_FILENAME_COMPONENT(pyfile_name ${pyfile} NAME)
- GET_FILENAME_COMPONENT(pyfile ${pyfile} ABSOLUTE)
- STRING(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pycfile "${pyfile}c")
- LIST(APPEND python_install_gen_targets ${pycfile})
+ foreach(pyfile ${GR_PYTHON_INSTALL_FILES})
+ get_filename_component(pyfile_name ${pyfile} NAME)
+ get_filename_component(pyfile ${pyfile} ABSOLUTE)
+ string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pycfile "${pyfile}c")
+ list(APPEND python_install_gen_targets ${pycfile})
- GET_FILENAME_COMPONENT(pycfile_path ${pycfile} PATH)
- FILE(MAKE_DIRECTORY ${pycfile_path})
+ get_filename_component(pycfile_path ${pycfile} PATH)
+ file(MAKE_DIRECTORY ${pycfile_path})
#create a command to generate the byte-compiled pyc file
- ADD_CUSTOM_COMMAND(
+ add_custom_command(
OUTPUT ${pycfile} DEPENDS ${pyfile}
COMMAND ${PYTHON_EXECUTABLE} -c
\"import py_compile\; py_compile.compile(file='${pyfile}', cfile='${pycfile}', doraise=True)\"
COMMENT "Byte-compiling ${pyfile_name}"
)
- INSTALL(FILES ${pycfile}
+ install(FILES ${pycfile}
DESTINATION ${GR_PYTHON_INSTALL_DESTINATION}
COMPONENT ${GR_PYTHON_INSTALL_COMPONENT}
)
- ENDFOREACH(pyfile)
+ endforeach(pyfile)
####################################################################
- ELSEIF(GR_PYTHON_INSTALL_PROGRAMS)
+ elseif(GR_PYTHON_INSTALL_PROGRAMS)
####################################################################
- FILE(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native)
+ file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} pyexe_native)
- FOREACH(pyfile ${GR_PYTHON_INSTALL_PROGRAMS})
- GET_FILENAME_COMPONENT(pyfile_name ${pyfile} NAME)
- GET_FILENAME_COMPONENT(pyfile ${pyfile} ABSOLUTE)
- STRING(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pyexefile "${pyfile}.exe")
- LIST(APPEND python_install_gen_targets ${pyexefile})
+ foreach(pyfile ${GR_PYTHON_INSTALL_PROGRAMS})
+ get_filename_component(pyfile_name ${pyfile} NAME)
+ get_filename_component(pyfile ${pyfile} ABSOLUTE)
+ string(REPLACE "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" pyexefile "${pyfile}.exe")
+ list(APPEND python_install_gen_targets ${pyexefile})
- GET_FILENAME_COMPONENT(pyexefile_path ${pyexefile} PATH)
- FILE(MAKE_DIRECTORY ${pyexefile_path})
+ get_filename_component(pyexefile_path ${pyexefile} PATH)
+ file(MAKE_DIRECTORY ${pyexefile_path})
- ADD_CUSTOM_COMMAND(
+ add_custom_command(
OUTPUT ${pyexefile} DEPENDS ${pyfile}
COMMAND ${PYTHON_EXECUTABLE} -c
\"open('${pyexefile}', 'w').write('\#!${pyexe_native}\\n'+open('${pyfile}').read())\"
@@ -159,19 +159,19 @@ FUNCTION(GR_PYTHON_INSTALL)
)
#on windows, python files need an extension to execute
- GET_FILENAME_COMPONENT(pyfile_ext ${pyfile} EXT)
- IF(WIN32 AND NOT pyfile_ext)
- SET(pyfile_name "${pyfile_name}.py")
- ENDIF()
+ get_filename_component(pyfile_ext ${pyfile} EXT)
+ if(WIN32 AND NOT pyfile_ext)
+ set(pyfile_name "${pyfile_name}.py")
+ endif()
- INSTALL(PROGRAMS ${pyexefile} RENAME ${pyfile_name}
+ install(PROGRAMS ${pyexefile} RENAME ${pyfile_name}
DESTINATION ${GR_PYTHON_INSTALL_DESTINATION}
COMPONENT ${GR_PYTHON_INSTALL_COMPONENT}
)
- ENDFOREACH(pyfile)
+ endforeach(pyfile)
- ENDIF()
+ endif()
GR_UNIQUE_TARGET("pygen" ${python_install_gen_targets})
-ENDFUNCTION(GR_PYTHON_INSTALL)
+endfunction(GR_PYTHON_INSTALL)
diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/GrSwig.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/GrSwig.cmake
index 0d4cce2b3..0fa1c7b77 100644
--- a/gr-howto-write-a-block-cmake/cmake/Modules/GrSwig.cmake
+++ b/gr-howto-write-a-block-cmake/cmake/Modules/GrSwig.cmake
@@ -17,12 +17,12 @@
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
-IF(DEFINED __INCLUDED_GR_SWIG_CMAKE)
- RETURN()
-ENDIF()
-SET(__INCLUDED_GR_SWIG_CMAKE TRUE)
+if(DEFINED __INCLUDED_GR_SWIG_CMAKE)
+ return()
+endif()
+set(__INCLUDED_GR_SWIG_CMAKE TRUE)
-INCLUDE(GrPython)
+include(GrPython)
########################################################################
# Build a swig target for the common gnuradio use case. Usage:
@@ -35,11 +35,11 @@ INCLUDE(GrPython)
# - GR_SWIG_SOURCE_DEPS
# - GR_SWIG_TARGET_DEPS
########################################################################
-MACRO(GR_SWIG_MAKE name)
- SET(ifiles ${ARGN})
+macro(GR_SWIG_MAKE name)
+ set(ifiles ${ARGN})
#determine include dependencies for swig file
- EXECUTE_PROCESS(
+ execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/get_swig_deps.py
"${ifiles}" "${GR_SWIG_INCLUDE_DIRS}"
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -48,30 +48,30 @@ MACRO(GR_SWIG_MAKE name)
)
#append the specified include directories
- INCLUDE_DIRECTORIES(${GR_SWIG_INCLUDE_DIRS})
- LIST(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${GR_SWIG_SOURCE_DEPS})
+ include_directories(${GR_SWIG_INCLUDE_DIRS})
+ list(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${GR_SWIG_SOURCE_DEPS})
- FIND_PACKAGE(PythonLibs)
- INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS})
+ find_package(PythonLibs)
+ include_directories(${PYTHON_INCLUDE_DIRS})
#setup the swig flags with flags and include directories
- SET(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -module ${name} ${GR_SWIG_FLAGS})
- FOREACH(dir ${GR_SWIG_INCLUDE_DIRS})
- LIST(APPEND CMAKE_SWIG_FLAGS "-I${dir}")
- ENDFOREACH(dir)
+ set(CMAKE_SWIG_FLAGS -fvirtual -modern -keyword -w511 -module ${name} ${GR_SWIG_FLAGS})
+ foreach(dir ${GR_SWIG_INCLUDE_DIRS})
+ list(APPEND CMAKE_SWIG_FLAGS "-I${dir}")
+ endforeach(dir)
#set the C++ property on the swig .i file so it builds
- SET_SOURCE_FILES_PROPERTIES(${ifiles} PROPERTIES CPLUSPLUS ON)
+ set_source_files_properties(${ifiles} PROPERTIES CPLUSPLUS ON)
#setup the actual swig library target to be built
- INCLUDE(UseSWIG)
+ include(UseSWIG)
SWIG_ADD_MODULE(${name} python ${ifiles})
SWIG_LINK_LIBRARIES(${name} ${PYTHON_LIBRARIES} ${GR_SWIG_LIBRARIES})
- IF(GR_SWIG_TARGET_DEPS)
- ADD_DEPENDENCIES(${SWIG_MODULE_${name}_REAL_NAME} ${GR_SWIG_TARGET_DEPS})
- ENDIF(GR_SWIG_TARGET_DEPS)
+ if(GR_SWIG_TARGET_DEPS)
+ add_dependencies(${SWIG_MODULE_${name}_REAL_NAME} ${GR_SWIG_TARGET_DEPS})
+ endif(GR_SWIG_TARGET_DEPS)
-ENDMACRO(GR_SWIG_MAKE)
+endmacro(GR_SWIG_MAKE)
########################################################################
# Install swig targets generated by GR_SWIG_MAKE. Usage:
@@ -81,25 +81,25 @@ ENDMACRO(GR_SWIG_MAKE)
# [COMPONENT component]
# )
########################################################################
-MACRO(GR_SWIG_INSTALL)
+macro(GR_SWIG_INSTALL)
- INCLUDE(CMakeParseArgumentsCopy)
+ include(CMakeParseArgumentsCopy)
CMAKE_PARSE_ARGUMENTS(GR_SWIG_INSTALL "" "DESTINATION;COMPONENT" "TARGETS" ${ARGN})
- FOREACH(name ${GR_SWIG_INSTALL_TARGETS})
- INSTALL(TARGETS ${SWIG_MODULE_${name}_REAL_NAME}
+ foreach(name ${GR_SWIG_INSTALL_TARGETS})
+ install(TARGETS ${SWIG_MODULE_${name}_REAL_NAME}
DESTINATION ${GR_SWIG_INSTALL_DESTINATION}
COMPONENT ${GR_SWIG_INSTALL_COMPONENT}
)
- INCLUDE(GrPython)
+ include(GrPython)
GR_PYTHON_INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}.py
DESTINATION ${GR_SWIG_INSTALL_DESTINATION}
COMPONENT ${GR_SWIG_INSTALL_COMPONENT}
)
- ENDFOREACH(name)
+ endforeach(name)
-ENDMACRO(GR_SWIG_INSTALL)
+endmacro(GR_SWIG_INSTALL)
########################################################################
# Generate a python file that can determine swig dependencies.
@@ -107,7 +107,7 @@ ENDMACRO(GR_SWIG_INSTALL)
# When you build C++, CMake figures out the header dependencies.
# This code essentially performs that logic for swig includes.
########################################################################
-FILE(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py "
+file(WRITE ${CMAKE_BINARY_DIR}/get_swig_deps.py "
import os, sys, re
diff --git a/gr-howto-write-a-block-cmake/cmake/Modules/GrTest.cmake b/gr-howto-write-a-block-cmake/cmake/Modules/GrTest.cmake
index e9e2a0c2e..9ec3141f9 100644
--- a/gr-howto-write-a-block-cmake/cmake/Modules/GrTest.cmake
+++ b/gr-howto-write-a-block-cmake/cmake/Modules/GrTest.cmake
@@ -17,10 +17,10 @@
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
-IF(DEFINED __INCLUDED_GR_TEST_CMAKE)
- RETURN()
-ENDIF()
-SET(__INCLUDED_GR_TEST_CMAKE TRUE)
+if(DEFINED __INCLUDED_GR_TEST_CMAKE)
+ return()
+endif()
+set(__INCLUDED_GR_TEST_CMAKE TRUE)
########################################################################
# Add a unit test and setup the environment for a unit test.
@@ -31,41 +31,41 @@ SET(__INCLUDED_GR_TEST_CMAKE TRUE)
# GR_TEST_LIBRARY_DIRS - directories for the library path
# GR_TEST_PYTHON_DIRS - directories for the python path
########################################################################
-FUNCTION(GR_ADD_TEST test_name)
+function(GR_ADD_TEST test_name)
- IF(WIN32)
+ if(WIN32)
#Ensure that the build exe also appears in the PATH.
- LIST(APPEND GR_TEST_TARGET_DEPS ${ARGN})
+ list(APPEND GR_TEST_TARGET_DEPS ${ARGN})
#In the land of windows, all libraries must be in the PATH.
#Since the dependent libraries are not yet installed,
#we must manually set them in the PATH to run tests.
#The following appends the path of a target dependency.
- FOREACH(target ${GR_TEST_TARGET_DEPS})
- GET_TARGET_PROPERTY(location ${target} LOCATION)
- IF(location)
- GET_FILENAME_COMPONENT(path ${location} PATH)
- STRING(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path})
- LIST(APPEND GR_TEST_LIBRARY_DIRS ${path})
- ENDIF(location)
- ENDFOREACH(target)
+ foreach(target ${GR_TEST_TARGET_DEPS})
+ get_target_property(location ${target} LOCATION)
+ if(location)
+ get_filename_component(path ${location} PATH)
+ string(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path})
+ list(APPEND GR_TEST_LIBRARY_DIRS ${path})
+ endif(location)
+ endforeach(target)
#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 ${GR_TEST_PYTHON_DIRS})
- GET_FILENAME_COMPONENT(name ${pydir} NAME)
- IF(name MATCHES "^(swig|lib|src)$")
- LIST(APPEND GR_TEST_PYTHON_DIRS ${pydir}/${CMAKE_BUILD_TYPE})
- ENDIF()
- ENDFOREACH(pydir)
- ENDIF(WIN32)
+ foreach(pydir ${GR_TEST_PYTHON_DIRS})
+ get_filename_component(name ${pydir} NAME)
+ if(name MATCHES "^(swig|lib|src)$")
+ list(APPEND GR_TEST_PYTHON_DIRS ${pydir}/${CMAKE_BUILD_TYPE})
+ endif()
+ endforeach(pydir)
+ endif(WIN32)
- FILE(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir)
- 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?
+ file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir)
+ 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 "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}")
#http://www.cmake.org/pipermail/cmake/2009-May/029464.html
#Replaced this add test + set environs code with the shell script generation.
@@ -73,61 +73,61 @@ FUNCTION(GR_ADD_TEST test_name)
#ADD_TEST(${ARGV})
#SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}")
- IF(UNIX)
- SET(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH")
+ if(UNIX)
+ 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 pypath "$PYTHONPATH")
+ list(APPEND libpath "$LD_LIBRARY_PATH" "$DYLD_LIBRARY_PATH")
+ 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}")
+ string(REPLACE ";" ":" libpath "${libpath}")
+ string(REPLACE ";" ":" pypath "${pypath}")
+ list(APPEND environs "PATH=${binpath}" "LD_LIBRARY_PATH=${libpath}" "DYLD_LIBRARY_PATH=${libpath}" "PYTHONPATH=${pypath}")
#generate a bat file that sets the environment and runs the test
- FIND_PROGRAM(SHELL sh)
- SET(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh)
- FILE(WRITE ${sh_file} "#!${SHELL}\n")
+ find_program(SHELL sh)
+ set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh)
+ file(WRITE ${sh_file} "#!${SHELL}\n")
#each line sets an environment variable
- FOREACH(environ ${environs})
- FILE(APPEND ${sh_file} "export ${environ}\n")
- ENDFOREACH(environ)
+ foreach(environ ${environs})
+ file(APPEND ${sh_file} "export ${environ}\n")
+ endforeach(environ)
#load the command to run with its arguments
- FOREACH(arg ${ARGN})
- FILE(APPEND ${sh_file} "${arg} ")
- ENDFOREACH(arg)
- FILE(APPEND ${sh_file} "\n")
+ foreach(arg ${ARGN})
+ file(APPEND ${sh_file} "${arg} ")
+ endforeach(arg)
+ file(APPEND ${sh_file} "\n")
#make the shell file executable
- EXECUTE_PROCESS(COMMAND chmod +x ${sh_file})
+ execute_process(COMMAND chmod +x ${sh_file})
- ADD_TEST(${test_name} ${SHELL} ${sh_file})
+ add_test(${test_name} ${SHELL} ${sh_file})
- ENDIF(UNIX)
+ endif(UNIX)
- IF(WIN32)
- LIST(APPEND libpath ${DLL_PATHS} "%PATH%")
- LIST(APPEND pypath "%PYTHONPATH%")
+ if(WIN32)
+ list(APPEND libpath ${DLL_PATHS} "%PATH%")
+ list(APPEND pypath "%PYTHONPATH%")
#replace list separator with the path separator (escaped)
- STRING(REPLACE ";" "\\;" libpath "${libpath}")
- STRING(REPLACE ";" "\\;" pypath "${pypath}")
- LIST(APPEND environs "PATH=${libpath}" "PYTHONPATH=${pypath}")
+ string(REPLACE ";" "\\;" libpath "${libpath}")
+ string(REPLACE ";" "\\;" pypath "${pypath}")
+ list(APPEND environs "PATH=${libpath}" "PYTHONPATH=${pypath}")
#generate a bat file that sets the environment and runs the test
- SET(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat)
- FILE(WRITE ${bat_file} "@echo off\n")
+ set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat)
+ file(WRITE ${bat_file} "@echo off\n")
#each line sets an environment variable
- FOREACH(environ ${environs})
- FILE(APPEND ${bat_file} "SET ${environ}\n")
- ENDFOREACH(environ)
+ foreach(environ ${environs})
+ file(APPEND ${bat_file} "SET ${environ}\n")
+ endforeach(environ)
#load the command to run with its arguments
- FOREACH(arg ${ARGN})
- FILE(APPEND ${bat_file} "${arg} ")
- ENDFOREACH(arg)
- FILE(APPEND ${bat_file} "\n")
+ foreach(arg ${ARGN})
+ file(APPEND ${bat_file} "${arg} ")
+ endforeach(arg)
+ file(APPEND ${bat_file} "\n")
- ADD_TEST(${test_name} ${bat_file})
- ENDIF(WIN32)
+ add_test(${test_name} ${bat_file})
+ endif(WIN32)
-ENDFUNCTION(GR_ADD_TEST)
+endfunction(GR_ADD_TEST)