Cmake build: Correct creation of lyx_date.h because of

not defined behaviour cmake command copy_if_different
in case, the destination is not present
This commit is contained in:
Kornel Benko 2013-01-09 16:31:45 +01:00
parent 75483b612c
commit 46e51018d5

View File

@ -46,9 +46,24 @@ if(LYX_GITVERSION)
endif()
endif()
configure_file(${TOP_CMAKE_PATH}/lyx_date.h.cmake ${TOP_BINARY_DIR}/lyx_date.tmp)
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TOP_BINARY_DIR}/lyx_date.tmp ${TOP_BINARY_DIR}/lyx_date.h
COMMAND ${CMAKE_COMMAND} -E remove ${TOP_BINARY_DIR}/lyx_date.tmp
)
if(NOT EXISTS ${TOP_BINARY_DIR}/lyx_date.h)
configure_file(${TOP_CMAKE_PATH}/lyx_date.h.cmake ${TOP_BINARY_DIR}/lyx_date.h)
else()
configure_file(${TOP_CMAKE_PATH}/lyx_date.h.cmake ${TOP_BINARY_DIR}/lyx_date.tmp)
message(STATUS "Created ${TOP_BINARY_DIR}/lyx_date.tmp")
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TOP_BINARY_DIR}/lyx_date.tmp ${TOP_BINARY_DIR}/lyx_date.h
ERROR_VARIABLE copy_err
)
if(copy_err)
message(FATAL_ERROR "${CMAKE_COMMAND} -E ${copy_command} not working")
endif()
EXECUTE_PROCESS(
COMMAND ${CMAKE_COMMAND} -E remove ${TOP_BINARY_DIR}/lyx_date.tmp
)
endif()