]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
make crunch build optional and disabled by default
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 aa1028d64d869b1efb61341377dbf72a37e96cd9..fb4a34c1c54f655e38fd2006161772129de45327 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 6fdcc0b20b8d3bcada056b8b2b5d1665d18d7c1a..633b965f2b1c253fde4858182300040f57c7816f 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 a41ed78042ae5ec2a771bb0b1f33ee783707bf5f..d6c7f075b474e957de5f9f4060c44aac9d88ddee 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 5182f833034f30c46d48b0121cc453d8e6fbe4ec..bea548ee600ee08efa667a8a762c1048376b1e00 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 574e4fab44819a78fc1b14ee4cc245e87310dac8..f7f73522e2ac66749a633b023b90fc4ce9f79520 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 8760512884b80b3a517fa1e840a4cbb796e35368..2dfc9ef98c5c99abbf4b8526e9423e0e941186cd 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 4bf1ec0ee5987442a23daba6423c78769d33a03a..1732867b6ca0aac13d825406cf7e66fe2346c44c 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
                                }
                        }
                }