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

more cmake cleanup

parent 76c3947b
......@@ -36,7 +36,7 @@ else()
endif()
# some configurable values
IF (OS_FREEBSD)
if (OS_FREEBSD)
set (BASEDIR ${INSTALL_PREFIX}/agocontrol CACHE STRING "Directory to store agocontrol installation")
set (ETCDIR ${INSTALL_PREFIX}/etc CACHE STRING "Directory for system-wide settings")
set (CONFDIR ${ETCDIR}/agocontrol CACHE STRING "Directory for agocontrol settings")
......@@ -44,14 +44,14 @@ IF (OS_FREEBSD)
# and those should be stored in share.
set (DATADIR ${INSTALL_PREFIX}/share/agocontrol CACHE STRING "Directory for variable data")
set (LOCALSTATEDIR ${INSTALL_PREFIX}/var/agocontrol CACHE STRING "Directory for state info")
ELSE()
else()
set (BASEDIR /opt/agocontrol CACHE STRING "Directory to store agocontrol installation")
set (ETCDIR /etc CACHE STRING "Directory for system-wide settings")
set (CONFDIR ${ETCDIR}/opt/agocontrol CACHE STRING "Directory for agocontrol settings")
set (DATADIR /var/opt/agocontrol CACHE STRING "Directory for variable data")
set (LOCALSTATEDIR /var/opt/agocontrol CACHE STRING "Directory for state info")
set (CMAKE_EXE_LINKER_FLAGS "-Wl,-z,now")
ENDIF (OS_FREEBSD)
endif()
# Common structure
set (BINDIR ${BASEDIR}/bin CACHE STRING "Directory to store Binaries")
......@@ -111,11 +111,11 @@ endmacro()
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)
if(Boost_LOG_FOUND)
ADD_DEFINITIONS(-DHAVE_BOOST_LOG)
ELSE()
else()
find_package(Boost COMPONENTS REQUIRED date_time)
ENDIF()
endif()
pkg_search_module(YAML_CPP REQUIRED yaml-cpp yaml-cpp03)
log_pkg_found(yamlcpp "${YAML_CPP_FOUND}" "${YAML_CPP_VERSION}" FATAL_ERROR "")
......@@ -161,14 +161,14 @@ include_directories(${Boost_INCLUDE_DIRS})
# Fix for Boost < 1.56 built without C++, when we build with C++11
# https://stackoverflow.com/questions/35007134/c-boost-undefined-reference-to-boostfilesystemdetailcopy-file
# https://chaste.cs.ox.ac.uk/trac/wiki/ChasteGuides/ModernCpp#Boostscopedenumsforboost1.56
IF(Boost_VERSION VERSION_LESS 105600)
if(Boost_VERSION VERSION_LESS 105600)
message(STATUS "Boost version < 1.56, building with BOOST_NO_CXX11_SCOPED_ENUMS")
set_property( DIRECTORY
APPEND PROPERTY
COMPILE_OPTIONS
-DBOOST_NO_CXX11_SCOPED_ENUMS
)
ENDIF()
endif()
find_package(CppUnit)
log_pkg_found(CppUnit "${CPPUNIT_FOUND}" "${CPPUNIT_VERSION}" STATUS "not building unit-tests")
......@@ -192,40 +192,40 @@ endif()
install(DIRECTORY DESTINATION ${BINDIR})
# add sub directories
OPTION(BUILD_SHARED "Build the agoclient shared library" ON)
option(BUILD_SHARED "Build the agoclient shared library" ON)
if (BUILD_SHARED)
add_subdirectory (shared)
endif()
OPTION(BUILD_TESTS "Build the unittests" ON)
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)
endif()
OPTION(BUILD_CORE "Build the CORE" ON)
option(BUILD_CORE "Build the CORE" ON)
if (BUILD_CORE)
add_subdirectory (core)
install (FILES data/inventory.sql data/datalogger.sql DESTINATION ${DATADIR})
endif()
OPTION(BUILD_GATEWAYS "Build the gateways" ON)
option(BUILD_GATEWAYS "Build the gateways" ON)
if (BUILD_GATEWAYS)
add_subdirectory (gateways)
endif()
OPTION(BUILD_DEVICES "Build the devices" ON)
option(BUILD_DEVICES "Build the devices" ON)
if (BUILD_DEVICES)
add_subdirectory (devices)
endif()
OPTION(BUILD_CONF "Build the configs" ON)
option(BUILD_CONF "Build the configs" ON)
if (BUILD_CONF)
add_subdirectory (conf)
endif()
OPTION(BUILD_SCRIPTS "Build the scripts" ON)
option(BUILD_SCRIPTS "Build the scripts" ON)
if (BUILD_SCRIPTS)
add_subdirectory (scripts)
endif()
......
......@@ -15,12 +15,12 @@ FIND_LIBRARY(CPPDB_LIBRARIES cppdb
/usr/local/lib
/usr/lib)
IF(CPPDB_INCLUDE_DIRS)
if(CPPDB_INCLUDE_DIRS)
IF(CPPDB_LIBRARIES)
SET(CPPDB_FOUND "YES")
SET(CPPDB_LIBRARIES ${CPPDB_LIBRARIES} ${CMAKE_DL_LIBS})
ENDIF(CPPDB_LIBRARIES)
ENDIF(CPPDB_INCLUDE_DIRS)
endif()
endif()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPDB DEFAULT_MSG CPPDB_LIBRARIES CPPDB_INCLUDE_DIRS)
......
......@@ -17,12 +17,12 @@ FIND_LIBRARY(CPPUNIT_LIBRARIES cppunit
/usr/local/lib
/usr/lib)
IF(CPPUNIT_INCLUDE_DIRS)
if(CPPUNIT_INCLUDE_DIRS)
IF(CPPUNIT_LIBRARIES)
SET(CPPUNIT_FOUND "YES")
SET(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARIES} ${CMAKE_DL_LIBS})
ENDIF(CPPUNIT_LIBRARIES)
ENDIF(CPPUNIT_INCLUDE_DIRS)
endif()
endif()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS)
......@@ -16,12 +16,12 @@ FIND_LIBRARY(EibClient_LIBRARIES eibclient
/usr/local/lib64
/usr/lib)
IF(EibClient_INCLUDE_DIRS)
if(EibClient_INCLUDE_DIRS)
IF(EibClient_LIBRARIES)
SET(EibClient_FOUND "YES")
SET(EibClient_LIBRARIES ${EibClient_LIBRARIES} ${CMAKE_DL_LIBS})
ENDIF(EibClient_LIBRARIES)
ENDIF(EibClient_INCLUDE_DIRS)
endif()
endif()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EibClient DEFAULT_MSG EibClient_LIBRARIES EibClient_INCLUDE_DIRS)
......
......@@ -16,7 +16,7 @@ FIND_LIBRARY(OpenZWave_LIBRARIES openzwave
/usr/local/lib64
/usr/lib)
IF(OpenZWave_INCLUDE_BASE_DIR)
if(OpenZWave_INCLUDE_BASE_DIR)
IF(OpenZWave_LIBRARIES)
set(OpenZWave_FOUND "YES")
set(OpenZWave_LIBRARIES ${OpenZWave_LIBRARIES})
......@@ -77,11 +77,11 @@ int main(void){
set(OpenZWave_VERSION_MAJOR "${OpenZWave_VERSION_MAJOR}" CACHE INTERNAL "OpenZWave major version")
set(OpenZWave_VERSION_MINOR "${OpenZWave_VERSION_MINOR}" CACHE INTERNAL "OpenZWave minor version")
set(OpenZWave_VERSION_REVISION "${OpenZWave_VERSION_REVISION}" CACHE INTERNAL "OpenZWave GIT revision")
ENDIF()
endif()
message(STATUS "Found OpenZWave version: ${OpenZWave_VERSION}")
ENDIF(OpenZWave_LIBRARIES)
ENDIF(OpenZWave_INCLUDE_BASE_DIR)
endif()
endif()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENZWAVE DEFAULT_MSG OpenZWave_LIBRARIES OpenZWave_INCLUDE_DIRS)
cmake_minimum_required (VERSION 3.0)
IF(COMMAND cmake_policy)
if(COMMAND cmake_policy)
# FILE GLOB_RECURSE calls should not follow symlinks by default.
cmake_policy(SET CMP0009 NEW)
ENDIF(COMMAND cmake_policy)
endif()
set (RPC_LIBRARIES
agoclient
......
......@@ -6,10 +6,10 @@ set (SYSTEM_LIBRARIES
)
set (AGOSYSTEM_SOURCE_FILES agosystem.cpp)
IF (OS_FREEBSD)
if(OS_FREEBSD)
list(APPEND AGOSYSTEM_SOURCE_FILES processinfo_freebsd.cpp)
list(APPEND SYSTEM_LIBRARIES kvm)
ELSE()
else()
list(APPEND AGOSYSTEM_SOURCE_FILES processinfo_linux.cpp)
list(APPEND SYSTEM_LIBRARIES ${LIBPROCPS_LIBRARIES})
......@@ -18,7 +18,7 @@ ELSE()
IF (FREEPROC_EXISTS)
ADD_DEFINITIONS(-DFREEPROC_EXISTS)
ENDIF (FREEPROC_EXISTS)
ENDIF()
endif()
# add the executable
add_executable (agosystem ${AGOSYSTEM_SOURCE_FILES})
......
......@@ -54,37 +54,37 @@ set (AGODEVICES
agoping
)
IF (NOT OpenCV_FOUND)
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)
IF (NOT OpenZWave_FOUND)
if(NOT OpenZWave_FOUND)
list(REMOVE_ITEM AGODEVICES zwave)
MESSAGE(STATUS "OpenZWave not found, not building zwave device")
message(STATUS "OpenZWave not found, not building zwave device")
ENDIF ()
IF (NOT EibClient_FOUND)
if(NOT EibClient_FOUND)
list(REMOVE_ITEM AGODEVICES knx)
MESSAGE(STATUS "eibclient not found, not building knx device")
message(STATUS "eibclient not found, not building knx device")
ENDIF ()
IF (NOT OpenLighting_FOUND)
if(NOT OpenLighting_FOUND)
list(REMOVE_ITEM AGODEVICES agodmx)
MESSAGE(STATUS "OpenLighting (ola) not found, not building agodmx device")
message(STATUS "OpenLighting (ola) not found, not building agodmx device")
ENDIF ()
if(NOT HAVE_I2C_SMBUS)
list(REMOVE_ITEM AGODEVICES i2c blinkm)
MESSAGE(STATUS "Linux i2c smbus not found, not building i2c & blinkm devices")
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")
message(STATUS "libcurl not found, not building zmcam & webcam devices")
endif()
IF (OS_FREEBSD)
if(OS_FREEBSD)
# These does not build on FreeBSD currently
list(REMOVE_ITEM AGODEVICES
firmata # S_IRUSR
......@@ -98,7 +98,7 @@ AgoPythonProgram(simulator DESCRIPTION "ago control Device simulator")
foreach (device ${AGODEVICES})
# options what to build
OPTION(BUILD_DEVICE_${device} "Build the device ${device}" ON)
option(BUILD_DEVICE_${device} "Build the device ${device}" ON)
if (BUILD_DEVICE_${device})
add_subdirectory(${device})
endif()
......
......@@ -7,7 +7,7 @@ set (DEVICE_EXTRA_LIBRARIES
agoclient
)
IF (OS_FREEBSD)
if(OS_FREEBSD)
list(APPEND DEVICE_EXTRA_LIBRARIES usb)
IF(NOT EXISTS "/usr/include/iconv.h")
# Pre 10.0 FreeBSD without globla iconv
......
......@@ -13,7 +13,7 @@ set(LIBAGOCLIENT_SOURCE_FILES
base64.cpp
)
IF (Boost_LOG_FOUND)
if(Boost_LOG_FOUND)
list(APPEND LIBAGOCLIENT_SOURCE_FILES agolog_boost.cpp)
else()
list(APPEND LIBAGOCLIENT_SOURCE_FILES agolog_basic.cpp)
......@@ -34,11 +34,11 @@ set (AGOCLIENT_LIBRARIES
${Boost_PROGRAM_OPTIONS_LIBRARY}
)
IF (Boost_LOG_FOUND)
if(Boost_LOG_FOUND)
LIST(APPEND AGOCLIENT_LIBRARIES ${Boost_LOG_LIBRARY})
ELSE()
else()
LIST(APPEND AGOCLIENT_LIBRARIES ${Boost_DATE_TIME_LIBRARY})
ENDIF()
endif()
target_link_libraries (agoclient ${AGOCLIENT_LIBRARIES})
......
......@@ -21,7 +21,7 @@ set (AGOHTTP_LIBRARIES
#IF (Boost_LOG_FOUND)
# LIST(APPEND AGOHTTP_LIBRARIES ${Boost_LOG_LIBRARY})
#ENDIF()
#endif()
target_link_libraries (agohttp ${AGOHTTP_LIBRARIES})
......
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