1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-11-26 23:07:17 +00:00

update CMakeLists.txt, add compiletime generated config

This commit is contained in:
Andrew Karpow 2014-01-08 02:22:05 +01:00
parent 38f5009140
commit 6d341cdf69
2 changed files with 48 additions and 20 deletions

View File

@ -1,23 +1,39 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
project (ympd) 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_DEBIAN_PACKAGE_MAINTAINER "andy@ndyk.de")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "1")
set(CPACK_PACKAGE_VERSION_PATCH "2")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "4")
set(CPACK_GENERATOR "DEB;RPM;TGZ")
set(CPACK_SOURCE_GENERATOR "TBZ2")
set(DEBIAN_PACKAGE_SECTION "web")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MPD web client based on Websockets and
Bootstrap")
set(CPACK_PACKAGE_CONTACT "Andrew Karpow <andy@ympd.org>")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "andy@ndyk.de")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libssl1.0.0,libmpdclient2")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
option(WITH_STATIC_WEBSOCKETS "Build with static libwebsockets library" OFF)
find_package(LibWebSockets REQUIRED)
find_package(LibMPDClient REQUIRED) find_package(LibMPDClient REQUIRED)
find_package(LibWebSockets REQUIRED)
if(WITH_STATIC_WEBSOCKETS)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
endif()
configure_file(${PROJECT_SOURCE_DIR}/src/config.h.in
${PROJECT_BINARY_DIR}/config.h)
include_directories(${PROJECT_BINARY_DIR})
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
include(CPack) include(CPack)
set(CMAKE_C_FLAGS_DEBRELEASE "-Wall -O2 -DNDEBUG -pipe") set(CMAKE_C_FLAGS "-std=gnu99 -Wall")
set(CMAKE_C_FLAGS_DEBUG "-Wall -ggdb") set(CMAKE_C_FLAGS_DEBUG "-ggdb -pedantic")
set(SOURCES set(SOURCES
src/ympd.c src/ympd.c
@ -26,9 +42,17 @@ set(SOURCES
) )
add_executable(ympd ${SOURCES}) add_executable(ympd ${SOURCES})
add_definitions(-DDATADIR="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
target_link_libraries(ympd ${LIBMPDCLIENT_LIBRARY} ${LIBWEBSOCKETS_LIBRARIES}) # TODO: use generator expressions introduced to CMake 2.8.12, too fresh yet
if(WITH_STATIC_WEBSOCKETS)
find_library(LIBWEBSOCKETS_LIBRARY_STATIC libwebsockets.a)
target_link_libraries(ympd ${LIBMPDCLIENT_LIBRARY}
${LIBWEBSOCKETS_LIBRARY_STATIC} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES})
else()
target_link_libraries(ympd ${LIBMPDCLIENT_LIBRARY}
${LIBWEBSOCKETS_LIBRARIES})
endif()
install(TARGETS ympd DESTINATION bin) install(TARGETS ympd DESTINATION bin)
install(DIRECTORY htdocs DESTINATION share/${PROJECT_NAME}) install(DIRECTORY htdocs DESTINATION share/${PROJECT_NAME})
@ -38,10 +62,3 @@ install(FILES contrib/init.debian DESTINATION /etc/init.d
install(FILES contrib/default.debian DESTINATION /etc/default/${PROJECT_NAME} install(FILES contrib/default.debian DESTINATION /etc/default/${PROJECT_NAME}
CONFIGURATIONS debrelease RENAME ${PROJECT_NAME}) CONFIGURATIONS debrelease RENAME ${PROJECT_NAME})
if(CMAKE_BUILD_TYPE STREQUAL "debrelease")
set(CPACK_BINARY_DEB "ON")
set(CPACK_BINARY_STGZ "OFF")
set(CPACK_BINARY_TGZ "OFF")
set(CPACK_BINARY_TZ "OFF")
endif()

11
src/config.h.in Normal file
View File

@ -0,0 +1,11 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
#define YMPD_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}
#define YMPD_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR}
#define YMPD_VERSION_PATCH ${CPACK_PACKAGE_VERSION_PATCH}
#define DATADIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}"
#define LOCAL_RESOURCE_PATH DATADIR"/htdocs"
#endif