Imported Debian patch 1.2.3-1~0
[ympd-debian.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 project (ympd)
4 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
5 set(CPACK_PACKAGE_VERSION_MAJOR "1")
6 set(CPACK_PACKAGE_VERSION_MINOR "2")
7 set(CPACK_PACKAGE_VERSION_PATCH "3")
8
9 option(WITH_MPD_HOST_CHANGE "Let users of the web frontend change the MPD Host" ON)
10 option(WITH_IPV6 "enable IPv6 support" ON)
11
12 find_package(LibMPDClient REQUIRED)
13 find_package(Threads REQUIRED)
14
15 configure_file(src/config.h.in ${PROJECT_BINARY_DIR}/config.h)
16 include_directories(${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR})
17
18 include(CheckCSourceCompiles)
19
20 set(CMAKE_C_FLAGS "-std=gnu99 -Wall") 
21 set(CMAKE_C_FLAGS_DEBUG "-ggdb -pedantic")
22 if(WITH_IPV6)
23         set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS NS_ENABLE_IPV6)
24 endif()
25
26 file(GLOB RESOURCES 
27         RELATIVE ${PROJECT_SOURCE_DIR}
28         htdocs/js/*
29         htdocs/assets/*
30         htdocs/css/*.min.css
31         htdocs/fonts/*
32         htdocs/index.html
33 )
34
35 if(CMAKE_CROSSCOMPILING)
36         set(MKDATA_EXE ${PROJECT_SOURCE_DIR}/htdocs/mkdata.pl)
37 else()
38         set(MKDATA_EXE $<TARGET_FILE:mkdata>)
39         set(MKDATA_TARGET mkdata)
40         add_executable(mkdata htdocs/mkdata.c)
41 endif()
42
43 add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/assets.c
44         COMMAND ${MKDATA_EXE} ${RESOURCES} > ${PROJECT_BINARY_DIR}/assets.c
45         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
46         DEPENDS ${RESOURCES} ${MKDATA_TARGET}
47 )
48
49 set(SOURCES
50     src/ympd.c
51     src/http_server.c
52     src/mpd_client.c
53     src/mongoose.c
54     src/json_encode.c
55     assets.c
56 )
57
58 add_executable(ympd ${SOURCES})
59 target_link_libraries(ympd ${LIBMPDCLIENT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
60
61 install(TARGETS ympd DESTINATION bin)
62 install(FILES ympd.1 DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1)