cmake_minimum_required(VERSION 3.16)

project(CoreCommand)

set(SOURCES
    "_cgal.cpp"
    "hlrcommands.cpp"
    "AddBimDlg.cpp"
    "AecEwEditorReactor.cpp"
    "BimPaletteSet.cpp"
    "BlkRecsPreviewCtrl.cpp"
    "BlkRecsPreviewCtrlEx.cpp"
    "BlkRecsPreviewList.cpp"
    "BtnST.cpp"
    "CheckLock.cpp"
    "ComboInListView.cpp"
    "CoreTools.cpp"
    "EarthWorm.cpp"
    "ent2db.cpp"
    "FSTZDlg.cpp"
    "GDFWDlg.cpp"
    "GsPreviewCtrl.cpp"
    "GsPreviewCtrlEx.cpp"
    "JSJKDlg.cpp"
    "JSTZDlg.cpp"
    "KCBusyProgressCtrl.cpp"
    "KTEarthWormCmd.cpp"
    "listeditctrl.cpp"
    "LJCSDlg.cpp"
    "LockReadWriteTool.cpp"
    "LockSrvIPDlg.cpp"
    "NameDlg.cpp"
    "rxdebug.cpp"
    "SCWJDlg.cpp"
    "SegEleDlg.cpp"
    "SegGradDlg.cpp"
    "SlideDc.cpp"
    "SLTDlg.cpp"
    "StdAfx.cpp"
    "supergridctrl.cpp"
    "SuperGridCtrlEx.cpp"
    "TextDlg.cpp"
    "TreeListCtrl.cpp"
    "TreeListWnd.cpp"
    "TTSZDlg.cpp"
    "TZJLDlg.cpp"
    "UIIInplaceComboBox.cpp"
    "UIIInplaceEdit.cpp"
    "UIIListCtrl.cpp"
    "WaitEventDlg.cpp"
    "WJYLDlg.cpp"
    "XGBGDlg.cpp"
    "XMTJDlg.cpp"
    "XZWJDlg.cpp"
    "ZHDLDlg.cpp"
    "selectblkdlg.cpp"
    "shsblocktoolsdlg.cpp"
    "sjqydlg.cpp"
    "textstylecombobox.cpp"
    "./xlistctrl/advcombobox.cpp"
    "./xlistctrl/advcomboedit.cpp"
    "./xlistctrl/droplistbox.cpp"
    "./xlistctrl/dropscrollbar.cpp"
    "./xlistctrl/dropwnd.cpp"
    "./xlistctrl/visualstylesxp.cpp"
    "./xlistctrl/xcombo.cpp"
    "./xlistctrl/xcombolist.cpp"
    "./xlistctrl/xedit.cpp"
    "./xlistctrl/xheaderctrl.cpp"
    "./xlistctrl/xlistctrl.cpp"
    "linefilterdlg.cpp"
    "gpc.cpp"
    "czhzldlg.cpp"
    "aecacdbdatabasereactor.cpp"
    "aecapdocmanagerreactor.cpp"
    "ktadsentity.cpp"
    "ktadspickset.cpp"
    "HlrCutOptionDlg.cpp"
    "cjjcsdlg.cpp"
    "cloadequdlg.cpp"
    "dimscalezonedlg.cpp"
    "sh_ai.cpp"
    "askaipaletteset.cpp"
    "aicloudsettingdlg.cpp"
    "aichatsettingdlg.cpp"
    "aisettingdlg.cpp"
    "entityfilter.cpp"
    "selectheaderdlg.cpp"
    "makecadtable.cpp"
    "ccksxdlg.cpp"
    "filepath.cpp"
    "uihistory.cpp"
    "initools.cpp"
    "subdmesh.cpp"
    "tickclock.cpp"
    "fxtsettingdlg.cpp"
    "quickselectdlg.cpp"
    "quickmodifydlg.cpp"
    "aecuicontextmenu.cpp"
    "sortedmenuitemdlg.cpp"
    "collisiondetection.cpp"
    "pcf.cpp"
    "PcfIso.cpp"
    "EarthWorm.rc"
    # CoreCommand.def
)

add_def_file_name(SOURCES "CoreCommand")

get_encryption_modes(ENCRYPTION_MODES)

foreach(MODE IN LISTS ENCRYPTION_MODES)

    set(_Target "CoreCommand_${MODE}")

    add_library(${_Target} SHARED ${SOURCES})

    target_precompile_headers(${_Target} PRIVATE StdAfx.h)

    target_link_objectarx(${_Target} EARTHWORM_EXPORT)

    target_set_name_and_suffix(${_Target} "CoreCommand" ".arx")

    target_link_libraries(${_Target} PRIVATE
        sqliteserver
        AecRxBase
        $<$<CONFIG:Debug>:CoreImplement>
        CoreLibrary_${MODE}
        ThirdParty::modernGlue
    )

if (IS_ZWCAD)
else()
    target_link_libraries(${_Target} PRIVATE "AsdkHlrApi${CAD_SDK_VERSION}.lib")
endif()

    set_debug_post_build(${_Target} "CoreCommand" ".arx")

    set_encryption_definitions_and_output_path(${_Target} "${MODE}")

    set_target_properties(${_Target} PROPERTIES FOLDER "SH/Core/CoreCommand")
endforeach()