Commit 182454db authored by Brad King's avatar Brad King

cmake: teach add_formatter to support configured formatters

Check in the build tree before the source tree.
parent a3a0f318
......@@ -19,12 +19,18 @@ function (add_formatter name type)
endif ()
endforeach ()
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/format.${name}")
set(script "${CMAKE_CURRENT_BINARY_DIR}/format.${name}")
else()
set(script "${CMAKE_CURRENT_SOURCE_DIR}/format.${name}")
endif()
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}")
PROPERTY "formatter_${name}_script" "${script}")
option("ENABLE_${name}" "Install the ${tool} formatter script" "${tools_exist}")
......@@ -41,12 +47,18 @@ function (add_formatter name type)
endfunction ()
function (install_formatter name)
get_property(script GLOBAL PROPERTY "formatter_${name}_script")
install(
PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR}/format.${name}"
PROGRAMS "${script}"
DESTINATION "bin"
COMPONENT "formatters")
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${name}.yaml.in")
set(yaml_in "${CMAKE_CURRENT_BINARY_DIR}/${name}.yaml.in")
else()
set(yaml_in "${CMAKE_CURRENT_SOURCE_DIR}/${name}.yaml.in")
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${name}.yaml.in"
"${yaml_in}"
"${CMAKE_CURRENT_BINARY_DIR}/${name}.yaml"
@ONLY)
install(
......
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