Browse Source

Add a `make doc` target to run Doxygen

pull/1/head
Daniel Scharrer 14 years ago
parent
commit
8d89a641fb
  1. 3
      CMakeLists.txt
  2. 60
      cmake/Doxygen.cmake
  3. 30
      cmake/StyleCheck.cmake
  4. 29
      cmake/VersionScript.cmake
  5. 49
      cmake/VersionString.cmake
  6. 1832
      doc/Doxyfile.in
  7. 15
      src/version.cpp.in

3
CMakeLists.txt

@ -16,6 +16,7 @@ include(VersionString)
include(CheckSymbolExists)
include(BuildType)
include(StyleCheck)
include(Doxygen)
include(TestBigEndian)
# Force re-checking libraries if the compiler or compiler flags change.
@ -173,3 +174,5 @@ install(FILES doc/innoextract.1 DESTINATION ${MAN_DIR}/man1 OPTIONAL)
# Additional targets.
add_style_check_target(style "${INNOEXTRACT_SOURCES}" "${ALL_INCLUDES}")
add_doxygen_target(doc "doc/Doxyfile.in" "VERSION" ".git" "${CMAKE_BINARY_DIR}/doc")

60
cmake/Doxygen.cmake

@ -0,0 +1,60 @@
# Copyright (C) 2011-2012 Daniel Scharrer
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the author(s) be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
find_package(Doxygen)
include(VersionString)
# Add a target that runs Doxygen on a configured Doxyfile
#
# Parameters:
# - TARGET_NAME the name of the target to add
# - DOXYFILE_IN the raw Doxyfile
# - VERSION_FILE VERSION file to be used by version_file()
# - GIT_DIR .git directory to be used by version_file()
# - OUT_DIR Doxygen output directory
#
# For the exact syntax of config options in DOXYFILE_IN see the documentation of the
# configure_file() cmake command.
#
# Available variables are those provided by version_file() as well as
# DOXYGEN_OUTPUT_DIR, which is set to OUT_DIR.
#
function(add_doxygen_target TARGET_NAME DOXYFILE_IN VERSION_FILE GIT_DIR OUT_DIR)
if(NOT DOXYGEN_EXECUTABLE)
return()
endif()
set(doxyfile "${CMAKE_BINARY_DIR}/Doxyfile.${TARGET_NAME}")
set(defines "-DDOXYGEN_OUTPUT_DIR=${OUT_DIR}")
version_file("${DOXYFILE_IN}" "${doxyfile}" "${VERSION_FILE}" "${GIT_DIR}" "${defines}")
add_custom_target(${TARGET_NAME}
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OUT_DIR}"
COMMAND ${DOXYGEN_EXECUTABLE} "${doxyfile}"
DEPENDS "${doxyfile}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Building doxygen documentation."
VERBATIM
SOURCES "${DOXYFILE_IN}"
)
endfunction(add_doxygen_target)

30
cmake/StyleCheck.cmake

@ -35,20 +35,26 @@ set(STYLE_FILTER ${STYLE_FILTER},-readability/todo)
# Annoyting to use with boost::program_options
set(STYLE_FILTER ${STYLE_FILTER},-whitespace/semicolon)
# Add a target that runs cpplint.py
#
# Parameters:
# - TARGET_NAME the name of the target to add
# - SOURCES_LIST a complete list of source files to check
# - INCLUDES_LIST a complete list of include files to check
function(add_style_check_target TARGET_NAME SOURCES_LIST INCLUDES_LIST)
if(PYTHONINTERP_FOUND)
add_custom_target(${TARGET_NAME}
COMMAND cmake -E chdir
"${CMAKE_SOURCE_DIR}"
"${PYTHON_EXECUTABLE}"
"${CMAKE_MODULE_PATH}/cpplint.py"
"--filter=${STYLE_FILTER}"
${SOURCES_LIST} ${INCLUDES_LIST}
DEPENDS ${SOURCES_LIST} ${INCLUDES_LIST} VERBATIM
)
if(NOT PYTHONINTERP_FOUND)
return()
endif()
add_custom_target(${TARGET_NAME}
COMMAND cmake -E chdir
"${CMAKE_SOURCE_DIR}"
"${PYTHON_EXECUTABLE}"
"${CMAKE_MODULE_PATH}/cpplint.py"
"--filter=${STYLE_FILTER}"
${SOURCES_LIST} ${INCLUDES_LIST}
DEPENDS ${SOURCES_LIST} ${INCLUDES_LIST} VERBATIM
)
endfunction(add_style_check_target)

