owlps/CMakeLists.txt

113 lines
2.9 KiB
CMake
Raw Normal View History

2013-05-18 19:39:36 +02:00
cmake_minimum_required(VERSION 2.8)
project(OwlPS)
### Build paths ###
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
2013-05-18 20:03:35 +02:00
# Path for the generated header files
set(GENERATED_INCLUDE "${PROJECT_BINARY_DIR}/include")
include_directories("${GENERATED_INCLUDE}")
2013-05-18 19:39:36 +02:00
2013-05-19 02:36:01 +02:00
### OwlPS' version ###
# First, try to get it from the environment variable OWLPS_VERSION
if (NOT "$ENV{OWLPS_VERSION}" STREQUAL "")
add_definitions(-DOWLPS_VERSION="$ENV{OWLPS_VERSION}")
# Environment variable OWLPS_VERSION not set: try to get the version
# number from git describe
else()
execute_process(
COMMAND git describe
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE RET
OUTPUT_VARIABLE OWLPS_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (${RET} EQUAL 0)
add_definitions(-DOWLPS_VERSION="${OWLPS_VERSION}")
endif()
endif()
2013-05-19 00:02:33 +02:00
### Options ###
# Configurations
set(CMAKE_CONFIGURATION_TYPES
Debug Release RelWithDebInfo MinSizeRel
CACHE STRING "Set the configurations" FORCE)
# Default configuration
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo
CACHE STRING "Set the default configuration" FORCE)
endif()
2013-05-19 00:02:33 +02:00
option (DEBUG
"Enable debug code"
on)
if (DEBUG)
add_definitions(-DDEBUG)
endif()
### Flags ###
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wextra -Wstrict-prototypes")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra")
2013-05-19 00:02:33 +02:00
2013-05-18 19:39:36 +02:00
### Libraries ###
add_subdirectory(libowlps)
include_directories(libowlps)
add_subdirectory(libowlps-client)
include_directories(libowlps-client)
add_subdirectory(libowlps-resultreader)
include_directories(libowlps-resultreader)
### Programs ###
add_subdirectory(owlps-aggregator)
add_subdirectory(owlps-client)
if (${CMAKE_SYSTEM_NAME} STREQUAL Linux)
add_subdirectory(owlps-listener)
else()
message(WARNING
"OwlPS Listener can be built only for Linux systems")
endif()
# OwlPS Positioner can be built only with GCC, and with a minimal
# version. CMAKE_CXX_COMPILER_VERSION is not guaranteed to be set,
# so we will test GCC's version number only if possible.
set(POSITIONER_MIN_GCC_VERSION 4.7)
if (CMAKE_COMPILER_IS_GNUCXX)
# Test the compiler version if we can
if (${CMAKE_CXX_COMPILER_VERSION})
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_EQUAL ${POSITIONER_MIN_GCC_VERSION} OR
${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER ${POSITIONER_MIN_GCC_VERSION})
add_subdirectory(owlps-positioner)
else() # GCC's version is too low
message(WARNING
"OwlPS Positioner requires GCC >= ${POSITIONER_MIN_GCC_VERSION}")
endif()
else() # we couldn't get GCC's version, let's try to build anyway
add_subdirectory(owlps-positioner)
endif()
else() # we're not using GCC
message(WARNING
"OwlPS Positioner requires GCC (>= ${POSITIONER_MIN_GCC_VERSION})")
endif()
2013-05-18 19:39:36 +02:00
add_subdirectory(owlps-udp-to-http)