aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cynapses.org>2010-12-29 13:51:21 +0100
committerAndreas Schneider <asn@cryptomilk.org>2011-05-31 19:45:28 +0200
commitdafc2dd4bd95e991ec69a22a729f9e0c79c6ca2e (patch)
tree23ae0aa3029bd0006b879cb51f453728d25bf74f /cmake
parent386504bff3f84b9b106c25f296685ba572fbab20 (diff)
downloadcmocka-dafc2dd4bd95e991ec69a22a729f9e0c79c6ca2e.tar.gz
cmocka-dafc2dd4bd95e991ec69a22a729f9e0c79c6ca2e.tar.xz
cmocka-dafc2dd4bd95e991ec69a22a729f9e0c79c6ca2e.zip
build: Added CMake build of cmockery.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/COPYING-CMAKE-SCRIPTS22
-rw-r--r--cmake/Modules/DefineCMakeDefaults.cmake27
-rw-r--r--cmake/Modules/DefineCompilerFlags.cmake68
-rw-r--r--cmake/Modules/DefineInstallationPaths.cmake107
-rw-r--r--cmake/Modules/DefinePlatformDefaults.cmake21
-rw-r--r--cmake/Modules/MacroCheckCCompilerFlagSSP.cmake26
-rw-r--r--cmake/Modules/MacroEnsureOutOfSourceBuild.cmake17
7 files changed, 288 insertions, 0 deletions
diff --git a/cmake/Modules/COPYING-CMAKE-SCRIPTS b/cmake/Modules/COPYING-CMAKE-SCRIPTS
new file mode 100644
index 0000000..4b41776
--- /dev/null
+++ b/cmake/Modules/COPYING-CMAKE-SCRIPTS
@@ -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.
diff --git a/cmake/Modules/DefineCMakeDefaults.cmake b/cmake/Modules/DefineCMakeDefaults.cmake
new file mode 100644
index 0000000..72893c3
--- /dev/null
+++ b/cmake/Modules/DefineCMakeDefaults.cmake
@@ -0,0 +1,27 @@
+# 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 "0.1.0")
+set(GENERIC_LIB_SOVERSION "0")
+
+# Set the default build type to release with debug info
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE RelWithDebInfo
+ CACHE STRING
+ "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+ )
+endif (NOT CMAKE_BUILD_TYPE)
diff --git a/cmake/Modules/DefineCompilerFlags.cmake b/cmake/Modules/DefineCompilerFlags.cmake
new file mode 100644
index 0000000..694cbdc
--- /dev/null
+++ b/cmake/Modules/DefineCompilerFlags.cmake
@@ -0,0 +1,68 @@
+# define system dependent compiler flags
+
+include(CheckCCompilerFlag)
+include(MacroCheckCCompilerFlagSSP)
+
+if (UNIX AND NOT WIN32)
+ #
+ # Define GNUCC compiler flags
+ #
+ if (${CMAKE_C_COMPILER_ID} MATCHES GNU)
+ # add -Wconversion ?
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute")
+
+ # with -fPIC
+ check_c_compiler_flag("-fPIC" WITH_FPIC)
+ if (WITH_FPIC)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+ endif (WITH_FPIC)
+
+ check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
+ if (WITH_STACK_PROTECTOR)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
+ endif (WITH_STACK_PROTECTOR)
+
+ check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
+ if (WITH_FORTIFY_SOURCE)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
+ endif (WITH_FORTIFY_SOURCE)
+ endif (${CMAKE_C_COMPILER_ID} MATCHES GNU)
+
+ #
+ # Check for large filesystem support
+ #
+ if (CMAKE_SIZEOF_VOID_P MATCHES "8")
+ # with large file support
+ execute_process(
+ COMMAND
+ getconf LFS64_CFLAGS
+ OUTPUT_VARIABLE
+ _lfs_CFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ else (CMAKE_SIZEOF_VOID_P MATCHES "8")
+ # with large file support
+ execute_process(
+ COMMAND
+ getconf LFS_CFLAGS
+ OUTPUT_VARIABLE
+ _lfs_CFLAGS
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
+ if (_lfs_CFLAGS)
+ string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_lfs_CFLAGS}")
+ endif (_lfs_CFLAGS)
+
+endif (UNIX AND NOT WIN32)
+
+if (MSVC)
+ # Suppress warning about "deprecated" functions
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
+endif (MSVC)
diff --git a/cmake/Modules/DefineInstallationPaths.cmake b/cmake/Modules/DefineInstallationPaths.cmake
new file mode 100644
index 0000000..71e1e85
--- /dev/null
+++ b/cmake/Modules/DefineInstallationPaths.cmake
@@ -0,0 +1,107 @@
+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"
+ )
+ SET(SHARE_INSTALL_PREFIX
+ "${CMAKE_INSTALL_PREFIX}/share"
+ CACHE PATH "Base directory for files which go to share/"
+ )
+ SET(DATA_INSTALL_PREFIX
+ "${SHARE_INSTALL_PREFIX}/${APPLICATION_NAME}"
+ CACHE PATH "The parent directory where applications can install their data")
+
+ # 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)"
+ )
+ SET(SBIN_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/sbin"
+ CACHE PATH "The ${APPLICATION_NAME} sbin install dir (default prefix/sbin)"
+ )
+ 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)"
+ )
+ 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)"
+ )
+ 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})"
+ )
+ SET(INCLUDE_INSTALL_DIR
+ "${CMAKE_INSTALL_PREFIX}/include"
+ CACHE PATH "The subdirectory to the header prefix (default prefix/include)"
+ )
+
+ SET(DATA_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}"
+ CACHE PATH "The parent directory where applications can install their data (default prefix/share/${APPLICATION_NAME})"
+ )
+ SET(HTML_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/doc/HTML"
+ CACHE PATH "The HTML install dir for documentation (default data/doc/html)"
+ )
+ SET(ICON_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/icons"
+ CACHE PATH "The icon install dir (default data/icons/)"
+ )
+ SET(SOUND_INSTALL_DIR
+ "${DATA_INSTALL_PREFIX}/sounds"
+ CACHE PATH "The install dir for sound files (default data/sounds)"
+ )
+
+ SET(LOCALE_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/locale"
+ CACHE PATH "The install dir for translations (default prefix/share/locale)"
+ )
+
+ SET(XDG_APPS_DIR
+ "${SHARE_INSTALL_PREFIX}/applications/"
+ CACHE PATH "The XDG apps dir"
+ )
+ SET(XDG_DIRECTORY_DIR
+ "${SHARE_INSTALL_PREFIX}/desktop-directories"
+ CACHE PATH "The XDG directory"
+ )
+
+ SET(SYSCONF_INSTALL_DIR
+ "${EXEC_INSTALL_PREFIX}/etc"
+ CACHE PATH "The ${APPLICATION_NAME} sysconfig install dir (default prefix/etc)"
+ )
+ SET(MAN_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/man"
+ CACHE PATH "The ${APPLICATION_NAME} man install dir (default prefix/man)"
+ )
+ SET(INFO_INSTALL_DIR
+ "${SHARE_INSTALL_PREFIX}/info"
+ CACHE PATH "The ${APPLICATION_NAME} info install dir (default prefix/info)"
+ )
+endif (UNIX)
+
+if (WIN32)
+ # Same same
+ set(BIN_INSTALL_DIR "bin" CACHE PATH "-")
+ set(SBIN_INSTALL_DIR "." CACHE PATH "-")
+ set(LIB_INSTALL_DIR "lib" CACHE PATH "-")
+ set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-")
+ set(PLUGIN_INSTALL_DIR "plugins" CACHE PATH "-")
+ set(HTML_INSTALL_DIR "doc/HTML" CACHE PATH "-")
+ set(ICON_INSTALL_DIR "." CACHE PATH "-")
+ set(SOUND_INSTALL_DIR "." CACHE PATH "-")
+ set(LOCALE_INSTALL_DIR "lang" CACHE PATH "-")
+endif (WIN32)
+
diff --git a/cmake/Modules/DefinePlatformDefaults.cmake b/cmake/Modules/DefinePlatformDefaults.cmake
new file mode 100644
index 0000000..46c3185
--- /dev/null
+++ b/cmake/Modules/DefinePlatformDefaults.cmake
@@ -0,0 +1,21 @@
+# Set system vars
+
+if (CMAKE_SYSTEM_NAME MATCHES "Linux")
+ set(LINUX TRUE)
+endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
+
+if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ set(FREEBSD TRUE)
+endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+
+if (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
+ set(OPENBSD TRUE)
+endif (CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
+
+if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+ set(NETBSD TRUE)
+endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+
+if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
+ set(SOLARIS TRUE)
+endif (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
diff --git a/cmake/Modules/MacroCheckCCompilerFlagSSP.cmake b/cmake/Modules/MacroCheckCCompilerFlagSSP.cmake
new file mode 100644
index 0000000..b64fb45
--- /dev/null
+++ b/cmake/Modules/MacroCheckCCompilerFlagSSP.cmake
@@ -0,0 +1,26 @@
+# - Check whether the C compiler supports a given flag in the
+# context of a stack checking compiler option.
+# CHECK_C_COMPILER_FLAG_SSP(FLAG VARIABLE)
+#
+# FLAG - the compiler flag
+# VARIABLE - variable to store the result
+#
+# This actually calls the check_c_source_compiles macro.
+# See help for CheckCSourceCompiles for a listing of variables
+# that can modify the build.
+
+# Copyright (c) 2006, Alexander Neundorf, <neundorf@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(CheckCSourceCompiles)
+
+MACRO (CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT)
+ SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+ SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
+ CHECK_C_SOURCE_COMPILES("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" ${_RESULT})
+ SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
+ENDMACRO (CHECK_C_COMPILER_FLAG_SSP)
+
diff --git a/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake b/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake
new file mode 100644
index 0000000..a2e9480
--- /dev/null
+++ b/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake
@@ -0,0 +1,17 @@
+# - MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
+# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
+
+# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+macro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage)
+
+ string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource)
+ if (_insource)
+ message(SEND_ERROR "${_errorMessage}")
+ message(FATAL_ERROR "Remove the file CMakeCache.txt in ${CMAKE_SOURCE_DIR} first.")
+ endif (_insource)
+
+endmacro (MACRO_ENSURE_OUT_OF_SOURCE_BUILD)