Fix the mess that was our hal CMakeLists.txt. Seperate all components into their own cmake files, 

svn path=/trunk/; revision=58594
This commit is contained in:
Timo Kreuzer 2013-03-23 21:15:28 +00:00
parent b8ae1388ea
commit e66df55a54
9 changed files with 187 additions and 236 deletions

View file

@ -7,263 +7,75 @@ include_directories(
include
${REACTOS_SOURCE_DIR}/ntoskrnl/include)
list(APPEND HAL_GENERIC_SOURCE
generic/beep.c
generic/cmos.c
generic/display.c
generic/dma.c
generic/drive.c
generic/halinit.c
generic/memory.c
generic/misc.c
generic/reboot.c
generic/sysinfo.c
generic/usage.c)
function(add_hal _halname)
cmake_parse_arguments(_haldata "" "" "SOURCES;COMPONENTS" ${ARGN})
if(ARCH STREQUAL "i386")
list(APPEND HAL_GENERIC_SOURCE
generic/bios.c
generic/portio.c)
endif()
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})
endif()
add_dependencies(lib_hal_generic asm)
add_pch(lib_hal_generic include/hal.h)
if(ARCH STREQUAL "i386")
#####################################
# Generate the pcidata source files in the x86 build
#
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.h
COMMAND native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_classes.ids ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.h ClassTable INIT_FUNCTION ${CMAKE_CURRENT_SOURCE_DIR}/include/hal.h
DEPENDS native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_classes.ids)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.h
COMMAND native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_vendors.ids ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.h VendorTable INIT_FUNCTION ${CMAKE_CURRENT_SOURCE_DIR}/include/hal.h
DEPENDS native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_vendors.ids)
#####################################
list(APPEND HAL_LEGACY_SOURCE
legacy/bus/bushndlr.c
legacy/bus/cmosbus.c
legacy/bus/isabus.c
legacy/bus/pcibus.c
${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c
${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c
legacy/bus/sysbus.c
legacy/bussupp.c
legacy/halpnpdd.c
legacy/halpcat.c)
# Handle the spec file for the dll name
spec2def(${_halname}.dll ../hal.spec ADD_IMPORTLIB)
# Create the actual target
if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
add_library(lib_hal_legacy OBJECT ${HAL_LEGACY_SOURCE})
foreach(_component ${_haldata_COMPONENTS})
list(APPEND _haldata_SOURCES "$<TARGET_OBJECTS:lib_hal_${_component}>")
endforeach()
add_library(${_halname} SHARED
${_haldata_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/hal.def)
else()
add_library(lib_hal_legacy ${HAL_LEGACY_SOURCE})
foreach(_component ${_haldata_COMPONENTS})
list(APPEND _haldata_LIBS "lib_hal_${_component}")
endforeach()
add_library(${_halname} SHARED
${_haldata_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/hal.def)
target_link_libraries(${_halname} ${_haldata_LIBS})
endif()
#add_pch(lib_hal_legacy include/hal.h)
if(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
target_link_libraries(lib_hal_legacy lib_hal_generic)
target_link_libraries(${_halname} libcntpr)
add_importlibs(${_halname} ntoskrnl)
#add_pch(${_halname} include/hal.h)
add_dependencies(${_halname} psdk bugcodes asm)
set_entrypoint(${_halname} HalInitSystem 8)
set_subsystem(${_halname} native)
set_image_base(${_halname} 0x00010000)
add_cd_file(TARGET ${_halname} DESTINATION reactos/system32 NO_CAB FOR all)
if(MSVC)
add_target_link_flags(${_halname} "/ignore:4216 /ignore:4078")
endif()
endfunction()
endif()
list(APPEND HAL_ACPI_SOURCE
acpi/halacpi.c
acpi/halpnpdd.c
acpi/busemul.c
legacy/bus/pcibus.c)
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(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
target_link_libraries(lib_hal_acpi lib_hal_generic)
endif()
list(APPEND HAL_UP_SOURCE
generic/spinlock.c
up/processor.c)
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/halinit_apic.c
apic/rtctimer.c
apic/tsc.c)
# The components
include(generic.cmake)
include(acpi.cmake)
include(apic.cmake)
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
up/halinit_up.c
up/pic.c)
if(NOT MSVC AND (CMAKE_VERSION VERSION_GREATER 2.8.7))
add_library(lib_hal_pic OBJECT ${HAL_PIC_SOURCE} ${HAL_PIC_ASM_SOURCE})
add_dependencies(lib_hal_pic asm)
endif()
list(APPEND MINI_HAL_SOURCE
generic/portio.c
generic/systimer.S
legacy/bus/bushndlr.c
legacy/bus/cmosbus.c
legacy/bus/isabus.c
legacy/bus/pcibus.c
legacy/bus/sysbus.c
legacy/bussupp.c
generic/beep.c
generic/bios.c
generic/cmos.c
generic/dma.c
generic/display.c
generic/drive.c
generic/misc.c
generic/profil.c
generic/reboot.c
generic/spinlock.c
generic/sysinfo.c
generic/timer.c
generic/usage.c
up/halinit_mini.c
up/pic.c
up/processor.c)
spec2def(hal.dll ../hal.spec ADD_IMPORTLIB)
include(pcidata.cmake)
include(legacy.cmake)
include(up.cmake)
include(pic.cmake)
include(minihal.cmake)
# hal
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>
$<TARGET_OBJECTS:lib_hal_up>
$<TARGET_OBJECTS:lib_hal_pic>
generic/v86.S
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}
${hal_asm}
up/halup.rc
${CMAKE_CURRENT_BINARY_DIR}/hal.def)
endif()
add_hal(hal SOURCES up/halup.rc COMPONENTS generic legacy up pic)
add_hal(halacpi SOURCES acpi/halacpi.rc COMPONENTS generic acpi up pic)
add_hal(halapic SOURCES acpi/halacpi.rc COMPONENTS generic legacy up apic)
add_hal(halaacpi SOURCES acpi/halacpi.rc COMPONENTS generic acpi up apic)
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)
add_importlibs(hal ntoskrnl)
#add_pch(hal include/hal.h)
add_dependencies(hal psdk bugcodes asm)
set_entrypoint(hal HalInitSystem 8)
set_subsystem(hal native)
set_image_base(hal 0x00010000)
add_cd_file(TARGET hal DESTINATION reactos/system32 NO_CAB FOR all)
if(MSVC)
add_target_link_flags(hal "/ignore:4216 /ignore:4078")
endif()
# hal acpi
spec2def(halacpi.dll ../hal.spec)
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>
$<TARGET_OBJECTS:lib_hal_up>
$<TARGET_OBJECTS:lib_hal_pic>
generic/v86.S
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}
${halacpi_asm}
acpi/halacpi.rc
${CMAKE_CURRENT_BINARY_DIR}/halacpi.def)
endif()
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)
add_importlibs(halacpi ntoskrnl)
add_dependencies(halacpi psdk bugcodes asm)
set_entrypoint(halacpi HalInitSystem@8)
set_subsystem(halacpi native)
set_image_base(halacpi 0x00010000)
add_target_compile_definitions(halacpi CONFIG_ACPI)
add_cd_file(TARGET halacpi DESTINATION reactos/system32 NO_CAB FOR all)
if(MSVC)
add_target_link_flags(halacpi "/ignore:4216 /ignore:4078")
endif()
# mini_hal
add_library(mini_hal ${MINI_HAL_SOURCE})
add_target_compile_definitions(mini_hal _BLDR_ _MINIHAL_)
add_dependencies(mini_hal psdk bugcodes asm)
#add_hal(halmps SOURCES up/halup.rc COMPONENTS generic legacy smp pic)
#add_hal(halmacpi SOURCES acpi/halacpi.rc COMPONENTS generic acpi smp pic)
#add_hal(halmapic SOURCES acpi/halacpi.rc COMPONENTS generic legacy smp apic)
#add_hal(halmaacpi SOURCES acpi/halacpi.rc COMPONENTS generic acpi smp apic)
elseif(ARCH STREQUAL "amd64")
spec2def(hal.dll ../hal.spec ADD_IMPORTLIB)
list(APPEND HAL_SOURCE
${HAL_GENERIC_SOURCE}
${HAL_ACPI_SOURCE}
${HAL_APIC_SOURCE}
generic/spinlock.c
amd64/x86bios.c
amd64/halinit.c
amd64/processor.c
${CMAKE_CURRENT_BINARY_DIR}/hal.def)
amd64/processor.c)
# hal
add_library(hal SHARED ${HAL_SOURCE})
add_pch(hal include/hal.h)
add_dependencies(hal psdk bugcodes asm)
set_entrypoint(hal HalInitSystem)
set_subsystem(hal native)
set_image_base(hal 0x00010000)
add_importlibs(hal ntoskrnl)
target_link_libraries(hal libcntpr)
if(MSVC)
add_target_link_flags(hal "/ignore:4216")
endif()
add_cd_file(TARGET hal DESTINATION reactos/system32 NO_CAB FOR all)
add_hal(hal SOURCES ${HAL_SOURCE} COMPONENTS generic acpi apic)
endif()

