Hi There,

First of all thanks for CMAKE , is has made my work a lot easier the last couple of years. We produce software for a number of platforms and cmake keeps me sane (as far as that's possible).

I've got a few modules I hope some other people might find usefull. With permission of my employer I offer them for potential inclusion.

They might need some polish , but for me at least they work.

Also I include a patch to get ExternalProject.cmake working with mercurial. (against version 2.8.7)

--
Met vriendelijke groet,
Minze Zwerver
van Ovost Automatisering

# The module defines the following variables:
#   HG_EXECUTABLE - path to mercurial command line client
#   HG_VERSION_STRING - set to the version of found hg executable
# Example usage:
#   include(FindMercurial)
#   if(HG_FOUND)
#     message("Mercurial found: ${HG_EXECUTABLE}" )
#   endif()

#=============================================================================
# Copyright 2012 Minze Zwerver / van Ovost Automatisering BV
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
#  License text for the above reference.)

# Look for 'hg' maybe more ?
set(hg_names hg)

find_program(HG_EXECUTABLE
  NAMES ${hg_names}
  DOC "Mercurial command line client"
  )
mark_as_advanced(HG_EXECUTABLE)

# Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if
# all listed variables are TRUE

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(Mercurial DEFAULT_MSG HG_EXECUTABLE)

if(HG_EXECUTABLE)
    execute_process(
        COMMAND "${HG_EXECUTABLE}" --version
      OUTPUT_VARIABLE HG_VERSION
      OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    string(REGEX REPLACE "^Mercurial Distributed SCM [(]version 
([.01234567890]+)[)].*" "\\1" HG_VERSION_STRING "${HG_VERSION}")
        SET(HG_VERSION_STRING ${HG_VERSION_STRING} CACHE STRING "Mercurial 
version found." )
        mark_as_advanced(HG_VERSION_STRING)
endif(HG_EXECUTABLE)
# This module tries to find the Curses Development Kit 
# Based on the LIBCDK_PATH variable
#
# The module defines the following variables if successfull:
#   LIBCDK_LIBRARIES - path to the cdk libraries

#=============================================================================
# Copyright 2012 Minze Zwerver / van Ovost Automatisering BV
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
#  License text for the above reference.)

IF(NOT LIBCDK_PATH) 
SET (LIBCDK_PATH CACHE PATH 
"What is the basepath for the CDK ?" 
FORCE)
ENDIF() 

IF(LIBCDK_PATH)
        FIND_PATH(LIBCDK_INCLUDE_DIR cdk/cdk.h
                HINTS
                ${LIBCDK_PATH}/include
        )
        
        FIND_LIBRARY(LIBCDK_LIBRARIES_RELEASE NAMES cdk
                HINTS 
                ${LIBCDK_PATH}
                PATH_SUFFIXES lib 
                )
                
        FIND_LIBRARY(LIBCDK_LIBRARIES_DEBUG NAMES cdk
                HINTS 
                ${LIBCDK_PATH}
                PATH_SUFFIXES lib 
                )
                
                IF (LIBCDK_LIBRARIES_RELEASE AND LIBCDK_LIBRARIES_DEBUG)
                        IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) 
                                SET(LIBCDK_LIBRARIES optimized 
${LIBCDK_LIBRARIES_RELEASE} 
                                debug ${LIBCDK_LIBRARIES_DEBUG})
                        ELSE()
                                SET(LIBCDK_LIBRARIES 
${LIBCDK_LIBRARIES_RELEASE} )
                        ENDIF()
                ENDIF()
                
                IF (LIBCDK_LIBRARIES_RELEASE AND NOT LIBCDK_LIBRARIES_DEBUG)
                        SET(LIBCDK_LIBRARIES ${LIBCDK_LIBRARIES_RELEASE} )
                ENDIF()
                
                IF (NOT LIBCDK_LIBRARIES_RELEASE AND LIBCDK_LIBRARIES_DEBUG)
                        SET(LIBCDK_LIBRARIES ${LIBCDK_LIBRARIES_DEBUG} )
                ENDIF()
                IF(LIBCDK_LIBRARIES)
                        SET(LIBCDK_LIBRARIES  "${LIBCDK_LIBRARIES}" CACHE 
FILEPATH "CursesDevelopmentKit libraries" )
                ENDIF()
ENDIF()
23a24,25
> #    [HG_REPOSITORY url]         # URL of the mercurial repo
> #    [HG_TAG tag]                # mercurial branch name, commit id or tag
260a263
> 
309a313,340
> function(_ep_write_hgclone_script script_filename source_dir hg_EXECUTABLE hg_repository hg_tag src_name work_dir)
>   file(WRITE ${script_filename}
> "if(\"${hg_tag}\" STREQUAL \"\")
>   message(FATAL_ERROR \"Tag for git checkout should not be empty.\")
> endif()
> 
> 
> execute_process(
>   COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\"
>   RESULT_VARIABLE error_code
>   )
> if(error_code)
>   message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\")
> endif()
> 
> execute_process(
>   COMMAND \"${hg_EXECUTABLE}\" clone \"${hg_repository}\" -r ${hg_tag} \"${src_name}\"
>   WORKING_DIRECTORY \"${work_dir}\"
>   RESULT_VARIABLE error_code
>   )
> if(error_code)
>   message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\")
> endif()
> 
> "
> )
> 
> endfunction(_ep_write_hgclone_script)
963a995,1000
> function(_ep_get_hg_version hg_EXECUTABLE hg_version_var)
>   if(HG_EXECUTABLE)
>     set(${hg_version_var} "${HG_VERSION_STRING}" PARENT_SCOPE)
>   endif()
> endfunction()
> 
982a1020
>   get_property(hg_repository TARGET ${name} PROPERTY _EP_HG_REPOSITORY)
1096a1135,1172
>   elseif(hg_repository)
>     include(FindMercurial)
>     if(NOT HG_EXECUTABLE)
>       message(FATAL_ERROR "error: could not find mercurial for clone of ${name}")
>     endif()
> 
> 	_ep_get_hg_version("${HG_EXECUTABLE}" hg_version)
> 	if(hg_version VERSION_LESS 2.0.0)
>       message(WARNING "Warning: hg version 2.0.0 or later might be required.  hg_version='${hg_version}'")
>     endif()
> 
>     get_property(hg_tag TARGET ${name} PROPERTY _EP_HG_TAG)
>     if(NOT hg_tag)
>       set(hg_tag "default")
>     endif()
> 
>     set(repository ${hg_repository})
>     set(module)
>     set(tag ${hg_tag})
>     configure_file(
>       "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in"
>       "${stamp_dir}/${name}-hginfo.txt"
>       @ONLY
>       )
> 
>     get_filename_component(src_name "${source_dir}" NAME)
>     get_filename_component(work_dir "${source_dir}" PATH)
> 
>     # Since git clone doesn't succeed if the non-empty source_dir exists,
>     # create a cmake script to invoke as download command.
>     # The script will delete the source directory and then call git clone.
>     #
>     _ep_write_hgclone_script(${tmp_dir}/${name}-hgclone.cmake ${source_dir}
>       ${HG_EXECUTABLE} ${hg_repository} ${hg_tag} ${src_name} ${work_dir}
>       )
>     set(comment "Performing download step (hg clone) for '${name}'")
>     set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-hgclone.cmake)
>     list(APPEND depends ${stamp_dir}/${name}-hginfo.txt)
1144c1220
<       message(SEND_ERROR "error: no download info for '${name}' -- please specify existing/non-empty SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY, GIT_REPOSITORY or DOWNLOAD_COMMAND")
---
>       message(SEND_ERROR "error: no download info for '${name}' -- please specify existing/non-empty SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY, GIT_REPOSITORY, HG_REPOSITORY or DOWNLOAD_COMMAND")
1173a1250
>   get_property(hg_repository TARGET ${name} PROPERTY _EP_HG_REPOSITORY)
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to