set(HEADERS
    ../descent3/aiambient.h
    ../descent3/AIGoal.h
    ../descent3/AIMain.h
    ../descent3/aipath.h
    ../descent3/aistruct.h
    ../descent3/aistruct_external.h
    ../descent3/aiterrain.h
    ../descent3/ambient.h
    ../descent3/args.h
    ../descent3/attach.h
    ../descent3/audiotaunts.h
    ../descent3/bnode.h
    ../descent3/BOA.h
    ../descent3/Briefing.h
    ../descent3/BriefingParse.h
    ../descent3/bsp.h
    ../descent3/buddymenu.h
    ../descent3/cinematics.h
    ../descent3/cockpit.h
    ../descent3/config.h
    ../descent3/ConfigItem.h
    ../descent3/controls.h
    ../descent3/credits.h
    ../descent3/CtlCfgElem.h
    ../descent3/ctlconfig.h
    ../descent3/ctlconfigtxt.h
    ../descent3/D3ForceFeedback.h
    ../descent3/d3serial.h
    ../descent3/damage.h
    ../descent3/damage_external.h
    ../descent3/DeathInfo.h
    ../descent3/deathinfo_external.h
    ../descent3/debuggraph.h
    ../descent3/descent.h
    ../descent3/difficulty.h
    ../descent3/difficulty_external.h
    ../descent3/DllWrappers.h
    ../descent3/door.h
    ../descent3/doorway.h
    ../descent3/fireball.h
    ../descent3/fireball_external.h
    ../descent3/game.h
    ../descent3/gamecinematics.h
    ../descent3/gamecinematics_external.h
    ../descent3/gameevent.h
    ../descent3/gamefile.h
    ../descent3/gamefont.h
    ../descent3/gameloop.h
    ../descent3/gamepath.h
    ../descent3/gamesave.h
    ../descent3/gamesequence.h
    ../descent3/gametexture.h
    ../descent3/gauges.h
    ../descent3/help.h
    ../descent3/hotspotmap.h
    ../descent3/hud.h
    ../descent3/init.h
    ../descent3/Inventory.h
    ../descent3/levelgoal.h
    ../descent3/levelgoal_external.h
    ../descent3/lighting.h
    ../descent3/lightmap_info.h
    ../descent3/list.h
    ../descent3/LoadLevel.h
    ../descent3/localization.h
    ../descent3/marker.h
    ../descent3/matcen.h
    ../descent3/matcen_external.h
    ../descent3/menu.h
    ../descent3/Mission.h
    ../descent3/mission_download.h
    ../descent3/mmItem.h
    ../descent3/multi.h
    ../descent3/multisafe.h
    ../descent3/multi_client.h
    ../descent3/multi_dll_mgr.h
    ../descent3/multi_external.h
    ../descent3/multi_save_settings.h
    ../descent3/multi_server.h
    ../descent3/multi_ui.h
    ../descent3/multi_world_state.h
    ../descent3/NewPyroGauges.h
    ../descent3/newui.h
    ../descent3/newui_core.h
    ../descent3/object.h
    ../descent3/object_external.h
    ../descent3/object_lighting.h
    ../descent3/objinfo.h
    ../descent3/objinit.h
    ../descent3/ObjScript.h
    ../descent3/osiris_dll.h
    ../descent3/osiris_predefs.h
    ../descent3/osiris_share.h
    ../descent3/pilot.h
    ../descent3/PilotPicsAPI.h
    ../descent3/pilot_class.h
    ../descent3/player.h
    ../descent3/player_external.h
    ../descent3/player_external_struct.h
    ../descent3/postrender.h
    ../descent3/powerup.h
    ../descent3/procedurals.h
    ../descent3/program.h
    ../descent3/render.h
    ../descent3/renderobject.h
    ../descent3/resource.h
    ../descent3/robot.h
    ../descent3/robotfire.h
    ../descent3/room.h
    ../descent3/room_external.h
    ../descent3/scorch.h
    ../descent3/screens.h
    ../descent3/ship.h
    ../descent3/slew.h
    ../descent3/SmallViews.h
    ../descent3/soar.h
    ../descent3/soar_helpers.h
    ../descent3/sounds.h
    ../descent3/special_face.h
    ../descent3/spew.h
    ../descent3/splinter.h
    ../descent3/stringtable.h
    ../descent3/subtitles.h
    ../descent3/TelCom.h
    ../descent3/TelComAutoMap.h
    ../descent3/TelComCargo.h
    ../descent3/TelComEffects.h
    ../descent3/TelComEfxStructs.h
    ../descent3/TelComGoals.h
    ../descent3/terrain.h
    ../descent3/trigger.h
    ../descent3/vclip.h
    ../descent3/viseffect.h
    ../descent3/viseffect_external.h
    ../descent3/voice.h
    ../descent3/weapon.h
    ../descent3/weapon_external.h
    ../descent3/weather.h
    AddScriptDialog.h
    AISettingsDlg.h
    AmbientSoundElement.h
    AmbientSoundPattern.h
    AnimStatesDialog.h
    BriefBitmapEdit.h
    BriefButtonEdit.h
    BriefEdit.h
    BriefManage.h
    BriefMissionFlagsDlg.h
    BriefMovieEdit.h
    BriefScreenEdit.h
    BriefSoundEdit.h
    BriefTextEdit.h
    CreateNewScriptDlg.h
    CustDefaultScriptSelect.h
    CustomObjectDialog.h
    d3edit.h
    D3Splash.h
    D3XStringEditor.h
    DallasFlagDlg.h
    DallasGenericPromptDlg.h
    DallasImportDlg.h
    DallasMainDlg.h
    DallasSoundDlg.h
    DallasStrmAudioDlg.h
    DallasTextureDlg.h
    DallasUserTypesDlg.h
    DallasUtilities.h
    DallasVectorPromptDialog.h
    DeathDialog.h
    DoorwayDialog.h
    drawworld.h
    ebnode.h
    EditLineDialog.h
    editor.h
    editorDoc.h
    editorView.h
    editor_lighting.h
    edoors.h
    EPath.h
    Erooms.h
    FilePageAddDlg.h
    FilePageDialog.h
    FloatingKeypadDialog.h
    GenericDeathDialog.h
    GenericLightDialog.h
    GrFontDialog.h
    GrListBox.h
    group.h
    GrWnd.h
    hemicube.h
    HFile.h
    HObject.h
    HogDialog.h
    HRoom.h
    HTexture.h
    HView.h
    IpFrame.h
    KeypadDialog.h
    LevelDialog.h
    LevelInfoDialog.h
    levelkeypad.h
    LightingDialog.h
    LightingStatus.h
    MainFrm.h
    ManageCheckin.h
    matcenkeypad.h
    MegacellDialog.h
    MegacellKeypad.h
    mfc_compatibility.h
    moveworld.h
    ObjCScript.h
    ObjectClipboard.h
    ObjectDialog.h
    ObjectListCombo.h
    ObjectListDialog.h
    ObjectPropertiesDialog.h
    ObjMoveManager.h
    OrphanRemoveDlg.h
    OsirisStatusDlg.h
    PathPadDialog.h
    PhysicsDlg.h
    PictListBox.h
    PlayerWeaponsDialog.h
    PowerupPropDialog.h
    PreferencesDialog.h
    ProceduralDialog.h
    ProgressWnd.h
    PropertyAIDlg.h
    PropertyPhysicsDlg.h
    QuickCompile.h
    radiosity.h
    radscan_leftedge.h
    radscan_rightedge.h
    rad_cast.h
    read3ds.h
    resource.h
    RobotEditWeaponsDialog.h
    roomkeypaddialog.h
    RoomListCombo.h
    RoomUVs.h
    rotateroom.h
    ScriptCompilerAPI.h
    ScriptEditorDlg.h
    ScriptLevelInterface.h
    ScriptMassCompile.h
    ScriptParmDialog.h
    ScriptSelect.h
    ScriptStudio.h
    ScriptSyncDialog.h
    ScriptWizard.h
    selectedroom.h
    SelectRangeDialog.h
    SelManager.h
    SoundListCombo.h
    SoundSourceDialog.h
    SrvrItem.h
    StatusDlg.h
    StdAfx.h
    TableFileEdit.h
    TableFileFilter.h
    TableFileFilterAddDlg.h
    TableFileFilterMng.h
    TableManage.h
    TerrainDialog.h
    TerrainSoundDialog.h
    TextureDialog.h
    TextureGrWnd.h
    TriggerDialog.h
    TriggerListCombo.h
    ViewerPropDlg.h
    VirtualCompilerConfig.h
    WaterProceduralDialog.h
    WireframeGrWnd.h
    WorldObjectsDoorDialog.h
    WorldObjectsGenericDialog.h
    WorldObjectsLightDialog.h
    WorldObjectsPlayerDialog.h
    WorldObjectsPowerupDialog.h
    WorldObjectsRobotDialog.h
    WorldSoundsDialog.h
    WorldTexturesDialog.h
    WorldWeaponsDialog.h
    d3x.h
)

