Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Syslog addon: Build if syslog.h found

  • Loading branch information...
commit f120d9267c83c661b89b9409064b970e61168a07 1 parent 5c4b8b2
@omf omf authored
Showing with 54 additions and 18 deletions.
  1. +23 −18 addons/Syslog/CMakeLists.txt
  2. +31 −0 modules/FindSyslog.cmake
View
41 addons/Syslog/CMakeLists.txt
@@ -3,28 +3,33 @@
#
# Builds the Syslog addon
+# Find syslog.h
+find_package(Syslog)
+
# Create the _build bundle hierarchy if needed.
make_build_bundle(_build)
-# Output our dynamic library to the top-level _build hierarchy
-set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/_build/dll)
+if(SYSLOG_FOUND)
+ # Output our dynamic library to the top-level _build hierarchy
+ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/_build/dll)
-# Generate the IoSyslogInit.c file.
-# Argument SHOULD ALWAYS be the exact name of the addon, case is
-# important.
-generate_ioinit(Syslog)
+ # Generate the IoSyslogInit.c file.
+ # Argument SHOULD ALWAYS be the exact name of the addon, case is
+ # important.
+ generate_ioinit(Syslog)
-# Our library sources.
-set(SRCS
- "${CMAKE_CURRENT_SOURCE_DIR}/source/IoSyslog.c"
- "${CMAKE_CURRENT_SOURCE_DIR}/source/IoSyslogInit.c"
-)
+ # Our library sources.
+ set(SRCS
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoSyslog.c"
+ "${CMAKE_CURRENT_SOURCE_DIR}/source/IoSyslogInit.c"
+ )
-# Now build the shared library
-add_library(IoSyslog SHARED ${SRCS})
-add_dependencies(IoSyslog iovmall)
-target_link_libraries(IoSyslog iovmall)
+ # Now build the shared library
+ add_library(IoSyslog SHARED ${SRCS})
+ add_dependencies(IoSyslog iovmall)
+ target_link_libraries(IoSyslog iovmall)
-# Install the addon to our global addons hierarchy.
-install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons)
-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_build DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons/Syslog)
+ # Install the addon to our global addons hierarchy.
+ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons)
+ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_build DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/io/addons/Syslog)
+endif(SYSLOG_FOUND)
View
31 modules/FindSyslog.cmake
@@ -0,0 +1,31 @@
+# Try to find syslog.h for Syslog
+
+
+IF (SYSLOG_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(SYSLOG_FIND_QUIETLY TRUE)
+ENDIF (SYSLOG_INCLUDE_DIR)
+
+FIND_PATH(SYSLOG_INCLUDE_DIR syslog.h)
+
+IF(SYSLOG_INCLUDE_DIR)
+ SET(SYSLOG_FOUND TRUE)
+ENDIF(SYSLOG_INCLUDE_DIR)
+
+IF(SYSLOG_FOUND)
+ set(CMAKE_REQUIRED_INCLUDES ${SYSLOG_INCLUDE_DIR})
+ set(CMAKE_REQUIRED_INCLUDES)
+ IF(NOT SYSLOG_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Syslog headers: ${SYSLOG_INCLUDE_DIR}/syslog.h")
+ ENDIF(NOT SYSLOG_FIND_QUIETLY)
+ELSE(SYSLOG_FOUND)
+ IF(Syslog_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find Syslog")
+ ENDIF(Syslog_FIND_REQUIRED)
+ENDIF(SYSLOG_FOUND)
+
+MARK_AS_ADVANCED(
+ SYSLOG_INCLUDE_DIR
+ SYSLOG_LIBRARIES
+ SYSLOG_SECOND_ARGUMENT_IS_CONST
+)
Please sign in to comment.
Something went wrong with that request. Please try again.