File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,16 +14,26 @@ execute_process(
1414
1515if (GIT_DIR)
1616 message (STATUS "Detected git repository. Automatic commit ID tracking is enabled." )
17-
18- # Generate commit ID header file in source dir if we are in a git repository
19- add_custom_command (
20- OUTPUT include /commit_id.h
21- COMMAND sh -c "echo '/* Auto-generated file. DO NOT EDIT */' > ${CMAKE_CURRENT_BINARY_DIR } /include/commit_id.h"
22- COMMAND sh -c "echo \" #define GIT_COMMIT_ID \\\" $(git describe --always --abbrev=0 --dirty)\\\"\" >> ${CMAKE_CURRENT_BINARY_DIR } /include/commit_id.h"
23- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR }
24- VERBATIM
25- DEPENDS always_rebuild
26- )
17+ if (OCRE_COMMIT_ID_IN_SRC_DIR)
18+ add_custom_command (
19+ OUTPUT commit_id.h
20+ COMMAND sh -c "echo '/* Auto-generated file. DO NOT EDIT */' > commit_id.h"
21+ COMMAND sh -c "echo \" #define GIT_COMMIT_ID \\\" $(git describe --always --abbrev=0 --dirty)\\\"\" >> commit_id.h"
22+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR }
23+ VERBATIM
24+ DEPENDS always_rebuild
25+ )
26+ add_custom_target (ocre_commit_id DEPENDS commit_id.h )
27+ else ()
28+ add_custom_command (
29+ OUTPUT commit_id.h
30+ COMMAND sh -c "echo '/* Auto-generated file. DO NOT EDIT */' > ${CMAKE_CURRENT_BINARY_DIR } /include/commit_id.h"
31+ COMMAND sh -c "echo \" #define GIT_COMMIT_ID \\\" $(git describe --always --abbrev=0 --dirty)\\\"\" >> ${CMAKE_CURRENT_BINARY_DIR } /include/commit_id.h"
32+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR }
33+ VERBATIM
34+ DEPENDS always_rebuild
35+ )
36+ endif ()
2737endif ()
2838
2939file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR } /include/ocre )
@@ -50,7 +60,7 @@ target_sources(OcreCommon
5060 PRIVATE
5161 common.c
5262 include /build_info.h
53- include / commit_id.h
63+ commit_id.h
5464)
5565
5666target_include_directories (OcreCommon
You can’t perform that action at this time.
0 commit comments