Skip to content

Commit 5ff7df0

Browse files
committed
Fix php_stubs target name collision with php_stubs directory name
Creating custom files and directories inside CMakeFiles must be done really carefully otherwise target collisions happen if target name has the same name as some directory inside CMakeFiles.
1 parent 7b0965e commit 5ff7df0

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

cmake/cmake/modules/PHP/Stubs.cmake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ endif()
9393
file(
9494
COPY
9595
${PROJECT_SOURCE_DIR}/build/gen_stub.php
96-
DESTINATION ${PROJECT_BINARY_DIR}/CMakeFiles/php_stubs
96+
DESTINATION ${PROJECT_BINARY_DIR}/CMakeFiles/PHP/Stubs
9797
)
9898

9999
block()
@@ -119,11 +119,11 @@ block()
119119
endforeach()
120120

121121
set(PHP_SOURCES "$<JOIN:$<REMOVE_DUPLICATES:${stubs}>,$<SEMICOLON>>")
122-
file(READ ${CMAKE_CURRENT_LIST_DIR}/Stubs/PHPStubsGenerator.cmake.in content)
122+
file(READ ${CMAKE_CURRENT_LIST_DIR}/Stubs/StubsGenerator.cmake.in content)
123123
string(CONFIGURE "${content}" content @ONLY)
124124
file(
125125
GENERATE
126-
OUTPUT ${PROJECT_BINARY_DIR}/CMakeFiles/php_stubs/PHPStubsGenerator.cmake
126+
OUTPUT ${PROJECT_BINARY_DIR}/CMakeFiles/PHP/Stubs/StubsGenerator.cmake
127127
CONTENT "${content}"
128128
)
129129

@@ -136,7 +136,8 @@ block()
136136
php_stubs ${targetOptions}
137137
COMMAND
138138
${CMAKE_COMMAND}
139-
-P ${PROJECT_BINARY_DIR}/CMakeFiles/php_stubs/PHPStubsGenerator.cmake
139+
-P ${PROJECT_BINARY_DIR}/CMakeFiles/PHP/Stubs/StubsGenerator.cmake
140140
VERBATIM
141+
COMMAND_EXPAND_LISTS
141142
)
142143
endblock()

cmake/cmake/modules/PHP/Stubs/PHPStubsGenerator.cmake.in renamed to cmake/cmake/modules/PHP/Stubs/StubsGenerator.cmake.in

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@ if(NOT CMAKE_SCRIPT_MODE_FILE)
77
endif()
88

99
set(sources "@PHP_SOURCES@")
10+
set(phpCommand "@PHP_COMMAND@")
11+
set(phpGenStubScriptSource "@PROJECT_SOURCE_DIR@/build/gen_stub.php")
1012

1113
# Ensure sources include only *.stub.php files.
1214
list(FILTER sources INCLUDE REGEX [[\.stub\.php$]])
1315

1416
# Create a list of sources that must be parsed by the generator.
15-
if(@PROJECT_SOURCE_DIR@/build/gen_stub.php IS_NEWER_THAN ${CMAKE_CURRENT_LIST_FILE})
16-
file(
17-
COPY
18-
@PROJECT_SOURCE_DIR@/build/gen_stub.php
19-
DESTINATION @PROJECT_BINARY_DIR@/CMakeFiles/php_stubs
20-
)
17+
if(${phpGenStubScriptSource} IS_NEWER_THAN ${CMAKE_CURRENT_LIST_FILE})
18+
file(COPY ${phpGenStubScriptSource} DESTINATION ${CMAKE_CURRENT_LIST_DIR})
2119
set(stubs ${sources})
2220
file(TOUCH ${CMAKE_CURRENT_LIST_FILE})
2321
else()
@@ -35,15 +33,10 @@ endif()
3533

3634
execute_process(
3735
COMMAND
38-
${CMAKE_COMMAND}
39-
-E cmake_echo_color --blue --bold
40-
"Regenerating *_arginfo.h headers from *.stub.php sources"
41-
)
42-
43-
execute_process(
36+
${CMAKE_COMMAND} -E cmake_echo_color --blue --bold
37+
"Regenerating *_arginfo.h headers from *.stub.php sources"
4438
COMMAND
45-
@PHP_COMMAND@ @PROJECT_BINARY_DIR@/CMakeFiles/php_stubs/gen_stub.php
46-
${stubs}
39+
${phpCommand} ${CMAKE_CURRENT_LIST_DIR}/gen_stub.php ${stubs}
4740
)
4841

4942
# Ensure that *_arginfo.h headers are newer than their *.stub.php sources.

0 commit comments

Comments
 (0)