29
cmake/VersionScript.cmake

@ -33,7 +33,33 @@ string(STRIP "${BASE_VERSION}" BASE_VERSION)
string(REGEX MATCHALL "[^\r\n]+" version_lines "${BASE_VERSION}")
set(BASE_VERSION_COUNT 0)
foreach(version_line IN LISTS version_lines)
set(BASE_VERSION_${BASE_VERSION_COUNT} "${version_line}")
# Find the last space
string(STRIP "${version_line}" version_line)
string(LENGTH "${version_line}" version_line_length)
set(version_line_split ${version_line_length})
foreach(i RANGE ${version_line_length})
if(${i} LESS ${version_line_length})
string(SUBSTRING "${version_line}" ${i} 1 version_line_char)
if(version_line_char STREQUAL " ")
set(version_line_split ${i})
endif()
endif()
endforeach()
# Get everything before the last space
string(SUBSTRING "${version_line}" 0 ${version_line_split} version_line_name)
string(STRIP "${version_line_name}" BASE_NAME_${BASE_VERSION_COUNT})
# Get everything after the last space
if(${version_line_split} LESS ${version_line_length})
math(EXPR num_length "${version_line_length} - ${version_line_split}")
string(SUBSTRING "${version_line}" ${version_line_split} ${num_length} version_line_num)
string(STRIP "${version_line_num}" BASE_NUMBER_${BASE_VERSION_COUNT})
endif()
math(EXPR BASE_VERSION_COUNT "${BASE_VERSION_COUNT} + 1")
endforeach()
@ -64,8 +90,9 @@ if(EXISTS "${GIT_DIR}")
if(GIT_COMMIT)
string(TOLOWER "${GIT_COMMIT}" GIT_COMMIT)
string(LENGTH "${GIT_COMMIT}" git_commit_length)
foreach(i RANGE "${git_commit_length}")
foreach(i RANGE ${git_commit_length})
string(SUBSTRING "${GIT_COMMIT}" 0 ${i} GIT_COMMIT_PREFIX_${i})
set(GIT_SUFFIX_${i} " + ${GIT_COMMIT_PREFIX_${i}}")
endforeach()
endif()

49
cmake/VersionString.cmake

