mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 03:39:43 -06:00
FindBISON, FindFLEX: Create output directories
Bison and Flex executables at the time of writing don't create output directories when generating files. In most cases this isn't issue if the build directory is created before running bison or flex. If any of the output directories that can be determined isn't available, these modules now create them before running the bison or flex command. Issue: #19529
This commit is contained in:
@@ -276,7 +276,27 @@ if(BISON_EXECUTABLE)
|
||||
endif()
|
||||
unset(_BISON_CMP0088)
|
||||
|
||||
# Bison cannot create output directories. Create any missing determined
|
||||
# directories where the files will be generated if they don't exist yet.
|
||||
set(_BisonMakeDirectoryCommand "")
|
||||
foreach(output IN LISTS BISON_TARGET_outputs)
|
||||
cmake_path(GET output PARENT_PATH dir)
|
||||
if(dir)
|
||||
list(APPEND _BisonMakeDirectoryCommand ${dir})
|
||||
endif()
|
||||
unset(dir)
|
||||
endforeach()
|
||||
if(_BisonMakeDirectoryCommand)
|
||||
list(REMOVE_DUPLICATES _BisonMakeDirectoryCommand)
|
||||
list(
|
||||
PREPEND
|
||||
_BisonMakeDirectoryCommand
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${BISON_TARGET_outputs}
|
||||
${_BisonMakeDirectoryCommand}
|
||||
COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${_BisonInput}
|
||||
VERBATIM
|
||||
DEPENDS ${_BisonInput}
|
||||
@@ -295,7 +315,7 @@ if(BISON_EXECUTABLE)
|
||||
set(BISON_${Name}_OUTPUT_HEADER "${BISON_TARGET_output_header}")
|
||||
|
||||
unset(_BisonInput)
|
||||
|
||||
unset(_BisonMakeDirectoryCommand)
|
||||
endif()
|
||||
endmacro()
|
||||
#
|
||||
|
||||
@@ -211,8 +211,28 @@ if(FLEX_EXECUTABLE)
|
||||
list(APPEND _flex_EXE_OPTS --header-file=${_flex_OUTPUT_HEADER_ABS})
|
||||
endif()
|
||||
|
||||
# Flex cannot create output directories. Create any missing determined
|
||||
# directories where the files will be generated if they don't exist yet.
|
||||
set(_flex_MAKE_DIRECTORY_COMMAND "")
|
||||
foreach(output IN LISTS _flex_TARGET_OUTPUTS)
|
||||
cmake_path(GET output PARENT_PATH dir)
|
||||
if(dir)
|
||||
list(APPEND _flex_MAKE_DIRECTORY_COMMAND ${dir})
|
||||
endif()
|
||||
unset(dir)
|
||||
endforeach()
|
||||
if(_flex_MAKE_DIRECTORY_COMMAND)
|
||||
list(REMOVE_DUPLICATES _flex_MAKE_DIRECTORY_COMMAND)
|
||||
list(
|
||||
PREPEND
|
||||
_flex_MAKE_DIRECTORY_COMMAND
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
)
|
||||
endif()
|
||||
|
||||
get_filename_component(_flex_EXE_NAME_WE "${FLEX_EXECUTABLE}" NAME_WE)
|
||||
add_custom_command(OUTPUT ${_flex_TARGET_OUTPUTS}
|
||||
${_flex_MAKE_DIRECTORY_COMMAND}
|
||||
COMMAND ${FLEX_EXECUTABLE} ${_flex_EXE_OPTS} -o${_flex_OUTPUT} ${_flex_INPUT}
|
||||
VERBATIM
|
||||
DEPENDS ${_flex_INPUT}
|
||||
@@ -228,12 +248,12 @@ if(FLEX_EXECUTABLE)
|
||||
unset(_flex_EXE_NAME_WE)
|
||||
unset(_flex_EXE_OPTS)
|
||||
unset(_flex_INPUT)
|
||||
unset(_flex_MAKE_DIRECTORY_COMMAND)
|
||||
unset(_flex_OUTPUT)
|
||||
unset(_flex_OUTPUT_HEADER)
|
||||
unset(_flex_OUTPUT_HEADER_ABS)
|
||||
unset(_flex_TARGET_OUTPUTS)
|
||||
unset(_flex_WORKING_DIR)
|
||||
|
||||
endif()
|
||||
endmacro()
|
||||
#============================================================
|
||||
|
||||
Reference in New Issue
Block a user