View file

@ -0,0 +1,14 @@
list(APPEND HAL_ACPI_SOURCE
acpi/halacpi.c
acpi/halpnpdd.c
acpi/busemul.c
legacy/bus/pcibus.c)
add_object_library(lib_hal_acpi ${HAL_ACPI_SOURCE})
#add_pch(lib_hal_acpi include/hal.h)
if(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
target_link_libraries(lib_hal_acpi lib_hal_generic)
endif()

View file

@ -0,0 +1,14 @@
list(APPEND HAL_APIC_ASM_SOURCE
apic/apictrap.S
apic/tsccal.S)
list(APPEND HAL_APIC_SOURCE
apic/apic.c
apic/apictimer.c
apic/halinit_apic.c
apic/rtctimer.c
apic/tsc.c)
add_object_library(lib_hal_apic ${HAL_APIC_SOURCE} ${HAL_APIC_ASM_SOURCE})
add_dependencies(lib_hal_apic asm)

View file

@ -0,0 +1,27 @@
list(APPEND HAL_GENERIC_SOURCE
generic/beep.c
generic/cmos.c
generic/display.c
generic/dma.c
generic/drive.c
generic/halinit.c
generic/memory.c
generic/misc.c
generic/reboot.c
generic/sysinfo.c
generic/usage.c)
if(ARCH STREQUAL "i386")
list(APPEND HAL_GENERIC_SOURCE
generic/bios.c
generic/portio.c)
list(APPEND HAL_GENERIC_ASM_SOURCE
generic/v86.S)
endif()
add_asm_files(halacpi_asm ${HAL_PIC_ASM_SOURCE} generic/v86.S)
add_object_library(lib_hal_generic ${HAL_GENERIC_SOURCE} ${HAL_GENERIC_ASM_SOURCE})
add_dependencies(lib_hal_generic asm)
add_pch(lib_hal_generic include/hal.h)

View file

@ -0,0 +1,20 @@
list(APPEND HAL_LEGACY_SOURCE
legacy/bus/bushndlr.c
legacy/bus/cmosbus.c
legacy/bus/isabus.c
legacy/bus/pcibus.c
${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c
${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c
legacy/bus/sysbus.c
legacy/bussupp.c
legacy/halpnpdd.c
legacy/halpcat.c)
add_object_library(lib_hal_legacy ${HAL_LEGACY_SOURCE})
#add_pch(lib_hal_legacy include/hal.h)
if(MSVC OR (NOT CMAKE_VERSION VERSION_GREATER 2.8.7))
target_link_libraries(lib_hal_legacy lib_hal_generic)
endif()

View file

@ -0,0 +1,32 @@
list(APPEND MINI_HAL_SOURCE
generic/portio.c
generic/systimer.S
legacy/bus/bushndlr.c
legacy/bus/cmosbus.c
legacy/bus/isabus.c
legacy/bus/pcibus.c
legacy/bus/sysbus.c
legacy/bussupp.c
generic/beep.c
generic/bios.c
generic/cmos.c
generic/dma.c
generic/display.c
generic/drive.c
generic/misc.c
generic/profil.c
generic/reboot.c
generic/spinlock.c
generic/sysinfo.c
generic/timer.c
generic/usage.c
up/halinit_mini.c
up/pic.c
up/processor.c)
# mini_hal
add_library(mini_hal ${MINI_HAL_SOURCE})
add_target_compile_definitions(mini_hal _BLDR_ _MINIHAL_)
add_dependencies(mini_hal psdk bugcodes asm)

View file

@ -0,0 +1,13 @@
#####################################
# Generate the pcidata source files in the x86 build
#
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.h
COMMAND native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_classes.ids ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.c ${CMAKE_CURRENT_BINARY_DIR}/pci_classes.h ClassTable INIT_FUNCTION ${CMAKE_CURRENT_SOURCE_DIR}/include/hal.h
DEPENDS native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_classes.ids)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.h
COMMAND native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_vendors.ids ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.c ${CMAKE_CURRENT_BINARY_DIR}/pci_vendors.h VendorTable INIT_FUNCTION ${CMAKE_CURRENT_SOURCE_DIR}/include/hal.h
DEPENDS native-bin2c ${CMAKE_CURRENT_SOURCE_DIR}/legacy/bus/pci_vendors.ids)
#####################################

View file

@ -0,0 +1,13 @@
list(APPEND HAL_PIC_ASM_SOURCE
generic/systimer.S
generic/trap.S)
list(APPEND HAL_PIC_SOURCE
generic/profil.c
generic/timer.c
up/halinit_up.c
up/pic.c)
add_object_library(lib_hal_pic ${HAL_PIC_SOURCE} ${HAL_PIC_ASM_SOURCE})
add_dependencies(lib_hal_pic asm)

View file

@ -0,0 +1,6 @@
list(APPEND HAL_UP_SOURCE
generic/spinlock.c
up/processor.c)
add_object_library(lib_hal_up ${HAL_UP_SOURCE})