add workng cmake build enviroment
authorAndrew Karpow <andy@ndyk.de>
Fri, 8 Nov 2013 22:32:07 +0000 (23:32 +0100)
committerAndrew Karpow <andy@ndyk.de>
Fri, 8 Nov 2013 22:32:07 +0000 (23:32 +0100)
CMakeLists.txt [new file with mode: 0644]
cmake/FindLibMPDClient.cmake [new file with mode: 0644]
cmake/FindLibWebSockets.cmake [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b8ff586
--- /dev/null
@@ -0,0 +1,29 @@
+cmake_minimum_required(VERSION 2.6)
+
+project (ympd)
+
+SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MPD web client based on Websockets and
+Bootstrap")
+SET(CPACK_PACKAGE_VENDOR "Andrew Karpow <andy@ndyk.de>")
+SET(CPACK_PACKAGE_VERSION_MAJOR "0")
+SET(CPACK_PACKAGE_VERSION_MINOR "1")
+SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
+
+FIND_PACKAGE(LibWebSockets REQUIRED)
+FIND_PACKAGE(LibMPDClient REQUIRED)
+INCLUDE(CheckCSourceCompiles)
+
+SET(SOURCES
+    src/ympd.c
+    src/http_server.c
+    src/mpd_client.c
+    )
+
+ADD_EXECUTABLE(ympd ${SOURCES})
+ADD_DEFINITIONS(-DDATADIR="${CMAKE_INSTALL_PREFIX}/share")
+
+TARGET_LINK_LIBRARIES(ympd ${LIBMPDCLIENT_LIBRARY} ${LIBWEBSOCKETS_LIBRARIES})
+
+INSTALL(TARGETS ympd DESTINATION bin)
+INSTALL(DIRECTORY htdocs DESTINATION share/${PROJECT_NAME})
+
diff --git a/cmake/FindLibMPDClient.cmake b/cmake/FindLibMPDClient.cmake
new file mode 100644 (file)
index 0000000..037d032
--- /dev/null
@@ -0,0 +1,32 @@
+# - Try to find LibMPDClient
+# Once done, this will define
+#
+#   LIBMPDCLIENT_FOUND - System has LibMPDClient
+#   LIBMPDCLIENT_INCLUDE_DIRS - The LibMPDClient include directories
+#   LIBMPDCLIENT_LIBRARIES - The libraries needed to use LibMPDClient
+#   LIBMPDCLIENT_DEFINITIONS - Compiler switches required for using LibMPDClient
+
+find_package(PkgConfig)
+pkg_check_modules(PC_LIBMPDCLIENT QUIET libmpdclient)
+set(LIBMPDCLIENT_DEFINITIONS ${PC_LIBMPDCLIENT_CFLAGS_OTHER})
+
+find_path(LIBMPDCLIENT_INCLUDE_DIR
+    NAMES mpd/player.h
+    HINTS ${PC_LIBMPDCLIENT_INCLUDEDIR} ${PC_LIBMPDCLIENT_INCLUDE_DIRS}
+)
+
+find_library(LIBMPDCLIENT_LIBRARY
+    NAMES mpdclient
+    HINTS ${PC_LIBMPDCLIENT_LIBDIR} ${PC_LIBMPDCLIENT_LIBRARY_DIRS}
+)
+
+set(LIBMPDCLIENT_LIBRARIES ${LIBMPDCLIENT_LIBRARY})
+set(LIBMPDCLIENT_INCLUDE_DIRS ${LIBMPDCLIENT_INCLUDE_DIR})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibMPDClient DEFAULT_MSG
+    LIBMPDCLIENT_LIBRARY LIBMPDCLIENT_INCLUDE_DIR
+)
+
+mark_as_advanced(LIBMPDCLIENT_LIBRARY LIBMPDCLIENT_INCLUDE_DIR)
+
diff --git a/cmake/FindLibWebSockets.cmake b/cmake/FindLibWebSockets.cmake
new file mode 100644 (file)
index 0000000..e7d2839
--- /dev/null
@@ -0,0 +1,33 @@
+# This module tries to find libWebsockets library and include files
+#
+# LIBWEBSOCKETS_INCLUDE_DIR, path where to find libwebsockets.h
+# LIBWEBSOCKETS_LIBRARY_DIR, path where to find libwebsockets.so
+# LIBWEBSOCKETS_LIBRARIES, the library to link against
+# LIBWEBSOCKETS_FOUND, If false, do not try to use libWebSockets
+#
+# This currently works probably only for Linux
+
+FIND_PATH ( LIBWEBSOCKETS_INCLUDE_DIR libwebsockets.h
+    /usr/local/include
+    /usr/include
+)
+
+FIND_LIBRARY ( LIBWEBSOCKETS_LIBRARIES websockets
+    /usr/local/lib
+    /usr/lib
+)
+
+GET_FILENAME_COMPONENT( LIBWEBSOCKETS_LIBRARY_DIR ${LIBWEBSOCKETS_LIBRARIES} PATH )
+
+SET ( LIBWEBSOCKETS_FOUND "NO" )
+IF ( LIBWEBSOCKETS_INCLUDE_DIR )
+    IF ( LIBWEBSOCKETS_LIBRARIES )
+        SET ( LIBWEBSOCKETS_FOUND "YES" )
+    ENDIF ( LIBWEBSOCKETS_LIBRARIES )
+ENDIF ( LIBWEBSOCKETS_INCLUDE_DIR )
+
+MARK_AS_ADVANCED(
+    LIBWEBSOCKETS_LIBRARY_DIR
+    LIBWEBSOCKETS_INCLUDE_DIR
+    LIBWEBSOCKETS_LIBRARIES
+)