make crunch build optional and disabled by default 104/head
authorThomas Debesse <dev@illwieckz.net>
Sun, 28 Oct 2018 21:24:54 +0000 (22:24 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sun, 28 Oct 2018 21:28:42 +0000 (22:28 +0100)
14 files changed:
CMakeLists.txt
libs/CMakeLists.txt
plugins/CMakeLists.txt
plugins/image/CMakeLists.txt
plugins/image/crn.cpp [deleted file]
plugins/image/crn.h [deleted file]
plugins/image/image.cpp
plugins/imagecrn/CMakeLists.txt [new file with mode: 0644]
plugins/imagecrn/crn.cpp [new file with mode: 0644]
plugins/imagecrn/crn.h [new file with mode: 0644]
plugins/imagecrn/imagecrn.cpp [new file with mode: 0644]
plugins/imagecrn/imagecrn.def [new file with mode: 0644]
tools/quake3/CMakeLists.txt
tools/quake3/q3map2/image.c

index aa1028d..fb4a34c 100644 (file)
@@ -3,6 +3,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
 project(NetRadiant C CXX)
 
 option(BUILD_RADIANT "Build the GUI" ON)
+option(BUILD_CRUNCH "Build Crunch image support" OFF)
 
 if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
     set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE PATH "..." FORCE)
index 6fdcc0b..633b965 100644 (file)
@@ -1,6 +1,8 @@
 add_subdirectory(cmdlib)
 add_subdirectory(container)
-add_subdirectory(crnrgba)
+if (BUILD_CRUNCH)
+    add_subdirectory(crnrgba)
+endif ()
 add_subdirectory(ddslib)
 add_subdirectory(debugging)
 add_subdirectory(etclib)
index a41ed78..d6c7f07 100644 (file)
@@ -17,6 +17,11 @@ add_subdirectory(archivewad)
 add_subdirectory(archivezip)
 add_subdirectory(entity)
 add_subdirectory(image)
+
+if(BUILD_CRUNCH)
+       add_subdirectory(imagecrn)
+endif()
+
 add_subdirectory(imagehl)
 add_subdirectory(imagepng)
 add_subdirectory(imageq2)
index 5182f83..bea548e 100644 (file)
@@ -6,10 +6,9 @@ radiant_plugin(image
         ktx.cpp ktx.h
         pcx.cpp pcx.h
         tga.cpp tga.h
-        crn.cpp crn.h
         )
 
 find_package(JPEG REQUIRED)
