| 1 |
# Copyright (c) 2009, Whispersoft s.r.l. |
|---|
| 2 |
# All rights reserved. |
|---|
| 3 |
# |
|---|
| 4 |
# Redistribution and use in source and binary forms, with or without |
|---|
| 5 |
# modification, are permitted provided that the following conditions are |
|---|
| 6 |
# met: |
|---|
| 7 |
# |
|---|
| 8 |
# * Redistributions of source code must retain the above copyright |
|---|
| 9 |
# notice, this list of conditions and the following disclaimer. |
|---|
| 10 |
# * Redistributions in binary form must reproduce the above |
|---|
| 11 |
# copyright notice, this list of conditions and the following disclaimer |
|---|
| 12 |
# in the documentation and/or other materials provided with the |
|---|
| 13 |
# distribution. |
|---|
| 14 |
# * Neither the name of Whispersoft s.r.l. nor the names of its |
|---|
| 15 |
# contributors may be used to endorse or promote products derived from |
|---|
| 16 |
# this software without specific prior written permission. |
|---|
| 17 |
# |
|---|
| 18 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|---|
| 19 |
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|---|
| 20 |
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|---|
| 21 |
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|---|
| 22 |
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|---|
| 23 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|---|
| 24 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|---|
| 25 |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|---|
| 26 |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|---|
| 27 |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|---|
| 28 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 29 |
# |
|---|
| 30 |
## |
|---|
| 31 |
## Some common cmake junk used in all our root CMakeLists.txt |
|---|
| 32 |
## |
|---|
| 33 |
|
|---|
| 34 |
if (NOT INSTALL_PREFIX) |
|---|
| 35 |
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/whispercast" |
|---|
| 36 |
CACHE PATH "installation directory prefix" FORCE) |
|---|
| 37 |
else (NOT INSTALL_PREFIX) |
|---|
| 38 |
set(CMAKE_INSTALL_PREFIX "${INSTALL_PREFIX}" |
|---|
| 39 |
CACHE PATH "installation directory prefix" FORCE) |
|---|
| 40 |
endif (NOT INSTALL_PREFIX) |
|---|
| 41 |
|
|---|
| 42 |
set(CMAKE_INSTALL_PREFIX_ETC "etc" |
|---|
| 43 |
CACHE PATH "installation directory prefix (etc)" FORCE) |
|---|
| 44 |
set(CMAKE_INSTALL_PREFIX_VAR "var" |
|---|
| 45 |
CACHE PATH "installation directory prefix (var)" FORCE) |
|---|
| 46 |
set(CMAKE_INSTALL_PREFIX_MEDIA "media" |
|---|
| 47 |
CACHE PATH "installation directory prefix (media)" FORCE) |
|---|
| 48 |
|
|---|
| 49 |
###################################################################### |
|---|
| 50 |
|
|---|
| 51 |
if (NOT CMAKE_BUILD_TYPE) |
|---|
| 52 |
set(CMAKE_BUILD_TYPE Release CACHE STRING |
|---|
| 53 |
"Options: Debug Release." FORCE) |
|---|
| 54 |
endif (NOT CMAKE_BUILD_TYPE) |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
# |
|---|
| 58 |
# Generic definitions for all build types |
|---|
| 59 |
# |
|---|
| 60 |
add_definitions(-Wall -Wno-sign-compare -Werror) |
|---|
| 61 |
|
|---|
| 62 |
if (CMAKE_BUILD_TYPE STREQUAL "Debug") |
|---|
| 63 |
message(STATUS "Compiling in Debug mode.") |
|---|
| 64 |
set(CMAKE_CXX_FLAGS_DEBUG |
|---|
| 65 |
"${CMAKE_CXX_FLAGS_DEBUG} -D _FILE_OFFSET_BITS=64 -ggdb3 -D _DEBUG") |
|---|
| 66 |
else (CMAKE_BUILD_TYPE STREQUAL "Debug") |
|---|
| 67 |
message(STATUS "Compiling in Release mode.") |
|---|
| 68 |
set(CMAKE_CXX_FLAGS_RELEASE |
|---|
| 69 |
"${CMAKE_CXX_FLAGS_RELEASE} -D _FILE_OFFSET_BITS=64 -ggdb3 -O2 -fomit-frame-pointer") |
|---|
| 70 |
endif (CMAKE_BUILD_TYPE STREQUAL "Debug") |
|---|
| 71 |
|
|---|
| 72 |
## set (COMMON_LINK_LIBRARIES pthread rt) |
|---|
| 73 |
set (COMMON_LINK_LIBRARIES pthread) |
|---|
| 74 |
|
|---|
| 75 |
###################################################################### |
|---|
| 76 |
|
|---|
| 77 |
if ( ENABLE_BFD ) |
|---|
| 78 |
find_package(Bfd) |
|---|
| 79 |
endif ( ENABLE_BFD ) |
|---|
| 80 |
|
|---|
| 81 |
if ( Bfd_FOUND ) |
|---|
| 82 |
message(STATUS "====> Enabling BFD.") |
|---|
| 83 |
set( COMMON_LINK_LIBRARIES "${COMMON_LINK_LIBRARIES} ${Bfd_LIBRARY}") |
|---|
| 84 |
else (Bfd_FOUND) |
|---|
| 85 |
message(STATUS "====> Disabling BFD.") |
|---|
| 86 |
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D _NO_BFD") |
|---|
| 87 |
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D _NO_BFD") |
|---|
| 88 |
endif (Bfd_FOUND) |
|---|
| 89 |
|
|---|
| 90 |
###################################################################### |
|---|
| 91 |
|
|---|
| 92 |
find_package(GooglePerfTools) |
|---|
| 93 |
|
|---|
| 94 |
if (profiler_LIBRARY) |
|---|
| 95 |
message(STATUS "====> Enabling profiler") |
|---|
| 96 |
set( COMMON_LINK_LIBRARIES "${COMMON_LINK_LIBRARIES} ${profiler_LIBRARIES}") |
|---|
| 97 |
endif (profiler_LIBRARY) |
|---|
| 98 |
|
|---|
| 99 |
if (tcmalloc_LIBRARY) |
|---|
| 100 |
message(STATUS "====> Enabling tcmalloc") |
|---|
| 101 |
set( COMMON_LINK_LIBRARIES "${COMMON_LINK_LIBRARIES} ${tcmalloc_LIBRARIES}") |
|---|
| 102 |
endif (tcmalloc_LIBRARY) |
|---|
| 103 |
|
|---|
| 104 |
if (google_perftools_INCLUDE_DIR) |
|---|
| 105 |
message(STATUS "====> Enabling google-perftools") |
|---|
| 106 |
include_directories (${google_perftools_INCLUDE_DIR}) |
|---|
| 107 |
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D _HAVE_GOOGLE_PERFTOOLS") |
|---|
| 108 |
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D _HAVE_GOOGLE_PERFTOOLS") |
|---|
| 109 |
endif (google_perftools_INCLUDE_DIR) |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
###################################################################### |
|---|
| 113 |
|
|---|
| 114 |
## Simple macro for test definition |
|---|
| 115 |
|
|---|
| 116 |
macro(WHISPER_TEST NAME SRCS DEPS LIBS) |
|---|
| 117 |
add_executable(${NAME} ${SRCS}) |
|---|
| 118 |
add_dependencies(${NAME} ${DEPS}) |
|---|
| 119 |
target_link_libraries(${NAME} ${LIBS}) |
|---|
| 120 |
add_test(${NAME} ${NAME}) |
|---|
| 121 |
endmacro(WHISPER_TEST) |
|---|
| 122 |
|
|---|
| 123 |
macro(WHISPER_ADD_LIBRARY NAME SRCS) |
|---|
| 124 |
add_library(${NAME} STATIC ${SRCS}) |
|---|
| 125 |
set_target_properties(${NAME} PROPERTIES SOURCES ${SRCS}) |
|---|
| 126 |
endmacro(WHISPER_ADD_LIBRARY) |
|---|
| 127 |
|
|---|
| 128 |
###################################################################### |
|---|
| 129 |
|
|---|
| 130 |
exec_program(date ARGS "+%N" OUTPUT_VARIABLE BUILD_TIMESTAMP) |
|---|
| 131 |
|
|---|
| 132 |
message(STATUS "====> NOW "${BUILD_TIMESTAMP}) |
|---|
| 133 |
|
|---|
| 134 |
###################################################################### |
|---|
| 135 |
|
|---|
| 136 |
enable_testing() |
|---|