diff --git a/reactos/boot/freeldr/freeldr/CMakeLists.txt b/reactos/boot/freeldr/freeldr/CMakeLists.txt index 8f48a344b0e..cc65e0e6330 100644 --- a/reactos/boot/freeldr/freeldr/CMakeLists.txt +++ b/reactos/boot/freeldr/freeldr/CMakeLists.txt @@ -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) diff --git a/reactos/cmake/CMakeMacros.cmake b/reactos/cmake/CMakeMacros.cmake index 34aeebd6191..ba7f4a73418 100644 --- a/reactos/cmake/CMakeMacros.cmake +++ b/reactos/cmake/CMakeMacros.cmake @@ -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? diff --git a/reactos/cmake/gcc.cmake b/reactos/cmake/gcc.cmake index ac14dfaf25c..0f35c17273e 100644 --- a/reactos/cmake/gcc.cmake +++ b/reactos/cmake/gcc.cmake @@ -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() + diff --git a/reactos/cmake/msvc.cmake b/reactos/cmake/msvc.cmake index 952403ed6b5..b01267d3689 100644 --- a/reactos/cmake/msvc.cmake +++ b/reactos/cmake/msvc.cmake @@ -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 " ${I18N_DEFS} /fo ") +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, 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 ${definitions} /D__ASM__ /D_USE_ML /EP /c > .tmp" - " /nologo /Cp /Fo /c /Ta .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 " ${I18N_DEFS} /fo ") set(CMAKE_ASM_COMPILE_OBJECT "cl /nologo /X /I${REACTOS_SOURCE_DIR}/include/asm /I${REACTOS_BINARY_DIR}/include/asm /D__ASM__ /D_USE_ML /EP /c > .tmp" " /nologo /Cp /Fo /c /Ta .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() diff --git a/reactos/dll/ntdll/CMakeLists.txt b/reactos/dll/ntdll/CMakeLists.txt index 1a9047962b5..7ad854796d1 100644 --- a/reactos/dll/ntdll/CMakeLists.txt +++ b/reactos/dll/ntdll/CMakeLists.txt @@ -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) diff --git a/reactos/dll/win32/kernel32/CMakeLists.txt b/reactos/dll/win32/kernel32/CMakeLists.txt index efc98c9dd8c..72a1c34ce8c 100644 --- a/reactos/dll/win32/kernel32/CMakeLists.txt +++ b/reactos/dll/win32/kernel32/CMakeLists.txt @@ -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) diff --git a/reactos/dll/win32/oleaut32/CMakeLists.txt b/reactos/dll/win32/oleaut32/CMakeLists.txt index 5c3621c6c35..fa836d0ac99 100644 --- a/reactos/dll/win32/oleaut32/CMakeLists.txt +++ b/reactos/dll/win32/oleaut32/CMakeLists.txt @@ -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) diff --git a/reactos/dll/win32/rpcrt4/CMakeLists.txt b/reactos/dll/win32/rpcrt4/CMakeLists.txt index a6b142a1b50..ce6108a424d 100644 --- a/reactos/dll/win32/rpcrt4/CMakeLists.txt +++ b/reactos/dll/win32/rpcrt4/CMakeLists.txt @@ -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) diff --git a/reactos/drivers/CMakeLists.txt b/reactos/drivers/CMakeLists.txt index 7a672a385c5..fcfaa9396d8 100644 --- a/reactos/drivers/CMakeLists.txt +++ b/reactos/drivers/CMakeLists.txt @@ -1,4 +1,6 @@ +PROJECT(Drivers) + add_subdirectory(base) add_subdirectory(battery) add_subdirectory(bluetooth) diff --git a/reactos/drivers/ksfilter/ks/CMakeLists.txt b/reactos/drivers/ksfilter/ks/CMakeLists.txt index fdd2fa40d27..18d74c6013a 100644 --- a/reactos/drivers/ksfilter/ks/CMakeLists.txt +++ b/reactos/drivers/ksfilter/ks/CMakeLists.txt @@ -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") diff --git a/reactos/hal/CMakeLists.txt b/reactos/hal/CMakeLists.txt index e767918faa5..965a08d1376 100644 --- a/reactos/hal/CMakeLists.txt +++ b/reactos/hal/CMakeLists.txt @@ -1,4 +1,5 @@ +project(HAL) if((ARCH STREQUAL "i386") OR (ARCH STREQUAL "amd64")) add_subdirectory(halx86) elseif(ARCH STREQUAL "arm") diff --git a/reactos/hal/halx86/CMakeLists.txt b/reactos/hal/halx86/CMakeLists.txt index 4684c89859f..7fa5cf55f4c 100644 --- a/reactos/hal/halx86/CMakeLists.txt +++ b/reactos/hal/halx86/CMakeLists.txt @@ -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 $ $ @@ -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 $ $ @@ -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) diff --git a/reactos/lib/pseh/CMakeLists.txt b/reactos/lib/pseh/CMakeLists.txt index 1e957bf6b3c..d58e089fe99 100644 --- a/reactos/lib/pseh/CMakeLists.txt +++ b/reactos/lib/pseh/CMakeLists.txt @@ -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() diff --git a/reactos/lib/rtl/CMakeLists.txt b/reactos/lib/rtl/CMakeLists.txt index 5009360f037..46b17c26309 100644 --- a/reactos/lib/rtl/CMakeLists.txt +++ b/reactos/lib/rtl/CMakeLists.txt @@ -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) diff --git a/reactos/lib/sdk/crt/CMakeLists.txt b/reactos/lib/sdk/crt/CMakeLists.txt index dd4a9d327d3..5df63e0ad96 100644 --- a/reactos/lib/sdk/crt/CMakeLists.txt +++ b/reactos/lib/sdk/crt/CMakeLists.txt @@ -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) diff --git a/reactos/lib/sdk/crt/crt.cmake b/reactos/lib/sdk/crt/crt.cmake index b1479770f13..8433a708f3c 100644 --- a/reactos/lib/sdk/crt/crt.cmake +++ b/reactos/lib/sdk/crt/crt.cmake @@ -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 diff --git a/reactos/lib/sdk/crt/libcntpr.cmake b/reactos/lib/sdk/crt/libcntpr.cmake index c3401721867..7c8e490b3ca 100644 --- a/reactos/lib/sdk/crt/libcntpr.cmake +++ b/reactos/lib/sdk/crt/libcntpr.cmake @@ -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_ diff --git a/reactos/lib/sdk/crt/msvcrtex.cmake b/reactos/lib/sdk/crt/msvcrtex.cmake index 97bf4a954b7..fb5ae7b425c 100644 --- a/reactos/lib/sdk/crt/msvcrtex.cmake +++ b/reactos/lib/sdk/crt/msvcrtex.cmake @@ -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 diff --git a/reactos/lib/sdk/crt/oldnames.cmake b/reactos/lib/sdk/crt/oldnames.cmake index 8e2c2eb00c8..146db7f6b8d 100644 --- a/reactos/lib/sdk/crt/oldnames.cmake +++ b/reactos/lib/sdk/crt/oldnames.cmake @@ -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() diff --git a/reactos/ntoskrnl/CMakeLists.txt b/reactos/ntoskrnl/CMakeLists.txt index 02605d87e1c..381b7bcee59 100644 --- a/reactos/ntoskrnl/CMakeLists.txt +++ b/reactos/ntoskrnl/CMakeLists.txt @@ -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") diff --git a/reactos/win32ss/CMakeLists.txt b/reactos/win32ss/CMakeLists.txt index eb53a470e96..e269274e407 100644 --- a/reactos/win32ss/CMakeLists.txt +++ b/reactos/win32ss/CMakeLists.txt @@ -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")