<commit_before>project(Executor)
cmake_minimum_required(VERSION 3.9)
set(CMAKE_CXX_STANDARD 14)

find_program(PERL_COMMAND perl)

if(WIN32)
else()
find_library(DB_LIBRARY db)
find_path(DB_INCLUDE_PATH db.h ndbm.h)
include_directories(${DB_INCLUDE_PATH})
endif()

find_program(BISON_COMMAND bison)
find_package(Threads REQUIRED)

include_directories(include/)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(FRONT_END qt CACHE STRING "which front-end to use (qt, sdl2, sdl, x)")
set(HOST_ARCH generic_le)

if(WIN32)
set(HOST_OS "win32")
elseif(APPLE AND UNIX)
set(HOST_OS "macosx")
elseif(UNIX AND NOT APPLE)
set(HOST_OS "linux")
endif()


if(CMAKE_COMPILER_IS_GNUCXX)
    # -Wno-enum-compare: Mac OSErr codes are currently spread between different
    #                    anonymous enums in the headers.
    #                    Code like (blah ? noErr : paramErr) triggers the enum-compare warning.

    add_definitions(
        -Wall
        -Wno-unused-but-set-variable
        -Wno-sign-compare
        -Werror=return-type
        -Wno-enum-compare)
endif()

add_subdirectory(config/front-ends/x)
add_subdirectory(config/front-ends/sdl)
add_subdirectory(config/front-ends/sdl2)
add_subdirectory(config/front-ends/qt)
add_subdirectory(config/arch/generic_le)
add_subdirectory(config/os/win32)
add_subdirectory(config/os/macosx)


function(linkheader from to variant)
    if(DEFINED ARGV3)
        set(input ${ARGV3})
    else()
        set(input ${variant}.h)
    endif()

    configure_file(${from}/${variant}/${input} ${to} COPYONLY)
endfunction()

linkheader("config/os" "host-os-config.h" ${HOST_OS})
linkheader("config/arch" "host-arch-config.h" ${HOST_ARCH})
linkheader("config/front-ends" "front-end-config.h" ${FRONT_END})
linkheader("config/sound" "sound-config.h" "dummy" "dummy-sound.h")

add_executable(map_to_c map_to_c/map_to_c.cpp)
add_executable(mkseedtables mkseedtables/mkseedtables.c)
add_executable(mkultable mkultable/mkultable.c)
add_executable(mksspairtable mksspairtable/mksspairtable.c)

include_directories(config/os/${HOST_OS})

set(MAP_FILES
        active             arrow_down_inactive  arrow_right_active    arrow_up_inactive  ractive      zoom
        apple              arrow_left_active    arrow_right_inactive  go_away            thumb_horiz
        arrow_down_active  arrow_left_inactive  arrow_up_active       grow               thumb_vert
    )
set(GENERATED_FILES)
foreach(mapfile ${MAP_FILES})
    add_custom_command(
        OUTPUT ${mapfile}.cmap
        DEPENDS ${mapfile}.map
        COMMAND map_to_c < ${CMAKE_CURRENT_SOURCE_DIR}/${mapfile}.map > ${mapfile}.cmap
        )
    list(APPEND GENERATED_FILES ${mapfile}.cmap)
endforeach()

add_custom_command(OUTPUT seedtables.ctable COMMAND mkseedtables > seedtables.ctable)
add_custom_command(OUTPUT ultable.ctable COMMAND mkultable > ultable.ctable)
add_custom_command(OUTPUT sspairtable.ctable COMMAND mksspairtable > sspairtable.ctable)
list(APPEND GENERATED_FILES seedtables.ctable ultable.ctable sspairtable.ctable)


