set(LIB_NAME core_lib)

qt_add_library(${LIB_NAME} SHARED

    # local files
    core_lib_global.h
    bscintillaedit.h
    bscintillaedit.cpp

    # from src/core_lib/scintilla/qt/ScintillaEditBase/ScintillaEditBase.pro
    scintilla/include/ILexer.h
    scintilla/include/Scintilla.h
    scintilla/src/AutoComplete.cxx
    scintilla/src/AutoComplete.h
    scintilla/src/CallTip.cxx
    scintilla/src/CallTip.h
    scintilla/src/CaseConvert.cxx
    scintilla/src/CaseConvert.h
    scintilla/src/CaseFolder.cxx
    scintilla/src/CaseFolder.h
    scintilla/src/CellBuffer.cxx
    scintilla/src/CellBuffer.h
    scintilla/src/ChangeHistory.cxx
    scintilla/src/ChangeHistory.h
    scintilla/src/CharacterCategoryMap.cxx
    scintilla/src/CharacterCategoryMap.h
    scintilla/src/CharacterType.cxx
    scintilla/src/CharacterType.h
    scintilla/src/CharClassify.cxx
    scintilla/src/CharClassify.h
    scintilla/src/ContractionState.cxx
    scintilla/src/ContractionState.h
    scintilla/src/DBCS.cxx
    scintilla/src/Decoration.cxx
    scintilla/src/Decoration.h
    scintilla/src/Document.cxx
    scintilla/src/Document.h
    scintilla/src/EditModel.cxx
    scintilla/src/Editor.cxx
    scintilla/src/Editor.h
    scintilla/src/EditView.cxx
    scintilla/src/Geometry.cxx
    scintilla/src/Geometry.h
    scintilla/src/Indicator.cxx
    scintilla/src/Indicator.h
    scintilla/src/KeyMap.cxx
    scintilla/src/KeyMap.h
    scintilla/src/LineMarker.cxx
    scintilla/src/LineMarker.h
    scintilla/src/MarginView.cxx
    scintilla/src/Partitioning.h
    scintilla/src/PerLine.cxx
    scintilla/src/PerLine.h
    scintilla/src/Platform.h
    scintilla/src/PositionCache.cxx
    scintilla/src/PositionCache.h
    scintilla/src/RESearch.cxx
    scintilla/src/RESearch.h
    scintilla/src/RunStyles.cxx
    scintilla/src/RunStyles.h
    scintilla/src/ScintillaBase.cxx
    scintilla/src/ScintillaBase.h
    scintilla/src/Selection.cxx
    scintilla/src/Selection.h
    scintilla/src/SplitVector.h
    scintilla/src/Style.cxx
    scintilla/src/Style.h
    scintilla/src/UndoHistory.cxx
    scintilla/src/UndoHistory.h
    scintilla/src/UniConversion.cxx
    scintilla/src/UniConversion.h
    scintilla/src/UniqueString.cxx
    scintilla/src/ViewStyle.cxx
    scintilla/src/ViewStyle.h
    scintilla/src/XPM.cxx
    scintilla/src/XPM.h
    scintilla/qt/ScintillaEditBase/PlatQt.cpp
    scintilla/qt/ScintillaEditBase/PlatQt.h
    scintilla/qt/ScintillaEditBase/ScintillaEditBase.cpp
    scintilla/qt/ScintillaEditBase/ScintillaEditBase.h
    scintilla/qt/ScintillaEditBase/ScintillaQt.cpp
    scintilla/qt/ScintillaEditBase/ScintillaQt.h
)

target_include_directories(
    ${LIB_NAME}
    PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/scintilla/include
    ${CMAKE_CURRENT_SOURCE_DIR}/scintilla/qt/ScintillaEditBase
    ${CMAKE_CURRENT_SOURCE_DIR}/scintilla/src
)

target_link_libraries(
    ${LIB_NAME} PUBLIC
    Qt6::Core5Compat # scintilla needs this
    Qt6::Widgets
)

target_compile_definitions(
    ${LIB_NAME} PRIVATE
    SCINTILLA_QT=1

    # ScintillaEditBase is private to BScintillaEdit, so we don't need to expose it
    MAKING_LIBRARY=0

    # Needed mostly on Windows to export symbols, and create a .lib file, otherwise
    # the binding library can't link to the sample library.
    CORE_LIB_BUILD
)

# By default the prefix of the shared library is "lib" on UNIX.
# We set it to the empty string "" on all platforms.
set_property(TARGET ${LIB_NAME} PROPERTY PREFIX "")
