# Copyright 2008 Corentin Chary.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
project (Zia CXX C)
#### Include ##
include (CheckIncludeFiles)
include (CheckFunctionExists)
include (CheckVariableExists)
include (CheckTypeSize)
include (CheckLibraryExists)
include (CMakeDetermineCCompiler)
include (FindThreads)
include (CPack)
include (FindPkgConfig)
#include (ZiaMacros)
#### SETUP #####
cmake_minimum_required (VERSION 2.6)
cmake_policy(SET CMP0005 NEW)
set (CMAKE_MODULE_PATH ${ZIA_SOURCE_DIR}/cmake)
set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
## BUILD_TYPE ##
IF (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type determining compiler flags" FORCE)
ENDIF ()
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions ("-DDEBUG=1")
ENDIF()
## MISC ##
# A CMake convenience to avoid using LD_LIBRARY_PATH after installation:
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON
CACHE BOOL "Whether to set an rpath for dynamic libraries.")
set (CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib
CACHE STRING "Rpath set at install stage." FORCE)
## Tests ##
##### Project defs #####
set (VERSION_MAJOR "0")
set (VERSION_MINOR "0")
set (VERSION_PATCH "1")
set (CPACK_RESOURCE_FILE_LICENSE "COPYING")
set (CPACK_RESOURCE_FILE_README "README")
set (PACKAGE_CONTACT "Corentin Chary ")
set (VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
add_definitions ("-DZIA_VERSION=\"${VERSION}\"")
include_directories (./include)
#### Platform Specific ####
## GCC ##
IF (CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_C_FLAGS "$ENV{CFLAGS} -O2 -Wall")
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -Werror -O0 -ggdb3")
set (CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O2 -Wall ")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
ENDIF ()
## OS ##
IF (CMAKE_SYSTEM_NAME MATCHES Linux)
# LINUX
add_definitions ("-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64") # For 64 bits files
ELSE ()
# DEFAULT
message ("For now, Zia has only been tested under GNU/Linux.")
ENDIF ()
#### Modules ####
OPTION (BUILD_STATIC "build a static zia with all modules added")
IF (BUILD_STATIC)
set (ZIA_STATIC 1)
ELSE (BUILD_STATIC)
set (CMAKE_SHARED_LIBRARY_PREFIX "")
ENDIF (BUILD_STATIC)
#### Sources ####
add_subdirectory (src)
add_subdirectory (modules)
#### Packages ###
set (CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set (CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set (CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATH})
set (CPACK_SOURCE_GENERATOR "TGZ")
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.;~$;/_;build/;CMakeFiles/;CMakeCache;gz$;Makefile\\\\.;trace;Testing/;foo;autom4te;cmake_install;CPack;\\\\.pem;ltmain.sh;configure;libtool;/config\\\\.;missing;autogen.sh;install-sh;Dart;aclocal;log$;Makefile$")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")