add_custom_command(OUTPUT rawpatstubs.ctable
    DEPENDS makerawblt.pl pat-blitters.tmpl
    COMMAND ${PERL_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/makerawblt.pl
        < ${CMAKE_CURRENT_SOURCE_DIR}/pat-blitters.tmpl
        > rawpatstubs.ctable)

add_custom_command(OUTPUT rawsrcstubs.ctable
    DEPENDS makerawblt.pl src-blitters.tmpl
    COMMAND ${PERL_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/makerawblt.pl
        < ${CMAKE_CURRENT_SOURCE_DIR}/src-blitters.tmpl
        > rawsrcstubs.ctable)

add_custom_command(OUTPUT parse.tab.cpp
        DEPENDS parse.ypp
        COMMAND ${BISON_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/parse.ypp)
list(APPEND GENERATED_FILES rawpatstubs.ctable rawsrcstubs.ctable parse.tab.cpp)


set(ctl_sources ctlArrows.cpp ctlDisplay.cpp ctlIMIV.cpp ctlInit.cpp ctlMisc.cpp
    ctlMouse.cpp ctlSet.cpp ctlSize.cpp ctlStddef.cpp ctlPopup.cpp)
source_group(Controls FILES ${ctl_sources})

set(dial_sources dialAlert.cpp dialCreate.cpp dialHandle.cpp dialInit.cpp dialManip.cpp
    dialDispatch.cpp dialItem.cpp)
source_group(Dialogs FILES ${dial_sources})

set(file_sources fileAccess.cpp fileCreate.cpp fileDirs.cpp fileDouble.cpp fileInfo.cpp
    fileMisc.cpp fileVolumes.cpp fileHighlevel.cpp dcache.cpp)
source_group(Files FILES ${file_sources})

set(hfs_sources hfsBtree.cpp hfsChanging.cpp hfsCreate.cpp hfsFile.cpp hfsHelper.cpp
    hfsHier.cpp hfsMisc.cpp hfsVolume.cpp hfsWorkingdir.cpp hfsXbar.cpp)
source_group(HFS FILES ${hfs_sources})

set(list_sources listAccess.cpp listAddDel.cpp listCreate.cpp listDisplay.cpp
    listMouse.cpp listOps.cpp listStdLDEF.cpp)
source_group(Lists FILES ${list_sources})

set(menu_sources menu.cpp menuColor.cpp menuV.cpp stdmdef.cpp stdmbdf.cpp)
source_group(Menus FILES ${menu_sources})

set(print_sources PSstrings.cpp prError.cpp prInit.cpp prLowLevel.cpp
    prPrinting.cpp prRecords.cpp PSprint.cpp )
source_group(Printing FILES ${print_sources})

set(qd_sources qBit.cpp qCConv.cpp qCGrafPort.cpp qCRegular.cpp qColor.cpp qColorMgr.cpp
             qColorutil.cpp qCursor.cpp qGrafport.cpp qIMIV.cpp qIMV.cpp qIMVxfer.cpp
             qMisc.cpp qPaletteMgr.cpp qPen.cpp qPicstuff.cpp qPicture.cpp
             qPixMapConv.cpp qPoint.cpp qPoly.cpp qRect.cpp qRegion.cpp qRegular.cpp
             qScale.cpp qStandard.cpp qStdArc.cpp qStdBits.cpp qStdLine.cpp qStdOval.cpp
             qStdPic.cpp qStdPoly.cpp qStdRRect.cpp qStdRect.cpp qStdRgn.cpp
             qStdText.cpp qText.cpp qGWorld.cpp qGDevice.cpp qIMVI.cpp qHooks.cpp
             xdata.cpp xdblt.cpp rawpatblt.cpp rawsrcblt.cpp dirtyrect.cpp srcblt.cpp
             qColorPicker.cpp qPict2.cpp image.cpp image_inits.cpp
             default_ctab_values.cpp dcconvert.cpp rgbutil.cpp dcmaketables.cpp)
source_group(QuickDraw FILES ${qd_sources})

set(res_sources resGet.cpp resGetinfo.cpp resGettype.cpp resIMIV.cpp resInit.cpp
    resMisc.cpp resMod.cpp resOpen.cpp resSetcur.cpp resPartial.cpp)
source_group(Resources FILES ${res_sources})

set(te_sources teAccess.cpp teDisplay.cpp teEdit.cpp teIMIV.cpp teIMV.cpp teInit.cpp
    teInsert.cpp teMisc.cpp teScrap.cpp)
source_group(TextEdit FILES ${te_sources})

set(wind_sources windColor.cpp windDisplay.cpp windDocdef.cpp windInit.cpp windMisc.cpp
    windMouse.cpp windSize.cpp windUpdate.cpp windRootless.cpp)
source_group(Windows FILES ${wind_sources})

set(ae_sources AE.cpp AE_desc.cpp AE_hdlr.cpp AE_coercion.cpp)
source_group(AppleEvents FILES ${ae_sources})

set(sound_sources sounddriver.cpp sound.cpp soundIMVI.cpp soundfake.cpp snth5.cpp
    SpeechManager.cpp)
source_group(Sound FILES ${sound_sources})

set(num_sources bindec.cpp float4.cpp float5.cpp float7.cpp floatnext.cpp toolmath.cpp
    mathlib.cpp)
source_group(Numerics FILES ${num_sources})

set(misc_sources desk.cpp device.cpp disk.cpp diskinit.cpp dump.cpp trapname.cpp font.cpp
  gestalt.cpp globals.cpp iu.cpp launch.cpp main.cpp mman.cpp mmansubr.cpp notify.cpp hle.cpp
  osevent.cpp osutil.cpp pack.cpp scrap.cpp script.cpp segment.cpp serial.cpp
  slash.cpp stdfile.cpp romlib_stubs.cpp syserr.cpp toolevent.cpp toolutil.cpp time.cpp
  vbl.cpp syncint.cpp virtualint.cpp refresh.cpp autorefresh.cpp aboutbox.cpp
  option.cpp parseopt.cpp parsenum.cpp desperate.cpp
  version.cpp shutdown.cpp uniquefile.cpp screen-dump.cpp
  process.cpp alias.cpp string.cpp tempmem.cpp edition.cpp fontIMVI.cpp balloon.cpp
  error.cpp adb.cpp color_wheel_bits.cpp finder.cpp system_error.cpp ibm_keycodes.cpp
  icon.cpp redrawscreen.cpp ini.cpp checkpoint.cpp qt.cpp
  paramline.c fauxdbm.cpp commtool.cpp cfm.cpp pef_hash.cpp
  interfacelib.cpp mixed_mode.cpp suffix_maps.cpp appearance.cpp lockrange.cpp
  emutrap.cpp emutraptables.cpp emustubs.cpp functions.cpp unix_like.cpp parse.ypp check_structs.cpp
  executor.cpp  crc.cpp)

set(include_sources hintemplate.h
                  include/ADB.h
                  include/AliasMgr.h
                  include/AppleEvents.h
                  include/AppleTalk.h
                  include/BinaryDecimal.h
                  include/CommTool.h
                  include/Components.h
                  include/ControlMgr.h
                  include/CQuickDraw.h
                  include/DeskMgr.h
                  include/DeviceMgr.h
                  include/DialogMgr.h
                  include/Disk.h
                  include/DiskInit.h
                  include/EditionMgr.h
                  include/EventMgr.h
                  include/FileMgr.h
                  include/Finder.h
                  include/FontMgr.h
                  include/Gestalt.h
                  include/HelpMgr.h
                  include/Iconutil.h
                  include/IntlUtil.h
                  include/ListMgr.h
                  include/ExMacTypes.h<commit_msg>reorder source files for compilation parallelism<commit_after>project(Executor)
cmake_minimum_required(VERSION 3.9)
set(CMAKE_CXX_STANDARD 14)

find_program(PERL_COMMAND perl)

if(WIN32)
else()
find_library(DB_LIBRARY db)
find_path(DB_INCLUDE_PATH db.h ndbm.h)
include_directories(${DB_INCLUDE_PATH})
endif()

find_program(BISON_COMMAND bison)
find_package(Threads REQUIRED)

include_directories(include/)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

set(FRONT_END qt CACHE STRING "which front-end to use (qt, sdl2, sdl, x)")
set(HOST_ARCH generic_le)

if(WIN32)
set(HOST_OS "win32")
elseif(APPLE AND UNIX)
set(HOST_OS "macosx")
elseif(UNIX AND NOT APPLE)
set(HOST_OS "linux")
endif()


if(CMAKE_COMPILER_IS_GNUCXX)
    # -Wno-enum-compare: Mac OSErr codes are currently spread between different
    #                    anonymous enums in the headers.
    #                    Code like (blah ? noErr : paramErr) triggers the enum-compare warning.

    add_definitions(
        -Wall
        -Wno-unused-but-set-variable
        -Wno-sign-compare
        -Werror=return-type
        -Wno-enum-compare)
endif()

add_subdirectory(config/front-ends/x)
add_subdirectory(config/front-ends/sdl)
add_subdirectory(config/front-ends/sdl2)
add_subdirectory(config/front-ends/qt)
add_subdirectory(config/arch/generic_le)
add_subdirectory(config/os/win32)
add_subdirectory(config/os/macosx)


function(linkheader from to variant)
    if(DEFINED ARGV3)
        set(input ${ARGV3})
    else()
        set(input ${variant}.h)
    endif()

    configure_file(${from}/${variant}/${input} ${to} COPYONLY)
endfunction()

linkheader("config/os" "host-os-config.h" ${HOST_OS})
linkheader("config/arch" "host-arch-config.h" ${HOST_ARCH})
linkheader("config/front-ends" "front-end-config.h" ${FRONT_END})
linkheader("config/sound" "sound-config.h" "dummy" "dummy-sound.h")

add_executable(map_to_c map_to_c/map_to_c.cpp)
add_executable(mkseedtables mkseedtables/mkseedtables.c)
add_executable(mkultable mkultable/mkultable.c)
add_executable(mksspairtable mksspairtable/mksspairtable.c)

include_directories(config/os/${HOST_OS})

set(MAP_FILES
        active             arrow_down_inactive  arrow_right_active    arrow_up_inactive  ractive      zoom
        apple              arrow_left_active    arrow_right_inactive  go_away            thumb_horiz
        arrow_down_active  arrow_left_inactive  arrow_up_active       grow               thumb_vert
    )
set(GENERATED_FILES)
foreach(mapfile ${MAP_FILES})
    add_custom_command(
        OUTPUT ${mapfile}.cmap
        DEPENDS ${mapfile}.map
        COMMAND map_to_c < ${CMAKE_CURRENT_SOURCE_DIR}/${mapfile}.map > ${mapfile}.cmap
        )
    list(APPEND GENERATED_FILES ${mapfile}.cmap)
endforeach()

add_custom_command(OUTPUT seedtables.ctable COMMAND mkseedtables > seedtables.ctable)
add_custom_command(OUTPUT ultable.ctable COMMAND mkultable > ultable.ctable)
add_custom_command(OUTPUT sspairtable.ctable COMMAND mksspairtable > sspairtable.ctable)
list(APPEND GENERATED_FILES seedtables.ctable ultable.ctable sspairtable.ctable)


add_custom_command(OUTPUT rawpatstubs.ctable
    DEPENDS makerawblt.pl pat-blitters.tmpl
    COMMAND ${PERL_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/makerawblt.pl
        < ${CMAKE_CURRENT_SOURCE_DIR}/pat-blitters.tmpl
        > rawpatstubs.ctable)

add_custom_command(OUTPUT rawsrcstubs.ctable
    DEPENDS makerawblt.pl src-blitters.tmpl
    COMMAND ${PERL_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/makerawblt.pl
        < ${CMAKE_CURRENT_SOURCE_DIR}/src-blitters.tmpl
        > rawsrcstubs.ctable)

add_custom_command(OUTPUT parse.tab.cpp
        DEPENDS parse.ypp
        COMMAND ${BISON_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/parse.ypp)
list(APPEND GENERATED_FILES rawpatstubs.ctable rawsrcstubs.ctable parse.tab.cpp)


set(ctl_sources ctlArrows.cpp ctlDisplay.cpp ctlIMIV.cpp ctlInit.cpp ctlMisc.cpp
    ctlMouse.cpp ctlSet.cpp ctlSize.cpp ctlStddef.cpp ctlPopup.cpp)
source_group(Controls FILES ${ctl_sources})

set(dial_sources dialAlert.cpp dialCreate.cpp dialHandle.cpp dialInit.cpp dialManip.cpp
    dialDispatch.cpp dialItem.cpp)
source_group(Dialogs FILES ${dial_sources})

set(file_sources fileAccess.cpp fileCreate.cpp fileDirs.cpp fileDouble.cpp fileInfo.cpp
    fileMisc.cpp fileVolumes.cpp fileHighlevel.cpp dcache.cpp)
source_group(Files FILES ${file_sources})

set(hfs_sources hfsBtree.cpp hfsChanging.cpp hfsCreate.cpp hfsFile.cpp hfsHelper.cpp
    hfsHier.cpp hfsMisc.cpp hfsVolume.cpp hfsWorkingdir.cpp hfsXbar.cpp)
source_group(HFS FILES ${hfs_sources})

set(list_sources listAccess.cpp listAddDel.cpp listCreate.cpp listDisplay.cpp
    listMouse.cpp listOps.cpp listStdLDEF.cpp)
source_group(Lists FILES ${list_sources})

set(menu_sources menu.cpp menuColor.cpp menuV.cpp stdmdef.cpp stdmbdf.cpp)
source_group(Menus FILES ${menu_sources})

set(print_sources PSstrings.cpp prError.cpp prInit.cpp prLowLevel.cpp
    prPrinting.cpp prRecords.cpp PSprint.cpp )
source_group(Printing FILES ${print_sources})

set(qd_sources qBit.cpp qCConv.cpp qCGrafPort.cpp qCRegular.cpp qColor.cpp qColorMgr.cpp
             qColorutil.cpp qCursor.cpp qGrafport.cpp qIMIV.cpp qIMV.cpp qIMVxfer.cpp
             qMisc.cpp qPaletteMgr.cpp qPen.cpp qPicstuff.cpp qPicture.cpp
             qPixMapConv.cpp qPoint.cpp qPoly.cpp qRect.cpp qRegion.cpp qRegular.cpp
             qScale.cpp qStandard.cpp qStdArc.cpp qStdBits.cpp qStdLine.cpp qStdOval.cpp
             qStdPic.cpp qStdPoly.cpp qStdRRect.cpp qStdRect.cpp qStdRgn.cpp
             qStdText.cpp qText.cpp qGWorld.cpp qGDevice.cpp qIMVI.cpp qHooks.cpp
             xdata.cpp xdblt.cpp rawpatblt.cpp rawsrcblt.cpp dirtyrect.cpp srcblt.cpp
             qColorPicker.cpp qPict2.cpp image.cpp image_inits.cpp
             default_ctab_values.cpp dcconvert.cpp rgbutil.cpp dcmaketables.cpp)
source_group(QuickDraw FILES ${qd_sources})

set(res_sources resGet.cpp resGetinfo.cpp resGettype.cpp resIMIV.cpp resInit.cpp
    resMisc.cpp resMod.cpp resOpen.cpp resSetcur.cpp resPartial.cpp)
source_group(Resources FILES ${res_sources})

set(te_sources teAccess.cpp teDisplay.cpp teEdit.cpp teIMIV.cpp teIMV.cpp teInit.cpp
    teInsert.cpp teMisc.cpp teScrap.cpp)
source_group(TextEdit FILES ${te_sources})

set(wind_sources windColor.cpp windDisplay.cpp windDocdef.cpp windInit.cpp windMisc.cpp
    windMouse.cpp windSize.cpp windUpdate.cpp windRootless.cpp)
source_group(Windows FILES ${wind_sources})

set(ae_sources AE.cpp AE_desc.cpp AE_hdlr.cpp AE_coercion.cpp)
source_group(AppleEvents FILES ${ae_sources})

set(sound_sources sounddriver.cpp sound.cpp soundIMVI.cpp soundfake.cpp snth5.cpp
    SpeechManager.cpp)
source_group(Sound FILES ${sound_sources})

set(num_sources bindec.cpp float4.cpp float5.cpp float7.cpp floatnext.cpp toolmath.cpp
    mathlib.cpp)
source_group(Numerics FILES ${num_sources})

set(misc_sources functions.cpp desk.cpp device.cpp disk.cpp diskinit.cpp dump.cpp trapname.cpp font.cpp
  gestalt.cpp globals.cpp iu.cpp launch.cpp main.cpp mman.cpp mmansubr.cpp notify.cpp hle.cpp
  osevent.cpp osutil.cpp pack.cpp scrap.cpp script.cpp segment.cpp serial.cpp
  slash.cpp stdfile.cpp romlib_stubs.cpp syserr.cpp toolevent.cpp toolutil.cpp time.cpp
  vbl.cpp syncint.cpp virtualint.cpp refresh.cpp autorefresh.cpp aboutbox.cpp
  option.cpp parseopt.cpp parsenum.cpp desperate.cpp
  version.cpp shutdown.cpp uniquefile.cpp screen-dump.cpp
  process.cpp alias.cpp string.cpp tempmem.cpp edition.cpp fontIMVI.cpp balloon.cpp
  error.cpp adb.cpp color_wheel_bits.cpp finder.cpp system_error.cpp ibm_keycodes.cpp
  icon.cpp redrawscreen.cpp ini.cpp checkpoint.cpp qt.cpp
  paramline.c fauxdbm.cpp commtool.cpp cfm.cpp pef_hash.cpp
  interfacelib.cpp mixed_mode.cpp suffix_maps.cpp appearance.cpp lockrange.cpp
  emutrap.cpp emutraptables.cpp emustubs.cpp unix_like.cpp parse.ypp check_structs.cpp
  executor.cpp  crc.cpp)

set(include_sources hintemplate.h
                  include/ADB.h
                  include/AliasMgr.h
                  include/AppleEvents.h
                  include/AppleTalk.h
                  include/BinaryDecimal.h
                  include/CommTool.h
                  include/Components.h
                  include/ControlMgr.h
                  include/CQuickDraw.h
                  include/DeskMgr.h
                  include/DeviceMgr.h
                  include/DialogMgr.h
                  include/Disk.h
                  include/DiskInit.h
                  include/EditionMgr.h
                  include/EventMgr.h
                  include/FileMgr.h
                  include/Finder.h
                  include/FontMgr.h
                  include/Gestalt.h
                  include/HelpMgr.h
                  include/Iconutil.h
                  include/IntlUtil.h
                  include/ListMgr.h
                  include/ExMacTypes.h
{'fraction_non_alphanumeric': 0.08737147077202749, 'fraction_numerical': 0.002385956939158098, 'mean_word_length': 3.4862385321100917, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '873453', 'n_tokens_mistral': 6176, 'n_tokens_neox': 5993, 'n_words': 1066}