Skip to content

Commit df20a8c

Browse files
authored
Use cppfront's new -o flag to avoid copying. (#5)
Previously, cppfront would always output the generated source file to the current directory and with the same base name as the input file. Now that -o exists, we have control over this and the custom command we need to drive cppfront can be simpler.
1 parent 56a0e86 commit df20a8c

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

cmake/CppfrontHelpers.cmake

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ function(_cppfront_unique_name base hash outvar)
2020
endfunction()
2121

2222
function(_cppfront_generate_source src out)
23-
# TODO: there's probably something nicer/more user-friendly to be
24-
# done here, but it's maybe not worth thinking about until cppfront's
25-
# command line improves.
26-
2723
file(REAL_PATH "${src}" src)
2824
string(SHA256 src_hash "${src}")
2925

@@ -38,15 +34,12 @@ function(_cppfront_generate_source src out)
3834

3935
# assume no SHA256 collisions
4036
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/_cppfront/")
41-
set(src_file "${CMAKE_BINARY_DIR}/_cppfront/${basename}.cpp2")
4237
set(out_file "${CMAKE_BINARY_DIR}/_cppfront/${basename}.cpp")
4338

4439
add_custom_command(
4540
OUTPUT "${out_file}"
46-
COMMAND "${CMAKE_COMMAND}" -E copy "${src}" "${src_file}"
47-
COMMAND cppfront::cppfront "${basename}.cpp2" ${CPPFRONT_FLAGS}
48-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/_cppfront"
49-
DEPENDS "${src}" cppfront::cppfront
41+
COMMAND cppfront::cppfront "${src}" -o "${out_file}" ${CPPFRONT_FLAGS}
42+
DEPENDS cppfront::cppfront "${src}"
5043
VERBATIM
5144
)
5245

0 commit comments

Comments
 (0)