mirror of
https://github.com/reactos/reactos.git
synced 2026-06-23 03:25:52 +08:00
[0.4.16][BOOTDATA][CMAKE] Improve the add_livecd_shortcut/add_link helpers (#8936)
CMakeLists.txt: `add_livecd_shortcut()`:
Turn the macro into a function. Instead of keeping a `LIVECD_SHORTCUTS`
global-scope list variable, just define a `livecd_links` custom target
as initially empty, then, using `set_property()`, directly append to it
its "SOURCES" i.e. generated .lnk files.
(This is equivalent to using `target_sources(livecd_links PRIVATE ...)`
only in CMake 3.20+ for the custom target.)
CMakeMacros.cmake: `add_link()`:
- Since both `name` and `path` parameters are mandatory, make them
explicit in the function declaration instead of defining them as
"optional" parameters.
- Remove the `set_source_files_properties(... PROPERTIES GENERATED TRUE)`
invocation that followed the `add_custom_command(...)` call, since,
per the documentation[^1],
"Each output file will be marked with the `GENERATED` source file
property automatically." (Since CMake 3.2 at least.)
[^1]: https://cmake.org/cmake/help/v3.17/command/add_custom_command.html
This is a cherry-pick of 3a3b16af0d.
This commit is contained in:
committed by
Carl J. Bialorucki
parent
8245ab8eca
commit
deeae5db00
@@ -58,14 +58,16 @@ add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/bootcdregtest/unattend.inf DESTINAT
|
||||
add_cd_file(FILE ${CMAKE_CURRENT_SOURCE_DIR}/livecd/unattend.inf DESTINATION reactos NO_CAB FOR livecd)
|
||||
|
||||
# LiveImage shortcuts
|
||||
macro(add_livecd_shortcut name app dest)
|
||||
add_link(NAME ${name} CMD_LINE_ARGS ${app} ICON ${app} PATH livecd_start.cmd GUID "{450D8FBA-AD25-11D0-98A8-0800361B1103}" MINIMIZE)
|
||||
list(APPEND LIVECD_SHORTCUTS "${CMAKE_CURRENT_BINARY_DIR}/${name}.lnk")
|
||||
add_custom_target(livecd_links)
|
||||
function(add_livecd_shortcut name app dest)
|
||||
add_link(${name} livecd_start.cmd GUID "{450D8FBA-AD25-11D0-98A8-0800361B1103}" CMD_LINE_ARGS ${app} ICON ${app} MINIMIZE)
|
||||
# Only on CMake 3.20+: target_sources(livecd_links PRIVATE ...)
|
||||
set_property(TARGET livecd_links APPEND PROPERTY SOURCES "${CMAKE_CURRENT_BINARY_DIR}/${name}.lnk")
|
||||
add_cd_file(FILE "${CMAKE_CURRENT_BINARY_DIR}/${name}.lnk"
|
||||
TARGET livecd_links
|
||||
DESTINATION ${dest}
|
||||
FOR livecd)
|
||||
endmacro(add_livecd_shortcut)
|
||||
endfunction()
|
||||
|
||||
## NOTE: What would be nice is to create this list using /media/inf/shortcuts.inf
|
||||
## and taking their default english translation!
|
||||
@@ -100,5 +102,3 @@ add_livecd_shortcut("WineMine" winmine.exe "Profiles/All Users/Start Menu/Progra
|
||||
add_livecd_shortcut("ReactOS Explorer" explorer.exe "Profiles/All Users/Start Menu/Programs")
|
||||
add_livecd_shortcut("Command Prompt" cmd.exe "Profiles/Default User/Application Data/Microsoft/Internet Explorer/Quick Launch")
|
||||
add_livecd_shortcut("ReactOS Explorer" explorer.exe "Profiles/Default User/Application Data/Microsoft/Internet Explorer/Quick Launch")
|
||||
|
||||
add_custom_target(livecd_links DEPENDS ${LIVECD_SHORTCUTS})
|
||||
|
||||
@@ -53,11 +53,8 @@ function(add_message_headers _type)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(add_link)
|
||||
cmake_parse_arguments(_LINK "MINIMIZE" "NAME;PATH;CMD_LINE_ARGS;ICON;GUID" "" ${ARGN})
|
||||
if(NOT _LINK_NAME OR NOT _LINK_PATH)
|
||||
message(FATAL_ERROR "You must provide name and path")
|
||||
endif()
|
||||
function(add_link name path)
|
||||
cmake_parse_arguments(_LINK "MINIMIZE" "CMD_LINE_ARGS;ICON;GUID" "" ${ARGN})
|
||||
|
||||
if(_LINK_CMD_LINE_ARGS)
|
||||
set(_LINK_CMD_LINE_ARGS -c ${_LINK_CMD_LINE_ARGS})
|
||||
@@ -76,11 +73,9 @@ function(add_link)
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk
|
||||
COMMAND native-mkshelllink -o ${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk ${_LINK_CMD_LINE_ARGS} ${_LINK_ICON} ${_LINK_GUID} ${_LINK_MINIMIZE} ${_LINK_PATH}
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${name}.lnk
|
||||
COMMAND native-mkshelllink -o ${CMAKE_CURRENT_BINARY_DIR}/${name}.lnk ${_LINK_CMD_LINE_ARGS} ${_LINK_ICON} ${_LINK_GUID} ${_LINK_MINIMIZE} ${path}
|
||||
DEPENDS native-mkshelllink)
|
||||
set_source_files_properties(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${_LINK_NAME}.lnk PROPERTIES GENERATED TRUE)
|
||||
endfunction()
|
||||
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user