2013-12-29 06:27:36 +00:00
|
|
|
# This directory contains Lean builtin libraries and Lua scripts
|
|
|
|
# needed to run Lean. The builtin Lean libraries are compiled
|
|
|
|
# using ${LEAN_BINARY_DIR}/shell/lean
|
|
|
|
# The library builtin is not a real library.
|
|
|
|
# It is just a hack to force CMake to consider our custom targets
|
2013-12-29 06:06:11 +00:00
|
|
|
add_library(builtin builtin.cpp)
|
|
|
|
|
2013-12-29 06:27:36 +00:00
|
|
|
# We copy files to the shell directory, to make sure we can test lean
|
|
|
|
# without installing it.
|
|
|
|
set(SHELL_DIR ${LEAN_BINARY_DIR}/shell)
|
|
|
|
|
2013-12-29 19:19:17 +00:00
|
|
|
file(GLOB LEANLIB "*.lua")
|
|
|
|
FOREACH(FILE ${LEANLIB})
|
|
|
|
get_filename_component(FNAME ${FILE} NAME)
|
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FNAME}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${FILE} ${CMAKE_CURRENT_BINARY_DIR}/${FNAME}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${FILE} ${SHELL_DIR}/${FNAME}
|
|
|
|
DEPENDS ${FILE})
|
|
|
|
add_custom_target("${FNAME}_builtin" DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FNAME})
|
|
|
|
add_dependencies(builtin "${FNAME}_builtin")
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${FNAME} DESTINATION library)
|
|
|
|
ENDFOREACH(FILE)
|
|
|
|
|
2013-12-29 10:44:49 +00:00
|
|
|
function(add_theory_core FILE ARG EXTRA_DEPS)
|
2013-12-29 06:06:11 +00:00
|
|
|
get_filename_component(BASENAME ${FILE} NAME_WE)
|
|
|
|
set(FNAME "${BASENAME}.olean")
|
2013-12-29 06:27:36 +00:00
|
|
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${FNAME}
|
2013-12-29 10:44:49 +00:00
|
|
|
COMMAND ${SHELL_DIR}/lean ${ARG} -o ${CMAKE_CURRENT_BINARY_DIR}/${FNAME} ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}
|
2013-12-29 06:27:36 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${FNAME} ${SHELL_DIR}/${FNAME}
|
2013-12-29 10:44:49 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} ${SHELL_DIR}/lean ${EXTRA_DEPS})
|
2013-12-29 06:27:36 +00:00
|
|
|
add_custom_target(${FNAME}_builtin DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${FNAME})
|
2013-12-29 06:06:11 +00:00
|
|
|
add_dependencies(builtin ${FNAME}_builtin)
|
2013-12-29 06:27:36 +00:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${FNAME} DESTINATION library)
|
2013-12-29 10:44:49 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(add_kernel_theory FILE)
|
2013-12-29 19:19:17 +00:00
|
|
|
add_theory_core(${FILE} "-k" "${CMAKE_CURRENT_BINARY_DIR}/macros.lua")
|
2013-12-29 10:44:49 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(add_theory FILE)
|
|
|
|
add_theory_core(${FILE} "" "${CMAKE_CURRENT_BINARY_DIR}/basic.olean")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
add_kernel_theory("basic.lean")
|
|
|
|
add_theory("cast.lean")
|