Permalink
Browse files

Add support for cmake build system!

  • Loading branch information...
1 parent 9f283ca commit 6dc99f6caf4e0939231e56a2ba35490a30f8b04e flithm committed Aug 6, 2007
View
@@ -0,0 +1,59 @@
+#################################
+# Project
+##############
+
+project(Gizmod)
+
+#################################
+# Defines
+##############
+
+# global needed variables
+set(APPLICATION_NAME ${PROJECT_NAME})
+set(APPLICATION_VERSION "3.4")
+
+#################################
+# Preamble
+##############
+
+# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is check$
+set(CMAKE_MODULE_PATH
+ ${CMAKE_SOURCE_DIR}/cmake/Modules
+)
+
+# set default build type to release
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release")
+endif (NOT CMAKE_BUILD_TYPE)
+
+# add definitions
+include(DefineProjectDefaults)
+include(DefineProjectOptions)
+include(DefineCompilerFlags)
+include(DefineInstallationPaths)
+
+# add macros
+include(MacroAddPlugin)
+include(MacroEnsureOutOfSourceBuild)
+include(ConfigureChecks.cmake)
+
+# config.h
+configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+#################################
+# Sub-directories
+##############
+
+subdirs(libH libGizmod gizmod visplugin)
+
+#################################
+# Information
+##############
+
+message(STATUS "Installation Variables:
+ Install Prefix (CMAKE_INSTALL_PREFIX): ${CMAKE_INSTALL_PREFIX}
+ Data Dir (DATA_INSTALL_DIR): ${DATA_INSTALL_DIR}
+ Lib Dir (LIB_INSTALL_DIR): ${LIB_INSTALL_DIR}
+ Plugin Dir (PLUGIN_INSTALL_DIR): ${PLUGIN_INSTALL_DIR}
+ Config Dir (SYSCONF_INSTALL_DIR): ${SYSCONF_INSTALL_DIR}"
+)
View
@@ -0,0 +1,36 @@
+#################################
+# Includes
+##############
+
+INCLUDE(CheckIncludeFile)
+INCLUDE(CheckSymbolExists)
+INCLUDE(CheckFunctionExists)
+INCLUDE(CheckLibraryExists)
+INCLUDE(CheckTypeSize)
+INCLUDE(CheckCXXSourceCompiles)
+
+#################################
+# Defines
+##############
+
+SET(PACKAGE ${APPLICATION_NAME})
+SET(VERSION ${APPLICATION_VERSION})
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(DATADIR ${DATA_INSTALL_DIR})
+SET(LIBDIR ${LIB_INSTALL_DIR})
+SET(PLUGINDIR ${PLUGIN_INSTALL_DIR})
+SET(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
+
+#################################
+# Inotify
+##############
+
+check_include_file(sys/inotify.h HAVE_INOTIFY_H) # inotify
+if (NOT HAVE_INOTIFY_H)
+ message(FATAL_ERROR "You must have sys/inotify.h!")
+endif (NOT HAVE_INOTIFY_H)
+
+check_function_exists(inotify_init HAVE_INOTIFY_INIT) # inotify
+if (NOT HAVE_INOTIFY_INIT)
+ message(FATAL_ERROR "You must have inotify_init!")
+endif (NOT HAVE_INOTIFY_INIT)
@@ -0,0 +1,22 @@
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. The name of the author may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,16 @@
+# - Check whether the compiler supports a given flag.
+# CHECK_CXX_COMPILER_FLAG(FLAG VARIABLE)
+#
+# FLAG - the compiler flag
+# VARIABLE - variable to store the result
+#
+
+INCLUDE(CheckCXXSourceCompiles)
+
+MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
+ SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+ SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
+ CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT})
+ SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
+ENDMACRO (CHECK_CXX_COMPILER_FLAG)
+
@@ -0,0 +1,15 @@
+# define system dependent compiler flags
+
+include(CheckCXXCompilerFlag)
+
+# with -fPIC
+if (UNIX AND NOT WIN32)
+ #if (CMAKE_SIZEOF_VOID_P MATCHES "8")
+ check_cxx_compiler_flag("-fPIC" WITH_FPIC)
+ if (WITH_FPIC)
+ add_definitions(-fPIC)
+ endif (WITH_FPIC)
+ #endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
+endif (UNIX AND NOT WIN32)
+
+add_definitions(-DHAVE_CONFIG_H -Wall -Werror)
@@ -0,0 +1,124 @@
+if (UNIX)
+ IF (NOT APPLICATION_NAME)
+ MESSAGE(STATUS "${PROJECT_NAME} is used as APPLICATION_NAME")
+ SET(APPLICATION_NAME ${PROJECT_NAME})
+ ENDIF (NOT APPLICATION_NAME)
+
+ # Suffix for Linux
+ SET(LIB_SUFFIX
+ CACHE STRING "Define suffix of directory name (32/64)"
+ )
+
+ SET(EXEC_INSTALL_PREFIX
+ "${CMAKE_INSTALL_PREFIX}"
+ CACHE PATH "Base directory for executables and libraries"
+ FORCE
+ )
+ SET(SHARE_INSTALL_PREFIX
+ "${CMAKE_INSTALL_PREFIX}/share"
+ CACHE PATH "Base directory for files which go to share/"
+ FORCE
+ )
+ SET(DATA_INSTALL_PREFIX
+ "${SHARE_INSTALL_PREFIX}/${APPLICATION_NAME}"
+ CACHE PATH "The parent directory where applications can install their data" FORCE)
+
+ # The following are directories where stuff will be installed to
+ SET(BIN_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/bin"
+ CACHE PATH "The ${APPLICATION_NAME} binary install dir (default prefix/bin)"
+ FORCE
+ )
+ SET(SBIN_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/sbin"
+ CACHE PATH "The ${APPLICATION_NAME} sbin install dir (default prefix/sbin)"
+ FORCE
+ )
+ SET(LIB_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
+ CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/lib)"
+ FORCE
+ )
+ SET(LIBEXEC_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/libexec"
+ CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/libexec)"
+ FORCE
+ )
+ SET(PLUGIN_INSTALL_DIR
+ "${LIB_INSTALL_DIR}/${APPLICATION_NAME}"
+ CACHE PATH "The subdirectory relative to the install prefix where plugins will be installed (default is prefix/lib/${APPLICATION_NAME})"
+ FORCE
+ )
+ SET(INCLUDE_INSTALL_DIR
+ "${CMAKE_INSTALL_PREFIX}/include"
+ CACHE PATH "The subdirectory to the header prefix (default prefix/include)"
+ FORCE
+ )
+
+ SET(DATA_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}"
+ CACHE PATH "The parent directory where applications can install their data (default prefix/share/${APPLICATION_NAME})"
+ FORCE
+ )
+ SET(HTML_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/doc/HTML"
+ CACHE PATH "The HTML install dir for documentation (default data/doc/html)"
+ FORCE
+ )
+ SET(ICON_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/icons"
+ CACHE PATH "The icon install dir (default data/icons/)"
+ FORCE
+ )
+ SET(SOUND_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/sounds"
+ CACHE PATH "The install dir for sound files (default data/sounds)"
+ FORCE
+ )
+
+ SET(LOCALE_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/locale"
+ CACHE PATH "The install dir for translations (default prefix/share/locale)"
+ FORCE
+ )
+
+ SET(XDG_APPS_DIR
+ "${SHARE_INSTALL_PREFIX}/applications/"
+ CACHE PATH "The XDG apps dir"
+ FORCE
+ )
+ SET(XDG_DIRECTORY_DIR
+ "${SHARE_INSTALL_PREFIX}/desktop-directories"
+ CACHE PATH "The XDG directory"
+ FORCE
+ )
+
+ SET(SYSCONF_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/etc"
+ CACHE PATH "The ${APPLICATION_NAME} sysconfig install dir (default prefix/etc)"
+ FORCE
+ )
+ SET(MAN_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/man"
+ CACHE PATH "The ${APPLICATION_NAME} man install dir (default prefix/man)"
+ FORCE
+ )
+ SET(INFO_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/info"
+ CACHE PATH "The ${APPLICATION_NAME} info install dir (default prefix/info)"
+ FORCE
+ )
+endif (UNIX)
+
+if (WIN32)
+ # Same same
+ SET(BIN_INSTALL_DIR .)
+ SET(SBIN_INSTALL_DIR .)
+ SET(LIB_INSTALL_DIR .)
+ SET(PLUGIN_INSTALL_DIR plugins)
+ SET(HTML_INSTALL_DIR doc/HTML)
+ SET(ICON_INSTALL_DIR .)
+ SET(SOUND_INSTALL_DIR .)
+ SET(LOCALE_INSTALL_DIR lang)
+endif (WIN32)
+
@@ -0,0 +1,31 @@
+# Required cmake version
+cmake_minimum_required(VERSION 2.4.3)
+
+# Always include srcdir and builddir in include path
+# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
+# about every subdir
+# since cmake 2.4.0
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+# Put the include dirs which are in the source or build tree
+# before all other include dirs, so the headers in the sources
+# are prefered over the already installed ones
+# since cmake 2.4.1
+set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
+
+# Use colored output
+# since cmake 2.4.0
+set(CMAKE_COLOR_MAKEFILE ON)
+
+# Define the generic version of the libraries here
+set(GENERIC_LIB_VERSION "2.0.0")
+set(GENERIC_LIB_SOVERSION "2")
+
+# Set the default build type to release with debug info
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Debug
+ CACHE STRING
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+ FORCE
+ )
+endif (NOT CMAKE_BUILD_TYPE)
No changes.
@@ -0,0 +1,60 @@
+# Alsa check, based on libkmid/configure.in.in.
+# Only the support for Alsa >= 0.9.x was included; 0.5.x was dropped (but feel free to re-add it if you need it)
+# It defines ...
+# It offers the following macros:
+# ALSA_CONFIGURE_FILE(config_header) - generate a config.h, typical usage:
+# ALSA_CONFIGURE_FILE(${CMAKE_BINARY_DIR}/config-alsa.h)
+# ALSA_VERSION_STRING(version_string) looks for alsa/version.h and reads the version string into
+# the first argument passed to the macro
+
+# Copyright (c) 2006, David Faure, <faure@kde.org>
+# Copyright (c) 2007, Matthias Kretz <kretz@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+include(CheckIncludeFiles)
+include(CheckIncludeFileCXX)
+include(CheckLibraryExists)
+
+# Already done by toplevel
+FIND_LIBRARY(ASOUND_LIBRARY asound)
+check_library_exists(asound snd_seq_create_simple_port ${ASOUND_LIBRARY} HAVE_LIBASOUND2)
+if(HAVE_LIBASOUND2)
+ #message(STATUS "Found ALSA: ${ASOUND_LIBRARY}")
+else(HAVE_LIBASOUND2)
+ message(STATUS "ALSA not found")
+endif(HAVE_LIBASOUND2)
+set(ALSA_FOUND ${HAVE_LIBASOUND2})
+FIND_PATH(ALSA_INCLUDES alsa/version.h)
+
+MACRO(ALSA_VERSION_STRING _result)
+ # check for version in alsa/version.h
+ IF(ALSA_INCLUDES)
+ FILE(READ "${ALSA_INCLUDES}/alsa/version.h" _ALSA_VERSION_CONTENT)
+ STRING(REGEX REPLACE ".*SND_LIB_VERSION_STR.*\"(.*)\".*" "\\1" ${_result} ${_ALSA_VERSION_CONTENT})
+ ELSE(ALSA_INCLUDES)
+ MESSAGE(STATUS "ALSA version not known. ALSA output will probably not work correctly.")
+ ENDIF(ALSA_INCLUDES)
+ENDMACRO(ALSA_VERSION_STRING _result)
+
+get_filename_component(_FIND_ALSA_MODULE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+macro(ALSA_CONFIGURE_FILE _destFile)
+ check_include_files(sys/soundcard.h HAVE_SYS_SOUNDCARD_H)
+ check_include_files(machine/soundcard.h HAVE_MACHINE_SOUNDCARD_H)
+
+ check_include_files(linux/awe_voice.h HAVE_LINUX_AWE_VOICE_H)
+ check_include_files(awe_voice.h HAVE_AWE_VOICE_H)
+ check_include_files(/usr/src/sys/i386/isa/sound/awe_voice.h HAVE__USR_SRC_SYS_I386_ISA_SOUND_AWE_VOICE_H)
+ check_include_files(/usr/src/sys/gnu/i386/isa/sound/awe_voice.h HAVE__USR_SRC_SYS_GNU_I386_ISA_SOUND_AWE_VOICE_H)
+
+ check_include_file_cxx(sys/asoundlib.h HAVE_SYS_ASOUNDLIB_H)
+ check_include_file_cxx(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
+
+ check_library_exists(asound snd_pcm_resume ${ASOUND_LIBRARY} ASOUND_HAS_SND_PCM_RESUME)
+ if(ASOUND_HAS_SND_PCM_RESUME)
+ set(HAVE_SND_PCM_RESUME 1)
+ endif(ASOUND_HAS_SND_PCM_RESUME)
+
+ configure_file(${_FIND_ALSA_MODULE_DIR}/config-alsa.h.cmake ${_destFile})
+endmacro(ALSA_CONFIGURE_FILE _destFile)
Oops, something went wrong.

0 comments on commit 6dc99f6

Please sign in to comment.