Go to the documentation of this file.00001 ###############################################################################
00002 # Build utilities
00003 ###############################################################################
00004
00005 #ifdef DOXYGEN_SHOULD_SKIP_THIS
00006
00007 ###############################
00008 # Download
00009 ###############################
00010 # Adds a custom command for downloading a url to a
00011 # particular file.
00012 #
00013 # Depends : -
00014 # Outputs : ${file}
00015 #
00016 # Note: ${file} can be
00017 # - relative in which case it is rel to ${CMAKE_BINARY_DIR}
00018 # - absolute (e.g. ${CMAKE_BINARY_DIR}/dude.tar.gz
00019 #
00020 # Example:
00021 #
00022 # URL=http://snorriheim.dnsdojo.com/tmp/${TARBALL}
00023 # TARBALL=dude.tar.gz
00024 # ecl_download(${URL} ${TARBALL})
00025 #
00026 macro(ecl_download url file)
00027 add_custom_command(OUTPUT ${file}
00028 COMMAND wget ${url} -O ${file}
00029 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
00030 COMMENT "Downloading ${url}->${file}."
00031 )
00032 endmacro()
00033
00034 ###############################
00035 # Extract
00036 ###############################
00037 # Adds a custom command for untar'ing a tarball in the specified dir.
00038 #
00039 # Depends : ${tarball}
00040 # Outputs : ${dir}/extracted
00041 #
00042 # Example:
00043 #
00044 # TARBALL=${CMAKE_BINARY_DIR}/dude.tar.gz
00045 # URL=http://snorriheim.dnsdojo.com/tmp/${TARBALL}
00046 # ecl_download(${TARBALL} ${URL})
00047 # ecl_extract_tarball(${TARBALL} ${CMAKE_BINARY_DIR}/fakeroot)
00048 #
00049 macro(ecl_extract_tarball tarball dir)
00050 add_custom_command(OUTPUT ${dir}/extracted
00051 COMMAND mkdir -p ${dir}
00052 COMMAND tar -xvzf ${tarball} -C ${dir}
00053 COMMAND touch ${dir}/extracted
00054 DEPENDS ${tarball}
00055 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
00056 COMMENT "Extracting ${tarball} -> ${dir}."
00057 VERBATIM
00058 )
00059 endmacro()
00060
00061 # Similar to the untarball command, but for bzips.
00062 #
00063 macro(ecl_extract_bzip2 bzip2 dir)
00064 add_custom_command(OUTPUT ${dir}/extracted
00065 COMMAND tar -xvjf ${bzip2} -C ${dir}
00066 COMMAND touch ${dir}/extracted
00067 DEPENDS ${bzip2}
00068 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
00069 COMMENT "Extracting ${bzip2} -> ${dir}."
00070 VERBATIM
00071 )
00072 endmacro()
00073
00074 ###############################
00075 # Autotools Compile
00076 ###############################
00077 # This adds a custom command for a typical autotools compile.
00078 # Be sure to set up the configure command correctly before calling.
00079 #
00080 # Depends: ${depends} (input argument)
00081 # Outputs: ${dir}/compiled
00082 #
00083 macro(ecl_autotools_compile configure_command dir depends)
00084 add_custom_command(OUTPUT ${dir}/compiled
00085 COMMAND ${configure_command}
00086 COMMAND make $ENV{ROS_PARALLEL_JOBS} # If not ros, then that is just empty anyway
00087 COMMAND make install
00088 COMMAND touch ${dir}/compiled
00089 DEPENDS ${depends}
00090 WORKING_DIRECTORY ${dir}
00091 COMMENT "Compiling ${dir}."
00092 VERBATIM
00093 )
00094 endmacro()
00095
00096 ###############################
00097 # Uninstall
00098 ###############################
00099 # Creates an uninstall target.
00100 #
00101 # To do this, it needs to find the uninstall template and prep it.
00102 # In ros, we can grab it from ecl_build, otherwise we use pkgconfig
00103 # to find it from an already installed ecl.
00104 macro(ecl_add_uninstall_target)
00105
00106 # Find the template
00107 if(ROSBUILD_init_called)
00108 rosbuild_find_ros_package(ecl_build)
00109 set(ECL_CMAKE_TEMPLATES_PATH ${ecl_build_PACKAGE_PATH}/cmake/templates)
00110 else()
00111 find_package(PkgConfig)
00112 if(PKG_CONFIG_FOUND)
00113 PKG_CHECK_MODULES(ECL_CMAKE ecl_cmake)
00114 set(ECL_CMAKE_TEMPLATES_PATH ${ECL_CMAKE_PREFIX}/templates)
00115 else()
00116 message(FATAL_ERROR "Ecl cmake modules path not found (missing pkgconfig?).")
00117 endif()
00118 endif()
00119
00120 # Prep it
00121 configure_file(
00122 "${ECL_CMAKE_TEMPLATES_PATH}/uninstall.cmake.in"
00123 "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
00124 IMMEDIATE @ONLY)
00125
00126 # Add the target
00127 add_custom_target(uninstall
00128 "${CMAKE_COMMAND}" -P
00129 "${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake")
00130 endmacro()
00131
00132 #endif DOXYGEN_SHOULD_SKIP_THIS