* Visual Studio IDE support bringup. We can now even compile bootcd/livecd...etc...
authorAmine Khaldi <amine.khaldi@reactos.org>
Tue, 8 Jan 2013 20:33:08 +0000 (20:33 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Tue, 8 Jan 2013 20:33:08 +0000 (20:33 +0000)
* For anyone who wants to work only on a certain module (or a set of modules), you can add "project(module)" to the related CMake file. This will generate a solution that contains all the required dependencies needed to compile only that module, without having to open a huge solution with 900+ projects.
* We'll create a wiki page to explain how to use this in detail.
* Dedicated to all VS users. Have fun ;)

svn path=/trunk/; revision=58141

21 files changed:
reactos/boot/freeldr/freeldr/CMakeLists.txt
reactos/cmake/CMakeMacros.cmake
reactos/cmake/gcc.cmake
reactos/cmake/msvc.cmake
reactos/dll/ntdll/CMakeLists.txt
reactos/dll/win32/kernel32/CMakeLists.txt
reactos/dll/win32/oleaut32/CMakeLists.txt
reactos/dll/win32/rpcrt4/CMakeLists.txt
reactos/drivers/CMakeLists.txt
reactos/drivers/ksfilter/ks/CMakeLists.txt
reactos/hal/CMakeLists.txt
reactos/hal/halx86/CMakeLists.txt
reactos/lib/pseh/CMakeLists.txt
reactos/lib/rtl/CMakeLists.txt
reactos/lib/sdk/crt/CMakeLists.txt
reactos/lib/sdk/crt/crt.cmake
reactos/lib/sdk/crt/libcntpr.cmake
reactos/lib/sdk/crt/msvcrtex.cmake
reactos/lib/sdk/crt/oldnames.cmake
reactos/ntoskrnl/CMakeLists.txt
reactos/win32ss/CMakeLists.txt

index 8f48a34..cc65e0e 100644 (file)
@@ -80,11 +80,16 @@ list(APPEND FREELDR_COMMON_SOURCE
     windows/wlregistry.c)
 
 if(ARCH STREQUAL "i386")
+    list(APPEND FREELDR_COMMON_ASM_SOURCE
+        arch/i386/entry.S
+        arch/i386/i386pnp.S
+        arch/i386/i386trap.S
+        arch/i386/linux.S
+        arch/i386/mb.S)
     list(APPEND FREELDR_COMMON_SOURCE
         arch/i386/archmach.c
         arch/i386/custom.c
         arch/i386/drivemap.c
-        arch/i386/entry.S
         arch/i386/halstub.c
         arch/i386/hardware.c
         arch/i386/hwacpi.c
@@ -94,13 +99,9 @@ if(ARCH STREQUAL "i386")
         arch/i386/i386bug.c
         arch/i386/i386disk.c
         arch/i386/i386idt.c
-        arch/i386/i386pnp.S
         arch/i386/i386rtl.c
-        arch/i386/i386trap.S
         arch/i386/i386vid.c
-        arch/i386/linux.S
         arch/i386/machpc.c
-        arch/i386/mb.S
         arch/i386/miscboot.c
         arch/i386/ntoskrnl.c
         arch/i386/pccons.c
@@ -121,14 +122,14 @@ if(ARCH STREQUAL "i386")
         windows/headless.c
         disk/scsiport.c)
     if(NOT MSVC)
-        list(APPEND FREELDR_COMMON_SOURCE
-            arch/i386/drvmap.S)
+        list(APPEND FREELDR_COMMON_SOURCE arch/i386/drvmap.S)
     endif()
 elseif(ARCH STREQUAL "amd64")
