[CMAKE]
authorJérôme Gardou <jerome.gardou@reactos.org>
Thu, 7 Aug 2014 18:20:46 +0000 (18:20 +0000)
committerJérôme Gardou <jerome.gardou@reactos.org>
Thu, 7 Aug 2014 18:20:46 +0000 (18:20 +0000)
 - separate the custom target and the custom command generating reactos.cab, so that it isn't regenerated each time a bootcd is built
Note to make user: I tried a hack so that the sequence 'make module/fast reactos_cab/fast bootcd/fast' still works, but this is untested. Please use ninja if you really want fast dependency resolution.

svn path=/trunk/; revision=63837

reactos/boot/bootdata/CMakeLists.txt
reactos/boot/bootdata/packages/CMakeLists.txt
reactos/cmake/CMakeMacros.cmake

index a6842d2..9789420 100644 (file)
@@ -18,10 +18,14 @@ foreach(_hive ${_common_hives})
                        COMMAND native-utf16le ${_hive} ${_converted_hive}
                        DEPENDS native-utf16le ${_hive})
     list(APPEND _converted_common_hives ${_converted_hive})
                        COMMAND native-utf16le ${_hive} ${_converted_hive}
                        DEPENDS native-utf16le ${_hive})
     list(APPEND _converted_common_hives ${_converted_hive})
-    add_cd_file(FILE ${_converted_hive} DESTINATION reactos NO_CAB FOR bootcd regtest)
 endforeach()
 
 add_custom_target(converted_hives DEPENDS ${_converted_common_hives})
 endforeach()
 
 add_custom_target(converted_hives DEPENDS ${_converted_common_hives})
+add_cd_file(TARGET converted_hives
+            FILE ${_converted_common_hives}
+            DESTINATION reactos
+            NO_CAB
+            FOR bootcd regtest)
 
 # livecd hives
 list(APPEND _livecd_hives
 
 # livecd hives
 list(APPEND _livecd_hives
@@ -84,7 +88,7 @@ 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_cd_file(FILE "${CMAKE_CURRENT_BINARY_DIR}/${name}.lnk"
        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_cd_file(FILE "${CMAKE_CURRENT_BINARY_DIR}/${name}.lnk"
-                       TARGET livecd_links
+                    TARGET livecd_links
                    DESTINATION ${dest}
                    FOR livecd)
 endmacro(add_livecd_shortcut)
                    DESTINATION ${dest}
                    FOR livecd)
 endmacro(add_livecd_shortcut)
index 24b6ba2..3344a23 100644 (file)
@@ -15,12 +15,18 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/concat.cmake "
 
 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff.dyn "")
 
 
 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff.dyn "")
 
+# This finalizes reactos.dff by concat-ing the two files: one generated and one static containing the optional file.
+# please keep it this way as it permits to add files to reactos.dff.in without having to run cmake again
+# and also avoids rebuilding reactos.cab in case nothing changes after a cmake run
 add_custom_command(
     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff
     COMMAND ${CMAKE_COMMAND} -D SRC1=${CMAKE_CURRENT_SOURCE_DIR}/reactos.dff.in
                              -D SRC2=${CMAKE_CURRENT_BINARY_DIR}/reactos.dff.dyn
 add_custom_command(
     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff
     COMMAND ${CMAKE_COMMAND} -D SRC1=${CMAKE_CURRENT_SOURCE_DIR}/reactos.dff.in
                              -D SRC2=${CMAKE_CURRENT_BINARY_DIR}/reactos.dff.dyn
-                             -D DST=${CMAKE_CURRENT_BINARY_DIR}/reactos.dff
+                             -D DST=${CMAKE_CURRENT_BINARY_DIR}/reactos.dff.maydiff
                              -P ${CMAKE_CURRENT_BINARY_DIR}/concat.cmake
                              -P ${CMAKE_CURRENT_BINARY_DIR}/concat.cmake
+    COMMAND ${CMAKE_COMMAND} -E copy_if_different 
+                             ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff.maydiff
+                             ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff
     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/reactos.dff.in
     DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff.dyn
 )
     DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/reactos.dff.in
     DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff.dyn
 )
@@ -34,10 +40,15 @@ add_custom_command(
     DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff native-cabman)
 
 # Then we create the actual cab file using a custom target
     DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff native-cabman)
 
 # Then we create the actual cab file using a custom target
-# Please do not change this into custom command + custom target. This breaks reactos.cab dependencies on modules
-# and you can't do something like "make gdi32/fast reactos_cab/fast bootcd/fast"
-add_custom_target(reactos_cab
+add_custom_command(
+    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab
     COMMAND native-cabman -C ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff -RC ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf -L ${CMAKE_CURRENT_BINARY_DIR} -N -P ${REACTOS_SOURCE_DIR}
     DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf native-cabman)
 
     COMMAND native-cabman -C ${CMAKE_CURRENT_BINARY_DIR}/reactos.dff -RC ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf -L ${CMAKE_CURRENT_BINARY_DIR} -N -P ${REACTOS_SOURCE_DIR}
     DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf native-cabman)
 
-add_cd_file(TARGET reactos_cab FILE ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf DESTINATION reactos NO_CAB FOR bootcd regtest)
+add_custom_target(reactos_cab DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab)
+
+add_cd_file(
+    TARGET reactos_cab
+    FILE ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf
+    DESTINATION reactos
+    NO_CAB FOR bootcd regtest)
index 54e918b..716ac07 100644 (file)
@@ -318,6 +318,12 @@ function(add_cd_file)
             if(_CD_TARGET)
                 #manage dependency
                 add_dependencies(reactos_cab ${_CD_TARGET})
             if(_CD_TARGET)
                 #manage dependency
                 add_dependencies(reactos_cab ${_CD_TARGET})
+                # add this so that the combination make target/fast reactos_cab/fast bootcd/fast properly detects that reactos.cab must be rebuilt
+                if (CMAKE_BUILD_TOOL STREQUAL "make")
+                    add_custom_command(TARGET ${_CD_TARGET}
+                                       POST_BUILD
+                                       COMMAND ${CMAKE_COMMAND} -E touch ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff)
+                endif()
             endif()
         endif()
     endif() #end bootcd
             endif()
         endif()
     endif() #end bootcd