Commit 76c3947b authored by Johan Ström's avatar Johan Ström

cmake os specific cleanup

parent ce3163de
......@@ -15,52 +15,53 @@ include(cmake/AgoFileHelpers.cmake)
find_package(PythonNaive)
set (INSTALL_PREFIX /usr)
# FreeBSD have some differences in building, mainly
# that non-base libs/includes are located in /usr/local.
IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set (FREEBSD YES)
set (LOCALDIR /usr/local)
include_directories("${LOCALDIR}/include")
LINK_DIRECTORIES(${LOCALDIR}/lib)
ELSE (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set (LOCALDIR /usr)
ENDIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
# See README.OSX
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set (OS_FREEBSD YES)
set (INSTALL_PREFIX /usr/local)
include_directories("${INSTALL_PREFIX}/include")
link_directories(${INSTALL_PREFIX}/lib)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
set (OS_LINUX YES)
set (INSTALL_PREFIX /usr)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
# See README.OSX. Does not actually build.
set (OS_DARWIN YES)
include_directories("./local-include")
ENDIF ()
else()
message(STATUS "Unknown OS ${CMAKE_SYSTEM_NAME}, expect issues!")
endif()
# some configurable values
IF (FREEBSD)
set (BASEDIR ${LOCALDIR}/agocontrol CACHE STRING "Directory to store agocontrol installation")
set (BINDIR ${BASEDIR}/bin CACHE STRING "Directory to store Binaries")
set (ETCDIR ${LOCALDIR}/etc CACHE STRING "Directory for system-wide settings")
set (LIBDIR /usr/lib CACHE STRING "Directory for libraries")
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")
set (INCDIR ${LOCALDIR}/include/agocontrol CACHE STRING "Directory for include files")
# XXX: Not sure what "variable" data is, but only .sql files are installed currently,
# and those should be stored in share.
set (DATADIR ${LOCALDIR}/share/agocontrol CACHE STRING "Directory for variable data")
set (LOCALSTATEDIR ${LOCALDIR}/var/agocontrol CACHE STRING "Directory for state info")
set (HTMLDIR ${BASEDIR}/html CACHE STRING "Directory for rpc HTML files")
set (AUGEASLENSEDIR ${LOCALDIR}/share/augeas/lenses CACHE STRING "Directory for augeas lenses")
ELSE (FREEBSD)
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()
set (BASEDIR /opt/agocontrol CACHE STRING "Directory to store agocontrol installation")
set (BINDIR ${BASEDIR}/bin CACHE STRING "Directory to store Binaries")
set (ETCDIR /etc CACHE STRING "Directory for system-wide settings")
set (LIBDIR /usr/lib CACHE STRING "Directory for libraries")
set (CONFDIR ${ETCDIR}/opt/agocontrol CACHE STRING "Directory for agocontrol settings")
set (INCDIR /usr/include/agocontrol CACHE STRING "Directory for include files")
set (DATADIR /var/opt/agocontrol CACHE STRING "Directory for variable data")
set (LOCALSTATEDIR /var/opt/agocontrol CACHE STRING "Directory for state info")
set (HTMLDIR ${BASEDIR}/html CACHE STRING "Directory for rpc HTML files")
set (AUGEASLENSEDIR /usr/share/augeas/lenses CACHE STRING "Directory for augeas lenses")
set (CMAKE_EXE_LINKER_FLAGS "-Wl,-z,now")
ENDIF (FREEBSD)
ENDIF (OS_FREEBSD)
# Common structure
set (BINDIR ${BASEDIR}/bin CACHE STRING "Directory to store Binaries")
set (LIBDIR ${INSTALL_PREFIX}/lib CACHE STRING "Directory for libraries")
set (INCDIR ${INSTALL_PREFIX}/include/agocontrol CACHE STRING "Directory for include files")
set (HTMLDIR ${BASEDIR}/html CACHE STRING "Directory for rpc HTML files")
set (AUGEASLENSEDIR ${INSTALL_PREFIX}/share/augeas/lenses CACHE STRING "Directory for augeas lenses")
set (PYTHON2DIST ${LOCALDIR}/${Python2_SITELIB} CACHE STRING "Directory for Python 2.7 packages")
set (PYTHON3DIST ${LOCALDIR}/${Python3_SITELIB} CACHE STRING "Directory for Python 3 packages")
set (PYTHON2DIST ${INSTALL_PREFIX}/${Python2_SITELIB} CACHE STRING "Directory for Python 2.7 packages")
set (PYTHON3DIST ${INSTALL_PREFIX}/${Python3_SITELIB} CACHE STRING "Directory for Python 3 packages")
# Enable C++11
if (CMAKE_VERSION VERSION_LESS "3.1")
......@@ -132,7 +133,7 @@ log_pkg_found(cppdb "${CPPDB_FOUND}" "" WARNING ", parts of core will not be bui
pkg_search_module(LIBRRD librrd)
log_pkg_found(librrd "${LIBRRD_FOUND}" "${LIBRRD_VERSION}" WARNING ", parts of core will not be built")
if(NOT FREEBSD)
if(OS_LINUX)
# used by agosystem
pkg_search_module(LIBPROCPS REQUIRED libprocps)
log_pkg_found(libprocps "${LIBPROCPS_FOUND}" "${LIBPROCPS_VERSION}" WARNING "")
......
IF (DEFINED my_device_service)
string(REGEX REPLACE "\.in$" "" ${my_device_service_out} ${my_device_service})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${my_device_service}"
"${CMAKE_CURRENT_BINARY_DIR}/${my_device_service_out}"
@ONLY
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${my_device_service_out} DESTINATION /lib/systemd/system)
set(my_device_service)
set(my_device_service_out)
ENDIF (DEFINED my_device_service)
IF (DEFINED my_device_config)
string(REGEX REPLACE "\.in$" "" ${my_device_config_out} ${my_device_config})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${my_device_config}"
"${CMAKE_CURRENT_BINARY_DIR}/${my_device_config_out}"
@ONLY
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${my_device_config_out} DESTINATION ${CONFDIR}/conf.d)
set(my_device_config)
set(my_device_config_out)
ENDIF (DEFINED my_device_config)
IF (DEFINED my_device_schema)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${my_device_schema} DESTINATION ${CONFDIR}/schema.d)
set(my_device_schema)
ENDIF (DEFINED my_device_schema)
......@@ -20,7 +20,10 @@ add_subdirectory (conf.d)
add_subdirectory (schema.d)
add_subdirectory (sysvinit)
install (FILES security-limits.conf DESTINATION ${ETCDIR}/security/limits.d RENAME agocontrol.conf)
install (FILES sysctl.conf DESTINATION ${ETCDIR}/sysctl.d RENAME agocontrol.conf)
if(OS_LINUX)
install (FILES security-limits.conf DESTINATION ${ETCDIR}/security/limits.d RENAME agocontrol.conf)
install (FILES sysctl.conf DESTINATION ${ETCDIR}/sysctl.d RENAME agocontrol.conf)
endif()
install (FILES rpc_cert.pem DESTINATION ${CONFDIR}/rpc)
install (FILES agocontrol.aug DESTINATION ${AUGEASLENSEDIR})
......@@ -14,11 +14,6 @@ set (RPCPASSWD_LIBRARIES
agohttp
)
IF (NOT FREEBSD)
list(APPEND RPC_LIBRARIES dl )
list(APPEND RPCPASSWD_LIBRARIES dl )
ENDIF (NOT FREEBSD)
# add the executable
add_executable (agorpc agorpc.cpp)
target_link_libraries (agorpc ${RPC_LIBRARIES})
......
......@@ -6,7 +6,7 @@ set (SYSTEM_LIBRARIES
)
set (AGOSYSTEM_SOURCE_FILES agosystem.cpp)
IF (FREEBSD)
IF (OS_FREEBSD)
list(APPEND AGOSYSTEM_SOURCE_FILES processinfo_freebsd.cpp)
list(APPEND SYSTEM_LIBRARIES kvm)
ELSE()
......
......@@ -84,7 +84,7 @@ if(NOT LIBCURL_FOUND)
MESSAGE(STATUS "libcurl not found, not building zmcam & webcam devices")
endif()
IF (FREEBSD)
IF (OS_FREEBSD)
# These does not build on FreeBSD currently
list(REMOVE_ITEM AGODEVICES
firmata # S_IRUSR
......@@ -92,7 +92,7 @@ IF (FREEBSD)
MySensors # TCIFLUSH / TCIOFLUSH
zmcam # error: member access into incomplete type 'struct sockaddr_in'
)
ENDIF (FREEBSD)
ENDIF (OS_FREEBSD)
AgoPythonProgram(simulator DESCRIPTION "ago control Device simulator")
......
#add a minimum required version
cmake_minimum_required (VERSION 3.0)
# only set these variables if you actually have the files
# set (my_device_schema "example.yaml")
# set (my_device_service "example.service.in")
# set (my_device_config "example.conf.in")
# include this after you set your device variables to
# automatically configure the files and install into
# their proper directories
include(${CMAKE_SOURCE_DIR}/cmake/CMake_Device_Common.cmake)
# select your source files
file (GLOB_RECURSE DEVICE_SOURCE_FILES *.cpp)
......@@ -32,3 +21,6 @@ target_link_libraries (${DEVICE} ${DEVICE_EXTRA_LIBRARIES})
# create an install target for the device
install (TARGETS ${DEVICE} RUNTIME DESTINATION ${BINDIR})
# Use our AgoService function to create init files
AgoService(${DEVICE} DESCRIPTION "agocontrol example device")
cmake_minimum_required (VERSION 3.0)
# only set these variables if you actually have the files
# set (my_device_schema "example.yaml")
# set (my_device_service "example.service.in")
# set (my_device_config "example.conf.in")
# include this after you set your device variables to
# automatically configure the files and install into
# their proper directories
#include(${CMAKE_SOURCE_DIR}/cmake/CMake_Device_Common.cmake)
# select your source files
file (GLOB_RECURSE DEVICE_SOURCE_FILES
agoyamaha.cpp
......
......@@ -7,13 +7,13 @@ set (DEVICE_EXTRA_LIBRARIES
agoclient
)
IF (FREEBSD)
IF (OS_FREEBSD)
list(APPEND DEVICE_EXTRA_LIBRARIES usb)
IF(NOT EXISTS "/usr/include/iconv.h")
# Pre 10.0 FreeBSD without globla iconv
list(APPEND DEVICE_EXTRA_LIBRARIES iconv)
ENDIF ()
ENDIF (FREEBSD)
ENDIF (OS_FREEBSD)
# Use BEFORE to allow local installation of Zwave to take priority
# over global installation.
......
cmake_minimum_required (VERSION 3.0)
IF(COMMAND cmake_policy)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0009 NEW)
ENDIF(COMMAND cmake_policy)
endif()
set (IMPERIHOME_LIBRARIES
agoclient
agohttp
)
IF (NOT FREEBSD)
list(APPEND IMPERIHOME_LIBRARIES dl )
ENDIF (NOT FREEBSD)
# add the executable
add_executable (agoImperiHome agoImperiHome.cpp)
target_link_libraries (agoImperiHome ${IMPERIHOME_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