project(OpenMW)

# local files

set(GAME
    main.cpp
    engine.cpp)
set(GAME_HEADER
    engine.hpp)
source_group(game FILES ${GAME} ${GAME_HEADER})

set(GAMEREND
    mwrender/mwscene.cpp
    mwrender/cellimp.cpp
    mwrender/interior.cpp
    mwrender/sky.cpp)
set(GAMEREND_HEADER
    mwrender/cell.hpp
    mwrender/cellimp.hpp
    mwrender/mwscene.hpp
    mwrender/interior.hpp
    mwrender/playerpos.hpp
    mwrender/sky.hpp)
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})

set(GAMEINPUT
    mwinput/inputmanager.cpp
)
set(GAMEINPUT_HEADER
    mwinput/inputmanager.hpp)
source_group(apps\\openmw\\mwinput FILES ${GAMEINPUT} ${GAMEINPUT_HEADER})

set(GAMEGUI_HEADER
    mwgui/mw_layouts.hpp
    mwgui/window_manager.hpp
    mwgui/console.hpp
)
set(GAMEGUI
    mwgui/window_manager.cpp
    mwgui/console.cpp
)
source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI})

set(GAMEDIALOGUE_HEADER
    mwdialogue/dialoguemanager.hpp
)
set(GAMEDIALOGUE
    mwdialogue/dialoguemanager.cpp
)
source_group(apps\\openmw\\mwdialogue FILES ${GAMEDIALOGUE_HEADER} ${GAMEDIALOGUE})

set(GAMESCRIPT
    mwscript/scriptmanager.cpp
    mwscript/compilercontext.cpp
    mwscript/interpretercontext.cpp
    mwscript/cellextensions.cpp
    mwscript/miscextensions.cpp
    mwscript/guiextensions.cpp
    mwscript/soundextensions.cpp
    mwscript/skyextensions.cpp
    mwscript/statsextensions.cpp
    mwscript/containerextensions.cpp
    mwscript/aiextensions.cpp
    mwscript/controlextensions.cpp
    mwscript/extensions.cpp
    mwscript/globalscripts.cpp
    )
set(GAMESCRIPT_HEADER
    mwscript/locals.hpp
    mwscript/scriptmanager.hpp
    mwscript/compilercontext.hpp
    mwscript/interpretercontext.hpp
    mwscript/cellextensions.hpp
    mwscript/miscextensions.hpp
    mwscript/guiextensions.hpp
    mwscript/soundextensions.hpp
    mwscript/skyextensions.hpp
    mwscript/statsextensions.hpp
    mwscript/containerextensions.hpp
    mwscript/aiextensions.hpp
    mwscript/controlextensions.hpp
    mwscript/extensions.hpp
    mwscript/globalscripts.hpp
    )
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})

set(GAMESOUND
    mwsound/soundmanager.cpp)
set(GAMESOUND_HEADER
    mwsound/soundmanager.hpp)
source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER})

set(GAMEWORLD
    mwworld/world.cpp
    mwworld/globals.cpp
    mwworld/class.cpp
    mwworld/actionteleport.cpp
    mwworld/actiontalk.cpp
    mwworld/actiontake.cpp
    mwworld/containerutil.cpp
    )
set(GAMEWORLD_HEADER
    mwworld/refdata.hpp
    mwworld/world.hpp
    mwworld/ptr.hpp
    mwworld/environment.hpp
    mwworld/globals.hpp
    mwworld/class.hpp
    mwworld/action.hpp
    mwworld/nullaction.hpp
    mwworld/actionteleport.hpp
    mwworld/containerstore.hpp
    mwworld/actiontalk.hpp
    mwworld/actiontake.hpp
    mwworld/containerstore.hpp
    mwworld/manualref.hpp
    mwworld/containerutil.hpp
    )
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})

set(GAMECLASS
    mwclass/classes.cpp
    mwclass/activator.cpp
    mwclass/creature.cpp
    mwclass/npc.cpp
    mwclass/weapon.cpp
    mwclass/armor.cpp
    mwclass/potion.cpp
    mwclass/apparatus.cpp
    mwclass/book.cpp
    mwclass/clothing.cpp
    mwclass/container.cpp
    mwclass/door.cpp
    mwclass/ingredient.cpp
    mwclass/creaturelevlist.cpp
    mwclass/itemlevlist.cpp
    mwclass/light.cpp
    mwclass/lockpick.cpp
    mwclass/misc.cpp
    mwclass/probe.cpp
    mwclass/repair.cpp
    mwclass/static.cpp
    )
set(GAMECLASS_HEADER
    mwclass/classes.hpp
    mwclass/activator.hpp
    mwclass/creature.hpp
    mwclass/npc.hpp
    mwclass/weapon.hpp
    mwclass/armor.hpp
    mwclass/potion.hpp
    mwclass/apparatus.hpp
    mwclass/book.hpp
    mwclass/clothing.hpp
    mwclass/container.hpp
    mwclass/door.hpp
    mwclass/ingredient.hpp
    mwclass/creaturelevlist.hpp
    mwclass/itemlevlist.hpp
    mwclass/light.hpp
    mwclass/lockpick.hpp
    mwclass/misc.hpp
    mwclass/probe.hpp
    mwclass/repair.hpp
    mwclass/static.hpp
    mwclass/containerutil.hpp
    )
source_group(apps\\openmw\\mwclass FILES ${GAMECLASS} ${GAMECLASS_HEADER})

set(GAMEMECHANICS
    mwmechanics/mechanicsmanager.cpp)
set(GAMEMECHANICS_HEADER
    mwmechanics/mechanicsmanager.hpp
    mwmechanics/stat.hpp
    mwmechanics/creaturestats.hpp
    )
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})

set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD}
    ${GAMECLASS} ${GAMEMECHANICS} ${GAMEDIALOGUE}
    )
set(OPENMW_HEADER ${GAME_HEADER} ${GAMEREND_HEADER} ${GAMEINPUT_HEADER} ${GAMESCRIPT_HEADER}
    ${GAMESOUND_HEADER} ${GAMEGUI_HEADER} ${GAMEWORLD_HEADER}  ${GAMECLASS_HEADER}
    ${GAMEMECHANICS_HEADER} ${GAMEDIALOG_HEADERUE}
    )

# Main executable
add_executable(openmw
    ${COMPONENTS} ${COMPONENTS_HEADER}
    ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER}
    ${OPENMW_CPP} ${OPENMW_HEADER}
    ${APPLE_BUNDLE_RESOURCES}
    )

# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING
# when we change the backend.
include_directories(${SOUND_INPUT_INCLUDES})
add_definitions(${SOUND_DEFINE})

target_link_libraries(openmw
  ${OGRE_LIBRARIES}
  ${OIS_LIBRARIES}
  ${Boost_LIBRARIES}
  ${OPENAL_LIBRARY}
  ${SOUND_INPUT_LIBRARY}
  caelum
  MyGUIEngine
  MyGUI.OgrePlatform
)

if (APPLE)
    find_library(CARBON_FRAMEWORK Carbon)
    target_link_libraries(openmw ${CARBON_FRAMEWORK})
endif (APPLE)
