[CMAKE]
[reactos.git] / reactos / cmake / CMakeMacros.cmake
index 716ac07..080277f 100644 (file)
@@ -316,15 +316,11 @@ function(add_cd_file)
             file(APPEND ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff.dyn "\"${__relative_file}\" ${_num}\n")
             unset(__relative_file)
             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()
+                #manage dependency - target level
+                add_dependencies(reactos_cab_inf ${_CD_TARGET})
             endif()
+            # manage dependency - file level
+            set_property(GLOBAL APPEND PROPERTY REACTOS_CAB_DEPENDS ${_CD_FILE})
         endif()
     endif() #end bootcd
 
@@ -378,6 +374,29 @@ function(add_cd_file)
 endfunction()
 
 function(create_iso_lists)
+    # generate reactos.cab before anything else
+    get_property(_filelist GLOBAL PROPERTY REACTOS_CAB_DEPENDS)
+
+    # begin with reactos.inf. We want this command to be always executed, so we pretend it generates another file although it will never do.
+    add_custom_command(
+        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf ${CMAKE_CURRENT_BINARY_DIR}/__some_non_existent_file
+        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.inf ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf
+        DEPENDS ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.inf reactos_cab_inf)
+
+    add_custom_command(
+        OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab
+        COMMAND native-cabman -C ${REACTOS_BINARY_DIR}/boot/bootdata/packages/reactos.dff -RC ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf -N -P ${REACTOS_SOURCE_DIR}
+        DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.inf native-cabman ${_filelist})
+
+    add_custom_target(reactos_cab DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab)
+    add_dependencies(reactos_cab reactos_cab_inf)
+
+    add_cd_file(
+        TARGET reactos_cab
+        FILE ${CMAKE_CURRENT_BINARY_DIR}/reactos.cab
+        DESTINATION reactos
+        NO_CAB FOR bootcd regtest)
+
     get_property(_filelist GLOBAL PROPERTY BOOTCD_FILE_LIST)
     string(REPLACE ";" "\n" _filelist "${_filelist}")
     file(APPEND ${REACTOS_BINARY_DIR}/boot/bootcd.lst "${_filelist}")
@@ -483,6 +502,14 @@ function(add_importlibs _module)
         if("${LIB}" MATCHES "msvcrt")
             add_target_compile_definitions(${_module} _DLL __USE_CRTIMP)
             target_link_libraries(${_module} msvcrtex)
+            if(MSVC)
+                if(RUNTIME_CHECKS)
+                    if(NOT ${_module} STREQUAL "kernel32")
+                        add_target_compile_flags(${_module} "/RTC1")
+                        target_link_libraries(${_module} RunTmChk.lib)
+                    endif()
+                endif()
+            endif()
         endif()
         target_link_libraries(${_module} lib${LIB})
         add_dependencies(${_module} lib${LIB})
@@ -499,7 +526,8 @@ function(set_module_type MODULE TYPE)
 
     # Set subsystem. Also take this as an occasion
     # to error out if someone gave a non existing type
-    if((${TYPE} STREQUAL nativecui) OR (${TYPE} STREQUAL nativedll) OR (${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver))
+    if((${TYPE} STREQUAL nativecui) OR (${TYPE} STREQUAL nativedll) 
+            OR (${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kerneldll))
         set(__subsystem native)
     elseif(${TYPE} STREQUAL win32cui)
         set(__subsystem console)
@@ -515,7 +543,6 @@ function(set_module_type MODULE TYPE)
         else()
             # Use a custom linker script
             add_target_link_flags(${MODULE} "-Wl,-T,${CMAKE_SOURCE_DIR}/kbdlayout.lds")
-            add_dependencies(${MODULE} "${CMAKE_SOURCE_DIR}/kbdlayout.lds")
         endif()
     elseif(NOT ((${TYPE} STREQUAL win32dll) OR (${TYPE} STREQUAL win32ocx)
             OR (${TYPE} STREQUAL cpl) OR (${TYPE} STREQUAL module)))
@@ -591,21 +618,23 @@ function(set_module_type MODULE TYPE)
 
     #set base address
     if(__module_IMAGEBASE)
-        set_image_base(${MODULE} __module_IMAGEBASE)
+        set_image_base(${MODULE} ${__module_IMAGEBASE})
     elseif(${TYPE} STREQUAL win32dll)
         if(DEFINED baseaddress_${MODULE})
             set_image_base(${MODULE} ${baseaddress_${MODULE}})
         else()
             message(STATUS "${MODULE} has no base address")
         endif()
-    elseif((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver))
+    elseif((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kernelmodedll))
         set_image_base(${MODULE} 0x00010000)
     endif()
 
     # Now do some stuff which is specific to each type
-    if((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver))
+    if((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver) OR (${TYPE} STREQUAL kernelmodedll))
         add_dependencies(${MODULE} bugcodes)
-        set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
+        if((${TYPE} STREQUAL kernelmodedriver) OR (${TYPE} STREQUAL wdmdriver))
+            set_target_properties(${MODULE} PROPERTIES SUFFIX ".sys")
+        endif()
     endif()
 
     if(${TYPE} STREQUAL win32ocx)