Commit fe79cd50 authored by Johan Ström's avatar Johan Ström

Properly search for librrd, libprocps, libcurl, libaugeas

general cmake cleanup
parent b1dd53a2
......@@ -96,30 +96,64 @@ include_directories("${PROJECT_SOURCE_DIR}/shared")
# We have an amalgamated version of jsoncpp, ensure we can include <json/json.h>
include_directories("${PROJECT_SOURCE_DIR}/shared/jsoncpp")
# fix augeas bug
include_directories("${LOCALDIR}/include/libxml2")
macro(log_pkg_found PKG_NAME PKG_FOUND PKG_VERSION NOTFOUND_LEVEL NOTFOUND_EXTRA)
if("${PKG_FOUND}" AND "${PKG_VERSION}" STREQUAL "")
message(STATUS "${PKG_NAME} found")
elseif(${PKG_FOUND})
message(STATUS "${PKG_NAME} version: ${PKG_VERSION}")
else()
message(${NOTFOUND_LEVEL} "${PKG_NAME} not found${NOTFOUND_EXTRA}")
endif()
endmacro()
find_package(CppDb REQUIRED)
if (CPPDB_FOUND)
include_directories(${CPPDB_INCLUDE_DIRS})
else()
IF (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
# TEMP: Disable this requirement on OS X, not in brew.
message(FATAL_ERROR "Could not find cppdb")
endif ()
endif (CPPDB_FOUND)
find_package(Threads REQUIRED)
find_package(Boost COMPONENTS system filesystem thread program_options date_time regex chrono REQUIRED)
find_package(Boost COMPONENTS log)
IF (Boost_LOG_FOUND)
ADD_DEFINITIONS(-DHAVE_BOOST_LOG)
ELSE()
find_package(Boost COMPONENTS REQUIRED date_time)
ENDIF()
# FreeBSD user might only have 0.3 installed.
pkg_search_module(YAML_CPP REQUIRED yaml-cpp yaml-cpp03)
message(STATUS "yaml-cpp version: ${YAML_CPP_VERSION}")
log_pkg_found(yamlcpp "${YAML_CPP_FOUND}" "${YAML_CPP_VERSION}" FATAL_ERROR "")
# Linux/debian has lua5.x, FreeBSD has lua-5.x
pkg_search_module(LUA REQUIRED lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua)
message(STATUS "lua version: ${LUA_VERSION}")
pkg_search_module(AUGEAS REQUIRED augeas)
log_pkg_found(augeas "${AUGEAS_FOUND}" "${AUGEAS_VERSION}" FATAL_ERROR "")
find_package(Threads REQUIRED)
find_package(Boost COMPONENTS system filesystem thread program_options date_time regex chrono REQUIRED)
# Linux/debian has lua5.x, FreeBSD has lua-5.x, fedora has just lua
pkg_search_module(LUA lua5.3 lua-5.3 lua5.2 lua-5.2 lua5.1 lua-5.1 lua)
log_pkg_found(lua "${LUA_FOUND}" "${LUA_VERSION}" WARNING ", parts of core will not be built")
find_package(CppDb)
log_pkg_found(cppdb "${CPPDB_FOUND}" "" WARNING ", parts of core will not be built")
pkg_search_module(LIBRRD librrd)
log_pkg_found(librrd "${LIBRRD_FOUND}" "${LIBRRD_VERSION}" WARNING ", parts of core will not be built")
if(NOT FREEBSD)
# used by agosystem
pkg_search_module(LIBPROCPS REQUIRED libprocps)
log_pkg_found(libprocps "${LIBPROCPS_FOUND}" "${LIBPROCPS_VERSION}" WARNING "")
find_package(LinuxI2C)
endif()
pkg_search_module(LIBCURL libcurl)
log_pkg_found(libcurl "${LIBCURL_FOUND}" "${LIBCURL_VERSION}" STATUS "")
find_package(OpenCV)
log_pkg_found(OpenCV "${OpenCV_FOUND}" "${OpenCV_VERSION}" STATUS "")
find_package(OpenZWave)
log_pkg_found(OpenZWave "${OpenZWave_FOUND}" "${OpenZWave_VERSION}" STATUS "")
find_package(EibClient)
log_pkg_found(EibClient "${EibClient_FOUND}" "${EibClient_VERSION}" STATUS "")
pkg_check_modules(OpenLighting libola)
log_pkg_found(OpenLighting "${OpenLighting_FOUND}" "${OpenLighting_VERSION}" STATUS "")
include_directories(${Boost_INCLUDE_DIRS})
......@@ -135,21 +169,8 @@ IF(Boost_VERSION VERSION_LESS 105600)
)
ENDIF()
FIND_PACKAGE(Boost COMPONENTS log)
IF (Boost_LOG_FOUND)
ADD_DEFINITIONS(-DHAVE_BOOST_LOG)
ELSE()
FIND_PACKAGE(Boost COMPONENTS REQUIRED date_time)
ENDIF()
FIND_PACKAGE(CppUnit)
IF (CPPUNIT_FOUND)
message(STATUS "CppUnit found, building unit-tests by default")
set(BUILD_TESTS_DEFAULT ON)
ELSE()
message(STATUS "CppUnit not found, NOT building unit-tests by default")
set(BUILD_TESTS_DEFAULT OFF)
ENDIF()
find_package(CppUnit)
log_pkg_found(CppUnit "${CPPUNIT_FOUND}" "${CPPUNIT_VERSION}" STATUS "not building unit-tests")
check_include_files("xlocale.h" HAVE_XLOCALE_H)
......@@ -175,8 +196,8 @@ if (BUILD_SHARED)
add_subdirectory (shared)
endif()
OPTION(BUILD_TESTS "Build the unittests" ${BUILD_TESTS_DEFAULT})
if (BUILD_TESTS)
OPTION(BUILD_TESTS "Build the unittests" ON)
if (BUILD_TESTS AND CPPUNIT_FOUND)
# These are only for Shared right now, so add them right after.
enable_testing()
add_subdirectory (unittest)
......
......@@ -54,12 +54,12 @@ if (BUILD_CORE_event)
endif()
OPTION(BUILD_CORE_datalogger "Build agodatalogger" ON)
if (BUILD_CORE_datalogger)
if (BUILD_CORE_datalogger AND LIBRRD_FOUND AND CPPDB_FOUND)
add_subdirectory (datalogger)
endif()
OPTION(BUILD_CORE_lua "Build agolua" ON)
if (BUILD_CORE_lua)
if (BUILD_CORE_lua AND LUA_FOUND)
add_subdirectory (lua)
endif()
......
......@@ -5,10 +5,12 @@ set (DATALOGGER_LIBRARIES
agoclient
sqlite3
${Boost_PROGRAM_DATE_TIME_LIBRARY}
rrd
cppdb
${LIBRRD_LIBRARIES}
${CPPDB_LIBRARIES}
)
include_directories(${CPPDB_INCLUDE_DIRS})
# add the executable
add_executable (agodatalogger ${AGODATALOGGER_SOURCE_FILES})
target_link_libraries (agodatalogger ${DATALOGGER_LIBRARIES})
......
cmake_minimum_required (VERSION 3.0)
set (SYSTEM_LIBRARIES
agoclient
${Boost_PROGRAM_DATE_TIME_LIBRARY}
)
set (AGOSYSTEM_SOURCE_FILES agosystem.cpp)
IF (FREEBSD)
list(APPEND AGOSYSTEM_SOURCE_FILES processinfo_freebsd.cpp)
list(APPEND SYSTEM_LIBRARIES kvm)
ELSE()
list(APPEND AGOSYSTEM_SOURCE_FILES processinfo_linux.cpp)
list(APPEND SYSTEM_LIBRARIES ${LIBPROCPS_LIBRARIES})
INCLUDE (CheckLibraryExists)
CHECK_LIBRARY_EXISTS(procps freeproc "" FREEPROC_EXISTS)
IF (FREEPROC_EXISTS)
ADD_DEFINITIONS(-DFREEPROC_EXISTS)
ENDIF (FREEPROC_EXISTS)
ENDIF()
set (SYSTEM_LIBRARIES
agoclient
${Boost_PROGRAM_DATE_TIME_LIBRARY}
)
IF (FREEBSD)
list(APPEND SYSTEM_LIBRARIES kvm)
ELSE()
list(APPEND SYSTEM_LIBRARIES procps)
ENDIF()
# add the executable
......
......@@ -54,36 +54,34 @@ set (AGODEVICES
agoping
)
find_package(OpenCV)
IF (NOT OpenCV_FOUND)
list(REMOVE_ITEM AGODEVICES NVR)
MESSAGE(STATUS "OpenCV not found, NOT building NVR device")
MESSAGE(STATUS "OpenCV not found, not building NVR device")
ENDIF (NOT OpenCV_FOUND)
find_package(OpenZWave)
IF (NOT OpenZWave_FOUND)
list(REMOVE_ITEM AGODEVICES zwave)
MESSAGE(STATUS "OpenZWave not found, NOT building zwave device")
list(REMOVE_ITEM AGODEVICES zwave)
MESSAGE(STATUS "OpenZWave not found, not building zwave device")
ENDIF ()
find_package(EibClient)
IF (NOT EibClient_FOUND)
list(REMOVE_ITEM AGODEVICES knx)
MESSAGE(STATUS "eibclient not found, NOT building knx device")
list(REMOVE_ITEM AGODEVICES knx)
MESSAGE(STATUS "eibclient not found, not building knx device")
ENDIF ()
pkg_check_modules(OpenLighting libola)
IF (NOT OpenLighting_FOUND)
list(REMOVE_ITEM AGODEVICES agodmx)
MESSAGE(STATUS "OpenLighting (ola) not found, NOT building agodmx device")
list(REMOVE_ITEM AGODEVICES agodmx)
MESSAGE(STATUS "OpenLighting (ola) not found, not building agodmx device")
ENDIF ()
if(NOT FREEBSD)
find_package(LinuxI2C)
endif()
if(NOT HAVE_I2C_SMBUS)
list(REMOVE_ITEM AGODEVICES i2c blinkm)
MESSAGE(STATUS "Linux i2c smbus not found, not building i2c & blinkm devices")
endif()
if(NOT LIBCURL_FOUND)
list(REMOVE_ITEM AGODEVICES zmcam webcam)
MESSAGE(STATUS "libcurl not found, not building zmcam & webcam devices")
endif()
IF (FREEBSD)
......
......@@ -3,8 +3,8 @@ cmake_minimum_required (VERSION 3.0)
file (GLOB_RECURSE DEVICE_SOURCE_FILES *.cpp)
set (DEVICE_EXTRA_LIBRARIES
curl
agoclient
${LIBCURL_LIBRARIES}
agoclient
)
set (DEVICE "agowebcam")
......
......@@ -4,8 +4,8 @@ file (GLOB_RECURSE DEVICE_SOURCE_FILES *.cpp
../webcam/base64.cpp)
set (DEVICE_EXTRA_LIBRARIES
curl
agoclient
${LIBCURL_LIBRARIES}
agoclient
)
set (DEVICE "agozmcam")
......
......@@ -26,7 +26,7 @@ set (AGOCLIENT_LIBRARIES
qpidmessaging
qpidtypes
uuid
augeas
${AUGEAS_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_THREAD_LIBRARY}
......@@ -42,6 +42,8 @@ ENDIF()
target_link_libraries (agoclient ${AGOCLIENT_LIBRARIES})
include_directories("${AUGEAS_INCLUDE_DIRS}")
set_property(
TARGET agoclient
PROPERTY COMPILE_DEFINITIONS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment