From 64d0f86d8dc2e477cf0dcea23467d2b1fffcae38 Mon Sep 17 00:00:00 2001 From: wangqr Date: Wed, 11 Mar 2020 17:07:33 -0400 Subject: [PATCH] Add git_version.h generation to CMake --- .travis.yml | 1 - CMakeLists.txt | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 983bc82d3..1ccf3e2e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -86,7 +86,6 @@ script: make test || travis_terminate 1; coveralls --exclude vendor --exclude src --exclude build --exclude tools --exclude libaegisub/windows > /dev/null; else - ./build/version.sh .; mkdir build-dir; cd build-dir; cmake -DCMAKE_CXX_FLAGS='-Wall -Wextra -Wno-unused-parameter -pedantic' -DCMAKE_C_FLAGS='-Wall' -DWITH_STARTUPLOG=ON -DWITH_TEST=ON ..; diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e5e7c93f..8459bb1b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -470,6 +470,23 @@ add_executable(Aegisub WIN32 target_link_libraries(Aegisub ${CMAKE_DL_LIBS} libaegisub luabins luajit resrc csri) target_compile_definitions(Aegisub PRIVATE CMAKE_BUILD) +if(WIN32) + if(NOT EXISTS "${PROJECT_SOURCE_DIR}/build/git_version.h") + message(SEND_ERROR + "build/git_version.h not found.\n" + "Automatic generation of build/git_version.h is not supported on Windows. Please run\n" + " build/version.sh .\n" + "at the source directory from an environment with bash and git. You may use WSL, msys (git bash), or Cygwin." + ) + endif() +else() + add_custom_target(git_version build/version.sh . + BYPRODUCTS "${PROJECT_SOURCE_DIR}/build/git_version.h" "${PROJECT_SOURCE_DIR}/build/git_version.xml" + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" + ) + add_dependencies(Aegisub git_version) +endif() + set(WITH_BUILD_CREDIT OFF CACHE BOOL "Whether show build credit in about dialog") if(WITH_BUILD_CREDIT) set(BUILD_CREDIT "" CACHE STRING "Build credit shown in about dialog")