# libradiantcore.so is already in the lib/darkradiant/modules directory, so the
# utility libraries are one directory level above
set(CMAKE_INSTALL_RPATH "$ORIGIN/..")

add_library(radiantcore MODULE
            brush/Brush.cpp
            brush/BrushModule.cpp
            brush/BrushNode.cpp
            brush/csg/CSG.cpp
            brush/export/CollisionModel.cpp
            brush/Face.cpp
            brush/FaceInstance.cpp
            brush/FacePlane.cpp
            brush/FixedWinding.cpp
            brush/TextureMatrix.cpp
            brush/TextureProjection.cpp
            brush/Winding.cpp
            camera/Camera.cpp
            camera/CameraManager.cpp
            clipper/BrushByPlaneClipper.cpp
            clipper/Clipper.cpp
            clipper/ClipPoint.cpp
            clipper/SplitAlgorithm.cpp
            commandsystem/CommandSystem.cpp
            decl/FavouritesManager.cpp
            eclass/EntityClass.cpp
            eclass/EClassColourManager.cpp
            eclass/EClassManager.cpp
            entity/AngleKey.cpp
            entity/AttachmentData.cpp
            entity/curve/CurveCatmullRom.cpp
            entity/curve/Curve.cpp
            entity/curve/CurveEditInstance.cpp
            entity/curve/CurveNURBS.cpp
            entity/SpawnArgs.cpp
            entity/doom3group/Doom3Group.cpp
            entity/doom3group/Doom3GroupNode.cpp
            entity/eclassmodel/EclassModelNode.cpp
            entity/EntityModule.cpp
            entity/EntityNode.cpp
            entity/EntitySettings.cpp
            entity/generic/GenericEntityNode.cpp
            entity/KeyValue.cpp
            entity/KeyValueObserver.cpp
            entity/light/Light.cpp
            entity/light/LightNode.cpp
            entity/light/Renderables.cpp
            entity/ModelKey.cpp
            entity/NameKeyObserver.cpp
            entity/NamespaceManager.cpp
            entity/RotationKey.cpp
            entity/RotationMatrix.cpp
            entity/ShaderParms.cpp
            entity/speaker/SpeakerNode.cpp
            entity/speaker/SpeakerRenderables.cpp
            entity/target/TargetableNode.cpp
            entity/target/TargetKeyCollection.cpp
            entity/target/TargetKey.cpp
            entity/target/TargetLineNode.cpp
            entity/target/TargetManager.cpp
            filetypes/FileTypeRegistry.cpp
            filters/BasicFilterSystem.cpp
            filters/XMLFilter.cpp
            filters/XmlFilterEventAdapter.cpp
            fonts/FontLoader.cpp
            fonts/FontManager.cpp
            fonts/GlyphInfo.cpp
            fonts/GlyphSet.cpp
            grid/GridManager.cpp
            imagefile/BMPLoader.cpp
            imagefile/dds.cpp
            imagefile/ddslib.cpp
            imagefile/ImageLoader.cpp
            imagefile/JPEGLoader.cpp
            imagefile/PNGLoader.cpp
            imagefile/TGALoader.cpp
            layers/LayerInfoFileModule.cpp
            layers/LayerManager.cpp
            layers/LayerModule.cpp
            log/COutRedirector.cpp
            log/LogFile.cpp
            log/LogStreamBuf.cpp
            log/LogStream.cpp
            log/LogWriter.cpp
            log/SegFaultHandler.cpp
            log/StringLogDevice.cpp
            map/aas/AasFileManager.cpp
            map/aas/Doom3AasFile.cpp
            map/aas/Doom3AasFileLoader.cpp
            map/aas/Doom3AasFileSettings.cpp
            map/algorithm/Export.cpp
            map/algorithm/Import.cpp
            map/algorithm/MapExporter.cpp
            map/algorithm/MapImporter.cpp
            map/algorithm/Models.cpp
            map/algorithm/Skins.cpp
            map/autosaver/AutoSaver.cpp
            map/ArchivedMapResource.cpp
            map/CounterManager.cpp
            map/EditingStopwatch.cpp
            map/EditingStopwatchInfoFileModule.cpp
            map/format/Doom3MapFormat.cpp
            map/format/Doom3MapReader.cpp
            map/format/Doom3MapWriter.cpp
            map/format/Doom3PrefabFormat.cpp
            map/format/MapFormatManager.cpp
            map/format/portable/PortableMapFormat.cpp
            map/format/portable/PortableMapReader.cpp
            map/format/portable/PortableMapWriter.cpp
            map/format/primitiveparsers/BrushDef3.cpp
            map/format/primitiveparsers/BrushDef.cpp
            map/format/primitiveparsers/Patch.cpp
            map/format/primitiveparsers/PatchDef2.cpp
            map/format/primitiveparsers/PatchDef3.cpp
            map/format/Quake3MapFormat.cpp
            map/format/Quake3MapReader.cpp
            map/format/Quake4MapFormat.cpp
            map/format/Quake4MapReader.cpp
            map/infofile/InfoFile.cpp
            map/infofile/InfoFileExporter.cpp
            map/infofile/InfoFileManager.cpp
            map/Map.cpp
            map/MapFileManager.cpp
            map/MapModules.cpp
            map/MapPosition.cpp
            map/MapPositionManager.cpp
            map/MapPropertyInfoFileModule.cpp
            map/MapResource.cpp
            map/MapResourceLoader.cpp
            map/MapResourceManager.cpp
            map/mru/MRU.cpp
            map/namespace/ComplexName.cpp
            map/namespace/Namespace.cpp
            map/namespace/NamespaceFactory.cpp
            map/PointFile.cpp
            map/RegionManager.cpp
            map/RootNode.cpp
            map/VcsMapResource.cpp
            model/export/AseExporter.cpp
            model/export/Lwo2Chunk.cpp
            model/export/Lwo2Exporter.cpp
            model/export/ModelExporter.cpp
            model/export/ModelScalePreserver.cpp
            model/export/PatchSurface.cpp
            model/export/ScaledModelExporter.cpp
            model/export/WavefrontExporter.cpp
            model/md5/MD5AnimationCache.cpp
            model/md5/MD5Anim.cpp
            model/md5/MD5Model.cpp
            model/md5/MD5ModelLoader.cpp
            model/md5/MD5ModelNode.cpp
            model/md5/MD5Module.cpp
            model/md5/MD5Skeleton.cpp
            model/md5/MD5Surface.cpp
            model/ModelCache.cpp
            model/ModelFormatManager.cpp
            model/NullModel.cpp
            model/NullModelNode.cpp
            model/import/AseModel.cpp
            model/import/AseModelLoader.cpp
            model/import/ModelImporterBase.cpp
            model/import/openfbx/ofbx.cpp
            model/import/FbxModelLoader.cpp
            model/picomodel/PicoModelLoader.cpp
            model/picomodel/PicoModelModule.cpp
            model/StaticModel.cpp
            model/StaticModelNode.cpp
            model/StaticModelSurface.cpp
            model/picomodel/lib/lwo/clip.c
            model/picomodel/lib/lwo/envelope.c
            model/picomodel/lib/lwo/list.c
            model/picomodel/lib/lwo/lwio.c
            model/picomodel/lib/lwo/lwo2.c
            model/picomodel/lib/lwo/lwob.c
            model/picomodel/lib/lwo/pntspols.c
            model/picomodel/lib/lwo/surface.c
            model/picomodel/lib/lwo/vecmath.c
            model/picomodel/lib/lwo/vmap.c
            model/picomodel/lib/picointernal.c
            model/picomodel/lib/picomodel.c
            model/picomodel/lib/picomodules.c
            model/picomodel/lib/pm_3ds.c
            model/picomodel/lib/pm_fm.c
            model/picomodel/lib/pm_iqm.c
            model/picomodel/lib/pm_lwo.c
            model/picomodel/lib/pm_md2.c
            model/picomodel/lib/pm_md3.c
            model/picomodel/lib/pm_mdc.c
            model/picomodel/lib/pm_ms3d.c
            model/picomodel/lib/pm_obj.c
            model/picomodel/lib/pm_terrain.c
            modulesystem/ModuleLoader.cpp
            modulesystem/ModuleRegistry.cpp
            particles/ParticleDef.cpp
            particles/ParticleNode.cpp
            particles/ParticleParameter.cpp
            particles/ParticlesManager.cpp
            particles/RenderableParticleBunch.cpp
            particles/RenderableParticle.cpp
            particles/RenderableParticleStage.cpp
            particles/StageDef.cpp
            patch/algorithm/General.cpp
            patch/algorithm/Prefab.cpp
            patch/Patch.cpp
            patch/PatchModule.cpp
            patch/PatchNode.cpp
            patch/PatchRenderables.cpp
            patch/PatchTesselation.cpp
            Radiant.cpp
            rendersystem/backend/GLProgramFactory.cpp
            rendersystem/backend/glprogram/GenericVFPProgram.cpp
            rendersystem/backend/glprogram/GLSLProgramBase.cpp
            rendersystem/backend/glprogram/GLSLBumpProgram.cpp
            rendersystem/backend/glprogram/GLSLDepthFillProgram.cpp
            rendersystem/backend/glprogram/GLSLDepthFillAlphaProgram.cpp
            rendersystem/backend/OpenGLShader.cpp
            rendersystem/backend/OpenGLShaderPass.cpp
            rendersystem/backend/DepthFillPass.cpp
            rendersystem/debug/SpacePartitionRenderer.cpp
            rendersystem/GLFont.cpp
            rendersystem/OpenGLModule.cpp
            rendersystem/OpenGLRenderSystem.cpp
            rendersystem/RenderSystemFactory.cpp
            rendersystem/SharedOpenGLContextModule.cpp
            scenegraph/Octree.cpp
            scenegraph/SceneGraph.cpp
            scenegraph/SceneGraphFactory.cpp
            selection/algorithm/Curves.cpp
            selection/algorithm/Entity.cpp
            selection/algorithm/General.cpp
            selection/algorithm/Group.cpp
            selection/algorithm/GroupCycle.cpp
            selection/algorithm/Patch.cpp
            selection/algorithm/Planes.cpp
            selection/algorithm/Primitives.cpp
            selection/algorithm/Shader.cpp
            selection/algorithm/Texturing.cpp
            selection/algorithm/Transformation.cpp
            selection/clipboard/Clipboard.cpp
            selection/group/SelectionGroupInfoFileModule.cpp
            selection/group/SelectionGroupManager.cpp
            selection/group/SelectionGroupModule.cpp
            selection/ManipulationPivot.cpp
            selection/SceneManipulationPivot.cpp
            selection/manipulators/DragManipulator.cpp
            selection/manipulators/ManipulatorBase.cpp
            selection/manipulators/ManipulatorComponents.cpp
            selection/manipulators/ModelScaleManipulator.cpp
            selection/manipulators/RotateManipulator.cpp
            selection/manipulators/ScaleManipulator.cpp
            selection/manipulators/TranslateManipulator.cpp
            selection/RadiantSelectionSystem.cpp
            selection/SelectedNodeList.cpp
            selection/selectionset/SelectionSet.cpp
            selection/selectionset/SelectionSetInfoFileModule.cpp
            selection/selectionset/SelectionSetManager.cpp
            selection/selectionset/SelectionSetModule.cpp
            selection/SelectionTestWalkers.cpp
            selection/shaderclipboard/ClosestTexturableFinder.cpp
            selection/shaderclipboard/ShaderClipboard.cpp
            selection/shaderclipboard/Texturable.cpp
            selection/textool/ColourSchemeManager.cpp
            selection/textool/FaceNode.cpp
            selection/textool/Node.cpp
            selection/textool/PatchNode.cpp
            selection/textool/TextureToolManipulationPivot.cpp
            selection/textool/TextureToolDragManipulator.cpp
            selection/textool/TextureToolRotateManipulator.cpp
            selection/textool/TextureToolSceneGraph.cpp
            selection/textool/TextureToolSelectionSystem.cpp
            selection/TransformationVisitors.cpp
            settings/ColourScheme.cpp
            settings/ColourSchemeManager.cpp
            settings/Game.cpp
            settings/GameManager.cpp
            settings/LanguageManager.cpp
            settings/PreferencePage.cpp
            settings/PreferenceSystem.cpp
            shaders/CameraCubeMapDecl.cpp
            shaders/CShader.cpp
            shaders/Doom3ShaderLayer.cpp
            shaders/Doom3ShaderSystem.cpp
            shaders/ExpressionSlots.cpp
            shaders/MapExpression.cpp
            shaders/MaterialSourceGenerator.cpp
            shaders/ShaderExpression.cpp
            shaders/ShaderLibrary.cpp
            shaders/ShaderTemplate.cpp
            shaders/TableDefinition.cpp
            shaders/TextureMatrix.cpp
            shaders/textures/GLTextureManager.cpp
            shaders/textures/TextureManipulator.cpp
            skins/Doom3SkinCache.cpp
            undo/UndoSystem.cpp
            undo/UndoSystemFactory.cpp
            versioncontrol/VersionControlManager.cpp
            vfs/DeflatedInputStream.cpp
            vfs/DirectoryArchive.cpp
            vfs/Doom3FileSystem.cpp
            vfs/Doom3FileSystemModule.cpp
            vfs/ZipArchive.cpp
            xmlregistry/RegistryTree.cpp
            xmlregistry/XMLRegistry.cpp)
target_compile_options(radiantcore PUBLIC ${SIGC_CFLAGS})
target_include_directories(radiantcore PRIVATE .)
target_link_libraries(radiantcore PUBLIC
                      math xmlutil scenegraph wxutil module
                      ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})

# Enable precompiled header for radiantcore
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
target_precompile_headers(radiantcore PRIVATE
                          "$<$<COMPILE_LANGUAGE:CXX>:precompiled.h>")
endif()