Skip to content

Commit

Permalink
Simplified CMakeLists.txt by using list(APPEND..)
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Kenda <[email protected]>
  • Loading branch information
matejk committed Feb 25, 2020
1 parent 490c4aa commit 7c633c7
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ endif()

if(WITH_LOCAL_BACKEND)
add_definitions(-DLOCAL_BACKEND=1)
set(LIBIIO_CFILES ${LIBIIO_CFILES} local.c)
list(APPEND LIBIIO_CFILES local.c)

# Link with librt if present
find_library(LIBRT_LIBRARIES rt)
if (LIBRT_LIBRARIES)
set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBRT_LIBRARIES})
list(APPEND LIBS_TO_LINK ${LIBRT_LIBRARIES})
endif()

option(WITH_LOCAL_CONFIG "Read local context attributes from /etc/libiio.ini" OFF)
Expand All @@ -164,7 +164,7 @@ if(WITH_LOCAL_BACKEND)
message(SEND_ERROR "WITH_LOCAL_CONFIG option requires libini to be installed")
else()
include_directories(${LIBINI_INCLUDE_DIR})
set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBINI_LIBRARIES})
list(APPEND LIBS_TO_LINK ${LIBINI_LIBRARIES})
endif()
endif()
endif()
Expand All @@ -178,8 +178,8 @@ if (LIBUSB_LIBRARIES AND LIBUSB_INCLUDE_DIR)

if(WITH_USB_BACKEND)
add_definitions(-DUSB_BACKEND=1)
set(LIBIIO_CFILES ${LIBIIO_CFILES} usb.c)
set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBUSB_LIBRARIES})
list(APPEND LIBIIO_CFILES usb.c)
list(APPEND LIBS_TO_LINK ${LIBUSB_LIBRARIES})
set(IIOD_CLIENT 1)
set(NEED_LIBXML2 1)
set(NEED_THREADS 1)
Expand All @@ -188,10 +188,8 @@ if (LIBUSB_LIBRARIES AND LIBUSB_INCLUDE_DIR)

set(TEMP ${CMAKE_REQUIRED_LIBRARIES})
set(TEMP1 ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}
${LIBUSB_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES}
${LIBUSB_INCLUDE_DIR})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${LIBUSB_LIBRARIES})
list(APPEND CMAKE_REQUIRED_INCLUDES ${LIBUSB_INCLUDE_DIR})
check_symbol_exists(libusb_get_version libusb.h
HAS_LIBUSB_GETVERSION)
set(CMAKE_REQUIRED_LIBRARIES ${TEMP})
Expand All @@ -214,8 +212,8 @@ if (LIBSERIALPORT_LIBRARIES AND LIBSERIALPORT_INCLUDE_DIR)
SET(WITH_SERIAL_BACKEND OFF)
else()
add_definitions(-DSERIAL_BACKEND=1)
set(LIBIIO_CFILES ${LIBIIO_CFILES} serial.c)
set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBSERIALPORT_LIBRARIES})
list(APPEND LIBIIO_CFILES serial.c)
list(APPEND LIBS_TO_LINK ${LIBSERIALPORT_LIBRARIES})

set(NEED_THREADS 1)
set(IIOD_CLIENT 1)
Expand All @@ -231,7 +229,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
if(WITH_NETWORK_BACKEND)
message(STATUS "Building with Network back end support")
if (WIN32)
set(LIBS_TO_LINK ${LIBS_TO_LINK} wsock32 ws2_32)
list(APPEND LIBS_TO_LINK wsock32 ws2_32)
endif()

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Expand All @@ -251,7 +249,7 @@ if(WITH_NETWORK_BACKEND)
endif()

add_definitions(-DNETWORK_BACKEND=1)
set(LIBIIO_CFILES ${LIBIIO_CFILES} network.c)
list(APPEND LIBIIO_CFILES network.c)

find_library(AVAHI_CLIENT_LIBRARIES avahi-client)
find_library(AVAHI_COMMON_LIBRARIES avahi-common)
Expand Down Expand Up @@ -289,10 +287,11 @@ if (LIBXML2_FOUND)
option(WITH_XML_BACKEND "Enable the XML backend" ON)

if (WITH_XML_BACKEND)
set(LIBIIO_CFILES ${LIBIIO_CFILES} xml.c)
list(APPEND LIBIIO_CFILES xml.c)

add_definitions(${LIBXML2_DEFINITIONS} -DXML_BACKEND=1)
include_directories(${LIBXML2_INCLUDE_DIR})
set(LIBS_TO_LINK ${LIBS_TO_LINK} ${LIBXML2_LIBRARIES})
list(APPEND LIBS_TO_LINK ${LIBXML2_LIBRARIES})
endif()
endif()

Expand All @@ -305,19 +304,19 @@ if (NEED_THREADS)
find_library(PTHREAD_LIBRARIES pthread)

if (PTHREAD_LIBRARIES)
set(LIBS_TO_LINK ${LIBS_TO_LINK} ${PTHREAD_LIBRARIES})
list(APPEND LIBS_TO_LINK ${PTHREAD_LIBRARIES})
else()
message(WARNING "pthread library not found; support for threads will be disabled")
set(NO_THREADS ON)
endif()
else()
endif()

set(LIBIIO_CFILES ${LIBIIO_CFILES} lock.c)
list(APPEND LIBIIO_CFILES lock.c)
endif()

if (IIOD_CLIENT)
set(LIBIIO_CFILES ${LIBIIO_CFILES} iiod-client.c)
list(APPEND LIBIIO_CFILES iiod-client.c)
if (HAVE_AVAHI)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/iio.service DESTINATION ${AVAHI_SERVICE_INSTALL_DIR})
endif()
Expand All @@ -341,7 +340,7 @@ option(MATLAB_BINDINGS "Build MATLAB bindings" OFF)
add_subdirectory(bindings)

if (WITH_MATLAB_BINDINGS_API)
set(LIBIIO_EXTRA_HEADERS ${LIBIIO_EXTRA_HEADERS} bindings/matlab/iio-wrapper.h)
list(APPEND LIBIIO_EXTRA_HEADERS bindings/matlab/iio-wrapper.h)
add_definitions(-DMATLAB_BINDINGS_API=1)
endif()

Expand Down

0 comments on commit 7c633c7

Please sign in to comment.