example/tests/check_money.6.c \
example/tests/check_money.7.c
+example_cmake = example/CMakeLists.txt \
+ example/src/CMakeLists.txt \
+ example/tests/CMakeLists.txt \
+ example/cmake/config.h.in \
+ example/cmake/COPYING-CMAKE-SCRIPTS.txt \
+ example/cmake/FindCheck.cmake
+
## what to clean
CLEANFILES = check.info *~ *.diff
EXTRA_DIST = $(example_docs) \
$(example_src_docs) \
- $(example_tests_docs)
+ $(example_tests_docs) \
+ $(example_cmake)
## what to install
--- /dev/null
+project(money C)
+
+cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+###############################################################################
+# Set build features
+set(CMAKE_BUILD_TYPE Debug)
+
+###############################################################################
+include(CheckCSourceCompiles)
+include(CheckCSourceRuns)
+include(CheckFunctionExists)
+include(CheckIncludeFile)
+include(CheckIncludeFiles)
+include(CheckLibraryExists)
+include(CheckSymbolExists)
+include(CheckTypeSize)
+
+###############################################################################
+# Check headers
+set(INCLUDES "")
+macro(ck_check_include_file header var)
+ check_include_files("${INCLUDES};${header}" ${var})
+ if(${var})
+ set(INCLUDES ${INCLUDES} ${header})
+ endif(${var})
+endmacro(ck_check_include_file)
+
+ck_check_include_file("stdlib.h" HAVE_STDLIB_H)
+
+###############################################################################
+# Check functions
+# (Nothing to check for the money example)
+
+###############################################################################
+# Check defines
+# (Nothing to check for the money example)
+
+###############################################################################
+# Check struct members
+# (Nothing to check for the money example)
+
+###############################################################################
+# Check for integer types
+# (The following are used in check.h. Regardless if they are used in
+# the project, they will need to be checked in order to use Check).
+check_type_size(intmax_t INTMAX_T)
+check_type_size(uintmax_t UINTMAX_T)
+
+check_type_size(pid_t PID_T)
+if(NOT HAVE_PID_T)
+ if(WIN32)
+ set(pid_t "int")
+ else(WIN32)
+ MESSAGE(FATAL_ERROR "pid_t doesn't exist on this platform?")
+ endif(WIN32)
+endif(NOT HAVE_PID_T)
+
+###############################################################################
+# Check libraries
+
+###############################################################################
+# Generate "config.h" from "cmake/config.h.cmake"
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
+add_definitions(-DHAVE_CONFIG_H)
+set(CONFIG_HEADER ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+###############################################################################
+# Subdirectories
+add_subdirectory(src)
+add_subdirectory(tests)
+
+###############################################################################
+# Unit tests
+enable_testing()
+add_test(NAME check_money COMMAND check_money)
+
This is the "money example" from the Check tutorial.
+This demonstrates using Check along with one of two build systems:
+autotools and CMake.
+
========================
Autotools:
|--- Makefile.am
Please send bug reports to check-devel AT lists.sourceforge.net.
+
+========================
+CMake:
+
+You need the following programs installed on your system:
+ -- CMake 2.8
+ -- Check 0.9.9
+ -- pkg-config 0.26
+
+Somewhat earlier versions of these programs might work.
+
+Then, do as follows for a Unix-compatible shell:
+
+$ cmake .
+$ make
+$ make test
+
+or the following for MSVC:
+
+$ cmake -G "NMake Makefiles" .
+$ nmake
+$ nmake test
+
+Don't do "make install" or "nmake install" unless you want to install the money example.
+
+money.c and money.h are built as a library. src/main.c:main() is a
+client of libmoney.la, just as tests/check_money.c:main() is a client
+of libmoney.la
+
+To use the CMake example in another project, start with the following files:
+
+ example
+ |--- CMakeFiles.txt
+ |--- cmake
+ | |--- config.h.in
+ | |--- FindCheck.cmake
+ |--- src
+ | |--- CMakeFiles.txt
+ |--- tests
+ |--- CMakeFiles.txt
+
+Please send bug reports to check-devel AT lists.sourceforge.net.
--- /dev/null
+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.
--- /dev/null
+# - Try to find the CHECK libraries
+# Once done this will define
+#
+# CHECK_FOUND - system has check
+# CHECK_INCLUDE_DIR - the check include directory
+# CHECK_LIBRARIES - check library
+#
+# This configuration file for finding libcheck is originally from
+# the opensync project. The originally was downloaded from here:
+# opensync.org/browser/branches/3rd-party-cmake-modules/modules/FindCheck.cmake
+#
+# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
+# Copyright (c) 2007 Bjoern Ricks <b.ricks@fh-osnabrueck.de>
+#
+# Redistribution and use is allowed according to the terms of the New
+# BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+INCLUDE( FindPkgConfig )
+
+# Take care about check.pc settings
+PKG_SEARCH_MODULE( CHECK check )
+
+# Look for CHECK include dir and libraries
+IF( NOT CHECK_FOUND )
+
+ FIND_PATH( CHECK_INCLUDE_DIR check.h )
+
+ FIND_LIBRARY( CHECK_LIBRARIES NAMES check )
+
+ IF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
+ SET( CHECK_FOUND 1 )
+ IF ( NOT Check_FIND_QUIETLY )
+ MESSAGE ( STATUS "Found CHECK: ${CHECK_LIBRARIES}" )
+ ENDIF ( NOT Check_FIND_QUIETLY )
+ ELSE ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
+ IF ( Check_FIND_REQUIRED )
+ MESSAGE( FATAL_ERROR "Could NOT find CHECK" )
+ ELSE ( Check_FIND_REQUIRED )
+ IF ( NOT Check_FIND_QUIETLY )
+ MESSAGE( STATUS "Could NOT find CHECK" )
+ ENDIF ( NOT Check_FIND_QUIETLY )
+ ENDIF ( Check_FIND_REQUIRED )
+ ENDIF ( CHECK_INCLUDE_DIR AND CHECK_LIBRARIES )
+ENDIF( NOT CHECK_FOUND )
+
+# Hide advanced variables from CMake GUIs
+MARK_AS_ADVANCED( CHECK_INCLUDE_DIR CHECK_LIBRARIES )
+
--- /dev/null
+/*-*- mode:C; -*- */
+/* config.h. Generated from build/cmake/config.h.in by cmake configure */
+
+/*
+ * Ensure we have C99-style int64_t, etc, all defined.
+ */
+
+/* First, we need to know if the system has already defined them. */
+#cmakedefine HAVE_INTMAX_T
+#cmakedefine HAVE_UINTMAX_T
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#cmakedefine pid_t ${pid_t}
--- /dev/null
+set(LIB_SOURCES
+ money.c
+)
+
+set(MAIN_SOURCES
+ main.c
+)
+
+set(HEADERS
+ ${CONFIG_HEADER}
+ money.h
+)
+
+add_library(money STATIC ${LIB_SOURCES} ${HEADERS})
+
+add_executable(main ${HEADERS} ${MAIN_SOURCES})
+target_link_libraries(main money)
+
+install(TARGETS money
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+
+install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/money.h DESTINATION include)
--- /dev/null
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
+
+find_package(Check REQUIRED)
+include_directories(${CHECK_INCLUDE_DIRS})
+
+set(TEST_SOURCES
+ check_money.c
+)
+
+add_executable(check_money ${TEST_SOURCES})
+target_link_libraries(check_money money ${CHECK_LIBRARIES})