1cmake_minimum_required(VERSION 2.8.7) 2project(libiio C) 3 4set(LIBIIO_VERSION_MAJOR 0) 5set(LIBIIO_VERSION_MINOR 18) 6set(VERSION "${LIBIIO_VERSION_MAJOR}.${LIBIIO_VERSION_MINOR}") 7if (WIN32) 8 string(TIMESTAMP BUILD_YEAR "%Y") 9endif() 10 11# Set the default install path to /usr 12if (NOT WIN32 AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 13 set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "default install path" FORCE) 14endif() 15 16set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/${PROJECT_NAME}${LIBIIO_VERSION_MAJOR}-doc)") 17include(GNUInstallDirs) 18if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") 19 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") 20 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 21endif() 22set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}${LIBIIO_VERSION_MAJOR}-doc") 23 24set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" 25 CACHE PATH "Installation directory for pkgconfig (.pc) files") 26mark_as_advanced(INSTALL_PKGCONFIG_DIR) 27 28if (NOT CMAKE_BUILD_TYPE) 29 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING 30 "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." 31 FORCE) 32 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS None Debug Release RelWithDebInfo MinSizeRel) 33endif() 34 35set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries") 36 37if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 38 option(OSX_PACKAGE "Create a OSX package" ON) 39 set(CMAKE_MACOSX_RPATH ON) 40 set(SKIP_INSTALL_ALL ${OSX_PACKAGE}) 41endif() 42 43option(WITH_NETWORK_BACKEND "Enable the network backend" ON) 44option(WITH_TESTS "Build the test programs" ON) 45 46if (WITH_TESTS) 47 set(NEED_THREADS 1) 48endif() 49 50if (MSVC) 51 # Avoid annoying warnings from Visual Studio 52 add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) 53 54 set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") 55 set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".a" ".lib") 56endif() 57 58if (NOT LOG_LEVEL) 59 set(LOG_LEVEL Info CACHE STRING "Log level" FORCE) 60 set_property(CACHE LOG_LEVEL PROPERTY STRINGS NoLog Error Warning Info Debug) 61endif() 62 63if (CMAKE_COMPILER_IS_GNUCC) 64 if (NOT WIN32) 65 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") 66 endif() 67 68 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare") 69 70 include(CheckCCompilerFlag) 71 check_c_compiler_flag(-Wpedantic HAS_WPEDANTIC) 72 if (HAS_WPEDANTIC) 73 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic") 74 endif() 75endif() 76 77include(CheckSymbolExists) 78check_symbol_exists(strdup "string.h" HAS_STRDUP) 79check_symbol_exists(strerror_r "string.h" HAS_STRERROR_R) 80check_symbol_exists(newlocale "locale.h" HAS_NEWLOCALE) 81 82IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 83 option(WITH_IIOD "Build the IIO Daemon" ON) 84 option(WITH_LOCAL_BACKEND "Enable the local backend" ON) 85 86 if (WITH_IIOD AND NOT WITH_LOCAL_BACKEND) 87 message(SEND_ERROR "IIOD can only be enabled if the local backend is enabled") 88 endif() 89 if (WITH_IIOD) 90 set(NEED_THREADS 1) 91 endif() 92 93 set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE=1") 94 add_definitions(-D_GNU_SOURCE=1) 95endif() 96 97option(ENABLE_IPV6 "Define if you want to enable IPv6 support" ON) 98if (ENABLE_IPV6) 99 check_symbol_exists(in6addr_any "netinet/in.h" HAVE_IPV6) 100 101 if (NOT HAVE_IPV6) 102 message(WARNING "IPv6 is not available in your system.") 103 endif() 104endif() 105 106set(LIBIIO_CFILES backend.c channel.c device.c context.c buffer.c utilities.c scan.c sort.c) 107set(LIBIIO_HEADERS iio.h) 108 109add_definitions(-D_POSIX_C_SOURCE=200809L -D__XSI_VISIBLE=500 -DLIBIIO_EXPORTS=1) 110 111# Get the GIT hash of the latest commit 112include(FindGit OPTIONAL) 113if (GIT_FOUND) 114 execute_process( 115 COMMAND ${GIT_EXECUTABLE} rev-parse --show-toplevel 116 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 117 OUTPUT_VARIABLE LIBIIO_GIT_REPO 118 OUTPUT_STRIP_TRAILING_WHITESPACE 119 ERROR_QUIET 120 ) 121 122 if ("${LIBIIO_GIT_REPO}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") 123 execute_process( 124 COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD 125 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 126 OUTPUT_VARIABLE LIBIIO_VERSION_GIT 127 OUTPUT_STRIP_TRAILING_WHITESPACE 128 ) 129 endif() 130endif() 131 132set(LIBIIO_VERSION ${VERSION}.g${LIBIIO_VERSION_GIT}) 133file(WRITE ${CMAKE_BINARY_DIR}/.version ${LIBIIO_VERSION}) 134 135if (NOT LIBIIO_VERSION_GIT) 136 set(LIBIIO_VERSION_GIT v${VERSION}) 137endif() 138 139if(WITH_LOCAL_BACKEND) 140 add_definitions(-DLOCAL_BACKEND=1) 141 set(LIBIIO_CFILES ${LIBIIO_CFILES} local.c) 142 143 # Link with librt if present 144 find_library(LIBRT_LIBRARIES rt) 145 if (LIBRT_LIBRARIES) 146 set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBRT_LIBRARIES}) 147 endif() 148 149 option(WITH_LOCAL_CONFIG "Read local context attributes from /etc/libiio.ini" OFF) 150 if (WITH_LOCAL_CONFIG) 151 find_library(LIBINI_LIBRARIES ini) 152 find_path(LIBINI_INCLUDE_DIR ini.h) 153 if (NOT LIBINI_LIBRARIES OR NOT LIBINI_INCLUDE_DIR) 154 message(SEND_ERROR "WITH_LOCAL_CONFIG option requires libini to be installed") 155 else() 156 include_directories(${LIBINI_INCLUDE_DIR}) 157 set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBINI_LIBRARIES}) 158 endif() 159 endif() 160endif() 161 162find_library(LIBUSB_LIBRARIES usb-1.0) 163find_path(LIBUSB_INCLUDE_DIR libusb-1.0/libusb.h) 164if (LIBUSB_LIBRARIES AND LIBUSB_INCLUDE_DIR) 165 message(STATUS "Looking for libusb-1.0 : Found") 166 option(WITH_USB_BACKEND "Enable the libusb backend" ON) 167 168 if(WITH_USB_BACKEND) 169 add_definitions(-DUSB_BACKEND=1) 170 set(LIBIIO_CFILES ${LIBIIO_CFILES} usb.c) 171 set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBUSB_LIBRARIES}) 172 set(IIOD_CLIENT 1) 173 set(NEED_LIBXML2 1) 174 set(NEED_THREADS 1) 175 176 include_directories(${LIBUSB_INCLUDE_DIR}) 177 178 set(TEMP ${CMAKE_REQUIRED_LIBRARIES}) 179 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} 180 ${LIBUSB_LIBRARIES}) 181 check_symbol_exists(libusb_get_version "libusb-1.0/libusb.h" 182 HAS_LIBUSB_GETVERSION) 183 set(CMAKE_REQUIRED_LIBRARIES ${TEMP}) 184 endif() 185else() 186 message(STATUS "Looking for libusb-1.0 : Failed; building without usb") 187endif() 188 189find_library(LIBSERIALPORT_LIBRARIES serialport) 190find_path(LIBSERIALPORT_INCLUDE_DIR libserialport.h) 191if (LIBSERIALPORT_LIBRARIES AND LIBSERIALPORT_INCLUDE_DIR) 192 option(WITH_SERIAL_BACKEND "Enable the serial backend" ON) 193 194 if (WITH_SERIAL_BACKEND) 195 file(STRINGS ${LIBSERIALPORT_INCLUDE_DIR}/libserialport.h LIBSERIALPORT_VERSION_STR REGEX "SP_PACKAGE_VERSION_STRING") 196 string(REGEX REPLACE "#define SP_PACKAGE_VERSION_STRING \"(.*)\"" "\\1" LIBSERIALPORT_VERSION ${LIBSERIALPORT_VERSION_STR}) 197 if ("${LIBSERIALPORT_VERSION}" VERSION_LESS 0.1.1) 198 message(WARNING "The installed version of libserialport is too old. The minimum version supported is 0.1.1. Disabling Serial support.") 199 SET(WITH_SERIAL_BACKEND OFF) 200 else() 201 add_definitions(-DSERIAL_BACKEND=1) 202 set(LIBIIO_CFILES ${LIBIIO_CFILES} serial.c) 203 set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBSERIALPORT_LIBRARIES}) 204 205 set(NEED_THREADS 1) 206 set(IIOD_CLIENT 1) 207 set(NEED_LIBXML2 1) 208 209 include_directories(${LIBSERIALPORT_INCLUDE_DIR}) 210 endif() 211 endif() 212endif() 213 214include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) 215 216if(WITH_NETWORK_BACKEND) 217 if (WIN32) 218 set(LIBS_TO_LINK ${LIBS_TO_LINK} wsock32 ws2_32) 219 endif() 220 221 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 222 include(CheckCSourceCompiles) 223 check_c_source_compiles("#include <fcntl.h>\nint main(void) { return O_TMPFILE; }" HAS_O_TMPFILE) 224 225 if (HAS_O_TMPFILE) 226 option(WITH_NETWORK_GET_BUFFER "Enable experimental zero-copy transfers" OFF) 227 endif(HAS_O_TMPFILE) 228 229 check_c_source_compiles("#include <sys/eventfd.h>\nint main(void) { return eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); }" WITH_NETWORK_EVENTFD) 230 endif() 231 232 if(NOT WIN32) 233 include(CheckCSourceCompiles) 234 check_c_source_compiles("#include <unistd.h>\n#include <fcntl.h>\nint main(void) { int fd[2]; return pipe2(fd, O_CLOEXEC | O_NONBLOCK); }" HAS_PIPE2) 235 endif() 236 237 add_definitions(-DNETWORK_BACKEND=1) 238 set(LIBIIO_CFILES ${LIBIIO_CFILES} network.c) 239 240 find_library(AVAHI_CLIENT_LIBRARIES avahi-client) 241 find_library(AVAHI_COMMON_LIBRARIES avahi-common) 242 if(AVAHI_CLIENT_LIBRARIES AND AVAHI_COMMON_LIBRARIES) 243 set(HAVE_AVAHI ON) 244 set(AVAHI_LIBRARIES ${AVAHI_CLIENT_LIBRARIES} ${AVAHI_COMMON_LIBRARIES}) 245 set(LIBS_TO_LINK ${LIBS_TO_LINK} ${AVAHI_LIBRARIES}) 246 endif() 247 248 set(NEED_THREADS 1) 249 set(IIOD_CLIENT 1) 250 set(NEED_LIBXML2 1) 251endif() 252 253# Since libxml2-2.9.2, libxml2 provides its own LibXml2-config.cmake, with all 254# variables correctly set. 255# So, try first to find the CMake module provided by libxml2 package, then fallback 256# on the CMake's FindLibXml2.cmake module (which can lack some definition, especially 257# in static build case). 258find_package(LibXml2 QUIET NO_MODULE) 259if(DEFINED LIBXML2_VERSION_STRING) 260 set(LIBXML2_FOUND ON) 261 set(LIBXML2_INCLUDE_DIR ${LIBXML2_INCLUDE_DIRS}) 262else() 263 include(FindLibXml2) 264endif() 265 266if (LIBXML2_FOUND) 267 option(WITH_XML_BACKEND "Enable the XML backend" ON) 268 269 if (WITH_XML_BACKEND) 270 set(LIBIIO_CFILES ${LIBIIO_CFILES} xml.c) 271 add_definitions(${LIBXML2_DEFINITIONS} -DXML_BACKEND=1) 272 include_directories(${LIBXML2_INCLUDE_DIR}) 273 set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBXML2_LIBRARIES}) 274 endif() 275endif() 276 277if (NEED_LIBXML2 AND NOT (LIBXML2_FOUND AND WITH_XML_BACKEND)) 278 message(SEND_ERROR "The selected backends require libxml2 and the XML backend to be enabled") 279endif() 280 281if (NEED_THREADS) 282 if (NOT WIN32) 283 find_library(PTHREAD_LIBRARIES pthread) 284 285 if (PTHREAD_LIBRARIES) 286 set(LIBS_TO_LINK ${LIBS_TO_LINK} ${PTHREAD_LIBRARIES}) 287 else() 288 message(WARNING "pthread library not found; support for threads will be disabled") 289 set(NO_THREADS ON) 290 endif() 291 else() 292 endif() 293 294 set(LIBIIO_CFILES ${LIBIIO_CFILES} lock.c) 295endif() 296 297if (IIOD_CLIENT) 298 set(LIBIIO_CFILES ${LIBIIO_CFILES} iiod-client.c) 299endif() 300 301configure_file(libiio.iss.cmakein ${CMAKE_CURRENT_BINARY_DIR}/libiio.iss @ONLY) 302 303set(LIBIIO_PC ${CMAKE_CURRENT_BINARY_DIR}/libiio.pc) 304configure_file(libiio.pc.cmakein ${LIBIIO_PC} @ONLY) 305 306if(NOT SKIP_INSTALL_ALL) 307 install(FILES ${LIBIIO_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}") 308endif() 309 310#set(SETUP_PY ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/setup.py) 311#configure_file(python/setup.py.in ${SETUP_PY} @ONLY) 312 313add_subdirectory(bindings) 314 315if (WITH_MATLAB_BINDINGS_API) 316 set(LIBIIO_EXTRA_HEADERS ${LIBIIO_EXTRA_HEADERS} bindings/matlab/iio-wrapper.h) 317 add_definitions(-DMATLAB_BINDINGS_API=1) 318endif() 319 320if(WITH_TESTS) 321 add_subdirectory(tests) 322endif() 323 324if (WIN32) 325 set(LIBIIO_ORIGINAL_FILENAME libiio.dll) 326 set(LIBIIO_RC ${CMAKE_CURRENT_BINARY_DIR}/properties.rc) 327 configure_file(properties.rc.cmakein ${LIBIIO_RC} @ONLY) 328endif() 329 330add_library(iio ${LIBIIO_CFILES} ${LIBIIO_HEADERS} ${LIBIIO_EXTRA_HEADERS} ${LIBIIO_RC}) 331set_target_properties(iio PROPERTIES 332 VERSION ${VERSION} 333 SOVERSION ${LIBIIO_VERSION_MAJOR} 334 FRAMEWORK TRUE 335 PUBLIC_HEADER ${LIBIIO_HEADERS} 336 C_STANDARD 99 337 C_STANDARD_REQUIRED ON 338 C_EXTENSIONS OFF 339) 340target_link_libraries(iio LINK_PRIVATE ${LIBS_TO_LINK}) 341 342if (MSVC) 343 set_target_properties(iio PROPERTIES OUTPUT_NAME libiio) 344endif() 345 346if(NOT SKIP_INSTALL_ALL) 347 install(TARGETS iio 348 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 349 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 350 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 351 FRAMEWORK DESTINATION /Library/Frameworks 352 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 353endif() 354 355find_package(Doxygen) 356if(DOXYGEN_FOUND) 357 option(WITH_DOC "Generate documentation with Doxygen" ON) 358 359 # It is not an error when 'dot' is not found, just switching off the Doxygen's HAVE_DOT option 360 find_package_handle_standard_args (Dot REQUIRED_VARS DOXYGEN_DOT_EXECUTABLE) 361 362 include(cmake/CheckCaseSensitiveFileSystem.cmake) 363 if (HAVE_CASE_SENSITIVE_FILESYSTEM) 364 set(CMAKE_CASE_SENSITIVE_FILESYSTEM "YES") 365 else() 366 set(CMAKE_CASE_SENSITIVE_FILESYSTEM "NO") 367 endif() 368 369 if (WITH_DOC) 370 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) 371 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CI/travis/generateDocumentationAndDeploy.sh.in 372 ${CMAKE_CURRENT_BINARY_DIR}/generateDocumentationAndDeploy.sh @ONLY) 373 set(HTML_DEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/html) 374 file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/doc DESTINATION ${HTML_DEST_DIR}) 375 376 add_custom_command(TARGET iio POST_BUILD 377 COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 378 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 379 COMMENT "Generating API documentation with Doxygen" VERBATIM 380 ) 381 382 if(NOT SKIP_INSTALL_ALL) 383 install(DIRECTORY ${HTML_DEST_DIR} DESTINATION ${CMAKE_INSTALL_DOCDIR}) 384 endif() 385 endif() 386else() 387 message(STATUS "Doxygen not found, API documentation won't be generated") 388endif() 389 390# Create an installer if compiling for OSX 391if(OSX_PACKAGE) 392 set(LIBIIO_PKG ${CMAKE_CURRENT_BINARY_DIR}/libiio-${VERSION}.g${LIBIIO_VERSION_GIT}.pkg) 393 set(LIBIIO_TEMP_PKG ${CMAKE_CURRENT_BINARY_DIR}/libiio-${VERSION}-temp.pkg) 394 set(LIBIIO_DISTRIBUTION_XML ${CMAKE_CURRENT_BINARY_DIR}/Distribution.xml) 395 set(LIBIIO_FRAMEWORK_DIR ${CMAKE_CURRENT_BINARY_DIR}/iio.framework) 396 configure_file(Distribution.xml.cmakein ${LIBIIO_DISTRIBUTION_XML} @ONLY) 397 398 find_program(PKGBUILD_EXECUTABLE 399 NAMES pkgbuild 400 DOC "OSX Package builder (pkgbuild)") 401 mark_as_advanced(PKGBUILD_EXECUTABLE) 402 403 find_program(PRODUCTBUILD_EXECUTABLE 404 NAMES productbuild 405 DOC "OSX Package builder (productbuild)") 406 mark_as_advanced(PRODUCTBUILD_EXECUTABLE) 407 408 foreach(_tool ${IIO_TESTS_TARGETS}) 409 list(APPEND IIO_TESTS $<TARGET_FILE:${_tool}>) 410 endforeach() 411 412 add_custom_command(OUTPUT ${LIBIIO_PKG} 413 COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBIIO_FRAMEWORK_DIR}/Tools 414 COMMAND ${CMAKE_COMMAND} -E copy ${IIO_TESTS} ${LIBIIO_FRAMEWORK_DIR}/Tools 415 COMMAND ${PKGBUILD_EXECUTABLE} 416 --component ${LIBIIO_FRAMEWORK_DIR} 417 --identifier com.adi.iio --version ${VERSION} 418 --install-location /Library/Frameworks ${LIBIIO_TEMP_PKG} 419 COMMAND ${PRODUCTBUILD_EXECUTABLE} 420 --distribution ${LIBIIO_DISTRIBUTION_XML} ${LIBIIO_PKG} 421 COMMAND ${CMAKE_COMMAND} -E remove ${LIBIIO_TEMP_PKG} 422 DEPENDS iio ${IIO_TESTS_TARGETS} ${LIBIIO_DISTRIBUTION_XML} 423 ) 424 425 if (PKGBUILD_EXECUTABLE AND PRODUCTBUILD_EXECUTABLE) 426 add_custom_target(libiio-pkg ALL DEPENDS ${LIBIIO_PKG}) 427 428 install(CODE "execute_process(COMMAND /usr/sbin/installer -pkg ${LIBIIO_PKG} -target /)") 429 else() 430 message(WARNING "Missing pkgbuild or productbuild: OSX installer won't be created.") 431 endif() 432endif() 433 434if(WITH_IIOD) 435 option(WITH_SYSTEMD "Enable installation of systemd service file for iiod" OFF) 436 set(SYSTEMD_UNIT_INSTALL_DIR /lib/systemd/system CACHE PATH "default install path for systemd unit files") 437 438 option(WITH_SYSVINIT "Enable installation of SysVinit script for iiod" OFF) 439 set(SYSVINIT_INSTALL_DIR /etc/init.d CACHE PATH "default install path for SysVinit scripts") 440 441 option(WITH_UPSTART "Enable installation of upstart config file for iiod" OFF) 442 set(UPSTART_CONF_INSTALL_DIR /etc/init CACHE PATH "default install path for upstart conf files") 443 444 if (NOT PTHREAD_LIBRARIES) 445 message(WARNING "IIOD requires threads support; disabling") 446 set(WITH_IIOD OFF CACHE BOOL "" FORCE) 447 else() 448 add_subdirectory(iiod) 449 endif() 450endif() 451 452if (NOT OSX_PACKAGE) 453 # Support creating some basic binpkgs via `make package`. 454 # Disabled if OSX_PACKAGE is enabled, as tarballs would end up empty otherwise. 455 option(ENABLE_PACKAGING "Create .deb/.rpm or .tar.gz packages via 'make package'" OFF) 456 457 if(ENABLE_PACKAGING) 458 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 459 include(cmake/DarwinPackaging.cmake) 460 endif() 461 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") 462 include(cmake/LinuxPackaging.cmake) 463 endif() 464 endif() 465endif() 466 467if (WITH_USB_BACKEND AND CMAKE_SYSTEM_NAME MATCHES "^Linux") 468 option(INSTALL_UDEV_RULE "Install a udev rule for detection of USB devices" ON) 469 470 if (INSTALL_UDEV_RULE) 471 set(UDEV_RULES_INSTALL_DIR /lib/udev/rules.d CACHE PATH "default install path for udev rules") 472 473 configure_file(libiio.rules.cmakein ${CMAKE_CURRENT_BINARY_DIR}/90-libiio.rules @ONLY) 474 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/90-libiio.rules DESTINATION ${UDEV_RULES_INSTALL_DIR}) 475 endif() 476endif() 477 478configure_file(iio-config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/iio-config.h @ONLY) 479