Improve the concatenate_files macro introduced by Timo in r52179 + r52182 and hackfixed in r53914 . Notice that now it can take an arbitrary number of files to be concatenated. Hence you need to specify first the output file, and all the rest is the different files.

[FREELDR]
Use the improved concatenate_files macro.

svn path=/trunk/; revision=66946
This commit is contained in:
Hermès Bélusca-Maïto 2015-03-29 01:53:10 +00:00
parent d8714d6ad9
commit 02997eb8f4
2 changed files with 13 additions and 31 deletions

View file

@ -226,10 +226,13 @@ endif()
add_dependencies(freeldr_pe asm)
add_dependencies(freeldr_pe_dbg asm)
# Retrieve the full path to the generated file of the 'freeldr_pe' target
get_target_property(_freeldr_pe_output_file freeldr_pe LOCATION)
concatenate_files(
${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
freeldr_pe
${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys)
${_freeldr_pe_output_file})
add_custom_target(freeldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys)
@ -238,9 +241,9 @@ add_cd_file(TARGET freeldr FILE ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys DESTINAT
add_cd_file(TARGET freeldr FILE ${CMAKE_CURRENT_BINARY_DIR}/freeldr.sys DESTINATION loader NO_CAB NOT_IN_HYBRIDCD FOR livecd hybridcd NAME_ON_CD setupldr.sys)
concatenate_files(
${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys
${CMAKE_CURRENT_BINARY_DIR}/frldr16.bin
freeldr_pe
${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys)
${_freeldr_pe_output_file})
add_custom_target(setupldr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys)
add_cd_file(TARGET setupldr FILE ${CMAKE_CURRENT_BINARY_DIR}/setupldr.sys DESTINATION loader NO_CAB FOR bootcd regtest)

View file

@ -504,33 +504,12 @@ elseif(USE_FOLDER_STRUCTURE)
endfunction()
endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
macro(to_win_path _cmake_path _native_path)
string(REPLACE "/" "\\" ${_native_path} "${_cmake_path}")
endmacro()
# yeah the parameter mess sucks, but thats what works...
function(concatenate_files _file1 _target2 _output)
get_target_property(_file2 ${_target2} LOCATION)
to_win_path("${_file1}" _real_file1)
to_win_path("${_file2}" _real_file2)
to_win_path("${_output}" _real_output)
add_custom_command(
OUTPUT ${_output}
COMMAND cmd.exe /C "copy /Y /B ${_real_file1} + ${_real_file2} ${_real_output} > nul"
DEPENDS ${_file1}
DEPENDS ${_target2})
endfunction()
else()
macro(concatenate_files _file1 _target2 _output)
get_target_property(_file2 ${_target2} LOCATION)
add_custom_command(
OUTPUT ${_output}
COMMAND cat ${_file1} ${_file2} > ${_output}
DEPENDS ${_file1}
DEPENDS ${_target2})
endmacro()
endif()
macro(concatenate_files _output)
add_custom_command(
OUTPUT ${_output}
COMMAND native-cat ${ARGN} > ${_output}
DEPENDS ${ARGN} native-cat)
endmacro()
function(add_importlibs _module)
add_dependency_node(${_module})