Skip to content

Commit

Permalink
fix: git-hash目标导致无变更时仍重新编译
Browse files Browse the repository at this point in the history
Close #8
  • Loading branch information
DawningW committed Apr 22, 2024
1 parent fd9210f commit 2e08c88
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
6 changes: 3 additions & 3 deletions cmake/git-hash.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif()
message(STATUS "Git hash is ${GIT_HASH}")

# generate file git_hash.h
file(WRITE
${TARGET_DIR}/generated/git_hash.h
"#define CRP_GIT_HASH \"${GIT_HASH}\"\n" # MSVC .rc need LF
file(CONFIGURE
OUTPUT ${TARGET_DIR}/generated/git_hash.h
CONTENT "#define CRP_GIT_HASH \"${GIT_HASH}\"\n" # MSVC .rc need LF
)
10 changes: 1 addition & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,13 @@ configure_file(
@ONLY
)

add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/generated/git_hash.h
ALL
add_custom_target(git_hash
COMMAND
${CMAKE_COMMAND} -D TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} -P ${CMAKE_MODULE_DIR}/git-hash.cmake
WORKING_DIRECTORY
${CoralReefPlayer_SOURCE_DIR}
)

add_custom_target(git_hash ALL
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/generated/git_hash.h
)

add_library(${PROJECT_NAME}
${CMAKE_CURRENT_BINARY_DIR}/generated/coralreefplayer.h
dllmain.cpp
Expand Down

0 comments on commit 2e08c88

Please sign in to comment.