diff --git a/CMakeLists.txt b/CMakeLists.txt index bb9a97b4..b885098c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,29 @@ cmake_minimum_required (VERSION 2.8.11) project (upm) +# Before going any further, define build options +option (BUILDDOC "Build all doc" OFF) +option (BUILDCPP "Build CPP sensor libraries" ON) +option (BUILDFTI "Build Funtion Table Interface (FTI) in C sensor libraries" OFF) +option (BUILDSWIGPYTHON "Build swig python modules" ON) +option (BUILDSWIGNODE "Build swig node modules" ON) +option (BUILDSWIGJAVA "Build swig java modules" OFF) +option (BUILDPYTHON3 "Use python3 for building/installing/testing" OFF) +option (BUILDEXAMPLES "Build C/C++ example binaries" OFF) +option (BUILDJAVAEXAMPLES "Build java example jars" OFF) +option (IPK "Generate IPK using CPack" OFF) +option (RPM "Generate RPM using CPack" OFF) +option (BUILDTESTS "Generate check-ups for upm" ON) +option (ENABLECXX11 "Enable C++11 standards support" ON) + +# Warn if building in source root if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") message (WARNING "Building into sources dir can be risky, prefer other directory") endif () +# Appends the cmake/modules path to MAKE_MODULE_PATH variable. +set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) + find_package (Threads REQUIRED) find_package (PkgConfig REQUIRED) @@ -12,10 +31,24 @@ find_package (PkgConfig REQUIRED) unset(MRAA_FOUND CACHE) set(MRAA_MINIMUM 1.1.1) pkg_check_modules (MRAA REQUIRED mraa>=${MRAA_MINIMUM}) -message (STATUS "found mraa version: ${MRAA_VERSION}") -# Appends the cmake/modules path to MAKE_MODULE_PATH variable. -set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) +# Check for BACNET +pkg_check_modules (BACNET libbacnet) + +# Check for MODBUS +pkg_check_modules (MODBUS libmodbus>=3.1.2) + +# Check for OPENZWAVE +pkg_check_modules (OPENZWAVE libopenzwave) + +# Find JPEG +find_package (JPEG) + +# Find swig if any wrapper is enabled +if (BUILDSWIGPYTHON OR BUILDSWIGNODE OR BUILDSWIGJAVA) + find_package (SWIG 3.0.5 REQUIRED) + include (${SWIG_USE_FILE}) +endif () # Set CMAKE_INSTALL_LIBDIR if not defined include(GNUInstallDirs) @@ -25,7 +58,7 @@ set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for include (GetGitRevisionDescription) git_describe (VERSION "--tags") if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND") - message (WARNING " - Install git to compile a production UPM!") + message (WARNING "Install git to compile a production UPM!") set (VERSION "v0.8.0-dirty") endif () @@ -47,34 +80,6 @@ set (upm_VERSION_MINOR ${VERSION_MINOR}) set (upm_VERSION_PATCH ${VERSION_PATCH}) set (upm_VERSION_STRING ${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}) -set (CMAKE_SWIG_FLAGS "") - -option (BUILDDOC "Build all doc" OFF) -option (BUILDCPP "Build CPP sensor libraries" ON) -option (BUILDFTI "Build Funtion Table Interface (FTI) in C sensor libraries" OFF) -option (BUILDSWIGPYTHON "Build swig python modules" ON) -option (BUILDSWIGNODE "Build swig node modules" ON) -option (BUILDSWIGJAVA "Build swig java modules" OFF) -option (BUILDPYTHON3 "Use python3 for building/installing/testing" OFF) -option (BUILDEXAMPLES "Build C/C++ example binaries" OFF) -option (BUILDJAVAEXAMPLES "Build java example jars" OFF) -option (IPK "Generate IPK using CPack" OFF) -option (RPM "Generate RPM using CPack" OFF) -option (BUILDTESTS "Generate check-ups for upm" ON) -option (ENABLECXX11 "Enable C++11 standards support" ON) - -# Find swig -if (BUILDSWIGPYTHON OR BUILDSWIGNODE OR BUILDSWIGJAVA) - if (BUILDSWIGNODE) - find_package (SWIG 3.0.5 REQUIRED) - else () - find_package (SWIG REQUIRED) - endif () - if (SWIG_FOUND) - include (${SWIG_USE_FILE}) - endif () -endif () - # Detect arch include (TargetArch) target_architecture (DETECTED_ARCH) diff --git a/src/bacnetmstp/CMakeLists.txt b/src/bacnetmstp/CMakeLists.txt index 7c47c345..be2daaa8 100644 --- a/src/bacnetmstp/CMakeLists.txt +++ b/src/bacnetmstp/CMakeLists.txt @@ -3,12 +3,10 @@ set (libdescription "upm driver module for BACnet MS/TP devices") set (module_src ${libname}.cxx device-client.c bacnetutil.cxx) set (module_hpp ${libname}.hpp bacnetutil.hpp) -pkg_check_modules(BACNET libbacnet) if (BACNET_FOUND) set (reqlibname "libbacnet") include_directories(${BACNET_INCLUDE_DIRS}) upm_module_init() - add_dependencies(${libname} ${BACNET_LIBRARIES}) target_link_libraries(${libname} ${BACNET_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) if (BUILDSWIGNODE) swig_link_libraries (jsupm_${libname} ${BACNET_LIBRARIES}) diff --git a/src/e50hx/CMakeLists.txt b/src/e50hx/CMakeLists.txt index 7d62b9ce..4a613e3e 100644 --- a/src/e50hx/CMakeLists.txt +++ b/src/e50hx/CMakeLists.txt @@ -3,7 +3,6 @@ set (libdescription "upm module for the Veris E50HX (E50H2/E50H5)Energy Meters") set (module_src ${libname}.cxx) set (module_hpp ${libname}.hpp) -pkg_check_modules(BACNET libbacnet) if (BACNET_FOUND) # upm-libbacnetmstp will bring in libbacnet, I hope set (reqlibname "upm-bacnetmstp") diff --git a/src/h803x/CMakeLists.txt b/src/h803x/CMakeLists.txt index 51ef3c43..e8901f68 100644 --- a/src/h803x/CMakeLists.txt +++ b/src/h803x/CMakeLists.txt @@ -3,7 +3,6 @@ set (libdescription "upm module for the Veris H803X (H8035/H8036)") set (module_src ${libname}.cxx) set (module_hpp ${libname}.hpp) -pkg_check_modules(MODBUS libmodbus) if (MODBUS_FOUND) set (reqlibname "libmodbus") include_directories(${MODBUS_INCLUDE_DIRS}) diff --git a/src/hwxpxx/CMakeLists.txt b/src/hwxpxx/CMakeLists.txt index 60ad8c9a..7dd1abdc 100644 --- a/src/hwxpxx/CMakeLists.txt +++ b/src/hwxpxx/CMakeLists.txt @@ -3,7 +3,6 @@ set (libdescription "upm module for the Veris HWXPXX (HWXPHTX)") set (module_src ${libname}.cxx) set (module_hpp ${libname}.hpp) -pkg_check_modules(MODBUS libmodbus) if (MODBUS_FOUND) set (reqlibname "libmodbus") include_directories(${MODBUS_INCLUDE_DIRS}) diff --git a/src/ozw/CMakeLists.txt b/src/ozw/CMakeLists.txt index 9b36c5d0..170ba589 100644 --- a/src/ozw/CMakeLists.txt +++ b/src/ozw/CMakeLists.txt @@ -3,7 +3,6 @@ set (libdescription "upm module for the OpenZWave library interface") set (module_src ${libname}.cxx zwNode.cxx ozwinterface.cxx ozwdump.cxx aeotecss6.cxx aeotecsdg2.cxx aeotecdw2e.cxx aeotecdsb09104.cxx tzemt400.cxx) set (module_hpp ${libname}.hpp ozwinterface.hpp ozwdump.hpp aeotecss6.hpp aeotecsdg2.hpp aeotecdw2e.hpp aeotecdsb09104.hpp tzemt400.hpp) -pkg_check_modules(OPENZWAVE libopenzwave) if (OPENZWAVE_FOUND) set (reqlibname "libopenzwave") include_directories(${OPENZWAVE_INCLUDE_DIRS}) diff --git a/src/t3311/CMakeLists.txt b/src/t3311/CMakeLists.txt index 6dac7253..4270403a 100644 --- a/src/t3311/CMakeLists.txt +++ b/src/t3311/CMakeLists.txt @@ -3,7 +3,6 @@ set (libdescription "upm module for the Comet System T3311") set (module_src ${libname}.cxx) set (module_hpp ${libname}.hpp) -pkg_check_modules(MODBUS libmodbus) if (MODBUS_FOUND) set (reqlibname "libmodbus") include_directories(${MODBUS_INCLUDE_DIRS}) diff --git a/src/t8100/CMakeLists.txt b/src/t8100/CMakeLists.txt index 4d79f8ab..66b0b5cd 100644 --- a/src/t8100/CMakeLists.txt +++ b/src/t8100/CMakeLists.txt @@ -3,7 +3,6 @@ set (libdescription "upm module for the Telaire T8100 Ventostat") set (module_src ${libname}.cxx) set (module_hpp ${libname}.hpp) -pkg_check_modules(BACNET libbacnet) if (BACNET_FOUND) # upm-libbacnetmstp will bring in libbacnet, I hope set (reqlibname "upm-bacnetmstp") diff --git a/src/tb7300/CMakeLists.txt b/src/tb7300/CMakeLists.txt index 5cf1cc14..ba98055a 100644 --- a/src/tb7300/CMakeLists.txt +++ b/src/tb7300/CMakeLists.txt @@ -3,7 +3,6 @@ set (libdescription "upm module for the TB7300 Fan Coil Thermostat") set (module_src ${libname}.cxx) set (module_hpp ${libname}.hpp) -pkg_check_modules(BACNET libbacnet) if (BACNET_FOUND) # upm-libbacnetmstp will bring in libbacnet, I hope set (reqlibname "upm-bacnetmstp") diff --git a/src/vcap/CMakeLists.txt b/src/vcap/CMakeLists.txt index df38aac3..ae8d4dd5 100644 --- a/src/vcap/CMakeLists.txt +++ b/src/vcap/CMakeLists.txt @@ -3,7 +3,6 @@ set (libdescription "upm Video Frame Capture and image save utility") set (module_src ${libname}.cxx) set (module_hpp ${libname}.hpp) -find_package (JPEG) if (JPEG_FOUND) set (reqlibname "jpeg") upm_module_init() @@ -17,4 +16,4 @@ if (JPEG_FOUND) if (BUILDSWIGJAVA) swig_link_libraries (javaupm_${libname} jpeg) endif() -endif() \ No newline at end of file +endif()