Misc: Update CMakeLists.txt

Update CMakeLists.txt to support Asciidoc man page / HTML doc
generation, with various small changes.
This commit is contained in:
Richard Grenville 2012-11-09 09:32:21 +08:00
parent 59d6979612
commit b47205db08
2 changed files with 58 additions and 8 deletions

View File

@ -5,7 +5,9 @@ set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "0") set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0") set(CPACK_PACKAGE_VERSION_PATCH "0")
set(compton_SRCS src/compton.c) add_subdirectory(man)
set(compton_SRCS src/compton.c)
add_executable(compton ${compton_SRCS}) add_executable(compton ${compton_SRCS})
set(CMAKE_C_FLAGS_DEBUG "-ggdb") set(CMAKE_C_FLAGS_DEBUG "-ggdb")
@ -46,7 +48,7 @@ endif ()
target_link_libraries(compton "-lm" "-lrt") target_link_libraries(compton "-lm" "-lrt")
if (CONFIG_VSYNC_OPENGL) if (CONFIG_VSYNC_OPENGL)
target_link_libraries(compton "-lGL") target_link_libraries(compton "-lGL")
endif () endif ()
include(FindPkgConfig) include(FindPkgConfig)
@ -85,6 +87,12 @@ if (CONFIG_LIBCONFIG)
endif () endif ()
endif () endif ()
# --- Find libdrm ---
if (CONFIG_VSYNC_DRM)
pkg_check_modules(LIBDRM REQUIRED libdrm)
# We only use its header file
endif ()
# == Install == # == Install ==
include(GNUInstallDirs) include(GNUInstallDirs)
@ -92,10 +100,6 @@ install(TARGETS compton
DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog) DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog)
install(FILES "${PROJECT_SOURCE_DIR}/bin/compton-trans" install(FILES "${PROJECT_SOURCE_DIR}/bin/compton-trans"
DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog) DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT prog)
install(FILES
"${PROJECT_SOURCE_DIR}/man/compton.1"
"${PROJECT_SOURCE_DIR}/man/compton-trans.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}" COMPONENT doc)
install(FILES install(FILES
"${PROJECT_SOURCE_DIR}/README.md" "${PROJECT_SOURCE_DIR}/README.md"
"${PROJECT_SOURCE_DIR}/LICENSE" "${PROJECT_SOURCE_DIR}/LICENSE"
@ -150,11 +154,11 @@ set(CPACK_SOURCE_IGNORE_FILES
# --- DEB package config --- # --- DEB package config ---
set(CPACK_DEBIAN_PACKAGE_SECTION "x11") set(CPACK_DEBIAN_PACKAGE_SECTION "x11")
# The dependencies are unreliable, just an example here # The dependencies are unreliable, just an example here
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libx11-6, libxext6, libxcomposite1, libxrender1, libxdamage1, libxfixes3, libpcre3, libconfig8") set(CPACK_DEBIAN_PACKAGE_DEPENDS "libx11-6, libxext6, libxcomposite1, libxrender1, libxdamage1, libxfixes3, libpcre3, libconfig8, libdrm2")
# --- RPM package config --- # --- RPM package config ---
set(CPACK_RPM_PACKAGE_LICENSE "unknown") set(CPACK_RPM_PACKAGE_LICENSE "unknown")
# The dependencies are unreliable, just an example here # The dependencies are unreliable, just an example here
set(CPACK_RPM_PACKAGE_REQUIRES "libx11, libxext, libxcomposite, libxrender, libxdamage, libxfixes, libpcre, libconfig") set(CPACK_RPM_PACKAGE_REQUIRES "libx11, libxext, libxcomposite, libxrender, libxdamage, libxfixes, libpcre, libconfig, libdrm")
include(CPack) include(CPack)

46
man/CMakeLists.txt Normal file
View File

@ -0,0 +1,46 @@
option(NEW_DOC "Build new man pages and HTML documentation" ON)
# == Build documentation ==
# Stolen from https://issues.apache.org/jira/secure/attachment/12455612/AVRO-470.patch
if (NEW_DOC)
set (MAN_SRC
compton.1.asciidoc
compton-trans.1.asciidoc
)
find_program(ASCIIDOC_EXEC asciidoc)
find_program(ASCIIDOC_A2X_EXEC a2x)
if (ASCIIDOC_EXEC AND ASCIIDOC_A2X_EXEC)
foreach(_file ${MAN_SRC})
# get_filename_component() does not handle ".1.asciidoc"
# correctly
string(REPLACE ".asciidoc" "" _file_we "${_file}")
set(_file_path "${CMAKE_CURRENT_SOURCE_DIR}/${_file}")
set(_html_out "${_file_we}.html")
set(_man_out "${_file_we}")
add_custom_target(compton_man_${_file_we} ALL
COMMAND ${ASCIIDOC_A2X_EXEC} --format manpage
"${_file_path}"
DEPENDS "${_file_path}"
)
add_custom_command(
OUTPUT "${_html_out}"
COMMAND ${ASCIIDOC_EXEC} -o "${_html_out}" "${_file_path}"
DEPENDS "${_file_path}"
)
add_custom_target(compton_html_${_file_we} ALL
DEPENDS "${_html_out}"
)
endforeach(_file)
else(ASCIIDOC_EXEC AND ASCIIDOC_A2X_EXEC)
message(WARNING "asciidoc/a2x not found. New man pages and HTML documentation will not be built.")
endif(ASCIIDOC_EXEC AND ASCIIDOC_A2X_EXEC)
endif(NEW_DOC)
# == Install ==
include(GNUInstallDirs)
install(FILES
"compton.1"
"compton-trans.1"
DESTINATION "${CMAKE_INSTALL_MANDIR}" COMPONENT doc)