Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

swh:1:snp:597f10704966a63e22a6690fc91719ea5d363ec6
  • Code
  • Branches (1)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • 31424c6
  • /
  • Scripts
  • /
  • CMakeLists.txt
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
content badge Iframe embedding
swh:1:cnt:a20c71647bff7e0722e6a9faec0d927cfb841a9c
directory badge Iframe embedding
swh:1:dir:b1342126a4d6472fad3f6575a53883ef3afe21f6
revision badge
swh:1:rev:35742ac3ab1ae42cf2bbe8761fd7c8e630a638c4
snapshot badge
swh:1:snp:597f10704966a63e22a6690fc91719ea5d363ec6

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 35742ac3ab1ae42cf2bbe8761fd7c8e630a638c4 authored by JoshWolper on 28 October 2020, 15:53:00 UTC
Add files via upload
Tip revision: 35742ac
CMakeLists.txt
set(GIT_PATH "NOTSET" CACHE STRING "Absolute path to the git executable")
set(PYTHON_NAME "python" CACHE STRING "Name of the python executable, eg. python2")
set(PYTHON_PATH "NOTSET" CACHE STRING "Absolute path to the python executable")
set(CLANGFORMAT_PATH "NOTSET" CACHE STRING "Absolute path to the clang-format executable")
set(CLANGFORMAT_STYLE "file" CACHE STRING "Paremter pass to clang-format -style=<here>")
set(IGNORE_LIST "" CACHE STRING "Semi colon separeted list of directories to ignore")

if("${GIT_PATH}" STREQUAL "NOTSET")
	find_program(FIND_GIT git)
	if("${FIND_GIT}" STREQUAL "FIND_GIT-NOTFOUND")
		message(FATAL_ERROR "Could not find 'git' please set GIT_PATH:STRING")
	else()
		set(GIT_PATH ${FIND_GIT})
		message(STATUS "Found: ${GIT_PATH}")
	endif()
else()
	if(NOT EXISTS ${GIT_PATH})
		message(WARNING "Could not find git: ${GIT_PATH}")
	else()
		message(STATUS "Found: ${GIT_PATH}")
	endif()
endif()

if("${PYTHON_PATH}" STREQUAL "NOTSET")
	find_program(FIND_PYTHON ${PYTHON_NAME})
	if("${FIND_PYTHON}" STREQUAL "FIND_PYTHON-NOTFOUND")
		message(FATAL_ERROR "Could not find '${PYTHON_NAME}' please set PYTHON_PATH:STRING")
	else()
		set(PYTHON_PATH ${FIND_PYTHON})
		message(STATUS "Found: ${PYTHON_PATH}")
	endif()
else()
	if(NOT EXISTS ${PYTHON_PATH})
		message(WARNING "Could not find python: ${PYTHON_PATH}")
	else()
		message(STATUS "Found: ${PYTHON_PATH}")
	endif()
endif()

if("${CLANGFORMAT_PATH}" STREQUAL "NOTSET")
	find_program(FIND_CLANGFORMAT clang-format)
	if("${FIND_CLANGFORMAT}" STREQUAL "FIND_CLANGFORMAT-NOTFOUND")
		message(FATAL_ERROR "Could not find 'clang-format' please set CLANGFORMAT_PATH:STRING")
	else()
		set(CLANGFORMAT_PATH ${FIND_CLANGFORMAT})
		message(STATUS "Found: ${CLANGFORMAT_PATH}")
	endif()
else()
	if(NOT EXISTS ${CLANGFORMAT_PATH})
		message(WARNING "Could not find clang-format: ${CLANGFORMAT_PATH}")
	else()
		message(STATUS "Found: ${CLANGFORMAT_PATH}")
	endif()
endif()

set(SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/git-cmake-format.py)
string(REGEX REPLACE "\\\\" "/" GIT_PATH ${GIT_PATH})
string(REGEX REPLACE "\\\\" "/" PYTHON_PATH ${PYTHON_PATH})
string(REGEX REPLACE "\\\\" "/" CLANGFORMAT_PATH ${CLANGFORMAT_PATH})

execute_process(COMMAND git rev-parse --show-toplevel
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  OUTPUT_VARIABLE GIT_ROOT
  OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT GIT_ROOT)
  message(WARNING "Not in a git repository")
else()
  message(STATUS "Found git root: ${GIT_ROOT}")
  configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/git-pre-commit-hook
    ${GIT_ROOT}/.git/hooks/pre-commit)
  if(EXISTS ${GIT_ROOT}/Working)
    execute_process(COMMAND git rev-parse --show-toplevel
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Working
      OUTPUT_VARIABLE GIT_WORKING_ROOT
      OUTPUT_STRIP_TRAILING_WHITESPACE)

    configure_file(
      ${CMAKE_CURRENT_SOURCE_DIR}/git-pre-commit-hook
      ${GIT_ROOT}/Working/.git/hooks/pre-commit)
  endif()
endif()

add_custom_target(format ALL
	${PYTHON_PATH} ${SCRIPT} --cmake ${GIT_PATH} ${CLANGFORMAT_PATH} -style=${CLANGFORMAT_STYLE} -ignore=${IGNORE_LIST}
	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API