mirror of https://git.tukaani.org/xz.git
CMake: Use configure_file() to copy a file
I had missed this simpler method before. It does create a dependency
so that if .in.h changes the copying is done again.
(cherry picked from commit de215a0517
)
This commit is contained in:
parent
52a8c87f37
commit
809e69f1f5
|
@ -1578,17 +1578,14 @@ if(NOT HAVE_GETOPT_LONG)
|
||||||
# the Autotools build (m4/getopt.m4).
|
# the Autotools build (m4/getopt.m4).
|
||||||
target_compile_definitions(libgnu PUBLIC "__GETOPT_PREFIX=rpl_")
|
target_compile_definitions(libgnu PUBLIC "__GETOPT_PREFIX=rpl_")
|
||||||
|
|
||||||
# Create a custom copy command to copy the getopt header to the build
|
# Copy the getopt header to the build directory and re-copy it
|
||||||
# directory and re-copy it if it is updated. (Gnulib does it this way
|
# if it is updated. (Gnulib does it this way because it allows
|
||||||
# because it allows choosing which .in.h files to actually use in the
|
# choosing which .in.h files to actually use in the build. We
|
||||||
# build. We need just getopt.h so this is a bit overcomplicated for
|
# need just getopt.h so this is a bit overcomplicated for
|
||||||
# a single header file only.)
|
# a single header file only.)
|
||||||
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/lib/getopt.h"
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lib/getopt.in.h"
|
||||||
COMMAND "${CMAKE_COMMAND}" -E copy
|
"${CMAKE_CURRENT_BINARY_DIR}/lib/getopt.h"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/lib/getopt.in.h"
|
COPYONLY)
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/lib/getopt.h"
|
|
||||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/lib/getopt.in.h"
|
|
||||||
VERBATIM)
|
|
||||||
|
|
||||||
target_sources(libgnu PRIVATE
|
target_sources(libgnu PRIVATE
|
||||||
lib/getopt1.c
|
lib/getopt1.c
|
||||||
|
|
Loading…
Reference in New Issue