Skip to content

Commit 05108ed

Browse files
committed
cmake: make possible to use PCH with compilers with subcommands
1 parent 49b4182 commit 05108ed

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,13 @@ function(ADD_PRECOMPILED_HEADER Target)
413413
try_c_cxx_flag(PCH "-pch")
414414

415415
if (PCH)
416+
# CMAKE_CXX_COMPILER_ARG1 is used with compilers using subcommands.
417+
# For example when doing: cmake -D'CMAKE_CXX_COMPILER'='zig;c++'
418+
# CMAKE_CXX_COMPILER will be "zig",
419+
# CMAKE_CXX_COMPILER_ARG1 will be "c++".
416420
add_custom_command(OUTPUT "${OBJ_DIR}/${Target}.h.gch"
417-
COMMAND ${PNACLPYTHON_PREFIX2} ${CMAKE_CXX_COMPILER} ${Defs} ${Flags} -x c++-header ${Header} -o "${OBJ_DIR}/${Target}.h.gch"
421+
COMMAND ${PNACLPYTHON_PREFIX2} ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}
422+
${Defs} ${Flags} -x c++-header ${Header} -o "${OBJ_DIR}/${Target}.h.gch"
418423
DEPENDS ${Header}
419424
IMPLICIT_DEPENDS CXX ${Header}
420425
)

0 commit comments

Comments
 (0)