cmake_minimum_required(VERSION 3.3)
project(nuvie)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${nuvie_SOURCE_DIR}/builds/cmake")

find_package(SDL2 REQUIRED)

IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLUA_USE_MACOSX -DUNIX -DMACOSX -DHAVE_JOYSTICK_SUPPORT")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUA_USE_MACOSX -DMACOSX -DHAVE_JOYSTICK_SUPPORT")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLUA_USE_LINUX -DUNIX -DHAVE_JOYSTICK_SUPPORT")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUA_USE_LINUX -DHAVE_JOYSTICK_SUPPORT")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32 -D_CONSOLE -DHAVE_JOYSTICK_SUPPORT")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32 -DHAVE_JOYSTICK_SUPPORT")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_VERBOSE_MAKEFILE ON)

SET(SDL_VERSION "SDL2")

set(SOURCE_FILES
    actors/Actor.cpp
    actors/Actor.h
    actors/ActorManager.cpp
    actors/ActorManager.h
    actors/MDActor.cpp
    actors/MDActor.h
    actors/SEActor.cpp
    actors/SEActor.h
    actors/U6Actor.cpp
    actors/U6Actor.h
    actors/U6ActorTypes.h
    actors/U6WorkTypes.h
    actors/WOUActor.cpp
    actors/WOUActor.h
    conf/ConfigNode.h
    conf/Configuration.cpp
    conf/Configuration.h
    conf/misc.h
    conf/XMLNode.cpp
    conf/XMLNode.h
    conf/XMLTree.cpp
    conf/XMLTree.h
    data/scripts/common/actor.lua
    data/scripts/common/common.lua
    data/scripts/common/intro_common.lua
    data/scripts/common/lang.lua
    data/scripts/md/lang/en/game.lua
    data/scripts/md/lang/it/game.lua
    data/scripts/md/actor.lua
    data/scripts/md/combat.lua
    data/scripts/md/dreamworld.lua
    data/scripts/md/ending.lua
    data/scripts/md/init.lua
    data/scripts/md/intro.lua
    data/scripts/md/look.lua
    data/scripts/md/player.lua
    data/scripts/md/talk.lua
    data/scripts/md/usecode.lua
    data/scripts/md/worktype.lua
    data/scripts/se/lang/en/game.lua
    data/scripts/se/actor.lua
    data/scripts/se/init.lua
    data/scripts/se/intro.lua
    data/scripts/se/look.lua
    data/scripts/se/player.lua
    data/scripts/se/usecode.lua
    data/scripts/u6/lang/en/game.lua
    data/scripts/u6/magic/circle_01/create_food.lua
    data/scripts/u6/magic/circle_01/detect_magic.lua
    data/scripts/u6/magic/circle_01/detect_trap.lua
    data/scripts/u6/magic/circle_01/dispel_magic.lua
    data/scripts/u6/magic/circle_01/douse.lua
    data/scripts/u6/magic/circle_01/harm.lua
    data/scripts/u6/magic/circle_01/heal.lua
    data/scripts/u6/magic/circle_01/help.lua
    data/scripts/u6/magic/circle_01/ignite.lua
    data/scripts/u6/magic/circle_01/light.lua
    data/scripts/u6/magic/circle_02/infravision.lua
    data/scripts/u6/magic/circle_02/magic_arrow.lua
    data/scripts/u6/magic/circle_02/poison.lua
    data/scripts/u6/magic/circle_02/reappear.lua
    data/scripts/u6/magic/circle_02/sleep.lua
    data/scripts/u6/magic/circle_02/telekinesis.lua
    data/scripts/u6/magic/circle_02/trap.lua
    data/scripts/u6/magic/circle_02/unlock_magic.lua
    data/scripts/u6/magic/circle_02/untrap.lua
    data/scripts/u6/magic/circle_02/vanish.lua
    data/scripts/u6/magic/circle_03/curse.lua
    data/scripts/u6/magic/circle_03/dispel_field.lua
    data/scripts/u6/magic/circle_03/fireball.lua
    data/scripts/u6/magic/circle_03/great_light.lua
    data/scripts/u6/magic/circle_03/magic_lock.lua
    data/scripts/u6/magic/circle_03/mass_awaken.lua
    data/scripts/u6/magic/circle_03/mass_sleep.lua
    data/scripts/u6/magic/circle_03/peer.lua
    data/scripts/u6/magic/circle_03/protection.lua
    data/scripts/u6/magic/circle_03/repel_undead.lua
    data/scripts/u6/magic/circle_04/animate.lua
    data/scripts/u6/magic/circle_04/conjure.lua
    data/scripts/u6/magic/circle_04/disable.lua
    data/scripts/u6/magic/circle_04/fire_field.lua
    data/scripts/u6/magic/circle_04/great_heal.lua
    data/scripts/u6/magic/circle_04/locate.lua
    data/scripts/u6/magic/circle_04/mass_dispel.lua
    data/scripts/u6/magic/circle_04/poison_field.lua
    data/scripts/u6/magic/circle_04/sleep_field.lua
    data/scripts/u6/magic/circle_04/wind_change.lua
    data/scripts/u6/magic/circle_05/energy_field.lua
    data/scripts/u6/magic/circle_05/explosion.lua
    data/scripts/u6/magic/circle_05/insect_swarm.lua
    data/scripts/u6/magic/circle_05/invisibility.lua
    data/scripts/u6/magic/circle_05/lightning.lua
    data/scripts/u6/magic/circle_05/paralyze.lua
    data/scripts/u6/magic/circle_05/pickpocket.lua
    data/scripts/u6/magic/circle_05/reveal.lua
    data/scripts/u6/magic/circle_05/seance.lua
    data/scripts/u6/magic/circle_05/xray.lua
    data/scripts/u6/magic/circle_06/charm.lua
    data/scripts/u6/magic/circle_06/clone.lua
    data/scripts/u6/magic/circle_06/confuse.lua
    data/scripts/u6/magic/circle_06/flame_wind.lua
    data/scripts/u6/magic/circle_06/hail_storm.lua
    data/scripts/u6/magic/circle_06/mass_protect.lua
    data/scripts/u6/magic/circle_06/negate_magic.lua
    data/scripts/u6/magic/circle_06/poison_wind.lua
    data/scripts/u6/magic/circle_06/replicate.lua
    data/scripts/u6/magic/circle_06/web.lua
    data/scripts/u6/magic/circle_07/chain_bolt.lua
    data/scripts/u6/magic/circle_07/enchant.lua
    data/scripts/u6/magic/circle_07/energy_wind.lua
    data/scripts/u6/magic/circle_07/fear.lua
    data/scripts/u6/magic/circle_07/gate_travel.lua
    data/scripts/u6/magic/circle_07/kill.lua
    data/scripts/u6/magic/circle_07/mass_curse.lua
    data/scripts/u6/magic/circle_07/mass_invisibility.lua
    data/scripts/u6/magic/circle_07/wing_strike.lua
    data/scripts/u6/magic/circle_07/wizard_eye.lua
    data/scripts/u6/magic/circle_08/armageddon.lua
    data/scripts/u6/magic/circle_08/death_wind.lua
    data/scripts/u6/magic/circle_08/eclipse.lua
    data/scripts/u6/magic/circle_08/mass_charm.lua
    data/scripts/u6/magic/circle_08/mass_kill.lua
    data/scripts/u6/magic/circle_08/monster_invisible.lua
    data/scripts/u6/magic/circle_08/resurrect.lua
    data/scripts/u6/magic/circle_08/slime.lua
    data/scripts/u6/magic/circle_08/summon.lua
    data/scripts/u6/magic/circle_08/time_stop.lua
    data/scripts/u6/magic/circle_08/tremor.lua
    data/scripts/u6/actor.lua
    data/scripts/u6/ending.lua
    data/scripts/u6/init.lua
    data/scripts/u6/intro.lua
    data/scripts/u6/magic.lua
    data/scripts/u6/player.lua
    data/scripts/u6/usecode.lua
    data/BorderU6_1.bmp
    data/BorderU6_2.bmp
    data/BorderU6_3.bmp
    data/BorderU6_4.bmp
    data/BorderU6_5.bmp
    data/BorderU6_6.bmp
    data/BorderU6_7.bmp
    data/BorderU6_8.bmp
    data/defaultkeys.txt
    data/mdkeys.txt
    data/ScrollBarDown_1.bmp
    data/ScrollBarDown_2.bmp
    data/ScrollBarUp_1.bmp
    data/ScrollBarUp_2.bmp
    data/sekeys.txt
    data/U6_WOU_Scroll_bg.bmp
    data/u6keys.txt
    files/NuvieBmpFile.cpp
    files/NuvieBmpFile.h
    files/NuvieFileList.cpp
    files/NuvieFileList.h
    files/NuvieIO.cpp
    files/NuvieIO.h
    files/NuvieIOFile.cpp
    files/NuvieIOFile.h
    files/TMXMap.cpp
    files/TMXMap.h
    files/U6Bmp.cpp
    files/U6Bmp.h
    files/U6Lib_n.cpp
    files/U6Lib_n.h
    files/U6Lzw.cpp
    files/U6Lzw.h
    files/U6Shape.cpp
    files/U6Shape.h
    fonts/BMPFont.cpp
    fonts/BMPFont.h
    fonts/ConvFont.cpp
    fonts/ConvFont.h
    fonts/Font.cpp
    fonts/Font.h
    fonts/FontManager.cpp
    fonts/FontManager.h
    fonts/U6Font.cpp
    fonts/U6Font.h
    fonts/WOUFont.cpp
    fonts/WOUFont.h
    GUI/GUI.cpp
    GUI/GUI.h
    GUI/GUI_area.cpp
    GUI/GUI_area.h
    GUI/GUI_button.cpp
    GUI/GUI_button.h
    GUI/GUI_CallBack.h
    GUI/GUI_Console.cpp
    GUI/GUI_Console.h
    GUI/GUI_Dialog.cpp
    GUI/GUI_Dialog.h
    GUI/GUI_DragArea.h
    GUI/GUI_DragManager.cpp
    GUI/GUI_DragManager.h
    GUI/GUI_font.cpp
    GUI/GUI_font.h
    GUI/GUI_loadimage.cpp
    GUI/GUI_loadimage.h
    GUI/GUI_ScrollBar.cpp
    GUI/GUI_ScrollBar.h
    GUI/GUI_Scroller.cpp
    GUI/GUI_Scroller.h
    GUI/GUI_status.h
    GUI/GUI_text.cpp
    GUI/GUI_text.h
    GUI/GUI_TextInput.cpp
    GUI/GUI_TextInput.h
    GUI/GUI_TextToggleButton.cpp
    GUI/GUI_TextToggleButton.h
    GUI/GUI_types.h
    GUI/GUI_widget.cpp
    GUI/GUI_widget.h
    GUI/GUI_YesNoDialog.cpp
    GUI/GUI_YesNoDialog.h
    GUI/the_font.h
    keybinding/KeyActions.cpp
    keybinding/KeyActions.h
    keybinding/Keys.cpp
    keybinding/Keys.h
    keybinding/KeysEnum.h
    keybinding/Utils.cpp
    keybinding/Utils.h
    lua/lapi.c
    lua/lapi.h
    lua/lauxlib.c
    lua/lauxlib.h
    lua/lbaselib.c
    lua/lbitlib.c
    lua/lcode.c
    lua/lcode.h
    lua/lcorolib.c
    lua/lctype.c
    lua/lctype.h
    lua/ldblib.c
    lua/ldebug.c
    lua/ldebug.h
    lua/ldo.c
    lua/ldo.h
    lua/ldump.c
    lua/lfunc.c
    lua/lfunc.h
    lua/lgc.c
    lua/lgc.h
    lua/linit.c
    lua/liolib.c
    lua/llex.c
    lua/llex.h
    lua/llimits.h
    lua/lmathlib.c
    lua/lmem.c
    lua/lmem.h
    lua/loadlib.c
    lua/lobject.c
    lua/lobject.h
    lua/lopcodes.c
    lua/lopcodes.h
    lua/loslib.c
    lua/lparser.c
    lua/lparser.h
    lua/lstate.c
    lua/lstate.h
    lua/lstring.c
    lua/lstring.h
    lua/lstrlib.c
    lua/ltable.c
    lua/ltable.h
    lua/ltablib.c
    lua/ltm.c
    lua/ltm.h
    lua/lua.h
    lua/lua.hpp
    lua/luaconf.h
    lua/lualib.h
    lua/lundump.c
    lua/lundump.h
    lua/lvm.c
    lua/lvm.h
    lua/lzio.c
    lua/lzio.h
    menus/AudioDialog.cpp
    menus/AudioDialog.h
    menus/CheatsDialog.cpp
    menus/CheatsDialog.h
    menus/GameMenuDialog.cpp
    menus/GameMenuDialog.h
    menus/GameplayDialog.cpp
    menus/GameplayDialog.h
    menus/InputDialog.cpp
    menus/InputDialog.h
    menus/JoystickDialog.cpp
    menus/JoystickDialog.h
    menus/VideoDialog.cpp
    menus/VideoDialog.h
    misc/ActorList.h
    misc/CallBack.h
    misc/iAVLTree.cpp
    misc/iAVLTree.h
    misc/MapEntity.h
    misc/SDL_compat.h
    misc/U6LineWalker.cpp
    misc/U6LineWalker.h
    misc/U6LList.cpp
    misc/U6LList.h
    misc/U6misc.cpp
    misc/U6misc.h
    misc/SDLUtils.cpp
    misc/SDLUtils.h
    pathfinder/ActorPathFinder.cpp
    pathfinder/ActorPathFinder.h
    pathfinder/AStarPath.cpp
    pathfinder/AStarPath.h
    pathfinder/CombatPathFinder.cpp
    pathfinder/CombatPathFinder.h
    pathfinder/DirFinder.cpp
    pathfinder/DirFinder.h
    pathfinder/PartyPathFinder.cpp
    pathfinder/PartyPathFinder.h
    pathfinder/Path.cpp
    pathfinder/Path.h
    pathfinder/PathFinder.cpp
    pathfinder/PathFinder.h
    pathfinder/SchedPathFinder.cpp
    pathfinder/SchedPathFinder.h
    pathfinder/SeekPath.cpp
    pathfinder/SeekPath.h
    pathfinder/U6AStarPath.cpp
    pathfinder/U6AStarPath.h
    portraits/Portrait.cpp
    portraits/Portrait.h
    portraits/PortraitMD.cpp
    portraits/PortraitMD.h
    portraits/PortraitSE.cpp
    portraits/PortraitSE.h
    portraits/PortraitU6.cpp
    portraits/PortraitU6.h
    save/Objlist.h
    save/SaveDialog.cpp
    save/SaveDialog.h
    save/SaveGame.cpp
    save/SaveGame.h
    save/SaveManager.cpp
    save/SaveManager.h
    save/SaveSlot.cpp
    save/SaveSlot.h
    screen/Dither.cpp
    screen/Dither.h
    screen/GamePalette.cpp
    screen/GamePalette.h
    screen/Scale.cpp
    screen/Scale.h
    screen/Screen.cpp
    screen/Screen.h
    screen/Surface.cpp
    screen/Surface.h
    script/Script.cpp
    script/Script.h
    script/ScriptActor.cpp
    script/ScriptActor.h
    script/ScriptCutscene.cpp
    script/ScriptCutscene.h
    sound/adplug/adplug_player.cpp
    sound/adplug/adplug_player.h
    sound/adplug/emuopl.cpp
    sound/adplug/emuopl.h
    sound/adplug/fmopl.c
    sound/adplug/fmopl.h
    sound/adplug/mid.cpp
    sound/adplug/mid.h
    sound/adplug/opl.h
    sound/adplug/OplClass.cpp
    sound/adplug/OplClass.h
    sound/adplug/silentopl.h
    sound/adplug/u6m.cpp
    sound/adplug/u6m.h
    sound/mixer/decoder/wave/adpcm.cpp
    sound/mixer/decoder/wave/adpcm.h
    sound/mixer/decoder/wave/endian.h
    sound/mixer/decoder/wave/list.h
    sound/mixer/decoder/wave/list_intern.h
    sound/mixer/decoder/wave/memstream.h
    sound/mixer/decoder/wave/raw.cpp
    sound/mixer/decoder/wave/raw.h
    sound/mixer/decoder/wave/stdiostream.cpp
    sound/mixer/decoder/wave/stdiostream.h
    sound/mixer/decoder/wave/stream.cpp
    sound/mixer/decoder/wave/stream.h
    sound/mixer/decoder/wave/wave.cpp
    sound/mixer/decoder/wave/wave.h
    sound/mixer/decoder/AdLibSfxStream.cpp
    sound/mixer/decoder/AdLibSfxStream.h
    sound/mixer/decoder/FMtownsDecoderStream.cpp
    sound/mixer/decoder/FMtownsDecoderStream.h
    sound/mixer/decoder/PCSpeaker.cpp
    sound/mixer/decoder/PCSpeaker.h
    sound/mixer/decoder/PCSpeakerStream.cpp
    sound/mixer/decoder/PCSpeakerStream.h
    sound/mixer/decoder/U6AdPlugDecoderStream.cpp
    sound/mixer/decoder/U6AdPlugDecoderStream.h
    sound/mixer/audiostream.cpp
    sound/mixer/audiostream.h
    sound/mixer/doublebuffersdl-mixer.cpp
    sound/mixer/doublebuffersdl-mixer.h
    sound/mixer/frac.h
    sound/mixer/mixer.cpp
    sound/mixer/mixer.h
    sound/mixer/mixer_intern.h
    sound/mixer/mutex.cpp
    sound/mixer/mutex.h
    sound/mixer/rate.cpp
    sound/mixer/rate.h
    sound/mixer/sdl-mixer.cpp
    sound/mixer/sdl-mixer.h
    sound/mixer/timestamp.cpp
    sound/mixer/timestamp.h
    sound/mixer/types.h
    sound/AdLibSfxManager.cpp
    sound/AdLibSfxManager.h
    sound/CustomSfxManager.cpp
    sound/CustomSfxManager.h
    sound/OriginFXAdLibDriver.cpp
    sound/OriginFXAdLibDriver.h
    sound/PCSpeakerSfxManager.cpp
    sound/PCSpeakerSfxManager.h
    sound/sfx.h
    sound/SfxManager.h
    sound/Song.cpp
    sound/Song.h
    sound/SongAdPlug.cpp
    sound/SongAdPlug.h
    sound/Sound.h
    sound/SoundManager.cpp
    sound/SoundManager.h
    sound/TownsSfxManager.cpp
    sound/TownsSfxManager.h
    usecode/U6ObjectTypes.h
    usecode/U6UseCode.cpp
    usecode/U6UseCode.h
    usecode/UseCode.cpp
    usecode/UseCode.h
    views/ActorView.cpp
    views/ActorView.h
    views/ContainerViewGump.cpp
    views/ContainerViewGump.h
    views/ContainerWidget.cpp
    views/ContainerWidget.h
    views/ContainerWidgetGump.cpp
    views/ContainerWidgetGump.h
    views/DollViewGump.cpp
    views/DollViewGump.h
    views/DollWidget.cpp
    views/DollWidget.h
    views/DraggableView.cpp
    views/DraggableView.h
    views/InventoryFont.h
    views/InventoryMessage.h
    views/InventoryView.cpp
    views/InventoryView.h
    views/InventoryWidget.cpp
    views/InventoryWidget.h
    views/MapEditorView.cpp
    views/MapEditorView.h
    views/MDSkyStripWidget.cpp
    views/MDSkyStripWidget.h
    views/PartyView.cpp
    views/PartyView.h
    views/PortraitView.cpp
    views/PortraitView.h
    views/PortraitViewGump.cpp
    views/PortraitViewGump.h
    views/ScrollViewGump.cpp
    views/ScrollViewGump.h
    views/ScrollWidgetGump.cpp
    views/ScrollWidgetGump.h
    views/SignViewGump.cpp
    views/SignViewGump.h
    views/SpellView.cpp
    views/SpellView.h
    views/SpellViewGump.cpp
    views/SpellViewGump.h
    views/SunMoonRibbon.cpp
    views/SunMoonRibbon.h
    views/SunMoonStripWidget.cpp
    views/SunMoonStripWidget.h
    views/View.cpp
    views/View.h
    views/ViewManager.cpp
    views/ViewManager.h
    AnimManager.cpp
    AnimManager.h
    Background.cpp
    Background.h
    Book.cpp
    Book.h
    CommandBar.cpp
    CommandBar.h
    CommandBarNewUI.cpp
    CommandBarNewUI.h
    Console.cpp
    Console.h
    Converse.cpp
    Converse.h
    ConverseGump.cpp
    ConverseGump.h
    ConverseGumpWOU.cpp
    ConverseGumpWOU.h
    ConverseInterpret.cpp
    ConverseInterpret.h
    ConverseSpeech.cpp
    ConverseSpeech.h
    Cursor.cpp
    Cursor.h
    Debug.cpp
    Effect.cpp
    Effect.h
    EffectManager.cpp
    EffectManager.h
    EggManager.cpp
    EggManager.h
    Event.cpp
    Event.h
    FpsCounter.cpp
    FpsCounter.h
    Game.cpp
    Game.h
    GameClock.cpp
    GameClock.h
    GameSelect.cpp
    GameSelect.h
    Look.cpp
    Look.h
    Magic.cpp
    Magic.h
    main.cpp
    main.h
    Map.cpp
    Map.h
    MapWindow.cpp
    MapWindow.h
    MsgScroll.cpp
    MsgScroll.h
    MsgScrollNewUI.cpp
    MsgScrollNewUI.h
    nuvie.cpp
    nuvie.h
    nuvieDefs.h
    Obj.cpp
    Obj.h
    ObjManager.cpp
    ObjManager.h
    Party.cpp
    Party.h
    Player.cpp
    Player.h
    Text.cpp
    Text.h
    TileManager.cpp
    TileManager.h
    TimedEvent.cpp
    TimedEvent.h
    U6objects.h
    Weather.cpp
    Weather.h)

IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    list(APPEND SOURCE_FILES msvc/dirent.cpp msvc/dirent.h)
    include_directories(msvc)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")

INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIR})
include_directories(.)
include_directories(actors)
include_directories(conf)
include_directories(files)
include_directories(fonts)
include_directories(GUI)
include_directories(keybinding)
include_directories(lua)
include_directories(menus)
include_directories(misc)
include_directories(pathfinder)
include_directories(portraits)
include_directories(save)
include_directories(screen)
include_directories(script)
include_directories(sound)
include_directories(sound/adplug)
include_directories(sound/mixer)
include_directories(usecode)
include_directories(views)

#link_directories(/usr/local/lib)

add_executable(nuvie ${SOURCE_FILES})

TARGET_LINK_LIBRARIES(nuvie ${SDL2_LIBRARY})

#IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
##    TARGET_LINK_LIBRARIES(nuvie ${SDL_LIBS} -Wl,-framework,Cocoa)
#    TARGET_LINK_LIBRARIES(nuvie ${SDL2_LIBRARY})
#ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
#
#IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
#    TARGET_LINK_LIBRARIES(nuvie dl ${SDL_LIBS} )
#ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

#include(tools/CMakeLists.txt)
