Fix autorevision target not working on win32 or when disabled.

This commit is contained in:
Pentarctagon 2021-05-12 23:44:14 -05:00
parent 6794f231e5
commit 4030e572ea
No known key found for this signature in database
GPG Key ID: 9456BC54A21DBFA0
2 changed files with 34 additions and 22 deletions

View File

@ -113,28 +113,32 @@ if(NOT CMAKE_BUILD_TYPE)
endif(NOT CMAKE_BUILD_TYPE) endif(NOT CMAKE_BUILD_TYPE)
if(NOT DEFINED ENABLE_DISPLAY_REVISION) if(NOT DEFINED ENABLE_DISPLAY_REVISION)
# Test whether the code is used in a repository if not autorevision will # can't run the shell script on windows
# fail and should be disabled by default. If inside a repository enable if(NOT WIN32)
# the display of revision numbers by default. # Test whether the code is used in a repository if not autorevision will
execute_process( # fail and should be disabled by default. If inside a repository enable
COMMAND ${CMAKE_SOURCE_DIR}/utils/autorevision.sh -t h > ${CMAKE_CURRENT_BINARY_DIR}/revision.dummy # the display of revision numbers by default.
WORKING_DIRECTORY execute_process(
${CMAKE_SOURCE_DIR} COMMAND ${CMAKE_SOURCE_DIR}/utils/autorevision.sh -t h > ${CMAKE_CURRENT_BINARY_DIR}/revision.dummy
OUTPUT_VARIABLE WORKING_DIRECTORY
ENABLE_DISPLAY_REVISION_TEST_OUTPUT ${CMAKE_SOURCE_DIR}
ERROR_VARIABLE OUTPUT_VARIABLE
ENABLE_DISPLAY_REVISION_TEST_ERRNO ENABLE_DISPLAY_REVISION_TEST_OUTPUT
) ERROR_VARIABLE
ENABLE_DISPLAY_REVISION_TEST_ERRNO
)
if("${ENABLE_DISPLAY_REVISION_TEST_ERRNO}" STREQUAL "") if("${ENABLE_DISPLAY_REVISION_TEST_ERRNO}" STREQUAL "")
set(DEFAULT_ENABLE_DISPLAY_REVISION true) set(DEFAULT_ENABLE_DISPLAY_REVISION true)
else()
set(DEFAULT_ENABLE_DISPLAY_REVISION false)
endif()
unset(ENABLE_DISPLAY_REVISION_TEST_OUTPUT)
unset(ENABLE_DISPLAY_REVISION_TEST_ERRNO)
else() else()
set(DEFAULT_ENABLE_DISPLAY_REVISION false) set(DEFAULT_ENABLE_DISPLAY_REVISION false)
endif() endif()
unset(ENABLE_DISPLAY_REVISION_TEST_OUTPUT)
unset(ENABLE_DISPLAY_REVISION_TEST_ERRNO)
endif() endif()
option( option(

View File

@ -192,7 +192,9 @@ if(ENABLE_GAME)
Boost::locale Boost::locale
Boost::filesystem Boost::filesystem
) )
add_dependencies(wesnoth wesnoth-revision) if(ENABLE_DISPLAY_REVISION)
add_dependencies(wesnoth wesnoth-revision)
endif()
set_target_properties(wesnoth PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}wesnoth${BINARY_SUFFIX}) set_target_properties(wesnoth PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}wesnoth${BINARY_SUFFIX})
@ -229,7 +231,9 @@ if(ENABLE_TESTS)
Boost::filesystem Boost::filesystem
Boost::unit_test_framework Boost::unit_test_framework
) )
add_dependencies(boost_unit_tests wesnoth-revision) if(ENABLE_DISPLAY_REVISION)
add_dependencies(boost_unit_tests wesnoth-revision)
endif()
set_target_properties(boost_unit_tests PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}boost_unit_tests${BINARY_SUFFIX}) set_target_properties(boost_unit_tests PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}boost_unit_tests${BINARY_SUFFIX})
endif(ENABLE_TESTS) endif(ENABLE_TESTS)
@ -266,7 +270,9 @@ if(ENABLE_SERVER)
endif(WIN32) endif(WIN32)
set_target_properties(wesnothd PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}wesnothd${BINARY_SUFFIX}) set_target_properties(wesnothd PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}wesnothd${BINARY_SUFFIX})
add_dependencies(wesnothd wesnoth-revision) if(ENABLE_DISPLAY_REVISION)
add_dependencies(wesnothd wesnoth-revision)
endif()
install(TARGETS wesnothd DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS wesnothd DESTINATION ${CMAKE_INSTALL_BINDIR})
endif(ENABLE_SERVER) endif(ENABLE_SERVER)
@ -304,7 +310,9 @@ if(ENABLE_CAMPAIGN_SERVER)
endif(WIN32) endif(WIN32)
set_target_properties(campaignd PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}campaignd${BINARY_SUFFIX}) set_target_properties(campaignd PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}campaignd${BINARY_SUFFIX})
add_dependencies(campaignd wesnoth-revision) if(ENABLE_DISPLAY_REVISION)
add_dependencies(campaignd wesnoth-revision)
endif()
install(TARGETS campaignd DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS campaignd DESTINATION ${CMAKE_INSTALL_BINDIR})
endif(ENABLE_CAMPAIGN_SERVER) endif(ENABLE_CAMPAIGN_SERVER)