#############################################################################
# Name:        build/cmake/lib/core/CMakeLists.txt
# Purpose:     CMake file for core library
# Author:      Tobias Taschner
# Created:     2016-10-01
# Copyright:   (c) 2016 wxWidgets development team
# Licence:     wxWindows licence
#############################################################################

include(../../source_groups.cmake)

wx_append_sources(CORE_SRC GUI_CMN)
wx_append_sources(CORE_SRC BASE_AND_GUI_CMN)
if(WIN32)
    wx_append_sources(CORE_SRC BASE_AND_GUI_WIN32)
elseif(UNIX)
    wx_append_sources(CORE_SRC UNIX)
    if(wxUSE_LIBSDL)
        wx_append_sources(CORE_SRC UNIX_SOUND_SDL)
    endif()
endif()

if(WXMSW)
    wx_append_sources(CORE_SRC MSW_LOWLEVEL)
    wx_append_sources(CORE_SRC MSW_DESKTOP_LOWLEVEL)
    wx_append_sources(CORE_SRC MSW)
    wx_append_sources(CORE_SRC MSW_DESKTOP)
elseif(WXGTK)
    if(WXGTK2)
        wx_append_sources(CORE_SRC GTK2_LOWLEVEL)
        wx_append_sources(CORE_SRC GTK2)
    else()
        wx_append_sources(CORE_SRC GTK_LOWLEVEL)
        wx_append_sources(CORE_SRC GTK)
    endif()

    if(UNIX)
        wx_append_sources(CORE_SRC XWIN_LOWLEVEL)
    elseif(WIN32)
        wx_append_sources(CORE_SRC GTK_WIN32)
    endif()
elseif(WXOSX_COCOA)
    wx_append_sources(CORE_SRC BASE_AND_GUI_OSX_COCOA)
    wx_append_sources(CORE_SRC OSX_LOWLEVEL)
    wx_append_sources(CORE_SRC OSX_SHARED)
    wx_append_sources(CORE_SRC OSX_COCOA)
elseif(WXQT)
    wx_append_sources(CORE_SRC QT)
    if(WIN32)
        wx_append_sources(CORE_SRC QT_WIN32)
    endif()
endif()

wx_add_library(core ${CORE_SRC})
foreach(lib JPEG PNG TIFF)
    if(${lib}_LIBRARIES)
        if(lib STREQUAL JPEG)
            wx_lib_include_directories(core PRIVATE ${${lib}_INCLUDE_DIR})
        else()
            wx_lib_include_directories(core PRIVATE ${${lib}_INCLUDE_DIRS})
        endif()

        wx_lib_link_libraries(core PRIVATE ${${lib}_LIBRARIES})
    endif()
endforeach()

if(WIN32)
    wx_lib_link_libraries(core PRIVATE winmm)
endif()
if(WXOSX_COCOA)
    wx_lib_link_libraries(core PUBLIC "-framework AudioToolbox")
    if(wxUSE_WEBKIT)
        wx_lib_link_libraries(core PUBLIC "-framework WebKit")
    endif()
endif()
if(WXGTK AND wxUSE_PRIVATE_FONTS)
    wx_lib_include_directories(core PUBLIC ${FONTCONFIG_INCLUDE_DIR})
    wx_lib_link_libraries(core PUBLIC ${FONTCONFIG_LIBRARIES})
endif()
if(wxUSE_LIBSDL)
    if(SDL2_FOUND)
        wx_lib_include_directories(core PUBLIC ${SDL2_INCLUDE_DIR})
        wx_lib_link_libraries(core PUBLIC ${SDL2_LIBRARY})
    elseif(SDL_FOUND)
        wx_lib_include_directories(core PUBLIC ${SDL_INCLUDE_DIR})
        wx_lib_link_libraries(core PUBLIC ${SDL_LIBRARY})
    endif()
endif()
if(wxUSE_LIBNOTIFY)
    wx_lib_include_directories(core PUBLIC ${LIBNOTIFY_INCLUDE_DIRS})
    wx_lib_link_libraries(core PUBLIC ${LIBNOTIFY_LIBRARIES})
endif()

wx_finalize_lib(core)
