Skip to content

Commit

Permalink
added local cmake modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Park Joon-Kyu committed Mar 29, 2012
1 parent 978d145 commit 81ca1f3
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
78 changes: 78 additions & 0 deletions cmake/modules/FindSharedMimeInfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# - Try to find the shared-mime-info package
#
# Once done this will define
#
# SHAREDMIMEINFO_FOUND - system has the shared-mime-info package
# UPDATE_MIME_DATABASE_EXECUTABLE - the update-mime-database executable
#
# The minimum required version of SharedMimeInfo can be specified using the
# standard syntax, e.g. find_package(SharedMimeInfo 0.20)
#
# For backward compatiblity, the following two variables are also supported:
# SHARED_MIME_INFO_FOUND - same as SHAREDMIMEINFO_FOUND
# SHARED_MIME_INFO_MINIMUM_VERSION - set to the minimum version you need, default is 0.18.
# When both are used, i.e. the version is set in the find_package() call and
# SHARED_MIME_INFO_MINIMUM_VERSION is set, the version specified in the find_package()
# call takes precedence.


# Copyright (c) 2007, Pino Toscano, <toscano.pino@tiscali.it>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

# Support SHARED_MIME_INFO_MINIMUM_VERSION for compatibility:
if(NOT SharedMimeInfo_FIND_VERSION)
set(SharedMimeInfo_FIND_VERSION "${SHARED_MIME_INFO_MINIMUM_VERSION}")
endif(NOT SharedMimeInfo_FIND_VERSION)

# the minimum version of shared-mime-database we require
if(NOT SharedMimeInfo_FIND_VERSION)
set(SharedMimeInfo_FIND_VERSION "0.18")
endif(NOT SharedMimeInfo_FIND_VERSION)

find_program (UPDATE_MIME_DATABASE_EXECUTABLE NAMES update-mime-database)

# Store the version number in the cache, so we don't have to search the next time again:
if (UPDATE_MIME_DATABASE_EXECUTABLE AND NOT SHAREDMIMEINFO_VERSION)

exec_program (${UPDATE_MIME_DATABASE_EXECUTABLE} ARGS -v RETURN_VALUE _null OUTPUT_VARIABLE _smiVersionRaw)

string(REGEX REPLACE "update-mime-database \\([a-zA-Z\\-]+\\) ([0-9]\\.[0-9]+).*"
"\\1" smiVersion "${_smiVersionRaw}")

set(SHAREDMIMEINFO_VERSION "${smiVersion}" CACHE STRING "Version number of SharedMimeInfo" FORCE)
endif (UPDATE_MIME_DATABASE_EXECUTABLE AND NOT SHAREDMIMEINFO_VERSION)

# Use the new FPHSA() syntax:
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SharedMimeInfo REQUIRED_VARS UPDATE_MIME_DATABASE_EXECUTABLE
VERSION_VAR SHAREDMIMEINFO_VERSION )

# For backward compatiblity:
set(SHARED_MIME_INFO_FOUND ${SHAREDMIMEINFO_FOUND} )

# This should go into MacroLogFeature/FeatureSummary:
# message(FATAL_ERROR "Could NOT find shared-mime-info. See http://freedesktop.org/wiki/Software/shared-mime-info.")


mark_as_advanced(UPDATE_MIME_DATABASE_EXECUTABLE)


macro(UPDATE_XDG_MIMETYPES _path)
get_filename_component(_xdgmimeDir "${_path}" NAME)
if("${_xdgmimeDir}" STREQUAL packages )
get_filename_component(_xdgmimeDir "${_path}" PATH)
else("${_xdgmimeDir}" STREQUAL packages )
set(_xdgmimeDir "${_path}")
endif("${_xdgmimeDir}" STREQUAL packages )

install(CODE "
set(DESTDIR_VALUE \"\$ENV{DESTDIR}\")
if (NOT DESTDIR_VALUE)
# under Windows relative paths are used, that's why it runs from CMAKE_INSTALL_PREFIX
execute_process(COMMAND ${UPDATE_MIME_DATABASE_EXECUTABLE} ${_xdgmimeDir}
WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\")
endif (NOT DESTDIR_VALUE)
")
endmacro (UPDATE_XDG_MIMETYPES)
50 changes: 50 additions & 0 deletions cmake/modules/FindSqlite.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# - Try to find Sqlite
# Once done this will define
#
# SQLITE_FOUND - system has Sqlite
# SQLITE_INCLUDE_DIR - the Sqlite include directory
# SQLITE_LIBRARIES - Link these to use Sqlite
# SQLITE_DEFINITIONS - Compiler switches required for using Sqlite
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#


# Copyright (c) 2008, Gilles Caulier, <caulier.gilles@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

if ( SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES )
# in cache already
SET(Sqlite_FIND_QUIETLY TRUE)
endif ( SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES )

# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
if( NOT WIN32 )
find_package(PkgConfig)

pkg_check_modules(PC_SQLITE QUIET sqlite3)

set(SQLITE_DEFINITIONS ${PC_SQLITE_CFLAGS_OTHER})
endif( NOT WIN32 )

find_path(SQLITE_INCLUDE_DIR NAMES sqlite3.h
PATHS
${PC_SQLITE_INCLUDEDIR}
${PC_SQLITE_INCLUDE_DIRS}
)

find_library(SQLITE_LIBRARIES NAMES sqlite3
PATHS
${PC_SQLITE_LIBDIR}
${PC_SQLITE_LIBRARY_DIRS}
)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sqlite DEFAULT_MSG SQLITE_INCLUDE_DIR SQLITE_LIBRARIES )

# show the SQLITE_INCLUDE_DIR and SQLITE_LIBRARIES variables only in the advanced view
mark_as_advanced(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES )

0 comments on commit 81ca1f3

Please sign in to comment.