Fix generating version.cpp

Also removes BYPRODUCT dependency on CMake 3.2
This commit is contained in:
Howard Chu 2018-03-21 16:26:54 +00:00
parent 5710edf040
commit 522be96fe4
No known key found for this signature in database
GPG Key ID: FD2A70B44AB11BA7

View File

@ -37,14 +37,16 @@ if ("$Format:$" STREQUAL "")
write_static_version_header("release") write_static_version_header("release")
elseif (GIT_FOUND OR Git_FOUND) elseif (GIT_FOUND OR Git_FOUND)
message(STATUS "Found Git: ${GIT_EXECUTABLE}") message(STATUS "Found Git: ${GIT_EXECUTABLE}")
add_custom_target(genversion ALL add_custom_command(
OUTPUT "${CMAKE_BINARY_DIR}/version.cpp"
COMMAND "${CMAKE_COMMAND}" COMMAND "${CMAKE_COMMAND}"
"-D" "GIT=${GIT_EXECUTABLE}" "-D" "GIT=${GIT_EXECUTABLE}"
"-D" "TO=${CMAKE_BINARY_DIR}/version.cpp" "-D" "TO=${CMAKE_BINARY_DIR}/version.cpp"
"-P" "cmake/GenVersion.cmake" "-P" "cmake/GenVersion.cmake"
BYPRODUCTS "${CMAKE_BINARY_DIR}/version.cpp"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
else() else()
message(STATUS "WARNING: Git was not found!") message(STATUS "WARNING: Git was not found!")
write_static_version_header("unknown") write_static_version_header("unknown")
endif () endif ()
add_custom_target(genversion ALL
DEPENDS "${CMAKE_BINARY_DIR}/version.cpp")