@ -19,44 +19,55 @@
# Create a rule to generate a version string at compile time.
#
# An optional fifth argument can be used to add additional cmake defines.
#
# SRC is processed using the configure_file() cmake command
# at build to produce DST with the following variable available:
#
# - BASE_VERSION: The contents of the file specified by VERSION_FILE.
# - GIT_COMMIT: The current git commit. This variable is not defined if there is no GIT_DIR directory.
# - SHORT_GIT_COMMIT: The first 10 characters of the git commit.
# - BASE_VERSION: The contents of the file specified by VERSION_FILE
# - BASE_VERSION_COUNT: Number of lines in the VERSION file
# - BASE_VERSION_i: The i-th line of the VERSION file
# - BASE_NAME_i: Everything except the last component of the i-th line of the VERSION file
# - BASE_NUMBER_i: The last component of the i-th line of the VERSION file
# - GIT_COMMIT: The current git commit. (not defined if there is no GIT_DIR directory)
# - GIT_COMMIT_PREFIX_i: The first i characters of GIT_COMMIT (i=0..39)
# For the exact syntax of SRC see the documentation of the configure_file() cmake command.
#
# The version file is regenerated whenever VERSION_FILE or the current commit changes.
function(version_file SRC DST VERSION_FILE GIT_DIR)
get_filename_component(ABS_SRC "${SRC}" ABSOLUTE)
get_filename_component(ABS_DST "${DST}" ABSOLUTE)
get_filename_component(ABS_VERSION_FILE "${VERSION_FILE}" ABSOLUTE)
get_filename_component(ABS_GIT_DIR "${GIT_DIR}" ABSOLUTE)
get_filename_component(abs_src "${SRC}" ABSOLUTE)
get_filename_component(abs_dst "${DST}" ABSOLUTE)
get_filename_component(abs_version_file "${VERSION_FILE}" ABSOLUTE)
get_filename_component(abs_git_dir "${GIT_DIR}" ABSOLUTE)
set(defines)
if(${ARGC} GREATER 4)
set(defines ${ARGV4})
endif()
set(dependencies "${ABS_VERSION_FILE}" "${CMAKE_MODULE_PATH}/VersionScript.cmake")
set(dependencies "${abs_version_file}" "${CMAKE_MODULE_PATH}/VersionScript.cmake")
if(EXISTS "${ABS_GIT_DIR}/HEAD")
list(APPEND dependencies "${ABS_GIT_DIR}/HEAD")
if(EXISTS "${abs_git_dir}/HEAD")
list(APPEND dependencies "${abs_git_dir}/HEAD")
endif()
if(EXISTS "${ABS_GIT_DIR}/logs/HEAD")
list(APPEND dependencies "${ABS_GIT_DIR}/logs/HEAD")
if(EXISTS "${abs_git_dir}/logs/HEAD")
list(APPEND dependencies "${abs_git_dir}/logs/HEAD")
endif()
add_custom_command(
OUTPUT
"${ABS_DST}"
"${abs_dst}"
COMMAND
${CMAKE_COMMAND}
"-DINPUT=${ABS_SRC}"
"-DOUTPUT=${ABS_DST}"
"-DVERSION_FILE=${ABS_VERSION_FILE}"
"-DGIT_DIR=${ABS_GIT_DIR}"
"-DINPUT=${abs_src}"
"-DOUTPUT=${abs_dst}"
"-DVERSION_FILE=${abs_version_file}"
"-DGIT_DIR=${abs_git_dir}"
${defines}
-P "${CMAKE_MODULE_PATH}/VersionScript.cmake"
MAIN_DEPENDENCY
"${ABS_SRC}"
"${abs_src}"
DEPENDS
${dependencies}
COMMENT ""

1832
doc/Doxyfile.in

File diff suppressed because it is too large Load Diff

15
src/version.cpp.in

@ -22,13 +22,8 @@
/*!
* This file is automatically processed by cmake if the version or commit id changes.
* Available variables:
* - BASE_VERSION: The contents of the VERSION file.
* - BASE_VERSION_COUNT: Number of lines in the VERSION file.
* - BASE_VERSION_i: The i-th line of the VERSION file.
* - GIT_COMMIT: The current git commit. This variable is not defined if there is no .git directory.
* - GIT_COMMIT_PREFIX_i: The first i characters of the git commit (i=0..39).
* For the exact syntax see the documentation of the configure_file() cmake command.
* For available variables see cmake/VersionString.cmake.
*/
#cmakedefine GIT_COMMIT
@ -37,13 +32,7 @@
#error "Configure error - the VERSION file should specify exactly two lines!"
#endif
#ifdef GIT_COMMIT
#define GIT_SUFFIX " + ${GIT_COMMIT_PREFIX_5}"
#else
#define GIT_SUFFIX ""
#endif
const std::string innoextract_version = "${BASE_VERSION_0}" GIT_SUFFIX;
const std::string innoextract_version = "${BASE_VERSION_0}${GIT_SUFFIX_5}";
const std::string innosetup_versions = "${BASE_VERSION_1}";

Loading…
Cancel
Save