-target_include_directories(image PRIVATE ${JPEG_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/libs/crnrgba)
-target_link_libraries(image PRIVATE crnrgba ddslib etclib ${JPEG_LIBRARIES})
+target_include_directories(image PRIVATE ${JPEG_INCLUDE_DIR})
+target_link_libraries(image PRIVATE ddslib etclib ${JPEG_LIBRARIES})
 target_compile_options(image PRIVATE -fexceptions)
diff --git a/plugins/image/crn.cpp b/plugins/image/crn.cpp
deleted file mode 100644 (file)
index 85e1e5c..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-   Copyright (C) 2018, Unvanquished Developers
-   All Rights Reserved.
-
-   This file is part of NetRadiant.
-
-   NetRadiant is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   NetRadiant is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with NetRadiant; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-
-#include "crn.h"
-
-#include <stdlib.h>
-
-#include "ifilesystem.h"
-#include "iarchive.h"
-#include "idatastream.h"
-
-#include "crn_rgba.h"
-#include "ddslib.h"
-#include "imagelib.h"
-
-Image *LoadCRNBuff(const byte *buffer, int length)
-{
-    int width, height;
-    if (!GetCRNImageSize(buffer, length, &width, &height)) {
-        globalErrorStream() << "ERROR: Error getting crn imag dimensions.\n";
-        return nullptr;
-    }
-    RGBAImage *image = new RGBAImage(width, height);
-    if (!ConvertCRNtoRGBA(buffer, length, width * height, image->getRGBAPixels())) {
-        globalErrorStream() << "ERROR: Error decoding crn image.\n";
-        image->release();
-        return nullptr;
-    }
-    return image;
-}
-
-Image *LoadCRN(ArchiveFile &file)
-{
-    ScopedArchiveBuffer buffer(file);
-    return LoadCRNBuff(buffer.buffer, buffer.length);
-}
diff --git a/plugins/image/crn.h b/plugins/image/crn.h
deleted file mode 100644 (file)
index 4e97556..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-   Copyright (C) 2018, Unvanquished Developers
-   All Rights Reserved.
-
-   This file is part of NetRadiant.
-
-   NetRadiant is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
-   (at your option) any later version.
-
-   NetRadiant is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with NetRadiant; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#if !defined( INCLUDED_CRN_H )
-#define INCLUDED_CRN_H
-
-class Image;
-
-class ArchiveFile;
-
-Image *LoadCRN(ArchiveFile &file);
-
-#endif
-
index 574e4fa..f7f7352 100644 (file)
@@ -28,7 +28,6 @@
 #include "pcx.h"
 #include "dds.h"
 #include "ktx.h"
-#include "crn.h"
 
 
 #include "modulesystem/singletonmodule.h"
@@ -174,29 +173,6 @@ typedef SingletonModule<ImageKTXAPI, ImageDependencies> ImageKTXModule;
 ImageKTXModule g_ImageKTXModule;
 
 
-class ImageCRNAPI {
-    _QERPlugImageTable m_imagecrn;
-public:
-    typedef _QERPlugImageTable Type;
-
-    STRING_CONSTANT(Name, "crn");
-
-    ImageCRNAPI()
-    {
-        m_imagecrn.loadImage = LoadCRN;
-    }
-
-    _QERPlugImageTable *getTable()
-    {
-        return &m_imagecrn;
-    }
-};
-
-typedef SingletonModule<ImageCRNAPI, ImageDependencies> ImageCRNModule;
-
-ImageCRNModule g_ImageCRNModule;
-
-
 extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
 {
     initialiseModule(server);
@@ -207,5 +183,4 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
     g_ImagePCXModule.selfRegister();
     g_ImageDDSModule.selfRegister();
     g_ImageKTXModule.selfRegister();
-    g_ImageCRNModule.selfRegister();
 }
diff --git a/plugins/imagecrn/CMakeLists.txt b/plugins/imagecrn/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fd45552
--- /dev/null
@@ -0,0 +1,7 @@
+radiant_plugin(imagecrn
+        imagecrn.cpp
+        crn.cpp crn.h
+        )
+
+target_include_directories(imagecrn PRIVATE ${CMAKE_SOURCE_DIR}/libs/crnrgba)
+target_link_libraries(imagecrn PRIVATE crnrgba)
diff --git a/plugins/imagecrn/crn.cpp b/plugins/imagecrn/crn.cpp
new file mode 100644 (file)
index 0000000..85e1e5c
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+   Copyright (C) 2018, Unvanquished Developers
+   All Rights Reserved.
+
+   This file is part of NetRadiant.
+
+   NetRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   NetRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with NetRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+#include "crn.h"
+
+#include <stdlib.h>
+
+#include "ifilesystem.h"
+#include "iarchive.h"
+#include "idatastream.h"
+
+#include "crn_rgba.h"
+#include "ddslib.h"
+#include "imagelib.h"
+
+Image *LoadCRNBuff(const byte *buffer, int length)
+{
+    int width, height;
+    if (!GetCRNImageSize(buffer, length, &width, &height)) {
+        globalErrorStream() << "ERROR: Error getting crn imag dimensions.\n";
+        return nullptr;
+    }
+    RGBAImage *image = new RGBAImage(width, height);
+    if (!ConvertCRNtoRGBA(buffer, length, width * height, image->getRGBAPixels())) {
+        globalErrorStream() << "ERROR: Error decoding crn image.\n";
+        image->release();
+        return nullptr;
+    }
+    return image;
+}
+
+Image *LoadCRN(ArchiveFile &file)
+{
+    ScopedArchiveBuffer buffer(file);
+    return LoadCRNBuff(buffer.buffer, buffer.length);
+}
diff --git a/plugins/imagecrn/crn.h b/plugins/imagecrn/crn.h
new file mode 100644 (file)
index 0000000..4e97556
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+   Copyright (C) 2018, Unvanquished Developers
+   All Rights Reserved.
+
+   This file is part of NetRadiant.
+
+   NetRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   NetRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with NetRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#if !defined( INCLUDED_CRN_H )
+#define INCLUDED_CRN_H
+
+class Image;
+
+class ArchiveFile;
+
+Image *LoadCRN(ArchiveFile &file);
+
+#endif
+
diff --git a/plugins/imagecrn/imagecrn.cpp b/plugins/imagecrn/imagecrn.cpp
new file mode 100644 (file)
index 0000000..4516f06
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+   Copyright (C) 2001-2006, William Joseph.
+   All Rights Reserved.
+
+   This file is part of GtkRadiant.
+
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "ifilesystem.h"
+#include "iimage.h"
+
+#include "crn.h"
+
+
+#include "modulesystem/singletonmodule.h"
+
+class ImageDependencies : public GlobalFileSystemModuleRef {
+};
+
+class ImageCRNAPI {
+    _QERPlugImageTable m_imagecrn;
+public:
+    typedef _QERPlugImageTable Type;
+
+    STRING_CONSTANT(Name, "crn");
+
+    ImageCRNAPI()
+    {
+        m_imagecrn.loadImage = LoadCRN;
+    }
+
+    _QERPlugImageTable *getTable()
+    {
+        return &m_imagecrn;
+    }
+};
+
+typedef SingletonModule<ImageCRNAPI, ImageDependencies> ImageCRNModule;
+
+ImageCRNModule g_ImageCRNModule;
+
+
+extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server)
+{
+    initialiseModule(server);
+
+    g_ImageCRNModule.selfRegister();
+}
diff --git a/plugins/imagecrn/imagecrn.def b/plugins/imagecrn/imagecrn.def
new file mode 100644 (file)
index 0000000..df815fa
--- /dev/null
@@ -0,0 +1,7 @@
+; imagepng.def : Declares the module parameters for the DLL.
+
+LIBRARY      "IMAGECRN"
+
+EXPORTS
+    ; Explicit exports can go here
+       Radiant_RegisterModules @1
index 8760512..2dfc9ef 100644 (file)
@@ -121,6 +121,16 @@ radiant_tool(q3map2
         q3map2/writebsp.c
         )
 
