Skip to content

Commit 098edeb

Browse files
committed
cmake: make possible to use PCH with compilers with subcommands
1 parent 1b51cc3 commit 098edeb

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
@@ -418,8 +418,13 @@ function(ADD_PRECOMPILED_HEADER Target)
418418
try_c_cxx_flag(PCH "-pch")
419419

420420
if (PCH)
421+
# CMAKE_CXX_COMPILER_ARG1 is used with compilers using subcommands.
422+
# For example when doing: cmake -D'CMAKE_CXX_COMPILER'='zig;c++'
423+
# CMAKE_CXX_COMPILER will be "zig",
424+
# CMAKE_CXX_COMPILER_ARG1 will be "c++".
421425
add_custom_command(OUTPUT "${OBJ_DIR}/${Target}.h.gch"
422-
COMMAND ${PNACLPYTHON_PREFIX2} ${CMAKE_CXX_COMPILER} ${Defs} ${Flags} -x c++-header ${Header} -o "${OBJ_DIR}/${Target}.h.gch"
426+
COMMAND ${PNACLPYTHON_PREFIX2} ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}
427+
${Defs} ${Flags} -x c++-header ${Header} -o "${OBJ_DIR}/${Target}.h.gch"
423428
DEPENDS ${Header}
424429
IMPLICIT_DEPENDS CXX ${Header}
425430
)

0 commit comments

Comments
 (0)