set(SOURCE
    ../descent3/aiambient.cpp
    ../descent3/AIGoal.cpp
    ../descent3/AImain.cpp
    ../descent3/aipath.cpp
    ../descent3/aiterrain.cpp
    ../descent3/ambient.cpp
    ../descent3/args.cpp
    ../descent3/attach.cpp
    ../descent3/audiotaunts.cpp
    ../descent3/bnode.cpp
    ../descent3/BOA.cpp
    ../descent3/Briefing.cpp
    ../descent3/BriefingParse.cpp
    ../descent3/bsp.cpp
    ../descent3/buddymenu.cpp
    ../descent3/cinematics.cpp
    ../descent3/cockpit.cpp
    ../descent3/config.cpp
    ../descent3/ConfigItem.cpp
    ../descent3/Controls.cpp
    ../descent3/credits.cpp
    ../descent3/CtlCfgElem.cpp
    ../descent3/ctlconfig.cpp
    ../descent3/D3ForceFeedback.cpp
    ../Descent3/d3movie.cpp
    ../Descent3/d3music.cpp
    ../descent3/d3serial.cpp
    ../descent3/damage.cpp
    ../descent3/debuggraph.cpp
    ../descent3/dedicated_server.cpp
    ../descent3/demofile.cpp
    ../descent3/descent.cpp
    ../descent3/difficulty.cpp
    ../descent3/DllWrappers.cpp
    ../descent3/door.cpp
    ../descent3/doorway.cpp
    ../descent3/fireball.cpp
    ../descent3/game.cpp
    ../descent3/Game2DLL.cpp
    ../descent3/GameCheat.cpp
    ../descent3/gamecinematics.cpp
    ../descent3/gameevent.cpp
    ../descent3/gamefile.cpp
    ../descent3/gamefont.cpp
    ../descent3/GameLoop.cpp
    ../descent3/gamepath.cpp
    ../descent3/gamesave.cpp
    ../descent3/gamesequence.cpp
    ../descent3/gametexture.cpp
    ../descent3/gauges.cpp
    ../descent3/help.cpp
    ../descent3/hotspotmap.cpp
    ../descent3/hud.cpp
    ../descent3/huddisplay.cpp
    ../descent3/hudmessage.cpp
    ../descent3/init.cpp
    ../descent3/Inventory.cpp
    ../descent3/levelgoal.cpp
    ../descent3/lighting.cpp
    ../descent3/lightmap_info.cpp
    ../descent3/list.cpp
    ../descent3/LoadLevel.cpp
    ../descent3/loadstate.cpp
    ../descent3/localization.cpp
    ../descent3/marker.cpp
    ../descent3/matcen.cpp
    ../descent3/megacell.cpp
    ../descent3/menu.cpp
    ../descent3/Mission.cpp
    ../descent3/mission_download.cpp
    ../descent3/mmItem.cpp
    ../descent3/multi.cpp
    ../descent3/multisafe.cpp
    ../descent3/multisafe_server.cpp
    ../descent3/multi_client.cpp
    ../descent3/multi_connect.cpp
    ../descent3/multi_dll_mgr.cpp
    ../descent3/multi_save_setting.cpp
    ../descent3/multi_server.cpp
    ../descent3/multi_ui.cpp
    ../descent3/NewPyroGauges.cpp
    ../descent3/newui.cpp
    ../descent3/newui_core.cpp
    ../descent3/newui_filedlg.cpp
    ../descent3/object.cpp
    ../descent3/object_lighting.cpp
    ../descent3/objinfo.cpp
    ../descent3/ObjInit.cpp
    ../descent3/ObjScript.cpp
    ../descent3/OsirisLoadandBind.cpp
    ../descent3/osiris_predefs.cpp
    ../descent3/pilot.cpp
    ../descent3/PilotPicsAPI.cpp
    ../descent3/pilot_class.cpp
    ../descent3/Player.cpp
    ../descent3/postrender.cpp
    ../descent3/procedurals.cpp
    ../descent3/program.cpp
    ../descent3/render.cpp
    ../descent3/renderobject.cpp
    ../descent3/robotfire.cpp
    ../descent3/room.cpp
    ../descent3/scorch.cpp
    ../descent3/screens.cpp
    ../descent3/ship.cpp
    ../descent3/SLEW.cpp
    ../descent3/SmallViews.cpp
    ../descent3/soar.cpp
    ../descent3/soar_helpers.cpp
    ../descent3/special_face.cpp
    ../descent3/spew.cpp
    ../descent3/splinter.cpp
    ../descent3/subtitles.cpp
    ../descent3/TelCom.cpp
    ../descent3/TelComAutoMap.cpp
    ../descent3/TelComCargo.cpp
    ../descent3/TelComEffects.cpp
    ../descent3/TelcomEffectsRender.cpp
    ../descent3/TelComGoals.cpp
    ../descent3/terrain.cpp
    ../descent3/terrainrender.cpp
    ../descent3/TerrainSearch.cpp
    ../descent3/trigger.cpp
    ../descent3/vclip.cpp
    ../descent3/viseffect.cpp
    ../descent3/voice.cpp
    ../descent3/weapon.cpp
    ../descent3/WeaponFire.cpp
    ../descent3/weather.cpp
    AddScriptDialog.cpp
    AISettingsDlg.cpp
    AmbientSoundElement.cpp
    AmbientSoundPattern.cpp
    AnimStatesDialog.cpp
    BriefBitmapEdit.cpp
    BriefButtonEdit.cpp
    BriefEdit.cpp
    BriefManage.cpp
    BriefMissionFlagsDlg.cpp
    BriefMovieEdit.cpp
    BriefScreenEdit.cpp
    BriefSoundEdit.cpp
    BriefTextEdit.cpp
    christest.cpp
    CreateNewScriptDlg.cpp
    CustDefaultScriptSelect.cpp
    CustomObjectDialog.cpp
    D3Splash.cpp
    D3XStringEditor.cpp
    DallasFlagDlg.cpp
    DallasGenericPromptDlg.cpp
    DallasImportDlg.cpp
    DallasMainDlg.cpp
    DallasSoundDlg.cpp
    DallasStrmAudioDlg.cpp
    DallasTextureDlg.cpp
    DallasUserTypesDlg.cpp
    DallasUtilities.cpp
    DallasVectorPromptDialog.cpp
    DeathDialog.cpp
    DoorwayDialog.cpp
    drawworld.cpp
    ebnode.cpp
    EditLineDialog.cpp
    editor.cpp
    editorDoc.cpp
    editorView.cpp
    editor_lighting.cpp
    editor_object_lighting.cpp
    edoors.cpp
    EDVARS.cpp
    EPath.cpp
    Erooms.cpp
    FilePageAddDlg.cpp
    FilePageDialog.cpp
    FloatingKeypadDialog.cpp
    gameeditor.cpp
    GenericDeathDialog.cpp
    GenericLightDialog.cpp
    GrFontDialog.cpp
    GrListBox.cpp
    Group.cpp
    GrWnd.cpp
    HFile.cpp
    HObject.cpp
    HogDialog.cpp
    HRoom.cpp
    HTexture.cpp
    HView.cpp
    IpFrame.cpp
    KeypadDialog.cpp
    LevelDialog.cpp
    LevelInfoDialog.cpp
    levelkeypad.cpp
    LightingDialog.cpp
    LightingStatus.cpp
    MainFrm.cpp
    ManageCheckin.cpp
    matcenkeypad.cpp
    MegacellDialog.cpp
    MegacellKeypad.cpp
    moveworld.cpp
    ObjCScript.cpp
    ObjectClipboard.cpp
    ObjectDialog.cpp
    ObjectListCombo.cpp
    ObjectListDialog.cpp
    ObjectPropertiesDialog.cpp
    ObjMoveManager.cpp
    OrphanRemoveDlg.cpp
    OsirisStatusDlg.cpp
    PathPadDialog.cpp
    PhysicsDlg.cpp
    PictListBox.cpp
    PlayerWeaponsDialog.cpp
    PowerupPropDialog.cpp
    PreferencesDialog.cpp
    ProceduralDialog.cpp
    ProgressWnd.cpp
    PropertyAIDlg.cpp
    PropertyPhysicsDlg.cpp
    QuickCompile.cpp
    rad_cast.cpp
    rad_init.cpp
    rad_hemicube.cpp
    Read3ds.cpp
    RobotEditWeaponsDialog.cpp
    roomkeypaddialog.cpp
    RoomListCombo.cpp
    RoomUVs.cpp
    rotateroom.cpp
    ScriptCompilerAPI.cpp
    ScriptEditorDlg.cpp
    ScriptLevelInterface.cpp
    ScriptMassCompile.cpp
    ScriptParmDialog.cpp
    ScriptSelect.cpp
    ScriptStudio.cpp
    ScriptSyncDialog.cpp
    ScriptWizard.cpp
    selectedroom.cpp
    SelectRangeDialog.cpp
    SelManager.cpp
    SoundListCombo.cpp
    SoundSourceDialog.cpp
    SrvrItem.cpp
    StatusDlg.cpp
    StdAfx.cpp
    TableFileEdit.cpp
    TableFileFilter.cpp
    TableFileFilterAddDlg.cpp
    TableFileFilterMng.cpp
    TableManage.cpp
    TerrainDialog.cpp
    TerrainSoundDialog.cpp
    TextureDialog.cpp
    TextureGrWnd.cpp
    TriggerDialog.cpp
    TriggerListCombo.cpp
    ViewerPropDlg.cpp
    VirtualCompilerConfig.cpp
    WaterProceduralDialog.cpp
    WireframeGrWnd.cpp
    WorldObjectsDoorDialog.cpp
    WorldObjectsGenericDialog.cpp
    WorldObjectsLightDialog.cpp
    WorldObjectsPlayerDialog.cpp
    WorldObjectsPowerupDialog.cpp
    WorldObjectsRobotDialog.cpp
    WorldSoundsDialog.cpp
    WorldTexturesDialog.cpp
    WorldWeaponsDialog.cpp
    editor.rc
    ../Descent3/sdlmain.cpp
)

