Commit b474fd3d authored by Ben Boeckel's avatar Ben Boeckel
Browse files

cmake: add rules for installing scripts

parent 13566fd6
cmake_minimum_required(VERSION 3.1)
project(formatters NONE)
add_subdirectory(src)
function (add_formatter name)
set(tools_exist TRUE)
foreach (tool IN LISTS ARGN)
find_program("TOOL_${tool}"
NAMES "${tool}"
DOC "The path to the ${tool} formatting tool")
if (NOT TOOL_${tool})
set(tools_exist FALSE)
endif ()
endforeach ()
set_property(GLOBAL APPEND
PROPERTY formatters "${name}")
set_property(GLOBAL APPEND
PROPERTY "formatter_${name}_tools" "${tools_exist}")
set_property(GLOBAL APPEND
PROPERTY "formatter_${name}_script" "${CMAKE_CURRENT_SOURCE_DIR}/format.${name}")
option("ENABLE_${name}" "Install the ${tool} formatter script" "${tools_exist}")
if (ENABLE_${name})
install_formatter("${name}")
endif ()
endfunction ()
function (install_formatter name)
install(
PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/format.${name}"
DESTINATION "bin"
COMPONENT "formatters")
install(
FILES "${CMAKE_CURRENT_SOURCE_DIR}/${name}.yaml"
DESTINATION "share/formatters/examples"
COMPONENT "examples")
endfunction ()
add_subdirectory(c)
add_subdirectory(python)
add_subdirectory(rust)
add_formatter(clang-format clang-format)
add_formatter(autopep8 autopep8)
add_formatter(pep8 pep8)
add_formatter(flake8 flake8)
add_formatter(rustfmt rustfmt)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment