From 4030e572ea34c12926f613a76cdfb7130fa358b0 Mon Sep 17 00:00:00 2001 From: Pentarctagon Date: Wed, 12 May 2021 23:44:14 -0500 Subject: [PATCH] Fix autorevision target not working on win32 or when disabled. --- CMakeLists.txt | 40 ++++++++++++++++++++++------------------ src/CMakeLists.txt | 16 ++++++++++++---- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d4c7057812..49df563de87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f5fa918e62a..bbd79296a52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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)