diff --git a/CMakeLists.txt b/CMakeLists.txt index daf17ba3d..723d10b34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,12 @@ IF (APPLE) set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk") ENDIF (APPLE) +# Macros + +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) + +include (OpenMWMacros) + # Version set (OPENMW_VERSION_MAJOR 0) @@ -76,171 +82,6 @@ ELSE() message (STATUS "OpenMW pre-built binaries not found. Using standard locations.") ENDIF() -# Add path for CMake scripts -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) - -# source directory: components -set(COMP_DIR ${CMAKE_SOURCE_DIR}/components) - -set(BSA - ${COMP_DIR}/bsa/bsa_archive.cpp - ${COMP_DIR}/bsa/bsa_file.cpp) -set(BSA_HEADER - ${COMP_DIR}/bsa/bsa_archive.hpp - ${COMP_DIR}/bsa/bsa_file.hpp) -source_group(components\\bsa FILES ${BSA} ${BSA_HEADER}) - -set(CFG - ${COMP_DIR}/cfg/configurationmanager.cpp - ) -set(CFG_HEADER - ${COMP_DIR}/cfg/configurationmanager.hpp - ) -source_group(components\\cfg FILES ${CFG} ${CFG_HEADER}) - -set(NIF - ${COMP_DIR}/nif/nif_file.cpp) -set(NIF_HEADER - ${COMP_DIR}/nif/controlled.hpp - ${COMP_DIR}/nif/effect.hpp - ${COMP_DIR}/nif/nif_types.hpp - ${COMP_DIR}/nif/record.hpp - ${COMP_DIR}/nif/controller.hpp - ${COMP_DIR}/nif/extra.hpp - ${COMP_DIR}/nif/node.hpp - ${COMP_DIR}/nif/record_ptr.hpp - ${COMP_DIR}/nif/data.hpp - ${COMP_DIR}/nif/nif_file.hpp - ${COMP_DIR}/nif/property.hpp) -source_group(components\\nif FILES ${NIF} ${NIF_HEADER}) - -set(NIFOGRE - ${COMP_DIR}/nifogre/ogre_nif_loader.cpp) -set(NIFOGRE_HEADER - ${COMP_DIR}/nifogre/ogre_nif_loader.hpp) -source_group(components\\nifogre FILES ${NIFOGRE} ${NIFOGRE_HEADER}) - -set(NIFBULLET - ${COMP_DIR}/nifbullet/bullet_nif_loader.cpp) -set(NIFBULLET_HEADER - ${COMP_DIR}/nifbullet/bullet_nif_loader.hpp) -source_group(components\\nifbullet FILES ${NIFBULLET} ${NIFBULLET_HEADER}) - -set(TO_UTF8 - ${COMP_DIR}/to_utf8/to_utf8.cpp) -set(TO_UTF8_HEADER - ${COMP_DIR}/to_utf8/to_utf8.hpp) -source_group(components\\to_utf8 FILES ${TO_UTF8} ${TO_UTF8_HEADER}) - -set(FILE_FINDER - ${COMP_DIR}/file_finder/search.cpp) -set(FILE_FINDER_HEADER - ${COMP_DIR}/file_finder/file_finder.hpp - ${COMP_DIR}/file_finder/filename_less.hpp - ${COMP_DIR}/file_finder/search.hpp) -source_group(components\\file_finder FILES ${FILE_FINDER} ${FILE_FINDER_HEADER}) - -set(ESM_STORE - ${COMP_DIR}/esm_store/store.cpp) -set(ESM_STORE_HEADER - ${COMP_DIR}/esm_store/cell_store.hpp - ${COMP_DIR}/esm_store/reclists.hpp - ${COMP_DIR}/esm_store/store.hpp) -source_group(components\\esm_store FILES ${ESM_STORE} ${ESM_STORE_HEADER}) - -file(GLOB ESM_HEADER ${COMP_DIR}/esm/*.hpp) -set(ESM - ${COMP_DIR}/esm/attr.cpp - ${COMP_DIR}/esm/esm_reader.cpp - ${COMP_DIR}/esm/loadland.cpp - ${COMP_DIR}/esm/loadacti.cpp - ${COMP_DIR}/esm/loadalch.cpp - ${COMP_DIR}/esm/loadappa.cpp - ${COMP_DIR}/esm/loadarmo.cpp - ${COMP_DIR}/esm/loadbody.cpp - ${COMP_DIR}/esm/loadbook.cpp - ${COMP_DIR}/esm/loadbsgn.cpp - ${COMP_DIR}/esm/loadcell.cpp - ${COMP_DIR}/esm/loadclas.cpp - ${COMP_DIR}/esm/loadclot.cpp - ${COMP_DIR}/esm/loadcont.cpp - ${COMP_DIR}/esm/loadcrea.cpp - ${COMP_DIR}/esm/loaddial.cpp - ${COMP_DIR}/esm/loaddoor.cpp - ${COMP_DIR}/esm/loadench.cpp - ${COMP_DIR}/esm/loadfact.cpp - ${COMP_DIR}/esm/loadglob.cpp - ${COMP_DIR}/esm/loadgmst.cpp - ${COMP_DIR}/esm/loadinfo.cpp - ${COMP_DIR}/esm/loadingr.cpp - ${COMP_DIR}/esm/loadlevlist.cpp - ${COMP_DIR}/esm/loadligh.cpp - ${COMP_DIR}/esm/loadlocks.cpp - ${COMP_DIR}/esm/loadltex.cpp - ${COMP_DIR}/esm/loadmgef.cpp - ${COMP_DIR}/esm/loadmisc.cpp - ${COMP_DIR}/esm/loadnpc.cpp - ${COMP_DIR}/esm/loadpgrd.cpp - ${COMP_DIR}/esm/loadrace.cpp - ${COMP_DIR}/esm/loadregn.cpp - ${COMP_DIR}/esm/loadscpt.cpp - ${COMP_DIR}/esm/loadskil.cpp - ${COMP_DIR}/esm/loadsndg.cpp - ${COMP_DIR}/esm/loadsoun.cpp - ${COMP_DIR}/esm/loadspel.cpp - ${COMP_DIR}/esm/loadsscr.cpp - ${COMP_DIR}/esm/loadstat.cpp - ${COMP_DIR}/esm/loadweap.cpp - -) -source_group(components\\esm FILES ${ESM_HEADER} ${ESM}) - -set(MISC - ${COMP_DIR}/misc/stringops.cpp - ) -set(MISC_HEADER - ${COMP_DIR}/misc/slice_array.hpp - ${COMP_DIR}/misc/stringops.hpp - ) -source_group(components\\misc FILES ${MISC} ${MISC_HEADER}) - -set(FILES - ${COMP_DIR}/files/linuxpath.cpp - ${COMP_DIR}/files/windowspath.cpp - ${COMP_DIR}/files/macospath.cpp - ${COMP_DIR}/files/multidircollection.cpp - ${COMP_DIR}/files/collections.cpp - ${COMP_DIR}/files/fileops.cpp - ) -set(FILES_HEADER - ${COMP_DIR}/files/linuxpath.hpp - ${COMP_DIR}/files/windowspath.hpp - ${COMP_DIR}/files/macospath.hpp - ${COMP_DIR}/files/path.hpp - ${COMP_DIR}/files/multidircollection.hpp - ${COMP_DIR}/files/collections.hpp - ${COMP_DIR}/files/fileops.hpp - ) -source_group(components\\files FILES ${FILES} ${FILES_HEADER}) - -file(GLOB COMPILER ${COMP_DIR}/compiler/*.cpp) -file(GLOB COMPILER_HEADER ${COMP_DIR}/compiler/*.hpp) -source_group(components\\compiler FILES ${COMPILER} ${COMPILER_HEADER}) - -file(GLOB INTERPRETER ${COMP_DIR}/interpreter/*.cpp) -file(GLOB INTERPRETER_HEADER ${COMP_DIR}/interpreter/*.hpp) -source_group(components\\interpreter FILES ${INTERPRETER} ${INTERPRETER_HEADER}) - -set(COMPONENTS ${BSA} ${NIF} ${NIFOGRE} ${ESM_STORE} ${MISC} ${TO_UTF8} - ${COMPILER} ${INTERPRETER} ${ESM} ${FILE_FINDER} ${NIFBULLET} ${FILES} - ${CFG} - ) -set(COMPONENTS_HEADER ${BSA_HEADER} ${NIF_HEADER} ${NIFOGRE_HEADER} ${ESM_STORE_HEADER} - ${ESM_HEADER} ${MISC_HEADER} ${COMPILER_HEADER} ${TO_UTF8_HEADER} - ${INTERPRETER_HEADER} ${FILE_FINDER_HEADER} ${NIFBULLET_HEADER} ${FILES_HEADER} - ${CFG_HEADER} - ) - # source directory: libs set(LIBDIR ${CMAKE_SOURCE_DIR}/libs) @@ -510,6 +351,9 @@ if(DPKG_PROGRAM) include(CPack) endif(DPKG_PROGRAM) +# Components +add_subdirectory (components) + # Apps and tools add_subdirectory( apps/openmw ) diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index 583f1fabd..f2ab7bce7 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -8,13 +8,11 @@ source_group(apps\\esmtool FILES ${ESMTOOL}) # Main executable add_executable(esmtool ${ESMTOOL} - ${MISC} ${MISC_HEADER} - ${TO_UTF8} - ${ESM} ) target_link_libraries(esmtool ${Boost_LIBRARIES} + components ) #if (APPLE) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index a5c57efdf..2fc3189fc 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -52,11 +52,6 @@ include(${QT_USE_FILE}) # Main executable add_executable(omwlauncher ${LAUNCHER} - ${MISC} ${MISC_HEADER} - ${FILES} ${FILES_HEADER} - ${CFG} ${CFG_HEADER} - ${TO_UTF8} - ${ESM} ${RCC_SRCS} ${MOC_SRCS} ) @@ -66,6 +61,7 @@ target_link_libraries(omwlauncher ${OGRE_LIBRARIES} ${QT_LIBRARIES} ${PNG_LIBRARY} + components ) if(DPKG_PROGRAM) @@ -80,7 +76,7 @@ if (APPLE) else() configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") - + configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg") endif() diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 54abb948a..90b752264 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -15,244 +15,59 @@ set(GAME_HEADER config.hpp) source_group(game FILES ${GAME} ${GAME_HEADER}) -set(GAMEREND - mwrender/rendering_manager.cpp - mwrender/mwscene.cpp - mwrender/cellimp.cpp - mwrender/interior.cpp - mwrender/exterior.cpp - mwrender/sky.cpp - mwrender/player.cpp +add_openmw_dir (mwrender + rendering_manager mwscene cellimp interior exterior sky player ) -set(GAMEREND_HEADER - mwrender/rendering_manager.hpp - mwrender/cell.hpp - mwrender/cellimp.hpp - mwrender/mwscene.hpp - mwrender/interior.hpp - mwrender/exterior.hpp - mwrender/sky.hpp - mwrender/player.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/layouts.hpp - mwgui/text_input.hpp - mwgui/widgets.hpp - mwgui/race.hpp - mwgui/class.hpp - mwgui/birth.hpp - mwgui/review.hpp - mwgui/window_manager.hpp - mwgui/console.hpp - mwgui/dialogue.hpp - mwgui/dialogue_history.hpp - mwgui/window_base.hpp - mwgui/stats_window.hpp - mwgui/messagebox.hpp -) -set(GAMEGUI - mwgui/window_manager.cpp - mwgui/layouts.cpp - mwgui/console.cpp - mwgui/text_input.cpp - mwgui/widgets.cpp - mwgui/race.cpp - mwgui/birth.cpp - mwgui/class.cpp - mwgui/review.cpp - mwgui/dialogue.cpp - mwgui/dialogue_history.cpp - mwgui/window_base.cpp - mwgui/stats_window.cpp - mwgui/messagebox.cpp -) -source_group(apps\\openmw\\mwgui FILES ${GAMEGUI_HEADER} ${GAMEGUI}) - -set(GAMEDIALOGUE_HEADER - mwdialogue/dialoguemanager.hpp - mwdialogue/journal.hpp - mwdialogue/journalentry.hpp - mwdialogue/quest.hpp - mwdialogue/topic.hpp -) -set(GAMEDIALOGUE - mwdialogue/dialoguemanager.cpp - mwdialogue/journal.cpp - mwdialogue/journalentry.cpp - mwdialogue/quest.cpp - mwdialogue/topic.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 - mwscript/dialogueextensions.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 - mwscript/ref.hpp - mwscript/dialogueextensions.hpp +add_openmw_dir (mwinput + inputmanager ) -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/scene.cpp - mwworld/physicssystem.cpp - mwworld/globals.cpp - mwworld/class.cpp - mwworld/actionteleport.cpp - mwworld/actiontalk.cpp - mwworld/actiontake.cpp - mwworld/containerutil.cpp - mwworld/player.cpp - mwworld/cells.cpp - mwworld/localscripts.cpp - ) -set(GAMEWORLD_HEADER - mwworld/refdata.hpp - mwworld/world.hpp - mwworld/physicssystem.hpp - mwworld/scene.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 - mwworld/player.hpp - mwworld/cellfunctors.hpp - mwworld/cells.hpp - mwworld/localscripts.hpp +add_openmw_dir (mwgui + layouts text_input widgets race class birth review window_manager console dialogue + dialogue_history window_base stats_window messagebox ) -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 +add_openmw_dir (mwdialogue + dialoguemanager journal journalentry quest topic ) -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 + +add_openmw_dir (mwscript + locals scriptmanager compilercontext interpretercontext cellextensions miscextensions + guiextensions soundextensions skyextensions statsextensions containerextensions + aiextensions controlextensions extensions globalscripts ref dialogueextensions ) -source_group(apps\\openmw\\mwclass FILES ${GAMECLASS} ${GAMECLASS_HEADER}) -set(GAMEMECHANICS - mwmechanics/mechanicsmanager.cpp - mwmechanics/magiceffects.cpp +add_openmw_dir (mwsound + soundmanager ) -set(GAMEMECHANICS_HEADER - mwmechanics/mechanicsmanager.hpp - mwmechanics/stat.hpp - mwmechanics/creaturestats.hpp - mwmechanics/magiceffects.hpp - mwmechanics/movement.hpp + +add_openmw_dir (mwworld + refdata world physicssystem scene environment globals class action nullaction actionteleport + containerstore actiontalk actiontake containerstore manualref containerutil player cellfunctors + cells localscripts ) -source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER}) -set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD} - ${GAMECLASS} ${GAMEMECHANICS} ${GAMEDIALOGUE} +add_openmw_dir (mwclass + classes activator creature npc weapon armor potion apparatus book clothing container door + ingredient creaturelevlist itemlevlist light lockpick misc probe repair static ) -set(OPENMW_HEADER ${GAME_HEADER} ${GAMEREND_HEADER} ${GAMEINPUT_HEADER} ${GAMESCRIPT_HEADER} - ${GAMESOUND_HEADER} ${GAMEGUI_HEADER} ${GAMEWORLD_HEADER} ${GAMECLASS_HEADER} - ${GAMEMECHANICS_HEADER} ${GAMEDIALOG_HEADERUE} + +add_openmw_dir (mwmechanics + mechanicsmanager stat creaturestats magiceffects movement ) # Main executable add_executable(openmw - ${COMPONENTS} ${COMPONENTS_HEADER} ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} - ${OPENMW_CPP} ${OPENMW_HEADER} + ${CONPONENT_FILES} + ${OPENMW_FILES} + ${GAME} ${GAME_HEADER} ${APPLE_BUNDLE_RESOURCES} ) +target_link_libraries (openmw components) + # Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING # when we change the backend. include_directories(${SOUND_INPUT_INCLUDES} ${BULLET_INCLUDE_DIRS}) diff --git a/cmake/OpenMWMacros.cmake b/cmake/OpenMWMacros.cmake new file mode 100644 index 000000000..c40936691 --- /dev/null +++ b/cmake/OpenMWMacros.cmake @@ -0,0 +1,24 @@ + +macro (add_openmw_dir dir) +set (files) +foreach (u ${ARGN}) +file (GLOB ALL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.*") +foreach (f ${ALL}) +list (APPEND files "${f}") +list (APPEND OPENMW_FILES "${f}") +endforeach (f) +endforeach (u) +source_group ("apps\\openmw\\${dir}" FILES ${files}) +endmacro (add_openmw_dir) + +macro (add_component_dir dir) +set (files) +foreach (u ${ARGN}) +file (GLOB ALL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${dir}/${u}.*") +foreach (f ${ALL}) +list (APPEND files "${f}") +list (APPEND COMPONENT_FILES "${f}") +endforeach (f) +endforeach (u) +source_group ("components\\${dir}" FILES ${files}) +endmacro (add_component_dir) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt new file mode 100644 index 000000000..76e68dd89 --- /dev/null +++ b/components/CMakeLists.txt @@ -0,0 +1,66 @@ +project (Components) + +# source files + +add_component_dir (bsa + bsa_archive bsa_file + ) + +add_component_dir (cfg + configurationmanager + ) + +add_component_dir (nif + controlled effect nif_types record controller extra node record_ptr data nif_file property + ) + +add_component_dir (nifogre + ogre_nif_loader + ) + +add_component_dir (nifbullet + bullet_nif_loader + ) + +add_component_dir (to_utf8 + to_utf8 + ) + +add_component_dir (file_finder + file_finder filename_less search + ) + +add_component_dir (esm_store + cell_store reclists store + ) + +add_component_dir (esm + attr defs esm_reader loadacti loadalch loadappa loadarmo loadbody loadbook loadbsgn loadcell + loadclas loadclot loadcont loadcrea loadcrec loaddial loaddoor loadench loadfact loadglob loadgmst + loadinfo loadingr loadland loadlevlist loadligh loadlocks loadltex loadmgef loadmisc loadnpcc + loadnpc loadpgrd loadrace loadregn loadscpt loadskil loadsndg loadsoun loadspel loadsscr loadstat + loadweap records + ) + +add_component_dir (misc + slice_array stringops + ) + +add_component_dir (files + linuxpath windowspath macospath path multidircollection collections fileops + ) + +add_component_dir (compiler + context controlparser errorhandler exception exprparser extensions fileparser generator + lineparser literals locals output parser scanner scriptparser skipparser streamerrorhandler + stringparser tokenloc + ) + +add_component_dir (interpreter + context controlopcodes genericopcodes installopcodes interpreter localopcodes mathopcodes + miscopcodes opcodes runtime scriptopcodes spatialopcodes types + ) + +include_directories(${BULLET_INCLUDE_DIRS}) + +add_library (components STATIC ${COMPONENT_FILES})