# Editor only works in Windows, because of MFC and DirectX dependencies
set(PLATFORM_LIBS linux wsock32.lib winmm.lib dd_grwin32 win32 SDL2::SDL2)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /NODEFAULTLIB:LIBC")

add_executable(Descent3Editor WIN32 ${HEADERS} ${SOURCE})

target_include_directories(Descent3Editor PRIVATE ../lib ../ ../manage/ ${PROJECT_BINARY_DIR}/lib)
target_compile_definitions(Descent3Editor PUBLIC _AFXDLL EDITOR)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} /Zc:forScope-")

target_link_libraries(Descent3Editor PRIVATE
  2dlib AudioEncode bitmap cfile dd_video ddebug ddio libmve libacm
  fix grtext manage mem misc model module stream_audio
  music networking physics renderer rtperformance sndlib ui unzip vecmat md5
  ${PLATFORM_LIBS})
target_link_options(Descent3Editor PRIVATE $<$<PLATFORM_ID:Windows>:/DEBUG:FULL>)

add_dependencies(Descent3Editor get_git_hash)

# FIXME: enable installation again when the editor is stable/usable
# install(TARGETS Descent3Editor RUNTIME)
# if(MSVC)
#   install(FILES $<TARGET_PDB_FILE:Descent3Editor> DESTINATION ${CMAKE_INSTALL_BINDIR})
# endif()

