Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[5aee46]: CMakeLists.txt Maximize Restore History

Download this file

CMakeLists.txt    206 lines (174 with data), 8.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# Copyright (C) 2010 David Sugar, Tycho Softworks
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
cmake_minimum_required(VERSION 2.6)
PROJECT(apennine)
set (VERSION 0.1.0)
set (SOVERSION 0)
# when we override default install prefix, assume full path is used...
set(INSTALL_INCLUDEDIR include)
set(INSTALL_BINDIR bin)
set(INSTALL_SBINDIR sbin)
set(INSTALL_LIBEXEC libexec)
if(WIN32)
set(INSTALL_MANDIR man)
set(INSTALL_DOCDIR doc/${PROJECT_NAME})
set(INSTALL_LOCALE locale)
set(INSTALL_LIBDIR bin)
set(INSTALL_INFODIR info)
set(SYSCONFDIR "etc" CACHE PATH "config directory")
set(STATEDIR "var" CACHE PATH "state directory")
else()
set(INSTALL_MANDIR share/man)
set(INSTALL_LOCALE share/locale)
set(INSTALL_DOCDIR share/doc/${PROJECT_NAME})
set(INSTALL_INFODIR share/info)
set(INSTALL_LIBDIR lib${LIB_POSTFIX})
set(SYSCONFDIR "/etc" CACHE PATH "config directory")
set(STATEDIR "/var" CACHE PATH "state directory")
endif()
if(WIN32)
set(DEFAULT_CFGPATH "${CMAKE_INSTALL_PREFIX}/${SYSCONFDIR}")
set(DEFAULT_VARPATH "${CMAKE_INSTALL_PREFIX}/${STATEDIR}")
set(DEFAULT_DATAPATH ${CMAKE_INSTALL_PREFIX})
else()
set(DEFAULT_CFGPATH ${SYSCONFDIR})
set(DEFAULT_VARPATH ${STATEDIR})
set(DEFAULT_DATAPATH ${CMAKE_INSTALL_PREFIX}/${INSTALL_DATADIR})
endif()
set(INSTALL_PLUGINS ${INSTALL_LIBDIR})
set(DEFAULT_PLUGINS ${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINS})
set(DEFAULT_LIBEXEC ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBEXEC})
if (WIN32)
# too broken to build dll's with const static members...
if(MSVC60)
set(BUILD_STATIC ON CACHE BOOL "static linking only" FORCE)
MARK_AS_ADVANCED(FORCE BUILD_STATIC)
else()
option(BUILD_STATIC "Set to OFF to build shared libraries" ON)
endif()
set(HAVE_SIGWAIT false)
set(HAVE_SIGWAIT2 off CACHE BOOL "disable sigwait on windows" FORCE)
MARK_AS_ADVANCED(FORCE HAVE_SIGWAIT2)
else()
option(BUILD_STATIC "Set to ON to build static libraries" OFF)
option(HAVE_SIGWAIT2 "Set to OFF to build with single argument" ON)
set(HAVE_SIGWAIT true)
endif()
MESSAGE( STATUS "Configuring apennine ${VERSION}")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}")
SET(CPACK_PACKAGE_VENDOR "David Sugar")
# SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(PACKAGE_FILE_NAME ${PROJECT_NAME})
set(PACKAGE_FILE_VERSION ${VERSION})
IF (WIN32)
SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}-${PACKAGE_FILE_VERSION}")
ELSE (WIN32)
SET(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}-bin-${PACKAGE_FILE_VERSION}")
if (NOT CPACK_GENERATOR)
SET(CPACK_GENERATOR "TBZ2")
endif()
ENDIF (WIN32)
IF(WIN32 AND NOT UNIX)
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_FILE_NAME}")
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
# SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
# SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\MyExecutable.exe")
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}$")
SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.gnutelephony.org")
SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\www.gnutelephony.org")
SET(CPACK_NSIS_CONTACT "dyfet@gnutelephony.org")
SET(CPACK_NSIS_MODIFY_PATH ON)
ENDIF(WIN32 AND NOT UNIX)
set(CPACK_COMPONENTS_ALL server libraries headers)
set(CPACK_COMPONENT_SERVER_DISPLAY_NAME "Server")
set(CPACK_COMPONENT_SERVER_DESCRIPTION "Server Daemon")
set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Dynamic library")
set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers")
set(CPACK_COMPONENT_HEADERS_DESCRIPTION
"Header files needed to build applications using ucommon library")
SET(CPACK_SOURCE_IGNORE_FILES ".bzr" "build" ".swp$" ".*~" ".svn" ".git")
SET(CPACK_SOURCE_GENERATOR "TBZ2")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}-${PACKAGE_FILE_VERSION}")
# This must always be last!
INCLUDE(CPack)
# set to true for debug and trace during CMakeLists development
set(CMAKE_VERBOSE_MAKEFILE FALSE)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckIncludeFiles)
check_function_exists(mkfifo HAVE_MKFIFO)
check_function_exists(setpgrp HAVE_SETPGRP)
check_function_exists(setrlimit HAVE_SETRLIMIT)
check_function_exists(getuid HAVE_GETUID)
check_function_exists(execvp HAVE_EXECVP)
check_include_files(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_files(pwd.h HAVE_PWD_H)
# Set defaults and pass common options. Common build options can be passed
# to cmake using cmake -DWITH_CFLAGS="...", WITH_LIBS, and WITH_INCLUDES
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/inc ${WITH_INCLUDES})
add_definitions(${WITH_CFLAGS})
link_libraries(${WITH_LIBS})
if (USES_UCOMMON_INCLUDE_DIRS)
message(STATUS " Using local ucommon dependency")
else()
find_package(PkgConfig)
pkg_check_modules(USES_UCOMMON REQUIRED ucommon>=4.0.1)
endif()
include_directories(${USES_UCOMMON_INCLUDE_DIRS})
link_directories(${USES_UCOMMON_LIBRARY_DIRS})
add_definitions(${USES_UCOMMON_CFLAGS})
# by default we build static libs for windows, shared libs for unix.
# we may also set this from a top level cmake or -DWITH_XX_LIBS
if(BUILD_STATIC AND NOT BUILD_SHARED)
set(BUILD_LIBRARY_TYPE STATIC)
else()
set(BUILD_LIBRARY_TYPE SHARED)
endif()
if(NOT BUILD_RUNTIME_TYPE)
set(BUILD_RUNTIME_TYPE ${BUILD_LIBRARY_TYPE})
endif()
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
file(GLOB apennine_inc inc/apennine/*.h)
file(GLOB common_src common/*.cpp)
file(GLOB server_src server/*.cpp)
set(server_inc server/server.h)
add_library(apennine ${BUILD_LIBRARY_TYPE} ${common_src} ${apennine_inc})
set_target_properties(apennine PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION})
add_dependencies(apennine usecure ucommon)
target_link_libraries(apennine ${USES_UCOMMON_LIBRARIES})
add_executable(apennine-server ${server_src} ${server_inc})
add_dependencies(apennine-server apennine usecure ucommon)
set_target_properties(apennine-server PROPERTIES OUTPUT_NAME apennine)
target_link_libraries(apennine-server apennine usecure ucommon ${SECURE_LIBS} ${UCOMMON_LIBS})
install(FILES COPYING AUTHORS DESTINATION ${INSTALL_DOCDIR})
install(FILES ${apennine_inc} DESTINATION ${INSTALL_INCLUDEDIR}/apennine COMPONENT headers)
install(TARGETS apennine DESTINATION ${INSTALL_LIBDIR})
install(TARGETS apennine-server DESTINATION ${INSTALL_SBINDIR})
if(EXISTS ".svn" AND (${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}))
set(DISTNAME ${PROJECT_NAME})
add_custom_target(dist
COMMAND rm -f ${DISTNAME}-${VERSION}.zip
COMMAND rm -f ${DISTNAME}-${VERSION}.tar.gz
COMMAND rm -rf ${DISTNAME}-${VERSION}
COMMAND mkdir ${DISTNAME}-${VERSION}
COMMAND zip -q ${DISTNAME}-${VERSION}.zip `svn ls --recursive`
COMMAND unzip -q ${DISTNAME}-${VERSION}.zip -d ${DISTNAME}-${VERSION}
COMMAND tar -cvzf ${DISTNAME}-${VERSION}.tar.gz ${DISTNAME}-${VERSION}
COMMAND rm -rf ${DISTNAME}-${VERSION}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif ()