Skip to content

Commit 64d0f86

Browse files
committed
Add git_version.h generation to CMake
1 parent b6b2193 commit 64d0f86

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ script:
8686
make test || travis_terminate 1;
8787
coveralls --exclude vendor --exclude src --exclude build --exclude tools --exclude libaegisub/windows > /dev/null;
8888
else
89-
./build/version.sh .;
9089
mkdir build-dir;
9190
cd build-dir;
9291
cmake -DCMAKE_CXX_FLAGS='-Wall -Wextra -Wno-unused-parameter -pedantic' -DCMAKE_C_FLAGS='-Wall' -DWITH_STARTUPLOG=ON -DWITH_TEST=ON ..;

CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,23 @@ add_executable(Aegisub WIN32
470470
target_link_libraries(Aegisub ${CMAKE_DL_LIBS} libaegisub luabins luajit resrc csri)
471471
target_compile_definitions(Aegisub PRIVATE CMAKE_BUILD)
472472

473+
if(WIN32)
474+
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/build/git_version.h")
475+
message(SEND_ERROR
476+
"build/git_version.h not found.\n"
477+
"Automatic generation of build/git_version.h is not supported on Windows. Please run\n"
478+
" build/version.sh .\n"
479+
"at the source directory from an environment with bash and git. You may use WSL, msys (git bash), or Cygwin."
480+
)
481+
endif()
482+
else()
483+
add_custom_target(git_version build/version.sh .
484+
BYPRODUCTS "${PROJECT_SOURCE_DIR}/build/git_version.h" "${PROJECT_SOURCE_DIR}/build/git_version.xml"
485+
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
486+
)
487+
add_dependencies(Aegisub git_version)
488+
endif()
489+
473490
set(WITH_BUILD_CREDIT OFF CACHE BOOL "Whether show build credit in about dialog")
474491
if(WITH_BUILD_CREDIT)
475492
set(BUILD_CREDIT "" CACHE STRING "Build credit shown in about dialog")

0 commit comments

Comments
 (0)