-    list(APPEND FREELDR_COMMON_SOURCE
+    list(APPEND FREELDR_COMMON_ASM_SOURCE
         arch/amd64/entry.S
         arch/amd64/int386.S
-        arch/amd64/pnpbios.S
+        arch/amd64/pnpbios.S)
+    list(APPEND FREELDR_COMMON_SOURCE
         arch/i386/hardware.c
         arch/i386/hwacpi.c
         arch/i386/hwapm.c
@@ -150,9 +151,10 @@ else()
 endif()
 
 if((NOT MSVC) AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
-    add_library(freeldr_common OBJECT ${FREELDR_COMMON_SOURCE})
+    add_library(freeldr_common OBJECT ${FREELDR_COMMON_SOURCE} ${FREELDR_COMMON_ASM_SOURCE})
 else()
-    add_library(freeldr_common ${FREELDR_COMMON_SOURCE})
+    add_asm_files(freeldr_common_asm ${FREELDR_COMMON_ASM_SOURCE})
+    add_library(freeldr_common ${FREELDR_COMMON_SOURCE} ${freeldr_common_asm})
 endif()
 add_dependencies(freeldr_common bugcodes)
 
@@ -185,8 +187,8 @@ if(NOT MSVC)
     add_target_link_flags(freeldr_pe "-Wl,--strip-all,--exclude-all-symbols,--file-alignment,0x1000,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lds")
     add_target_link_flags(freeldr_pe_dbg "-Wl,--exclude-all-symbols,--file-alignment,0x1000,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lds")
 else()
-    add_target_link_flags(freeldr_pe "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION")
-    add_target_link_flags(freeldr_pe_dbg "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION")
+    add_target_link_flags(freeldr_pe "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text ")
+    add_target_link_flags(freeldr_pe_dbg "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text")
 endif()
 
 set_image_base(freeldr_pe 0x10000)
@@ -202,7 +204,7 @@ if(ARCH STREQUAL "i386")
     target_link_libraries(freeldr_pe_dbg mini_hal)
 endif()
 
-if(MSVC OR NOT CMAKE_VERSION VERSION_GREATER 2.8.7)
+if(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
     target_link_libraries(freeldr_pe freeldr_common)
     target_link_libraries(freeldr_pe_dbg freeldr_common)
 endif()
@@ -249,8 +251,8 @@ if(NOT MSVC)
     add_target_link_flags(setupldr_pe "-Wl,--strip-all,--exclude-all-symbols,--file-alignment,0x1000,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lds")
     add_target_link_flags(setupldr_pe_dbg "-Wl,--exclude-all-symbols,--file-alignment,0x1000,-T,${CMAKE_CURRENT_SOURCE_DIR}/freeldr_i386.lds")
 else()
-    add_target_link_flags(setupldr_pe "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION")
-    add_target_link_flags(setupldr_pe_dbg "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text /SUBSYSTEM:BOOT_APPLICATION")
+    add_target_link_flags(setupldr_pe "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text")
+    add_target_link_flags(setupldr_pe_dbg "/ignore:4078 /ignore:4254 /DRIVER /FIXED /ALIGN:0x400 /SECTION:.text,ERW /SECTION:.data,RW /MERGE:.text16=.text /MERGE:.data=.text /MERGE:.rdata=.text /MERGE:.bss=.text")
 endif()
 
 add_target_compile_definitions(setupldr_pe FREELDR_REACTOS_SETUP)
index 34aeebd..ba7f4a7 100644 (file)
@@ -134,7 +134,7 @@ function(add_cd_file)
 
     #get file if we need to
     if(NOT _CD_FILE)
-        get_target_property(_CD_FILE ${_CD_TARGET} LOCATION)
+        get_target_property(_CD_FILE ${_CD_TARGET} LOCATION_${CMAKE_BUILD_TYPE})
     endif()
 
     #do we add it to all CDs?
index ac14dfa..0f35c17 100644 (file)
@@ -368,3 +368,8 @@ endfunction()
 function(allow_warnings __module)
     add_target_compile_flags(${__module} "-Wno-error")
 endfunction()
+
+macro(add_asm_files _target)
+    list(APPEND ${_target} ${ARGN})
+endmacro()
+
index 952403e..b01267d 100644 (file)
@@ -43,23 +43,21 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
     add_compile_flags("/Ob2 /D NDEBUG")
 endif()
 
-if(${_MACHINE_ARCH_FLAG} MATCHES X86)
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB /RELEASE")
-    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB /RELEASE")
-    set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB /RELEASE")
+if(MSVC_IDE)
+    add_compile_flags("/MP")
 endif()
 
-set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> ${I18N_DEFS} /fo<OBJECT> <SOURCE>")
+if(${_MACHINE_ARCH_FLAG} MATCHES X86)
+    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
+    set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
+endif()
 
-if(MSVC_IDE)
-    # Asm source files are not supported in VS generators yet. As a result, <DEFINES> isn't recognized.
-    # We may temporarily use just the global defines, but this is not a solution as some modules (minihal for example) apply additional definitions to source files, so we get an incorrect build of such targets.
-    get_directory_property(definitions DEFINITIONS)
-    set(CMAKE_ASM_COMPILE_OBJECT
-        "cl /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm <FLAGS> ${definitions} /D__ASM__ /D_USE_ML /EP /c <SOURCE> > <OBJECT>.tmp"
-        "<CMAKE_ASM_COMPILER> /nologo /Cp /Fo<OBJECT> /c /Ta <OBJECT>.tmp")
+if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
+    # for VS builds we'll only have en-US in resource files
+    add_definitions(/DLANGUAGE_EN_US)
 else()
-    # NMake Makefiles
+    set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> ${I18N_DEFS} /fo<OBJECT> <SOURCE>")
     set(CMAKE_ASM_COMPILE_OBJECT
         "cl /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm <FLAGS> <DEFINES> /D__ASM__ /D_USE_ML /EP /c <SOURCE> > <OBJECT>.tmp"
         "<CMAKE_ASM_COMPILER> /nologo /Cp /Fo<OBJECT> /c /Ta <OBJECT>.tmp")
@@ -102,7 +100,7 @@ function(set_entrypoint _module _entrypoint)
 endfunction()
 
 function(set_subsystem MODULE SUBSYSTEM)
-    add_target_link_flags(${MODULE} "/subsystem:${SUBSYSTEM}")
+    add_target_link_flags(${MODULE} "/SUBSYSTEM:${SUBSYSTEM}")
 endfunction()
 
 function(set_image_base MODULE IMAGE_BASE)
@@ -243,3 +241,32 @@ endfunction()
 
 function(allow_warnings __module)
 endfunction()
+
+macro(add_asm_files _target)
+    if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
+        get_defines(_directory_defines)
+        get_includes(_directory_includes)
+        get_directory_property(_defines COMPILE_DEFINITIONS)
+        foreach(_source_file ${ARGN})
+            get_filename_component(_source_file_base_name ${_source_file} NAME_WE)
+            set(_preprocessed_asm_file ${CMAKE_CURRENT_BINARY_DIR}/asm/${_source_file_base_name}_${_target}.tmp)
+            set(_object_file ${CMAKE_CURRENT_BINARY_DIR}/asm/${_source_file_base_name}_${_target}.obj)
+            set(_source_file_full_path ${CMAKE_CURRENT_SOURCE_DIR}/${_source_file})
+            get_source_file_property(_defines_semicolon_list ${_source_file_full_path} COMPILE_DEFINITIONS)
+            unset(_source_file_defines)
+            foreach(_define ${_defines_semicolon_list})
+                if(NOT ${_define} STREQUAL "NOTFOUND")
+                    list(APPEND _source_file_defines -D${_define})
+                endif()
+            endforeach()
+            add_custom_command(
+                OUTPUT ${_preprocessed_asm_file} ${_object_file}
+                COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_source_file_full_path} > ${_preprocessed_asm_file} && ${CMAKE_ASM_COMPILER} /nologo /Cp /Fo${_object_file} /c /Ta ${_preprocessed_asm_file}
+                DEPENDS ${_source_file_full_path})
+            set_source_files_properties(${_object_file} PROPERTIES EXTERNAL_OBJECT 1)
+            list(APPEND ${_target} ${_object_file})
+        endforeach()
+    else()
+        list(APPEND ${_target} ${ARGN})
+    endif()
+endmacro()
index 1a90479..7ad8547 100644 (file)
@@ -26,16 +26,17 @@ list(APPEND SOURCE
     ${CMAKE_CURRENT_BINARY_DIR}/ntdll.def)
 
 if(ARCH STREQUAL "i386")
-    list(APPEND SOURCE dispatch/i386/dispatch.S)
+    list(APPEND ASM_SOURCE dispatch/i386/dispatch.S)
 elseif(ARCH STREQUAL "amd64")
-    list(APPEND SOURCE dispatch/amd64/dispatch.S)
+    list(APPEND ASM_SOURCE dispatch/amd64/dispatch.S)
 elseif(ARCH STREQUAL "arm")
-    list(APPEND SOURCE dispatch/arm/stubs_asm.s)
+    list(APPEND ASM_SOURCE dispatch/arm/stubs_asm.s)
 else()
     list(APPEND SOURCE dispatch/dispatch.c)
-endif(ARCH STREQUAL "i386")
+endif()
 
-add_library(ntdll SHARED ${SOURCE})
+add_asm_files(ntdll_asm ${ASM_SOURCE})
+add_library(ntdll SHARED ${SOURCE} ${ntdll_asm})
 
 set_module_type(ntdll win32dll ENTRYPOINT 0)
 
index efc98c9..72a1c34 100644 (file)
@@ -76,16 +76,17 @@ list(APPEND SOURCE
     ${CMAKE_CURRENT_BINARY_DIR}/kernel32.def)
 
 if(ARCH STREQUAL "i386")
-    list(APPEND SOURCE
+    list(APPEND ASM_SOURCE
         client/i386/fiber.S
         client/i386/thread.S)
 elseif(ARCH STREQUAL "amd64")
-    list(APPEND SOURCE
+    list(APPEND ASM_SOURCE
         client/amd64/fiber.S
         client/amd64/thread.S)
 endif()
 
-add_library(kernel32 SHARED ${SOURCE})
+add_asm_files(kernel32_asm ${ASM_SOURCE})
+add_library(kernel32 SHARED ${SOURCE} ${kernel32_asm})
 set_module_type(kernel32 win32dll ENTRYPOINT DllMain 12)
 target_link_libraries(kernel32 wine chkstk ${PSEH_LIB})
 add_importlibs(kernel32 ntdll)
index 5c3621c..fa836d0 100644 (file)
@@ -42,10 +42,10 @@ list(APPEND SOURCE
     ${CMAKE_CURRENT_BINARY_DIR}/oleaut32.def)
 
 if(MSVC)
-    list(APPEND SOURCE msvc.S)
+    add_asm_files(oleaut32_asm msvc.S)
 endif()
 
-add_library(oleaut32 SHARED ${SOURCE})
+add_library(oleaut32 SHARED ${SOURCE} ${oleaut32_asm})
 add_idl_headers(oleaut32_idlheader oleaut32_oaidl.idl)
 add_dependencies(oleaut32 oleaut32_idlheader)
 set_module_type(oleaut32 win32dll)
index a6b142a..ce6108a 100644 (file)
@@ -27,10 +27,6 @@ list(APPEND SOURCE
     ${CMAKE_CURRENT_BINARY_DIR}/rpcrt4_stubs.c
     ${CMAKE_CURRENT_BINARY_DIR}/rpcrt4.def)
 
-if(MSVC)
-    list(APPEND SOURCE msvc.S)
-endif()
-
 remove_definitions(-D_WIN32_WINNT=0x502)
 add_definitions(-D_WIN32_WINNT=0x600)
 
@@ -42,8 +38,13 @@ add_definitions(
 
 include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine)
 
+if(MSVC)
+    add_asm_files(rpcrt4_asm msvc.S)
+endif()
+
 add_library(rpcrt4 SHARED
     ${SOURCE}
+    ${rpcrt4_asm}
     rpcrt4.rc)
 
 set_module_type(rpcrt4 win32dll)
index 7a672a3..fcfaa93 100644 (file)
@@ -1,4 +1,6 @@
 
+PROJECT(Drivers)
+
 add_subdirectory(base)
 add_subdirectory(battery)
 add_subdirectory(bluetooth)
index fdd2fa4..18d74c6 100644 (file)
@@ -32,10 +32,10 @@ list(APPEND SOURCE
     ${CMAKE_CURRENT_BINARY_DIR}/ks.def)
 
 if(MSVC)
-    list(APPEND SOURCE msvc.S)
+    add_asm_files(ks_asm msvc.S)
 endif()
 
-add_library(ks SHARED ${SOURCE})
+add_library(ks SHARED ${SOURCE} ${ks_asm})
 
 set_target_properties(ks PROPERTIES SUFFIX ".sys")
 
index e767918..965a08d 100644 (file)
@@ -1,4 +1,5 @@
 
+project(HAL)
 if((ARCH STREQUAL "i386") OR (ARCH STREQUAL "amd64"))
     add_subdirectory(halx86)
 elseif(ARCH STREQUAL "arm")
index 4684c89..7fa5cf5 100644 (file)
@@ -26,7 +26,7 @@ if(ARCH STREQUAL "i386")
         generic/portio.c)
 endif()
 
-if(CMAKE_VERSION VERSION_GREATER 2.8.7)
+if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
     add_library(lib_hal_generic OBJECT ${HAL_GENERIC_SOURCE})
 else()
     add_library(lib_hal_generic ${HAL_GENERIC_SOURCE})
@@ -63,7 +63,7 @@ if(ARCH STREQUAL "i386")
         legacy/halpnpdd.c
         legacy/halpcat.c)
 
-    if(CMAKE_VERSION VERSION_GREATER 2.8.7)
+    if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
         add_library(lib_hal_legacy OBJECT ${HAL_LEGACY_SOURCE})
     else()
         add_library(lib_hal_legacy ${HAL_LEGACY_SOURCE})
@@ -71,7 +71,7 @@ if(ARCH STREQUAL "i386")
 
     #add_pch(lib_hal_legacy include/hal.h)
 
-    if(NOT CMAKE_VERSION VERSION_GREATER 2.8.7)
+    if(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
         target_link_libraries(lib_hal_legacy lib_hal_generic)
     endif()
 
@@ -83,14 +83,14 @@ list(APPEND HAL_ACPI_SOURCE
     acpi/busemul.c
     legacy/bus/pcibus.c)
 
-if(CMAKE_VERSION VERSION_GREATER 2.8.7)
+if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
     add_library(lib_hal_acpi OBJECT ${HAL_ACPI_SOURCE})
 else()
     add_library(lib_hal_acpi ${HAL_ACPI_SOURCE})
 endif()
 #add_pch(lib_hal_acpi include/hal.h)
 
-if(NOT CMAKE_VERSION VERSION_GREATER 2.8.7)
+if(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
     target_link_libraries(lib_hal_acpi lib_hal_generic)
 endif()
 
@@ -98,30 +98,33 @@ list(APPEND HAL_UP_SOURCE
     generic/spinlock.c
     up/processor.c)
 
-if(CMAKE_VERSION VERSION_GREATER 2.8.7)
+if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
     add_library(lib_hal_up OBJECT ${HAL_UP_SOURCE})
 endif()
 
+list(APPEND HAL_APIC_ASM_SOURCE
+    apic/apictrap.S
+    apic/tsccal.S)
+
 list(APPEND HAL_APIC_SOURCE
     apic/apic.c
     apic/apictimer.c
-    apic/apictrap.S
     apic/halinit_apic.c
     apic/rtctimer.c
-    apic/tsc.c
-    apic/tsccal.S)
+    apic/tsc.c)
 
 if(ARCH STREQUAL "i386")
+    list(APPEND HAL_PIC_ASM_SOURCE
+        generic/systimer.S
+        generic/trap.S)
     list(APPEND HAL_PIC_SOURCE
         generic/profil.c
         generic/timer.c
-        generic/systimer.S
-        generic/trap.S
         up/halinit_up.c
         up/pic.c)
 
-    if(CMAKE_VERSION VERSION_GREATER 2.8.7)
-        add_library(lib_hal_pic OBJECT ${HAL_PIC_SOURCE})
+    if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
+        add_library(lib_hal_pic OBJECT ${HAL_PIC_SOURCE} ${HAL_PIC_ASM_SOURCE})
     endif()
 
     list(APPEND MINI_HAL_SOURCE
@@ -153,7 +156,7 @@ if(ARCH STREQUAL "i386")
     spec2def(hal.dll ../hal.spec ADD_IMPORTLIB)
 
     # hal
-    if(CMAKE_VERSION VERSION_GREATER 2.8.7)
+    if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
         add_library(hal SHARED
             $<TARGET_OBJECTS:lib_hal_generic>
             $<TARGET_OBJECTS:lib_hal_legacy>
@@ -163,15 +166,18 @@ if(ARCH STREQUAL "i386")
             up/halup.rc
             ${CMAKE_CURRENT_BINARY_DIR}/hal.def)
     else()
+        add_asm_files(hal_asm
+            ${HAL_PIC_ASM_SOURCE}
+            generic/v86.S)
         add_library(hal SHARED
             ${HAL_UP_SOURCE}
             ${HAL_PIC_SOURCE}
-            generic/v86.S
+            ${hal_asm}
             up/halup.rc
             ${CMAKE_CURRENT_BINARY_DIR}/hal.def)
     endif()
 
-    if(NOT CMAKE_VERSION VERSION_GREATER 2.8.7)
+    if(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
         target_link_libraries(hal lib_hal_generic lib_hal_legacy)
     endif()
     target_link_libraries(hal libcntpr)
@@ -188,7 +194,7 @@ if(ARCH STREQUAL "i386")
 
     # hal acpi
     spec2def(halacpi.dll ../hal.spec)
-    if(CMAKE_VERSION VERSION_GREATER 2.8.7)
+    if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
         add_library(halacpi SHARED
             $<TARGET_OBJECTS:lib_hal_generic>
             $<TARGET_OBJECTS:lib_hal_acpi>
@@ -198,15 +204,17 @@ if(ARCH STREQUAL "i386")
             acpi/halacpi.rc
             ${CMAKE_CURRENT_BINARY_DIR}/halacpi.def)
     else()
+        set_source_files_properties(${HAL_PIC_ASM_SOURCE} generic/v86.S PROPERTIES COMPILE_DEFINITIONS "CONFIG_ACPI")
+        add_asm_files(halacpi_asm ${HAL_PIC_ASM_SOURCE} generic/v86.S)
         add_library(halacpi SHARED
             ${HAL_UP_SOURCE}
             ${HAL_PIC_SOURCE}
-            generic/v86.S
+            ${halacpi_asm}
             acpi/halacpi.rc
             ${CMAKE_CURRENT_BINARY_DIR}/halacpi.def)
     endif()
 
-    if(NOT CMAKE_VERSION VERSION_GREATER 2.8.7)
+    if(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
         target_link_libraries(halacpi lib_hal_generic lib_hal_acpi)
     endif()
     target_link_libraries(halacpi libcntpr)
index 1e957bf..d58e089 100644 (file)
@@ -25,18 +25,19 @@ if(NOT MSVC)
 else()
 
     if(ARCH STREQUAL "i386")
-        list(APPEND SOURCE
-            dummy.c
+        list(APPEND ASM_SOURCE
             i386/seh.s
             i386/seh_prolog.s)
+        list(APPEND SOURCE dummy.c)
     elseif(ARCH STREQUAL "amd64")
-        list(APPEND SOURCE
-            dummy.c
+        list(APPEND ASM_SOURCE
             amd64/seh.s
             amd64/seh_prolog.s)
+        list(APPEND SOURCE dummy.c)
     endif()
 
-    add_library(pseh ${SOURCE})
+    add_asm_files(pseh_asm ${ASM_SOURCE})
+    add_library(pseh ${SOURCE} ${pseh_asm})
     add_dependencies(pseh asm)
 
 endif()
index 5009360..46b17c2 100644 (file)
@@ -29,7 +29,7 @@ list(APPEND SOURCE
     handle.c
     heap.c
     heapdbg.c
-       heappage.c
+    heappage.c
     image.c
     interlck.c
     message.c
@@ -65,40 +65,44 @@ list(APPEND SOURCE
     workitem.c)
 
 if(ARCH STREQUAL "i386")
-    list(APPEND SOURCE
+    list(APPEND ASM_SOURCE
         i386/debug_asm.S
         i386/except_asm.s
-        i386/except.c
         i386/interlck.S
         i386/rtlmem.s
         i386/rtlswap.S
-        i386/res_asm.s
+        i386/res_asm.s)
+    list(APPEND SOURCE
+        i386/except.c
         i386/thread.c)
 elseif(ARCH STREQUAL "amd64")
-    list(APPEND SOURCE
-        byteswap.c
+    list(APPEND ASM_SOURCE
         amd64/debug_asm.S
         amd64/except_asm.S
-        amd64/slist.S
+        amd64/slist.S)
+    list(APPEND SOURCE
+        byteswap.c
         amd64/unwind.c
         amd64/stubs.c
         mem.c)
 elseif(ARCH STREQUAL "arm")
+    list(APPEND ASM_SOURCE arm/debug_asm.S)
     list(APPEND SOURCE
         byteswap.c
-        arm/debug_asm.S
         mem.c)
 elseif(ARCH STREQUAL "powerpc")
+    list(APPEND ASM_SOURCE
+        powerpc/rtlmem.s
+        powerpc/rtlswap.s)
     list(APPEND SOURCE
         byteswap.c
         powerpc/debug.c
         powerpc/except.c
         powerpc/interlocked.c
-        powerpc/rtlmem.s
-        powerpc/rtlswap.s
         powerpc/thread.c)
 endif()
 
-add_library(rtl ${SOURCE})
+add_asm_files(rtl_asm ${ASM_SOURCE})
+add_library(rtl ${SOURCE} ${rtl_asm})
 add_pch(rtl rtl.h)
 add_dependencies(rtl psdk asm)
index dd4a9d3..5df63e0 100644 (file)
@@ -4,20 +4,22 @@ include_directories(include)
 add_definitions(-D_CRTBLD)
 
 if(ARCH STREQUAL "i386")
-    list(APPEND CHKSTK_SOURCE except/i386/chkstk_asm.s)
+    list(APPEND CHKSTK_ASM_SOURCE except/i386/chkstk_asm.s)
     if(NOT MSVC)
         list(APPEND CHKSTK_SOURCE except/i386/chkstk_ms.s)
     endif()
 elseif(ARCH STREQUAL "amd64")
-    list(APPEND CHKSTK_SOURCE except/amd64/chkstk_asm.s)
+    list(APPEND CHKSTK_ASM_SOURCE except/amd64/chkstk_asm.s)
     if(NOT MSVC)
         list(APPEND CHKSTK_SOURCE except/amd64/chkstk_ms.s)
     endif()
 elseif(ARCH STREQUAL "powerpc")
-    list(APPEND CHKSTK_SOURCE except/powerpc/chkstk_asm.s)
+    list(APPEND CHKSTK_ASM_SOURCE except/powerpc/chkstk_asm.s)
 endif()
 
-add_library(chkstk ${CHKSTK_SOURCE})
+add_asm_files(chkstk_lib_asm ${CHKSTK_ASM_SOURCE})
+add_library(chkstk ${CHKSTK_SOURCE} ${chkstk_lib_asm})
+set_target_properties(chkstk PROPERTIES LINKER_LANGUAGE "C")
 add_dependencies(chkstk asm)
 
 include(crt.cmake)
index b147977..8433a70 100644 (file)
@@ -346,17 +346,11 @@ list(APPEND CRT_SOURCE
     wine/undname.c)
 
 if(ARCH STREQUAL "i386")
-    list(APPEND CRT_SOURCE
+    list(APPEND CRT_ASM_SOURCE
         except/i386/chkesp.s
         except/i386/prolog.s
         except/i386/seh.s
         except/i386/seh_prolog.s
-        except/i386/unwind.c
-        float/i386/clearfp.c
-        float/i386/cntrlfp.c
-        float/i386/fpreset.c
-        float/i386/logb.c
-        float/i386/statfp.c
         math/i386/alldiv_asm.s
         math/i386/alldvrm_asm.s
         math/i386/allmul_asm.s
@@ -383,16 +377,9 @@ if(ARCH STREQUAL "i386")
         math/i386/sqrt_asm.s
         math/i386/tan_asm.s
         math/i386/atan2_asm.s
-        math/i386/ci.c
-        math/i386/cicos.c
-        math/i386/cilog.c
-        math/i386/cipow.c
-        math/i386/cisin.c
-        math/i386/cisqrt.c
         math/i386/exp_asm.s
         math/i386/fmod_asm.s
         math/i386/fmodf_asm.s
-        math/i386/ldexp.c
         mem/i386/memchr_asm.s
         mem/i386/memmove_asm.s
         mem/i386/memset_asm.s
@@ -418,20 +405,32 @@ if(ARCH STREQUAL "i386")
         string/i386/wcsncpy_asm.s
         string/i386/wcsnlen_asm.s
         string/i386/wcsrchr_asm.s)
+
+    list(APPEND CRT_SOURCE
+        except/i386/unwind.c
+        float/i386/clearfp.c
+        float/i386/cntrlfp.c
+        float/i386/fpreset.c
+        float/i386/logb.c
+        float/i386/statfp.c
+        math/i386/ci.c
+        math/i386/cicos.c
+        math/i386/cilog.c
+        math/i386/cipow.c
+        math/i386/cisin.c
+        math/i386/cisqrt.c
+        math/i386/ldexp.c)
     if(MSVC)
-        list(APPEND CRT_SOURCE
+        list(APPEND CRT_ASM_SOURCE
             except/i386/cpp.s)
     endif()
 elseif(ARCH STREQUAL "amd64")
-    list(APPEND CRT_SOURCE
+    list(APPEND CRT_ASM_SOURCE
         except/amd64/seh.s
-        except/amd64/ehandler.c
         float/amd64/clearfp.S
         float/amd64/getsetfpcw.S
-        float/i386/cntrlfp.c
         float/amd64/fpreset.S
         float/amd64/logb.S
-        float/i386/statfp.c
         math/amd64/acos.S
         math/amd64/acosf.S
         math/amd64/atan.S
@@ -452,8 +451,13 @@ elseif(ARCH STREQUAL "amd64")
         math/amd64/sqrtf.S
         math/amd64/tan.S
         setjmp/amd64/setjmp.s)
+
+    list(APPEND CRT_SOURCE
+        except/amd64/ehandler.c
+        float/i386/cntrlfp.c
+        float/i386/statfp.c)
     if(MSVC)
-        list(APPEND CRT_SOURCE
+        list(APPEND CRT_ASM_SOURCE
             except/amd64/cpp.s)
     endif()
 endif()
@@ -489,7 +493,10 @@ if(NOT ARCH STREQUAL "i386")
         string/wcsrchr.c)
 endif()
 
-add_library(crt ${CRT_SOURCE})
+set_source_files_properties(${CRT_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "__MINGW_IMPORT=extern;USE_MSVCRT_PREFIX;_MSVCRT_LIB_;_MSVCRT_;_MT;CRTDLL")
+add_asm_files(crt_asm ${CRT_ASM_SOURCE})
+
+add_library(crt ${CRT_SOURCE} ${crt_asm})
 target_link_libraries(crt chkstk)
 add_target_compile_definitions(crt
     __MINGW_IMPORT=extern
index c340172..7c8e490 100644 (file)
@@ -68,7 +68,7 @@ list(APPEND LIBCNTPR_SOURCE
     wstring/wcsstr.c)
 
 if(ARCH STREQUAL "i386")
-    list(APPEND LIBCNTPR_SOURCE
+    list(APPEND LIBCNTPR_ASM_SOURCE
         except/i386/chkstk_asm.s
         except/i386/seh.s
         except/i386/seh_prolog.s
@@ -97,24 +97,23 @@ if(ARCH STREQUAL "i386")
         math/i386/sin_asm.s
         math/i386/sqrt_asm.s
         math/i386/tan_asm.s
+        misc/i386/readcr4.S)
+
+    list(APPEND LIBCNTPR_SOURCE
         math/i386/ci.c
         math/i386/cicos.c
         math/i386/cilog.c
         math/i386/cipow.c
         math/i386/cisin.c
-        math/i386/cisqrt.c
-        misc/i386/readcr4.S)
+        math/i386/cisqrt.c)
     if(NOT MSVC)
         list(APPEND LIBCNTPR_SOURCE except/i386/chkstk_ms.s)
     endif()
 elseif(ARCH STREQUAL "amd64")
-    list(APPEND LIBCNTPR_SOURCE
-        except/amd64/ehandler.c
+    list(APPEND LIBCNTPR_ASM_SOURCE
         except/amd64/chkstk_asm.s
         except/amd64/seh.s
         setjmp/amd64/setjmp.s
-        math/cos.c
-        math/sin.c
         math/amd64/atan.S
         math/amd64/atan2.S
         math/amd64/ceil.S
@@ -129,10 +128,14 @@ elseif(ARCH STREQUAL "amd64")
         math/amd64/pow.S
         math/amd64/sqrt.S
         math/amd64/tan.S)
+    list(APPEND LIBCNTPR_SOURCE
+        except/amd64/ehandler.c
+        math/cos.c
+        math/sin.c)
 endif()
 
 if(ARCH STREQUAL "i386")
-    list(APPEND LIBCNTPR_SOURCE
+    list(APPEND LIBCNTPR_ASM_SOURCE
         mem/i386/memchr_asm.s
         mem/i386/memmove_asm.s
         mem/i386/memset_asm.s
@@ -184,7 +187,10 @@ else()
         string/wcsrchr.c)
 endif()
 
-add_library(libcntpr ${LIBCNTPR_SOURCE})
+set_source_files_properties(${LIBCNTPR_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "NO_RTL_INLINES;_NTSYSTEM_;_NTDLLBUILD_;_LIBCNT_;__CRT__NO_INLINE;CRTDLL")
+add_asm_files(libcntpr_asm ${LIBCNTPR_ASM_SOURCE})
+
+add_library(libcntpr ${LIBCNTPR_SOURCE} ${libcntpr_asm})
 add_target_compile_definitions(libcntpr
     NO_RTL_INLINES
     _NTSYSTEM_
index 97bf4a9..fb5ae7b 100644 (file)
@@ -39,8 +39,7 @@ list(APPEND MSVCRTEX_SOURCE
     misc/fltused.c
     misc/isblank.c
     misc/iswblank.c
-    misc/ofmt_stub.c
-)
+    misc/ofmt_stub.c)
 
 if(NOT MSVC)
     list(APPEND MSVCRTEX_SOURCE
@@ -49,19 +48,20 @@ if(NOT MSVC)
 endif()
 
 if(ARCH STREQUAL "i386")
-    list(APPEND MSVCRTEX_SOURCE
+    list(APPEND MSVCRTEX_ASM_SOURCE
         except/i386/chkstk_asm.s
         except/i386/chkstk_ms.s
+        math/i386/ftol2_asm.s
+        math/i386/alldiv_asm.s)
+    list(APPEND MSVCRTEX_SOURCE
         math/i386/ci.c
         math/i386/cicos.c
         math/i386/cilog.c
         math/i386/cipow.c
         math/i386/cisin.c
-        math/i386/cisqrt.c
-        math/i386/ftol2_asm.s
-        math/i386/alldiv_asm.s)
+        math/i386/cisqrt.c)
 elseif(ARCH STREQUAL "amd64")
-    list(APPEND MSVCRTEX_SOURCE
+    list(APPEND MSVCRTEX_ASM_SOURCE
         except/amd64/chkstk_asm.s
         except/amd64/chkstk_ms.s)
 endif()
@@ -72,7 +72,10 @@ else()
     list(APPEND MSVCRTEX_SOURCE startup/gccmain.c)
 endif()
 
-add_library(msvcrtex ${MSVCRTEX_SOURCE})
+set_source_files_properties(${MSVCRTEX_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "_DLL;_MSVCRTEX_")
+add_asm_files(msvcrtex_asm ${MSVCRTEX_ASM_SOURCE})
+
+add_library(msvcrtex ${MSVCRTEX_SOURCE} ${msvcrtex_asm})
 add_target_compile_definitions(msvcrtex _DLL _MSVCRTEX_)
 set_source_files_properties(startup/crtdll.c PROPERTIES COMPILE_DEFINITIONS CRTDLL)
 set_source_files_properties(startup/crtexe.c
index 8e2c2eb..146db7f 100644 (file)
@@ -3,5 +3,7 @@ if(NOT MSVC)
     set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/moldname-msvcrt.def PROPERTIES EXTERNAL_OBJECT TRUE)
     set_target_properties(oldnames PROPERTIES LINKER_LANGUAGE "IMPLIB" PREFIX "")
 else()
-    add_library(oldnames oldnames-msvcrt.S)
+    add_asm_files(oldnames_asm oldnames-msvcrt.S)
+    add_library(oldnames ${oldnames_asm})
+    set_target_properties(oldnames PROPERTIES LINKER_LANGUAGE "C")
 endif()
index 02605d8..381b7bc 100644 (file)
@@ -109,7 +109,6 @@ list(APPEND SOURCE
     ex/work.c
     ex/xipdisp.c
     ex/zone.c
-    ex/zw.S
     fsrtl/dbcsname.c
     fsrtl/fastio.c
     fsrtl/faulttol.c
@@ -274,15 +273,21 @@ list(APPEND SOURCE
     wmi/wmi.c
     ntoskrnl.rc)
 
+list(APPEND ASM_SOURCE ex/zw.S)
+
 if(ARCH STREQUAL "i386")
-    list(APPEND SOURCE
-        config/i386/cmhardwr.c
+    list(APPEND ASM_SOURCE
         ex/i386/fastinterlck_asm.S
         ex/i386/ioport.S
+        ke/i386/ctxswitch.S
+        ke/i386/trap.s
+        ke/i386/usercall_asm.S
+        rtl/i386/stack.S)
+    list(APPEND SOURCE
+        config/i386/cmhardwr.c
         ke/i386/abios.c
         ke/i386/cpu.c
         ke/i386/context.c
-        ke/i386/ctxswitch.S
         ke/i386/exp.c
         ke/i386/irqobj.c
         ke/i386/kiinit.c
@@ -290,25 +295,24 @@ if(ARCH STREQUAL "i386")
         ke/i386/mtrr.c
         ke/i386/patpge.c
         ke/i386/thrdini.c
-        ke/i386/trap.s
         ke/i386/traphdlr.c
-        ke/i386/usercall_asm.S
         ke/i386/usercall.c
         ke/i386/v86vdm.c
         mm/i386/page.c
         mm/ARM3/i386/init.c
         ps/i386/psctx.c
         ps/i386/psldt.c
-        rtl/i386/stack.S
         vdm/vdmmain.c
         vdm/vdmexec.c)
 elseif(ARCH STREQUAL "amd64")
+    list(APPEND ASM_SOURCE
+        ke/amd64/boot.S
+        ke/amd64/ctxswitch.S
+        ke/amd64/trap.S)
     list(APPEND SOURCE
         config/i386/cmhardwr.c
-        ke/amd64/boot.S
         ke/amd64/context.c
         ke/amd64/cpu.c
-        ke/amd64/ctxswitch.S
         ke/amd64/except.c
         ke/amd64/interrupt.c
         ke/amd64/irql.c
@@ -317,21 +321,21 @@ elseif(ARCH STREQUAL "amd64")
         ke/amd64/spinlock.c
         ke/amd64/stubs.c
         ke/amd64/thrdini.c
-        ke/amd64/trap.S
         mm/amd64/init.c
         mm/amd64/page.c
         ps/amd64/psctx.c)
 elseif(ARCH STREQUAL "arm")
+    list(APPEND ASM_SOURCE
+        ke/arm/boot.s
+        ke/arm/ctxswtch.s
+        ke/arm/stubs_asm.s
+        ke/arm/trap.s)
     list(APPEND SOURCE
         config/arm/cmhardwr.c
-        ke/arm/boot.s
         ke/arm/cpu.c
-        ke/arm/ctxswtch.s
         ke/arm/exp.c
         ke/arm/kiinit.c
-        ke/arm/stubs_asm.s
         ke/arm/thrdini.c
-        ke/arm/trap.s
         ke/arm/trapc.c
         ke/arm/usercall.c
         mm/arm/page.c
@@ -339,9 +343,11 @@ elseif(ARCH STREQUAL "arm")
         ps/arm/psctx.c
         rtl/arm/rtlexcpt.c)
 elseif(ARCH STREQUAL "powerpc")
+    list(APPEND ASM_SOURCE
+        ke/powerpc/main_asm.S
+        ke/powerpc/ctxhelp.S)
     list(APPEND SOURCE
         config/powerpc/cmhardwr.c
-        ke/powerpc/main_asm.S
         ke/powerpc/cpu.c
         ke/powerpc/exp.c
         ke/powerpc/kiinit.c
@@ -350,7 +356,6 @@ elseif(ARCH STREQUAL "powerpc")
         ke/powerpc/systimer.c
         ke/powerpc/thrdini.c
         ke/powerpc/ctxswitch.c
-        ke/powerpc/ctxhelp.S
         mm/powerpc/pfault.c
         mm/powerpc/page.c)
 endif()
@@ -361,18 +366,17 @@ if(NOT _WINKD_)
             kd/i386/kdmemsup.c
             kd/wrappers/gdbstub.c)
         if(KDBG)
-            list(APPEND SOURCE
-                kdbg/i386/i386-dis.c
-                kdbg/i386/kdb_help.S)
+            list(APPEND ASM_SOURCE kdbg/i386/kdb_help.S)
+            list(APPEND SOURCE kdbg/i386/i386-dis.c)
         endif()
     elseif(ARCH STREQUAL "amd64")
         list(APPEND SOURCE
             kd/amd64/kd.c
             kd/amd64/kdmemsup.c)
         if(KDBG)
+            list(APPEND ASM_SOURCE kdbg/amd64/kdb_help.S)
             list(APPEND SOURCE
                 kdbg/amd64/i386-dis.c
-                kdbg/amd64/kdb_help.S
                 kdbg/amd64/kdb.c)
         endif()
     elseif(ARCH STREQUAL "powerpc")
@@ -421,7 +425,10 @@ else() # _WINKD_
 
 endif()
 
+add_asm_files(ntoskrnl_asm ${ASM_SOURCE})
+
 add_executable(ntoskrnl
+    ${ntoskrnl_asm}
     ${SOURCE}
     ${CMAKE_CURRENT_BINARY_DIR}/ntoskrnl.def)
 
@@ -462,7 +469,14 @@ add_cd_file(TARGET ntoskrnl DESTINATION reactos/system32 NO_CAB FOR all)
 if(BUILD_MP)
     spec2def(ntkrnlmp.exe ntoskrnl.spec)
 
+    if(MSVC_IDE AND (CMAKE_VERSION MATCHES "ReactOS"))
+        set_source_files_properties(${ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "CONFIG_SMP")
+    endif()
+
+    add_asm_files(ntkrnlmp_asm ${ASM_SOURCE})
+
     add_executable(ntkrnlmp
+        ${ntkrnlmp_asm}
         ${SOURCE}
         ${CMAKE_CURRENT_BINARY_DIR}/ntkrnlmp.def)
 
@@ -492,4 +506,6 @@ if(BUILD_MP)
     add_cd_file(TARGET ntkrnlmp DESTINATION reactos/system32 NO_CAB FOR all)
 endif()
 
-add_library(ntdllsys ntdll.S)
+add_asm_files(ntdllsys_asm ntdll.S)
+add_library(ntdllsys ${ntdllsys_asm})
+set_target_properties(ntdllsys PROPERTIES LINKER_LANGUAGE "C")
index eb53a47..e269274 100644 (file)
@@ -179,7 +179,8 @@ list(APPEND SOURCE
     gdi/ntgdi/xformobj.c
     gdi/eng/stubs.c
     gdi/eng/umpdstubs.c
-    win32k.rc)
+    win32k.rc
+    ${CMAKE_CURRENT_BINARY_DIR}/win32k.def)
 
 if(USE_DIBLIB)
     add_definitions(-D_USE_DIBLIB_)
@@ -200,7 +201,7 @@ else()
 endif()
 
 if(ARCH STREQUAL "i386")
-list(APPEND SOURCE
+list(APPEND ASM_SOURCE
     gdi/dib/i386/dib24bpp_hline.s
     gdi/dib/i386/dib32bpp_hline.s
     gdi/dib/i386/dib32bpp_colorfill.s
@@ -216,9 +217,8 @@ if(KDBG)
         gdi/ntgdi/gdikdbgext.c)
 endif()
 
-add_library(win32k SHARED
-    ${CMAKE_CURRENT_BINARY_DIR}/win32k.def
-    ${SOURCE})
+add_asm_files(win32k_asm ${ASM_SOURCE})
+add_library(win32k SHARED ${SOURCE} ${win32k_asm})
 
 set_module_type(win32k kernelmodedriver)
 
@@ -235,5 +235,7 @@ add_importlibs(win32k ntoskrnl hal ftfd)
 add_pch(win32k pch.h)
 add_cd_file(TARGET win32k DESTINATION reactos/system32 FOR all)
 
-add_library(win32ksys sys-stubs.S)
 set_source_files_properties(sys-stubs.S PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/w32ksvc.h)
+add_asm_files(win32ksys_asm sys-stubs.S)
+add_library(win32ksys ${win32ksys_asm})
+set_target_properties(win32ksys PROPERTIES LINKER_LANGUAGE "C")