+if (BUILD_CRUNCH)
+        set(OPTIONAL_IMAGE_LIBRARIES crnrgba)
+        set(OPTIONAL_IMAGE_DEFINES BUILD_CRUNCH=1)
+endif ()
+
+target_compile_definitions(q3map2
+        PRIVATE
+        ${OPTIONAL_IMAGE_DEFINES}
+        )
+
 target_link_libraries(q3map2
         ${GLIB_LIBRARIES}
         ${JPEG_LIBRARIES}
@@ -128,7 +138,7 @@ target_link_libraries(q3map2
         ${LIBXML2_LIBRARIES}
         ${Minizip_LIBRARIES}
         ${ZLIB_LIBRARIES}
-        crnrgba
+        ${OPTIONAL_IMAGE_LIBRARIES}
         ddslib
         etclib
         filematch
index 4bf1ec0..1732867 100644 (file)
@@ -86,6 +86,7 @@ static void LoadDDSBuffer( byte *buffer, int size, byte **pixels, int *width, in
        DDSDecompress( (ddsBuffer_t*) buffer, *pixels );
 }
 
+#ifdef BUILD_CRUNCH
 /*
     LoadCRNBuffer
     loads a crn image into a valid rgba image
@@ -106,6 +107,7 @@ void LoadCRNBuffer( byte *buffer, int size, byte **pixels, int *width, int *heig
                return;
        }
 }
+#endif // BUILD_CRUNCH
 
 
 /*
@@ -457,6 +459,7 @@ image_t *ImageLoad( const char *filename ){
                                        if ( size > 0 ) {
                                                LoadKTXBufferFirstImage( buffer, size, &image->pixels, &image->width, &image->height );
                                        }
+                                       #ifdef BUILD_CRUNCH
                                        else
                                        {
                                                /* attempt to load crn */
@@ -467,6 +470,7 @@ image_t *ImageLoad( const char *filename ){
                                                        LoadCRNBuffer( buffer, size, &image->pixels, &image->width, &image->height );
                                                }
                                        }
+                                       #endif // BUILD_CRUNCH
                                }
                        }
                }