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

View File

@ -192,7 +192,9 @@ if(ENABLE_GAME)
Boost::locale
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})
@ -229,7 +231,9 @@ if(ENABLE_TESTS)
Boost::filesystem
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})
endif(ENABLE_TESTS)
@ -266,7 +270,9 @@ if(ENABLE_SERVER)
endif(WIN32)
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})
endif(ENABLE_SERVER)
@ -304,7 +310,9 @@ if(ENABLE_CAMPAIGN_SERVER)
endif(WIN32)
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})
endif(ENABLE_CAMPAIGN_SERVER)