Commit Graph

437 Commits

Author SHA1 Message Date
David Korth
456760c64c [cmake] msvc.cmake: Added more /Zc options.
- /Zc:inline
- /Zc:__cplusplus
- /Zc:externC
- /Zc:noexceptTypes
- /Zc:rvalueCast
- /Zc:ternary

No code changes were needed, since gcc implements all of these anyway
as far as I know.
2022-07-11 22:30:58 -04:00
David Korth
6dfeed8c58 [cmake] msvc.cmake: Move /Zc:wchar_t here from win32-msvc.cmake; add /Zc:__cplusplus.
This sets the value of __cplusplus to reflect the C++ standard version
in use. MSVC normally doesn't do that for some reason.
2022-07-11 01:16:46 -04:00
David Korth
8feb4cb10f [cmake] gcc.cmake: Check for and use "-fcf-protection" if available. 2022-07-06 18:28:56 -04:00
David Korth
cb408e8351 [cmake] Very basic support for PowerPC.
I decided to try building rom-properties on Wii U Linux because why not.
2022-07-04 23:47:43 -04:00
David Korth
6e0e0db6d0 [kf6] Preliminary port to KDE Frameworks 6.
KF6 isn't out yet, so this is mostly just a compile test against
Qt 6.

Main changes:

- KeyStoreModel.hpp: #include "KeyStoreQt.hpp" instead of simply
  forward-defining the class.

src/kde/kf6/rom-properties-kf6_autogen/A2AGDIRYKS/moc_KeyStoreModel.cpp:151:1:   required from here
/usr/include/qt6/QtCore/qmetatype.h:858:23: error: invalid application of ‘sizeof’ to incomplete type ‘KeyStoreQt’
  858 |         static_assert(sizeof(T), "Type argument of Q_PROPERTY or Q_DECLARE_METATYPE(T*) must be fully defined");
      |                       ^~~~~~~~~

- stub-export.cpp: Don't set Qt::AA_EnableHighDpiScaling on Qt 6. It's
  always enabled on Qt 6 and this constant is now deprecated.

- AchievementsItemDelegate: QVariant::canConvert(int) is deprecated.
  The recommended replacement is QVariant::canConvert(QMetaType), which
  is Qt 6 only, or alternatively, QVariant::canConvert<T>, which is
  available in Qt 4 and Qt 5.

The only actual compile error I've hit so far is with KFileMetaData
because it uses QMap::insertMulti(), which was removed from Qt 6.
2022-07-02 11:51:37 -04:00
David Korth
28857f550e Use gcc's built-in functions to detect CPU flags in IFUNC resolvers.
Due to random shenanigans and symbol ordering, libromdata started
crashing because the linker was attempting to resolve the IFUNC
functions before the rpcpu functions were available. Use gcc's
built-in CPU support functions instead.

(It *was* working for me yesterday, then I rebooted and it stopped
working until I made this change.)

This requires gcc-4.8+ or clang-6.0+.

An alternative workaround is using lazy binding (-Wl,-z,lazy), but this
could just delay the crash until later.

IfuncTest.c: Test for the CPU support functions and disable IFUNC
if they aren't available.
2022-06-23 17:59:50 -04:00
David Korth
c365d41a48 [minizip-ng] Don't manually check for ZSTD using pkg_check_modules().
This causes issues on Xubuntu 16.04 if a system-wide zstd is installed
because extlib uses the internal version while minizip-ng tries using
the system version, and the system version isn't recent enough for
minizip-ng. (Requires 1.4.0; Xubuntu 16.04 has 1.3.1.)
2022-06-21 17:14:24 -04:00
David Korth
dd40b00c08 [win32] Build libromdata as a DLL.
librpthreads: Was missing SetMSVCDebugPath and EXCLUDE_FROM_ALL.
libunixcommon: Was missing "-fpic -fPIC".

[librpbase] ConfReader: Make it public:
Config.hpp(20,1): warning C4275: non dll-interface class
'LibRpBase::ConfReader' used as base for dll-interface class
'LibRpBase::Config'

================

RomData::supportedImageTypes_static(): Need to mark RP_LIBROMDATA_PUBLIC
in RomData_decl.hpp, not just the definition in each .cpp file. This
worked on Linux, but on Windows, it causes an error:

Amiibo.cpp(295,18): error C2375: 'LibRomData::Amiibo::supportedImageTypes_static': redefinition; different linkage

Note that this will result in more exported symbols than is strictly
necessary, but that shouldn't be too much of an issue.

================

Needed to change several libraries from STATIC to OBJECT in order to
ensure that files aren't truncated from libromdata.

TODO: Is it possible to remove "OBJECT"? It makes a mess in the compiler
output, since it links to each .obj individually instead of the .lib
files...

================

Need to define RP_BUILDING_FOR_DLL=1 for anything that links to libromdata
in order to ensure it has the dllimport definitions set up correctly.
This only seems to affect *some* symbols, not all of them... (notably
AboutTabText and ComBase data symbols)

[libwin32common] Moved IIDs from win_iid.c into IListView.hpp to avoid
having to export these symbols from libromdata.

ZLIB_LIBRARY -> ZLIB_LIBRARIES

Removed ZLIB_LIBRARIES from the KDE4 and KF5 UI frontends, since they
don't use zlib directly.

================

Link all tests to libromdata instead of individual static libraries.
This reduces the size of the compiled test executables, at the expense
of requiring libromdata to be built before the tests can be built.
This is required because librptest is linked to libromdata in order to
access librptexture to set the rp_image backend.

TODO: Only set the rp_image backend in tests that need it instead of
always setting it?
2022-06-21 00:53:13 -04:00
David Korth
510272c7bf Switch to CMake's built-in precompiled headers function.
Among other things, it supports handling multiple targets in a single
subdirectory, which will be needed for the "-dll" targets when converting
libromdata to a DLL on Windows.

NOTE: Requires CMake 3.16. PCH will be disabled if using an earlier
version.

Other changes:

- TARGET_PRECOMPILED_HEADER() ignores force-include flags, so add
  config.libc.h and c++11-compat.h to the header list to ensure that
  stdafx.h has access to them.

- Removed all stdafx.c and stdafx.cpp files. CMake generates its own.
2022-06-21 00:53:13 -04:00
David Korth
c67e06b6b2 Disable symbol visibility in several extlib modules using static linking.
PowerVR, basisu_astc, inih, libmspack-xenia, and unice68 were leaking
externally-visible symbols in the Linux builds of UI frontends.
2022-06-18 15:29:52 -04:00
David Korth
f2004d431e Disable IFUNC and "extra security" if -fsanitize is specified.
The sanitizer doesn't support IFUNC (crashes), and hangs on exit if
seccomp is in use, even if all the syscalls are added.
2022-06-13 21:15:32 -04:00
David Korth
b67b89607e [xdg] rp-config.desktop.in: Added an XDG desktop file for rp-config.
This will add a "ROM Properties configurator" entry to the applications
menu on most Linux desktop environments.

TODO:
- Custom rom-properties icon instead of "media-flash".
- GTK+ rp-config implementation.

Fixes #295: [Feature Request] rp-config launcher
Reported by @Amnesia1000.
2022-05-21 13:42:41 -04:00
David Korth
aea2d716f0 [cmake] gcc.cmake: Don't use -Wsuggest-override on gcc versions earlier than 9.2.
Earlier versions will warn if a function is marked 'final' but not
'override'.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010
2022-02-25 18:29:45 -05:00
David Korth
466b2787ad [cmake] gcc.cmake: Add "-Wno-error=suggest-override".
For some reason, "-Wsuggest-override" is being turned into an error in
the MinGW-w64 build. This breaks Google Test, which is apparently
triggering some "suggest override" warnings.
2022-02-23 19:50:50 -05:00
David Korth
51ad07363d [cmake] msvc.cmake: INCLUDE(CheckCXXCompilerFlag)
Needed for CHECK_CXX_COMPILER_FLAG().
2022-02-23 18:32:03 -05:00
David Korth
e0d07f37f1 [cmake] platform/msvc.cmake: Don't check for "/Zc:throwingNew" if using clang-cl.
clang-cl defaults to /Zc:throwingNew internally, but it prints a warning
if the parameter is specified:

clang-cl : warning : argument unused during compilation: '/Zc:throwingNew'
[-Wunused-command-line-argument]
2022-02-21 18:34:37 -05:00
David Korth
3ddd0f24d3 Consolidated CPU_* and instruction set flags into CPUInstructionSetFlags.cmake.
Set -mssse3 and -msse4.1 on clang-cl. clang-cl normally works like MSVC,
but it doesn't enable SSSE3 or SSE 4.1 intrinsics by default. Instead,
the gcc-style parameters need to be specified.

TODO: Clang also supports some gcc-style warning flags.
2022-02-21 18:24:45 -05:00
David Korth
ecc22c0699 [cmake] gcc.cmake: Enable "suggest override" if available. (C++ only) 2022-02-21 18:15:34 -05:00
David Korth
1d16c40449 Some minor MinGW-w64 improvements.
- Use host gettext executables when cross-compiling with MinGW.
- Change CHECK_GETTEXT() from a macro to a function.
- Disable -Wno-cast-function-type, since it prints warnings every time
  we use GetProcAddress().
2022-02-17 22:35:45 -05:00
David Korth
407d1dc972 Rework IFUNC detection into a compile-time check.
This makes it more reliable across different platforms, and it ensures
we don't try using IFUNC if e.g. -fanalysis=address is enabled, since
AddressSanitizer doesn't support it.

config.librpcpu.h now defines HAVE_IFUNC if IFUNC is available.

Note that we're still checking a few things:
- Windows and Mac OS will never have IFUNC.
- glibc-2.11 is required for most architectures.
- glibc-2.18 is required for ARM.
2022-01-27 20:02:08 -05:00
David Korth
77b3d1ec92 common.h: ATTR_PRINTF() should explicitly use gnu_printf or ms_printf.
This should fix the actual underlying problem. Adding the "fix" to
FstPrint.cpp failed because that uses snprintf(), not rp_sprintf().

Use the same setup as MinGW-w64:
- gnu_printf if not Windows, or if using UCRT or MinGW ANSI stdio.
- ms_printf if Windows and not using either UCRT or MinGW ANSI stdio.

This should fix the printf warning issues in all places in the MinGW-w64
build.
2021-09-06 14:39:13 -04:00
David Korth
c48f5b1b7e [cmake] win32-gcc.cmake: -D__USE_MINGW_ANSI_STDIO=0
msvcrt.dll doesn't support %llx-style printf specifiers, but MinGW-w64
enables ANSI stdio by default, even if we're using msvcrt.dll.

This results in PRIx64 using %llx instead of %I64x, which causes printf
warnings, which fails the build due to -Werror=format.

ELF.cpp: Remove the FIXME for this.
2021-09-06 12:11:27 -04:00
David Korth
86dbf36f3e [cmake] gcc.cmake: Enable -Werror for several different format warnings.
Reference: https://fedoraproject.org/wiki/Format-Security-FAQ

-Werror=format-nonliteral is *not* enabled because there are some
legitimate uses of non-literal format strings.

Separated the warning flags into multiple variables.

Updated everything to build with this change.
2021-09-06 01:41:59 -04:00
David Korth
1317a931d4 [librptexture] GodotSTEX: Initial implementation of ASTC 8x8 decoding.
Added the ASTC decoder from Basis Universal.

FIXME: The decoded images have swapped R and B channels.
2021-09-03 23:24:42 -04:00
David Korth
d6f584707f [cmake] win32-gcc.cmake: Use the _ld_out method instead of assuming ld always supports these options; add more options.
Previously, it tested for --large-address-aware, --nxcompat, and
--tsaware. We're now also testing for --dynamicbase and --high-entropy-va.

In addition, newer ld shows things like "--[disable-]dynamicbase", so
adjust the check to only look for the important part, then prepend "--"
to the option.

Also: --large-address-aware is only supported on 32-bit, and
--high-entropy-va is only supported on 64-bit, so restrict those.
(Technically, --large-address-aware does something on 64-bit, but
it's rather useless. If not set, it *might* restrict process memory
to 2 GB.)
2021-09-03 01:50:27 -04:00
David Korth
9bab82452c [cmake] msvc.cmake: Use /Zc:throwingNew if available.
This eliminates NULL pointer checks when calling operator new.
https://devblogs.microsoft.com/cppblog/new-in-vs-2015-zcthrowingnew/

Note that this probably won't affect the release build, since LTCG
already eliminated the NULL pointer checks.
2021-08-31 23:24:39 -04:00
David Korth
9a49d1d701 [cmake] platform/gcc.cmake: Use -Bsymbolic-functions if available.
KDE Frameworks 5.85.0 enables this by default. It reduces startup time
by pre-linking global function symbols.

Also, filter out '=' from variable names. This broke the caching of
-Werror=return-type.

msvc.cmake: Copy the '=' change here.
2021-08-14 10:05:05 -04:00
David Korth
6cfcf08f61 [cmake] platform/gcc.cmake: Specify the gcov library as "gcov", not "-lgcov".
Don't use compiler-specific library options. CMake will do the
"right thing" for us.
2021-08-12 23:51:57 -04:00
David Korth
a08cb02e0c [cmake] Remove excess quoting from some CMake macros for various checks. 2021-08-06 19:37:48 -04:00
David Korth
3a929276dc [cmake] Check64BitTimeSupport.cmake: Fix _TIME_BITS=64 detection on glibc-2.34.
NOTE: _TIME_BITS=64 is currently broken when building C++ code. An extra
CMake check has been added to detect this.
2021-08-03 21:16:41 -04:00
David Korth
86339962df [gtk] Use GSound if it's available.
GSound depends on libcanberra, but it's an indirect dependency, so
if we use GSound, we don't need to use libcanberra.

GSound is available on Ubuntu 16.04, so we can switch to it on
most systems. The libcanberra backend is still supported for now,
though it might be removed later.

Since GSound doesn't have a GTK+ dependency, we can use it in the
GTK4 backend. (libcanberra doesn't support GTK4.)
2021-07-30 20:55:12 -04:00
David Korth
bf72456833 [gtk] Initial experimental support for GTK4.
I don't have any GTK4 file browsers to test this, but it compiles.
GTK4 is disabled by default due to this.

GTK4 doesn't support Cairo, so we're falling back to GdkPixbuf for
now. There *is* a new GdkTexture class, which implements most of
GdkPixbuf's functionality without the overhead as Cairo.

Missing functionality:
- Drag & drop needs to be completely rewritten.
- gtk_dialog_run() doesn't exist anymore, so file dialogs need to be
  reworked to use a signal handler. This will work in older versions
  of GTK, too.
  - Also: Handle URIs properly?
- GtkHeaderBar: GTK4 no longer has GtkButtonBox. Figure out "secondary"
  there.
- GTK4 equivalent of gtk_container_set_border_width().

The Nautilus frontend is enabled, but Thunar is not, since that requires
more changes that can't easily be verified at the moment.
2021-07-30 00:08:52 -04:00
Cameron Cawley
9e3cbf76c8
[cmake] platform.cmake: Fix ARM CPU detection 2021-05-17 16:31:47 +01:00
David Korth
eadcdf9327 Remove "/Gz" for stdcall on i386 when building with MSVC.
I tested a release build and it saved a total of 10,752 bytes.

On the other hand, it had a rather huge maintenance overhead, since I had
to ensure that all extlibs had __cdecl set up in the headers properly,
and this had to be redone on every update.

The i386 build of LZ4 on AppVeyor was failing in tests because of missing
stdcall symbols. I decided not to bother adding stdcall support to LZ4
and simply revert stdcall entirely.
2021-03-31 22:24:17 -04:00
David Korth
4d86bdfbd0 [amiibo-data] CMakeLists.txt: Install amiibo-data.bin in ${DIR_INSTALL_SHARE}.
[cmake] DirInstallPath.cmake: Set ${DIR_INSTALL_SHARE} to "." on Windows.
2021-03-21 22:36:46 -04:00
David Korth
db17c1a7d5 [libromdata] AmiiboData: Initial rework to use amiibo-data.bin.
- Load the amiibo-data.bin on demand.
- Use amiibo-data.bin to look up all the names.
- AmiiboData is now a Singleton, similar to Achievements.
- New macro CHARTABLE_VARIANT_FLAG that replaces (1U << 31).

amiibo-data.bin will be installed in /usr/share/rom-properties on
Linux systems.

TODO:
- Reload amiibo-data.bin if the timestamp changes.
- Find amiibo-data.bin on Windows.
- Allow overriding amiibo-data.bin using the config directory.
2021-03-15 22:16:51 -04:00
David Korth
7bcffc8dfc [cmake] platform.cmake: Detect other 32-bit ARM variants. 2021-03-07 09:46:14 -05:00
David Korth
083d6ac20a cmake/platform.cmake: Fix 32-bit ARM platform detection.
Reported by @vaguerant.
2021-03-03 20:41:52 -05:00
David Korth
c3f4db832c [zlib] Updated from v1.2.11 to zlib-ng v2.0.0-RC2.
https://github.com/zlib-ng/zlib-ng
2021-02-18 23:50:27 -05:00
David Korth
7fad2e50aa [cmake] CheckNettle2or3.cmake: New macro to check for Nettle and determine its version.
Split from librpbase/CMakeLists.txt.

[librpbase/tests] CMakeLists.txt: Use CHECK_NETTLE_2_OR_3.
Previously, we were checking for the Nettle library, which broke when the
library package was changed to NETTLE to fix a warning from CMake 3.17's
FIND_PACKAGE() in commit 5645e9f9b5.
(Rename FindNettle and FindSeccomp to FindNETTLE and FindSECCOMP.)
2021-02-17 18:41:31 -05:00
David Korth
b6ed9ce74c [cmake] gcc.cmake: Add "-Werror=return-type".
I'm not sure when this started happening, but leaving out a return
value from a non-void function is causing gcc to jump to a semi-random
function instead of simply returning an undefined value.

language_combo_box_set_selected_lc() was calling
language_combo_box_set_property() because of this:

.#4  0x00007fffca11e468 in language_combo_box_set_property(GObject*, guint, GValue const*, GParamSpec*) (object=0x7ffff70d0108, prop_id=1, value=0xa8, pspec=0x1)
     at ../../src/gtk/LanguageComboBox.cpp:156
.#5  0x0000555555cf3ad0 in  ()
.#6  0x000000000000656e in  ()
.#7  0x0000555555cf3ad0 in  ()
.#8  0x0000555555c46838 in  ()
.#9  0x0000555555e5b6a0 in  ()
.#10 0x00007fffca111d0b in rom_data_view_update_multi(RomDataView*, uint32_t) (page=page@entry=0x7fffe8020490 [RomDataView], user_lc=user_lc@entry=0)
     at ../../src/gtk/RomDataView.cpp:1554
2020-10-12 02:26:59 -04:00
David Korth
fd984088a4 Added an option ENABLE_ACHIEVEMENTS to disable the achievement popups.
This won't actually disable achievement tracking, though.

[gtk, kde] Update everything to build properly with achievement popups
disabled.
2020-09-21 21:13:04 -04:00
David Korth
cb77351d45 MiniZip 2.10.0 requires zstd-1.4.0.
MiniZip 2.10.0 uses ZSTD_compressStream2() and ZSTD_EndDirective.

Note that MiniZip is not currently used outside of test suites,
so this won't be installed as part of the package.
2020-09-20 16:49:58 -04:00
David Korth
691d632098 [cmake] gcc.cmake: Undo accidentally-committed changes that disabled "-Og".
I set this while testing some refcounting stuff earlier.

This fixes a regression from commit 2b4ada24e4.
([librpbase] IconAnimData: Changed to a reference-counted class.)
2020-09-13 05:45:13 -04:00
David Korth
8d289d0145 [kf5] Port the KPropertiesDialog plugin (the main one) to JSON loading.
Starting with KDE Frameworks 5.74, KIO supports loading KPropertiesDialog
plugins using QPluginLoader, which uses JSON metadata instead of .desktop
files. KIO will print a warning to stderr if a plugin is still using the
.desktop method:

kf.kio.widgets: Plugin "rom-properties-kf5" is using the deprecated
loading style. Please port it to JSON loading.

Reference: 6519283f83

ParseMimeTypes.cmake: New function to print the MIME types in a format
usable by the JSON plugin metadata.

rom-properties-kf5.json.in: JSON version of the .desktop file.

NOTE: Even though the .desktop file still has the relevant data for older
versions of KIO, KIO 5.74 does *not* print a warning, since the JSON
metadata *is* present.

Moved the installed .so to kf5/propertiesdialog, which is required by the
plugin loader. The .desktop file has been updated for this, since it's
still needed for older versions and for ThumbCreator.

Updated all components that reference plugin paths for this change.

configure.kf5.h.in: Put the plugin paths here instead of defining them
using TARGET_COMPILE_DEFINITIONS().

TODO: Need to test on older KF5 versions and make sure that it still
works without any issues.
2020-09-12 23:57:30 -04:00
David Korth
2b4ada24e4 [librpbase] IconAnimData: Changed to a reference-counted class.
Updated all RomData subclasses and UI frontends for this change.

Animated icons now work correctly in UI frontends after e.g. extracting
an SRL from a DSi TAD package or Nintendo 3DS CIA.
2020-09-12 22:00:55 -04:00
David Korth
55792eefab [libromdata] Nintendo3DS: Removed the unnecessary references on IRpFile and IDiscReader objects.
We can unreference them since the RomData objects will keep a reference
until they're no longer needed.

Consolidated the SMDH and SRL objects into a single RomData* pointer.
dynamic_cast<> is used to distinguish between them where necessary.

The giant sbptr struct is no longer needed.

(NOTE: I thought the two RomData pointers were in a union, but apparently
they weren't...)

Removed CheckCXXNoRTTICompilerFlag.cmake to ensure we don't accidentally
re-add it and break dynamic_cast<>.
2020-09-11 02:35:51 -04:00
David Korth
7029c71017 [gtk] MessageSound: GTK+ version using libcanberra.
Tested on both GTK+ 2.x (XFCE) and GTK+ 3.x.
2020-09-07 03:42:19 -04:00
David Korth
7b282f5d81 [minilzo] Added an internal copy of MiniLZO.
I chose MiniLZO instead of regular LZO because we only need to be able to
decompress LZO1X blocks.

[libromdata] CisoPspReader: Don't call lzo_init() if this JISO isn't
actually using LZO. Otherwise, if the DLL is missing on Windows, the
program will crash.
2020-09-05 11:05:12 -04:00
David Korth
640cb2bf8a [libromdata] CisoPspReader: Added initial support for JISO.
It has a unique header, but the index entries table is similar to the
other formats. It does *not* set the high bit to indicate NC; instead,
it uses the same method as CISOv2, where the compressed block size
matches the uncompressed block size.

Compression algorithm is lzo1x.

TODO:
- JISO supports NC areas. Figure this part out.
- Add LZO to extlib.
2020-09-05 05:03:29 -04:00
David Korth
85485f9d37 [cmake] FindLZ4.cmake, FindZSTD.cmake: Fix some GTK+ copypasta. 2020-09-05 04:26:55 -04:00
David Korth
ad476eb9a0 [lz4] Added a copy of lz4-1.9.2 for PSP CISO. 2020-09-05 02:32:50 -04:00
David Korth
d5d38f67a6 [libromdata] CisoPspReader: Added LZ4 decompression for CISO and ZISO.
ZISO is basically CISO v0/v1 but with LZ4 instead of zlib.

CISO v2 can use either zlib or LZ4 on a per-block basis.

[cmake] Added LZ4 checks.
- TODO: Add an internal copy of LZ4.
2020-09-05 01:27:59 -04:00
David Korth
33201e1e0e [libcachecommon] Added a system-wide cache directory. (Linux only)
This is useful for cases where the thumbnailer cannot download files or
write to the user's cache directory. libgnome-desktop, when configured
with bubblewrap enabled, doesn't allow access to the home directory
(aside from the file being thumbnailed), but *does* allow access to the
/usr/ directory.

Three cases are now possible, depending on if a cache file is present in
the system-wide cache directory and/or the user's cache directory:

- IS in system-wide, NOT in user's: Use the system-wide version.
- IS in system-wide, AND in user's: Use the user's version.
- NOT in system-wide: Use the user's version, calling rp-download if the
  file doesn't exist.
2020-07-21 18:22:58 -04:00
David Korth
5645e9f9b5 Rename FindNettle and FindSeccomp to FindNETTLE and FindSECCOMP.
CMake 3.17's FIND_PACKAGE() is complaining that the package name
doesn't match the filename. Rename the filenames to match.
2020-07-17 18:43:00 -04:00
Cameron Cawley
a600b119ef Remove leftover references to OpenGL 2020-07-13 14:06:44 +01:00
David Korth
3f26630920 Rework MIME types for the .desktop files.
New MIME type files:
- xdg/mime.no-thumbnail.types (types that don't have supported thumbnails)
- xdg/mime.thumbnail.types (types that have supported thumbnails)

These are now read at CMake time and are used to generate the .desktop
and .thumbnailer files.

The mime.types files are one line per MIME type, which is easier to work
with than a single line of everything.

The GTK+ .thumbnailer files only have mime.thumbnail.types, whereas the
KDE .desktop files have both thumbnail and no-thumbnail.

TODO: Sort and remove duplicates?

Also: Cleaned up installation of the .desktop/.thumbnail files. Removed
the explicit source/binary directories, since these functions have good
defaults:
- CONFIGURE_FILE() uses source dir for source, binary dir for destination.
- INSTALL() defaults to binary dir.

Added some MIME types from RomData subclasses that weren't added before:
- iQuePlayer
- PokemonMini
- DidjTex
- KhronosKTX2
- PowerVR3
- SegaPVR (image/x-sega-svr only)
2020-06-29 19:44:35 -04:00
David Korth
f8fdaa7ae8 Allow disabling ZSTD entirely using ENABLE_ZSTD.
Similar to ENABLE_XML.

Print ZSTD status in the build summary.
2020-06-27 03:09:19 -04:00
David Korth
dc587561b4 [zstd] Added zstd for use with MiniZip.
MiniZip 2.10.0 added support for zstd as a compression method, so we
should support it.

Note that a system version of zstd is preferred on Linux systems.

Enabled the MiniZip test tools for manual builds only. Info-ZIP hasn't
been updated in a while, so I'm going to use the MiniZip test tools to
compress ZIP archives using zstd.

Enabled MiniZip compression in order to compress stuff using the minizip
test program.

mz_strm_zstd.c: FIXME: Compression level doesn't work. Hard-coded the
maximum compression level for now.
2020-06-27 03:09:15 -04:00
David Korth
fb61cafd1e [gtk] Updated the XFCE (GTK+ 2.x) plugin to use the gtk3 source directory.
The variables have been (mostly) renamed to GTK2, though the user-facing
variable is still BUILD_XFCE, and it shows "XFCE" in the UI_FRONTENDS
status message.

I don't know if I'll be adding support for old GTK+ 2.x Nautilus
versions...
2020-06-23 22:55:24 -04:00
David Korth
58e86c4ab9 [gtk3] Reworked the XFCE (GTK+ 3.x) plugin so it's now part of the GTK+ 3.x plugin.
Same sort of dynamic loading as the Nautilus version, but with separate
plugin initialization code.

thunarx-mini.h: Definitions of various ThunarX structs, since we no longer
use the system-wide version.

Use G_DEFINE_DYNAMIC_TYPE_EXTENDED() instead of the ThunarX version.
Note that for RpThunarProvider, we need to use G_IMPLEMENT_INTERFACE_DYNAMIC().
G_IMPLEMENT_INTERFACE() crashes at runtime, even though the ThunarX
version worked fine. (Presumably, the ThunarX version was actually the
same as the glib DYNAMIC version...)

Added dummy class_finalize() functions, which are needed by the
G_DEFINE_DYNAMIC_TYPE_EXTENDED() macro.
2020-06-23 22:29:40 -04:00
David Korth
9de5d028da [gtk] Renamed the GNOME plugin to gtk3.
Files have been renamed to indicate they're for Nautilus.

The XFCE plugin will be merged in with the GNOME plugin next.
2020-06-23 20:34:21 -04:00
David Korth
74661171dc [cmake] gcc.cmake: Set -Werror=implicit-function-declaration.
Copied from rvthtool.
2020-06-20 13:55:18 -04:00
David Korth
6dd716bd1d [gnome] Combine the MATE and Cinnamon plugins into the GNOME plugin.
The only differences are symbol names, which we can resolve at runtime.

Export all three plugin symbols. Depending on which initialization
function is called, we'll dlopen() the appropriate library and load
the symbols.

TODO:
- Create symlinks for the MATE and Cinnamon plugins.
- Update Debian packages to install symlinks.
- Other testing.
2020-04-19 18:01:50 -04:00
David Korth
8170400df8 [cmake] ConfigureMSVCRuntime.cmake: Add /NODEFAULT:MSVCRT.LIB when using the static CRT.
Otherwise, librpsecure.lib causes a linker error when building svrplus:

MSVCRT.lib(chandler4gs.obj) : error LNK2001: unresolved external symbol __except_handler4_common
pkg_windows\build.i386\bin\Release\svrplus.exe : fatal error LNK1120: 1 unresolved externals
2020-03-13 19:21:51 -04:00
David Korth
f5a749c3f0 Use statx() on Linux systems where available.
Note that we don't need to implement runtime fallbacks to stat():

1. If statx() isn't available at compile time, stat() will be used
   regardless.

2. If glibc supports statx() but the kernel doesn't, glibc will
   emulate statx(). This might introduce some extra overhead, but
   it's easier to work with.

3. The BSDs keep their libc in sync with the kernel, so there's no
   possibility that libc will support statx() if the kernel doesn't.
2020-03-08 01:01:01 -05:00
David Korth
6234bd0db5 [librpsecure] New consolidated security library.
The os-secure files from rpcli and rp-download have been consolidated
into a single library. seccomp-debug.h has also been moved here and
converted into a .c file with a public interface in the .h file.

rpcli and rp-download can now call rp_secure_enable() with an OS-specific
parameter. A struct is provided that makes the parameter type-safe.

NOTE: syscall_wl (seccomp syscall whitelist) can't be NULL-terminated,
since syscall 0 is valid on most architectures. On x86, it's read().
Hence, we're specifying an explicit array size.

Also moved the Win32 security options and integrity level files here.
Updated Win32 code for this change.

integrity_level.c: Removed the pthread_once() usage for the Windows Vista
check, since we're not linking to librpthreads. The worst that could happen
is both threads set isVista to the same value.

[cmake] Adjusted security options:
- USE_SECCOMP: Moved from cmake/options.cmake to librpsecure/CMakeLists.txt.
- ENABLE_SECCOMP_DEBUG: Added to librpsecure/CMakeLists.txt. Replaces
  the hard-coded SECCOMP_DEBUG in seccomp-debug.h.

[svrplus] Removed the libwin32common dependency. It was only used for the
Windows security options, and that's now handled by librpsecure.

[tests] Updated gtest_init.cpp to use librpsecure. Link all test suites to
librpsecure instead of libwin32common.
- TODO: seccomp() on Linux, pledge() on OpenBSD.
2020-02-26 22:32:21 -05:00
David Korth
1ea2ad7088 [cmake] PrecompiledHeader.cmake: Use ${CMAKE_${_lang}_FLAGS}.
This should ensure better utilization of precompiled headers in gcc builds.

Note that ${CMAKE_BUILD_TYPE} is not necessarily all uppercase, so
convert it to uppercase before using it.

CMakeLists.txt: Make sure CMAKE_BUILD_TYPE gets cached as "Release" if it
isn't specified on the command line.

TODO: Do we need to ensure that ADD_COMPILED_HEADER() is added *after* all
flags/definitions are set, or does the ordering not matter?
2020-02-23 12:51:14 -05:00
David Korth
8d973bc089 [cmake] Use ADD_DEFINITIONS() for macros that are common to both debug and release builds.
This cleans up the language-specific flags a bit.
2020-02-22 11:38:25 -05:00
David Korth
39ad7c32dc [cmake] CheckStackProtectorCompilerFlag.cmake: Make this a function and eliminate redundant checks. 2020-02-22 11:24:52 -05:00
David Korth
b453ff329e [cmake] PrecompiledHeader.cmake: Set C11/C99 and C++11 compiler flags.
This fixes the build on Ubuntu 14.04 with precompiled headers enabled.

Updated the compiler flag CMake files to use functions instead of macros
and to only check for functionality once regardless of how many times the
function is invoked. Among other things, this lets us remove the UNSET()
calls, since local variables are automatically deleted after returning
from the function.

FIXME: Make sure gcc is actually using the precompiled headers...
2020-02-22 11:15:16 -05:00
David Korth
e1e0f43f84 [cmake] Prepend ${CMAKE_INSTALL_PREFIX} to the default extension directories.
This seems to be needed on Ubuntu 14.04 for Thunar (GTK+ 2.x).

Newer versions have the extension directory defined in the pkgconfig
file, so it's not an issue there.
2020-02-18 20:31:08 -05:00
David Korth
058f6c7142 [rp-download] os-secure_linux.c: Linux version using libseccomp.
Tested on Ubuntu 14.04 and Gentoo Linux with glibc-2.31.
2020-02-10 23:14:07 -05:00
David Korth
736080f473 [rpcli] Added support for OpenBSD pledge().
It's a bit more restrictive than rp-download, since rpcli doesn't need
to access the Internet.

Moved Win32 security option initialization to an os-secure file as well
for consistency.

Moved the OpenBSD pledge()/tame() check to a CMake macro file.
2020-02-10 22:29:13 -05:00
David Korth
2af1767b5b [cmake] Check*CompilerFlag.cmake: Removed unnecessary variable dereferences.
These aren't needed in IF(), since they're automatically dereferenced.
2020-02-08 14:03:35 -05:00
David Korth
befce34da4 [cmake] CheckLargeFileSupport.cmake: Re-check if off_t/off64_t wasn't checked yet.
This might happen if the user updates their git repository to the
previous commit and runs an incremental build instead of a clean build.
2020-02-08 13:50:17 -05:00
David Korth
47f1d29466 Fixed off64_t detection on OpenBSD (and probably other systems).
OpenBSD (and probably other BSDs) are similar to Mac OS X in that they
have a 64-bit off_t and no off64_t. Detect this correctly using cmake
macros and handle it in config.libc.h.in.

config.libc.h is force-included using command line parameters, similar
to c++11-compat.h. We can't simply add the binary directory to
INCLUDE_DIRECTORIES() because this breaks other CMake checks, since
CMake doesn't use INCLUDE_DIRECTORIES() when checking stuff.
2020-02-08 13:32:30 -05:00
David Korth
1bc772b9bd [cmake] platform.cmake: Consolidate the ARM 32-bit and 64-bit branches in the non-MSVC check.
NOTE: UNTESTED!
2020-02-07 01:05:29 -05:00
David Korth
e800207e1c [cmake] platform.cmake: Leading underscore is only needed for i386.
Windows on ARM and ARM64 doesn't have a leading underscore for C function
names. (Nor on IA64, but Windows IA64 is discontinued.)
2020-02-01 00:24:46 -05:00
David Korth
8d88e435a7 Fixed cross-compilation for Windows on ARM (32-bit and 64-bit).
I decided to try building rom-properties with MSVC 2019's ARM compilers,
and it seems to build properly. I can't test it at the moment, though.

CMake changes:
- ${CMAKE_SYSTEM_PROCESSOR} is always set to the host CPU. Check
  _MSVC_C_ARCHITECTURE_FAMILY to determine the real CPU, then set
  CMAKE_SYSTEM_PROCESSOR accordingly.
- Enable /EHsc if it isn't set already. It's set by CMake for i386
  and amd64, but not for ARM or ARM64.
- Minimum subsystem version for ARM and ARM64 is 6.2. (Windows 8)
- Added some Win32 libraries that are included by default on i386 and
  amd64, but not on ARM or ARM64.
  - Reference: https://pete.akeo.ie/2017/05/compiling-desktop-arm-applications-with.html

Source changes:
- DelayLoadHelper.c, rp-config.c: Added subdirectory names for
  ia64, ARM, and ARM64.
  - TODO: Consolidate this into a common header file?

FIXME: Maybe we should use RP_LINKER_FLAGS_WIN32_EXE and
RP_LINKER_FLAGS_CONSOLE_EXE on MSVC. (We're using this on gcc.)
Not sure why I used one method or the other...
2020-02-01 00:18:11 -05:00
David Korth
d251edf572 [gtk] Added flags resources using glib-compile-resources.
Using GCR_Cmake macros from: https://github.com/Makman2/GCR_CMake

Currently loading the full 16x16 sprite sheet as the icon for each
dropdown entry. This is obviously wrong, but it works as a basic
test for now.

PIMGTYPE.cpp: New function PIMGTYPE_load_png_from_gresource(). This
function loads a PNG image from the glibresources and returns it as
PIMGTYPE. This does *not* use rp_image at all; it uses Cairo's
built-in PNG loading functionality.

TODO: GdkPixbuf version.
2020-01-20 00:00:00 -05:00
David Korth
abdc7efd61 s/Frameowrks/Frameworks/ 2020-01-19 13:32:26 -05:00
David Korth
04db869cee [cmake] options.cmake: "KF5" -> "KDE Frameworks 5" to make it more obvious as to what it is.
[kf5] CMakeLists.txt: Likewise.
2020-01-19 13:31:06 -05:00
David Korth
71a9b61cd8 Renamed the KDE5 frontend to KF5 to match upstream branding guidelines.
Related bug report for LibreOffice:
https://bugs.documentfoundation.org/show_bug.cgi?id=125922

NOTE: dll-search.c still checks for "KDE5" for compatibility.

NOTE 2 We did NOT include "KDE5" in the forwarding plugins for
compatibility because they shouldn't be mixed-and-matched with
rom-properties versions.
2020-01-19 13:28:17 -05:00
David Korth
40e802079f [cmake] options.cmake: Added an option to install AppArmor profiles.
Defaults to ON on Linux; not available on anything else.
(TODO: Disable on *BSD?)
2020-01-19 12:40:37 -05:00
David Korth
6aed6ce4b5 [rp-download] Added an AppArmor profile.
The AppArmor profile has the following permissions, with everything else
denied:

- Allow TCP network access to download from online image databases.
- Allow read access to rom-properties.conf.
- Allow write access to .cache/rom-properties/.
2020-01-19 12:28:33 -05:00
David Korth
debd62ac5d [cmake] win32-msvc.cmake: Remove kernel32.lib from the MSVC default libraries list and CMake's standard library list.
This ensures we can add it after liboldwincompat.

This fixes EncodePointer() and DecodePointer() being used from
kernel32.lib instead of liboldwincompat in rom-properties.dll.
2019-12-21 13:50:37 -05:00
David Korth
6e8c90b906 [oldwincompat] Added stubs for Windows 2000 (and maybe later Win9x) compatibility.
Stubbed functions for MSVC 2010-2017:
- InitializeSListHead()
- GetModuleHandleExW()
- EncodePointer()
- DecodePointer()
- SetFilePointerEx()

rpcli.exe now works, but rom-properties.dll fails to register.

CRT linkage is forced to static when enabling old Windows compatibility
on MSVC 2010 and later, since this is needed in order to get the CRT to
use the stub functions.

References:
- https://stackoverflow.com/questions/19516796/visual-studio-2012-win32-project-targeting-windows-2000/53548116
- https://stackoverflow.com/a/53548116

NOTE: NLS needs to be disabled; otherwise, gettext won't load due to
___mb_cur_max_func not being found in msvcrt.dll. This will require
a rebuild of gettext to use an older version.

Reference:
- https://docs.microsoft.com/en-us/cpp/c-runtime-library/mb-cur-max-func-mb-cur-max-l-func-p-mb-cur-max-mb-cur-max?view=vs-2019
2019-12-21 12:54:28 -05:00
David Korth
4e61fb6668 Make precompiled headers optional.
Enabled by default on MSVC only.

travis-ci still uses Ubuntu 14.04, and PrecompiledHeader.cmake doesn't
seem to pass the `-std=gnu++11` option properly, so gcc-4.8 ends up
failing.

TODO: Use cmake-3.16.0's built-in PCH support if available.
2019-12-18 00:44:56 -05:00
David Korth
fc69e180fa [cmake] PrecompiledHeader.cmake: Disable a debugging message when using PCH with gcc.
This ends up printing one line per file, which clutters up the output
significantly.
2019-12-16 22:32:40 -05:00
David Korth
0e1af27d94 [gtk] cinnamon: Implementation for Cinnamon desktop with the Nemo file browser.
Nemo is yet another Nautilus fork. Nemo was initially forked from
Nautilus 3.x, so we don't have to worry about GTK+ 2.x versions.

Everything's basically the same as the Caja version, except the
files are named "nemo" instead of "caja".
2019-12-15 15:48:53 -05:00
David Korth
e51803a4fe [librptexture] Use the PowerVR Native SDK (well, a subset) to decode PVRTC.
It seems that the R and B channels are backwards, so we'll need to fix
that next. Other than that, both 2bpp and 4bpp decoding seems to work.
(A lot better than my terrible attempt, at least.)

[cmake] options.cmake: Added an option for PVRTC. The code is licensed
under the MIT license, but we might as well provide an option for it
because it's third-party code instead of my own code.

TODO:
- Fix R/B channel ordering.
- PVRTC-II decoding?
- Add PVRTC decoding to KTX and DDS.
2019-12-10 22:01:21 -05:00
David Korth
2c5a15c559 [librptexture] gl_defs.h: Define all relevant GL enum values here instead of using the system GL headers.
This allows us to eliminate the OpenGL dependency, which lets us get rid
of the CMake option ENABLE_GL.

Removed all ENABLE_GL checks.
Removed #include "config.librptexture.h" where it's no longer needed.
2019-12-09 01:11:30 -05:00
David Korth
26edbe2592 [cmake] DirInstallPaths.cmake: Simplify CPU architecture handling. 2019-11-14 22:29:40 -05:00
David Korth
edc3e87c1b [cmake] platform/win32.cmake: Simplified CPU architecture detection.
When building with MinGW-w64, the manifests were being written with "x86"
even for 64-bit, which caused Windows to outright refuse to run the
program with no error message.

The check in platform.cmake checks both CMAKE_CL_64 and sizeof(void*),
so remove the one in platform/win32.cmake.

Also added untested checks for ARM/ARM64.

TODO: Verify cross-compile functionality.
2019-10-19 12:16:42 -04:00
David Korth
b5bdf59a84 [cmake] platform/msvc.cmake: Use /utf-8, which is an alias for source/execution-charset:utf-8. 2019-10-19 09:27:00 -04:00
David Korth
188f2b192c [cmake] platform/msvc.cmake: Set the source and execution character set to UTF-8. (MSVC 2015)
This fixes some build issues when the build system locale is set to
Japanese.

This bug was reported by @DankRank.
2019-10-19 09:24:25 -04:00
David Korth
c262825fb6 [cmake] options.cmake: Removed USE_INTERNAL_JPEG.
The included copy of libjpeg-turbo was removed in
commit 775a5c9048.
([libjpeg-turbo] Removed the bundled copy of libjpeg-turbo.)
2019-09-21 12:28:58 -04:00
David Korth
b69eadd1e4 [librpbase] config.librpbase.h.in: Remove ENABLE_GL.
librpbase doesn't use OpenGL at all.

[libromdata] RomDataFactory.cpp: #include "config.libromdata.h" for ENABLE_GL.
2019-09-21 12:28:58 -04:00
David Korth
255d66f5cc Use GDI+ for JPEG decoding on Windows.
JPEG decoding isn't as strictly checked as PNG decoding, and we don't
need specific JPEG writing functionality e.g. for APNGs and tEXt chunks,
so we can drop the libjpeg-turbo requirement on Windows.

This reduces the Windows distribution by around 1 MB uncompressed.
(521 KB for the 32-bit jpeg62.dll; 535 KB for the 64-bit jpeg32.dll.)

Related: Commit f548b5372d
(Removed the GDI+ PNG loader; renamed RpPng_libpng.cpp to RpPng.cpp.)

[librptexture] rp_image_backend: Allow width and height to be 0 if the
specified format is rp_image::FORMAT_NONE. This is done by
RpGdiplusBackend when constructing a backend using an existing
Gdiplus::Bitmap.
2019-09-21 12:28:58 -04:00
David Korth
3970bb1847 [cmake] gcc.cmake: ld "supports" --compress-debug-sections on NetBSD/OpenBSD, but it doesn't actually work.
Attempting to use the option results in an error at runtime:
ld: error: --compress-debug-sections: zlib is not available
2019-08-17 21:26:21 -04:00
David Korth
771e4504f5 [cmake] SplitDebugInformation> Check LDFLAG_--compress-debug-sections, not HAS_LD_COMPRESS_DEBUG_SECTIONS.
HAS_LD_COMPRESS_DEBUG_SECTIONS isn't actually being set. It was probably
set while I was testing stuff, but it got removed before committing in
commit 107224487f.
([cmake] Reworked --compress-debug-sections logic for compatibility with older systems.)
2019-08-17 21:17:04 -04:00
David Korth
d9078ff921 [cmake] gcc.cmake: Check for "-O", but use "-O1" instead.
GNU ld treats these as the same, but clang ld requires a value to be
specified.

This fixes a regression on FreeBSD from commit 107224487f.
([cmake] Reworked --compress-debug-sections logic for compatibility with older systems.)
2019-08-14 01:12:03 -04:00
David Korth
107224487f [cmake] Reworked --compress-debug-sections logic for compatibility with older systems.
Ubuntu 14.04's ld (binutils-2.24) doesn't have --compress-debug-sections,
which causes travis-ci to fail.

cmake-3.6's try_compile() attempts to build an executable by default,
which *should* test the linker flags, but that isn't working, either.
Ubuntu 14.04 has cmake-3.3, so that wouldn't help anyway.

Instead, check the output of `ld --help` for the various options.
This seems to work for the most part.

Enabled this method for Mac OS X as well.

If the --compress-debug-sections=zlib linker test fails, then we'll
fall back to the old objcopy method. SplitDebugInformation.cmake uses
the same detection method to check if objcopy supports the option,
and if it does, it uses it.
2019-08-12 23:22:59 -04:00
David Korth
5bd9b0c65e [librpbase] Use FindIconv from cmake-3.11.
Added our own copy for older CMake versions.

TextFuncs_iconv.cpp: #include </usr/include/iconv.h> on FreeBSD and
other non-Linux systems. This works around an issue where libiconv
takes over the default iconv.h if libiconv is installed *and* the
system has its own iconv(), which happens on FreeBSD 10.0 and later.

FIXME: The following TextFuncsTests are failing on FreeBSD 12.0:
- cp1252_to_utf8
- cp1252_to_utf16
- cp1252_sjis_to_utf8_fallback
- cp1252_sjis_to_utf16_fallback
- utf8_to_utf16
2019-08-10 13:22:35 -04:00
David Korth
dd45c055b4 [cmake] Use the LDFLAG -Wl,--compress-debug-sections=zlib instead of specifying --compress-debug-sections in objcopy.
FreeBSD's objcopy doesn't have --compress-debug-sections, but ld does.

On Linux, this does provide an advantage over the previous method because
ld compresses the debug sections when creating the original executable,
which results in less disk access.

Three compression options are available in GNU ld:
- zlib-gnu: Use .zdebug_* sections.
- zlib-gabi: Use .debug_* sections with the C flag.
- zlib: Same as zlib-gabi.

FreeBSD's zlib option is the same as GNU ld's zlib/zlib-gabi option,
so we'll use it on all platforms.

NOTE: FreeBSD's default toolchain is llvm/clang as of FreeBSD 10.0, so
this should apply to other systems using llvm/clang.
2019-08-10 12:47:09 -04:00
David Korth
d857f8f409 [xdg] Install rom-properties.xml into /usr/share/mime/packages/.
debian/: Added a rom-properties-xdg package. This includes postinst and
postrm files to update the system MIME database.
2019-08-04 15:50:37 -04:00
David Korth
de85a062ec Removed S2TC decoding and test images.
S2TC was originally implemented because the S3TC patents were still in
effect. The patents expired in October 2017, which was *before* the
release of v1.2 (the first version with S3TC decoding), but I didn't want
to remove it so close to release.

Pretty much no one used the S2TC version, so it was just wasting space.

Code size reduction: (64-bit Gentoo Linux, gcc-9.1.0, release build)

   text    data     bss     dec     hex filename
  17058       9       0   17067    42ab ImageDecoder_S3TC.cpp.o [before]
  13138       8       0   13146    335a ImageDecoder_S3TC.cpp.o [after]
  -3920      -1       0   -3921    -f51 Difference
2019-06-09 15:06:40 -04:00
David Korth
c0b90585f7 CMakeLists.txt, *.cmake: "INTERNAL" goes *before* the docstring in SET().
This fixes a ton of instances of the following warning, introduced in
cmake-3.14.0:

CMake Warning (dev) at cmake/libs/CheckGettext.cmake:30 (SET):
  implicitly converting 'msgfmt executable.' to 'STRING' type.
Call Stack (most recent call first):
  src/libi18n/CMakeLists.txt:9 (CHECK_GETTEXT)
This warning is for project developers.  Use -Wno-dev to suppress it.
2019-06-09 13:13:44 -04:00
David Korth
19a0394951 [gtk] mate: Initial implementation for MATE Desktop with the Caja file browser.
Caja is a fork of Nautilus 2.x, so everything's basically the same
as the GNOME extension, but with a different prefix.

Note that as of MATE 1.18.0, GTK+ 3.x is used, not 2.x. We're only
supporting GTK+ 3.x for MATE Desktop.

N.B.: Caja is a fork of Nautilus *2.x*, not *3.x*. The extension
interface doesn't seem to have changed, though.

Since the only real changes are names, the mate extension is handled
similarly to xfce3. The subdirectory has a CMakeLists file and defines
an RP_UI_GTK3_MATE macro, but it references the files in the gnome
directory.

gnome: Define RP_UI_GTK3_GNOME to distinguish between the two.

RomDataView: MATE uses the same settings as GNOME.

NOTE: We can't set up the MATE Debian configuration right now, since
Ubuntu 16.04 has a GTK+ 2.x version of MATE. I might set up a separate
"later-debian" directory with the updated files, though.

TODO:
- Both GNOME and MATE use /usr/share/thumbnailers, so the thumbnailer
  file needs to be moved to a common package.
- Caja has an "About Extension" button. Implement this.
- Check Nautilus and other file browsers?
- Make sure all relevant MIME types are added to the XDG service files.
  Caja *requires* the proper MIME types to be added, or else it won't
  thumbnail the files.
2019-06-08 17:12:06 -04:00
David Korth
6efca5165e [gnome] nautilus-extension.h was added in Nautilus 3.30.
If nautilus-extension.h is present, use it. Otherwise, use the file
from libnautilus-extension/ directly.

FindLibNautilusExtension: s/ThunarX2/libnautilus-extension/g
2019-06-08 15:17:39 -04:00
David Korth
b8af06bf52 Added Kreon drive support for Xbox discs on Linux.
This uses Kreon drive firmware commands to unlock Xbox disc
reading commands.

rpcli on Linux can now list Xbox discs directly, though the
required ioctl is blocked if not running as root.

FIXME: The Windows build is probably broken right now.
2019-02-18 02:20:55 -05:00
David Korth
11e8e14c8c [cmake] gcc.cmake: Enable build IDs.
Required for bloaty: https://github.com/google/bloaty

Ubuntu seems to have build IDs enabled by default, but Gentoo does not.
2019-02-09 03:20:03 -05:00
David Korth
22ef7f5637 [extlib] libmspack-xenia: Imported libmspack code from the Xenia emulator.
This is a stripped-down version of libmspack containing only the necessary
functionality for Xbox 360 executables.

Xenia commit: e706cf0d5413c31b7e80a50411cc88cc7c71af30
License: LGPLv2.1

config.h.in: Modified for cmake; removed unnecessary checks.

debian/copyright: Added copyright information.
cmake/options.cmake: Added an ENABLE_LIBMSPACK option. (default is ON)
2019-02-01 22:17:56 -05:00
David Korth
9e4bdc9be8 [cmake] CheckOpenGL.cmake: Fix detection on Windows; set the OpenGL preference to Legacy.
FindOpenGL.cmake doesn't set OPENGL_INCLUDE_DIR on Windows, but it does
set OPENGL_gl_LIBRARY.

For OpenGL preference: We're only using the GL headers, not the
libraries. cmake-3.11 added an option to switch between Legacy and
GLVND, and if the option isn't set, a warning is printed.
2019-01-28 20:38:23 -05:00
David Korth
59c2b4aedc Merge branch 'feature/overlay-icon-permissions'
Conflicts:
	src/libromdata/RomDataFactory.cpp

This fixes issue #164: Icon overlay for "dangerous" ROM permissions

TODO: GNOME version.
2018-12-30 16:27:13 -05:00
Cameron Cawley
aeceb4fab6 Make building with OpenGL optional. 2018-12-18 23:54:42 +00:00
David Korth
7fe888a67a Various fixes for MinGW-w64 v6.0.0.
- CMAKE_RC_COMPILE_OBJECT needs <INCLUDES>.
- N64.cpp: #include <cstring>
- ELF.cpp: TODO: 'l' printf format character.
- TextFuncs.cpp: ansi_to_utf8() has a required second parameter.
- commctrl_ts.h: Fix errors.
- secoptions_win8.h: Fix compatibility due to MinGW-w64 v6.0.0 defining
  some newer macros.
- [win32] stdafx.h: commoncontrols.h is lowercase.
2018-12-17 21:03:23 -05:00
David Korth
31731d9379 [win32] Initial RP_ShellIconOverlayIdentifier implementation.
This will be used to show a UAC shield on Nintendo 3DS ROM images (and
later Nintendo Switch ROM images) that have "dangerous" permissions set.

Currently, it's set to show on *all* files, not just the relevant ones.

[cmake] win32.cmake: Increased the SDK version to Windows Vista (0x0600)
in order to use SHGetStockIconInfo() and related definitions.

TODO:
- Add a function to RomData to check if the file has "dangerous"
  permissions set. (default will be no)
- Add a fallback for Windows XP, which does support overlay icons,
  but is missing the following:
  - UAC shield icon
  - SHGetStockIconInfo()
2018-12-16 13:31:05 -05:00
David Korth
0b6bdda96c [cmak]e CheckTinyXML2.cmake: TinyXML2 v7.0.0's CMakeLists.txt uses the same target for both DLL and static library builds.
This should fix the Mac OS X build on travis-ci.
2018-12-15 14:13:12 -05:00
David Korth
abe66f7656 [librpbase] SparseDiscReader: New protected virtual function getPhysBlockAddr().
Subclasses no longer have to implement the full readBlock() function.
Instead, they can implement getPhysBlockAddr(), which returns the
starting address of the specified physical block address.

Implemented readBlock() in SparseDiscReader. If a subclass doesn't
implement readBlock(), the default one will be used, which calls the
getPhysBlockAddr() function.

Updated all SparseDiscReader subclasses to use getPhysBlockAddr()
instead of readBlock(), *except* for GdiReader, which has to implement
its own readBlock() function because each track is stored in a separate
file.

This fixes issue #144: SparseDiscReader: Change readBlock() to
getBlockStart() or similar.

TODO: Test all affected formats before merging. 2352-byte CD images
and GDI images have been tested, but CISO, WBFS, and WUX have not.
2018-11-30 23:01:24 -05:00
David Korth
2d2c64f817 [extlib] unice68: Initial import of unice68-2.0.0.690.
This will be used to decompress Atari ST SNDH files.

Note that unice68 is GPLv3, so there's a compile-time option to
disable it.

TODO: Make it a DLL/SO instead and use dlopen().
2018-09-29 11:01:57 -04:00
David Korth
ec2a7d8c39 [cmake] platform.cmake: Set CPU_i386 vs. CPU_amd64 using CMAKE_CL_64 and CMAKE_SIZEOF_VOID_P. 2018-09-09 19:35:41 -04:00
David Korth
074b8ff57b [cmake] msvc.cmake: Check CMAKE_CL_64 to determine if it's 32-bit or 64-bit. 2018-09-09 19:33:49 -04:00
David Korth
c9f354a472 [cmake] $(arch) cleanup.
- Set CPU_i386, CPU_amd64, and CPU_ia64 as appropriate.
- These will be used to determine if MMX should be enabled or not.
2018-09-09 19:31:01 -04:00
David Korth
57f8980244 Fixed some issues caused by marking libraries as PRIVATE.
[libromdata/tests] GcnFstTest: Copy/paste error caused i18n to be
linked to GcnFstPrint (twice) instead of GcnFstTest.

[win32] Added the TinyXML2 include directory.
[libromdata] Likewise. (though it probably isn't needed...)

[cmake] CheckTinyXML2.cmake: Set TINYXML2_INCLUDE_DIR if using the
internal copy.
2018-08-26 20:29:22 -04:00
David Korth
76ccd13bb6 [minizip] Updated to v2.3.8 (plus some patches) from the MiniZip fork.
https://github.com/nmoinvaz/minizip

[extlib] CMakeLists.txt: Disabled MiniZip compression. We're currently
only using it for decompression, so there's no need to build the
compression code, which wastes time and disk space.
2018-07-23 14:51:36 -04:00
David Korth
81261614a3 [gtk] xfce3: Build a plugin for Thunar 1.8.0 (GTK+ 3.x).
All of the code is basically the same as xfce2, but the library
dependencies have changed.

- FindThunarX3.cmake: Find the GTK+ 3.x version of ThunarX.

- xfce3/CMakeLists.txt is a clone of xfce/CMakeLists.txt. It references
  all of the sources from the xfce/ directory.

- Thunar 1.8.0 doesn't change the formatting in the properties dialog,
  so RP_DFT_XFCE is kept as-is.

- #undef GTK_DISABLE_DEPRECATED in a few places because thunar-renamer.h
  uses GtkVBox, which is deprecated in GTK+ 3.x.

- doc/COMPILING.md: Added rom-properties-xfce3.

TODO: Add a Debian package once it's added to the repository.
2018-06-07 22:02:50 -04:00
David Korth
1c7be01a4a [gtk] Use Cairo for image handling with GTK+ 3.x.
Starting with GTK+ 3.10, GtkImage provides a function to set its image
from a Cairo surface. Cairo uses the same ARGB32 pixel format as
rp_image, so using a Cairo surface instead of a GdkPixbuf eliminates the
need to swap the R and B channels.

Consequently, there is no SSSE3 code for CairoImageConv, since we're
just doing a plain old memcpy().

PIMGTYPE.hpp: New header with a typedef PIMGTYPE, which is either
GdkPixbuf* or cairo_surface_t*, depending on GTK+ version. Also defines
RP_GTK_USE_CAIRO if using Cairo, and has wrapper functions for PIMGTYPE.

Updated CreateThumbnail and RomDataView to use PIMGTYPE where applicable.

TODO: CreateThumbnailPrivate::rescaleImgClass() is not currently
implemented for Cairo.
2018-06-03 13:45:17 -04:00
David Korth
7a6793922a [cmake] platform/win32.cmake: Fix the manifest processor architecture on i386.
We need to check CMAKE_CL_64, not just ${CMAKE_SYSTEM_PROCESSOR}, since
that variable indicates the host system, which is always 64-bit
regardless of the target architecture.

This fixes the 32-bit rp-config.exe. (rom-properties.dll didn't load
comctl32.dll due to the incorrect manifest, resulting in KeyManagerTab
crashing because GetModuleHandle(L"COMCTL32") returned nullptr.)
2018-06-02 23:19:03 -04:00
David Korth
cc354750e5 Clean up QT_SELECT so we no longer need it set by the caller.
cmake/options.cmake: Unset QT_SELECT initially.

Set QT_SELECT in each individual directory based on the required version.
For libunixcommon, set it, call the required program, then unset it.

This should fix all of the issues:
- Qt4: If set to 5, qmake would fail to detect Qt/X11.
- Qt5: If set to 4, the plugin path was wrong.
2018-06-02 15:40:59 -04:00
David Korth
96995202c1 Disable LTO on IFUNC files if using gcc-5.4.0 or earlier.
This caused byteswapping tests to fail, and ImageDecoderLinearTest and
ImageDecoderTest both crashed.

It seems the IFUNC resolver function *was* being called, but the returned
function pointer wasn't. I'm not sure why.

This fixes tests on Xubuntu 16.04.

TODO: Test on gcc6.
2018-06-02 14:53:48 -04:00
David Korth
bc995e249b [cmake] msvc.cmake: Handle C4024 and C4047 as errors.
C4024: 'function': different types for formal and actual parameter n
C4047: 'function': 'parameter' differs in levels of indirection from 'argument'

NOTE: /sdl doesn't do this.
2018-05-11 22:38:19 -04:00
David Korth
d2b7dddf00 [cmake] options.cmake: TODO: Tri-state ENABLE_DECRYPTION. 2018-05-06 14:33:25 -04:00
David Korth
7afea5cb73 Merge branch 'feature/gettext-win32'
Now with localization on Windows.
2018-05-02 22:45:48 -04:00
David Korth
1986e8ce9e [cmake] CheckTinyXML2.cmake: Use static libraries for Mac OS X here, too. 2018-05-02 02:05:38 -04:00
David Korth
9f20383ff8 [cmake] DirInstallsPaths.cmake: Use Linux paths for Mac OS X for now.
travis.sh: Disable split debug on Mac OS X due to lack of `objcopy`.
2018-05-02 00:52:14 -04:00
David Korth
314a8b7f81 Initial build of gettext for Win32.
The gettext libraries and executables were built on Ubuntu 18.04 using
MinGW-w64 with gcc-7.3.0.

iconv support has been disabled for the runtime, but it's still needed
for some of the build executables. For that, we're using win-iconv, which
is an iconv wrapper that uses the Windows API. [1]

In addition, several patches from the official MinGW package repository
were applied to gettext-0.19.8.1 in order to get it to build correctly
for Windows. [2]

TODO:
- Test packaging to ensure the correct DLL is packaged.
- Test bindtextdomain() to determine if it supports Unicode. If it
  doesn't, then another patch will be needed.

[1] https://github.com/win-iconv/win-iconv
[2] https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-gettext
2018-04-29 13:32:20 -04:00
David Korth
214473260c [cmake] options.cmake: BUILD_* variables are now tristate.
The default value is AUTO. If set to ON, CMake will fail if the
required packages are missing.

NOTE: OPTION() only supports BOOL. Use SET() and SET_PROPERTY() for
tristate support.
- Reference: https://cmake.org/pipermail/cmake/2016-October/064342.html

NOTE 2: libunixcommon still searches for the packages unconditionally
because it's used for rp-stub's search path.
2018-04-18 23:12:54 -04:00
David Korth
04c2ac8263 Various CMake changes from looking over mcrecover. 2018-04-15 15:15:48 -04:00
David Korth
b12dcf5214 [librpbase/tests] gtest_init.cpp: Set LC_ALL=C before running tests.
This ensures that the system locale doesn't affect printf() and cout
output.

CheckSymbolExistsOrInline.cmake: Split out of rpcli/CMakeLists.txt.
2018-04-04 20:52:13 -04:00
David Korth
1c3afce320 [libromdata] RomDataFactory: Use a templated function instead of a lambda function to construct RomData subclasses.
Based on some of the code by @DankRank in issue #119.
(Use templates instead of including 30 nearly-identical files in
RomDataFactory)

Removed CheckCXX11LambdaAsFunctionPointer.cmake, since this functionality
was only ever used in RomDataFactory.
2018-03-30 13:00:27 -04:00
David Korth
69c2091d0c [cmake] Check for C11 in addition to C99.
C11 has _Static_assert(), which is needed for ASSERT_STRUCT().
2018-02-17 21:18:08 -05:00
David Korth
2e669b0154 [cmake] msvc.cmake: Disable std::tr1 deprecation warnings.
Some MSVC 2017 update added deprecation warnings for std::tr1.
Google Test 1.8.0 still uses it, so disable the warnings for now.
2018-01-26 22:06:01 -05:00
David Korth
57a92ca74f [cmake] Moved the stack protection flag check from gcc.cmake and msvc.cmake to platform.cmake. 2018-01-15 06:37:29 -05:00
David Korth
5ae20ab40d [cmake] platform/gcc.cmake: Fix code coverage executable searches.
It was only searching for `gcov`, even though the other executables were
listed in the FOREACH() statement.
2018-01-13 02:25:16 -05:00
David Korth
02946ab837 CMakeLists.txt: Added an uninstall target.
[kde4, kde5] Disable KDE's own uninstall target.
2017-11-25 15:50:21 -05:00
David Korth
79a14dd0a3 Initial support for translations using GNU gettext.
TODO: Initialize in the DLL and/or EXE entry point.
TODO: Search the DLL directories on Windows.

Added ENABLE_NLS. (defaults to OFF on Windows for now)
2017-11-18 13:22:13 -05:00
David Korth
2070c61a72 [cmake] gcc.cmake: Use the P option when using thin archives.
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9a6cfca4f4130444cb02536a4fdf7b6e285c713e
2017-09-09 15:08:40 -04:00
David Korth
88b42e513c [cmake] gcc.cmake: Use thin archives on Linux.
This significantly reduces the size of the .a files.

References:
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a5967db9af51a84f5e181600954714a9e4c69f1f
- https://bugs.webkit.org/show_bug.cgi?id=108330
2017-09-09 14:24:10 -04:00
David Korth
c5d71f944b [cmake] msvc.cmake: Use /Gz on 32-bit i386 MSVC builds.
File sizes for the 32-bit MSVC 2017 (15.3) release build:

|      Filename      |   Before  |    After  |  Diff  |
|-------------------:|----------:|----------:|-------:|
| rom-properties.dll |   629,248 |   627,200 | -2,048 |
|          zlib1.dll |    78,848 |    78,848 |      0 |
|       libpng16.dll |   185,344 |   184,320 | -1,024 |
|         jpeg62.dll |   432,640 |   432,640 |      0 |
|       tinyxml2.dll |    73,728 |    73,728 |      0 |
|          rpcli.exe |   453,120 |   452,096 | -1,024 |
|      rp-config.exe |    17,408 |    17,408 |      0 |
|        svrplus.exe |   335,872 |   335,872 |      0 |
|          **Total** | 2,206,208 | 2,202,112 | -4,096 |
2017-09-02 13:22:48 -04:00
David Korth
979214a6fa [cmake] msvc.cmake: Disable thread-safe static initialization on MSVC 2015 and later.
Thread-safe static initialization requires Vista or later, since XP
doesn't have enough TLS slots.

NOTE: We need to make sure that we use pthread_once() for one-time init
instead of using a static initializer.
2017-09-02 11:44:29 -04:00
David Korth
b0e57af88d [cmake] FindTinyXML2.cmake: Fix copy/paste errors from GLIb2; set the imported target correctly.
NOTE: We're not linking to TinyXML2::tinyxml2 in libromdata because this
target only exists if it's found as a system library. Maybe we should
create it for the extlib version as well...
2017-08-12 18:05:34 -04:00
David Korth
45b37b1b8d Merge branch 'feature/Sega-PVR'
Good enough to merge for now, but still missing a few things:
- PVRX
- ImageDecoderTest for non-DDS images
2017-07-27 23:42:47 -04:00
David Korth
3f232dbe3a [librpbase] ImageDecoder_S3TC.cpp: Use S2TC if S3TC is disabled.
This allows the images to be decoded, but with lower quality.

Removed ENABLE_S3TC checks from all files except ImageDecoder_S3TC.cpp.
Unconditionally compile ImageDecoder_S3TC.cpp.
2017-07-22 17:26:43 -04:00
David Korth
4e3931c8e6 cmake/options.cmake: Disable LTO in non-MSVC builds by default.
Ubuntu 17.04's gcc doesn't seem to handle LTO properly for some reason.
It crashes when compiling Qt5 automoc files.

- gcc: 6.3.0-12ubuntu2
- qtbase5-dev-tools: 5.7.1+dfsg-2ubuntu4~1
2017-07-21 21:35:54 -04:00
David Korth
d76991f53a cmake/options.cmake: Added an option to disable S3TC.
S3TC's patent expires on October 2, 2017, so we should provide an option
to disable S3TC decompression.
2017-07-17 23:19:18 -04:00
David Korth
39a701f6f1 [cmake] Split GIO and GIO-UNIX library checks into their own files.
[xfce] CMakeLists.txt: Added GIO and GIO-UNIX dependencies for
rp-thumbnailer-dbus.
2017-06-17 18:25:37 -04:00
David Korth
2481c618d5 [xfce] rp-thumbnail-dbus: Converted from dbus-glib to GDBus.
Mostly based on xfce's tumbler:
https://github.com/xfce-mirror/tumbler

Instead of exporting the RpThumbnail object directly, a skeleton object
created using gdbus-codegen is exported. The server-side object has
signals that map to the D-Bus methods.

RpThumbnail no longer has signals that map directly to the D-Bus object.
Instead, it calls functions in the skeleton object, which export the
signals.

Unfortunately, the file size has increased a bit. (TODO measure file
sizes in debug and release.)

FindGLib2.cmake: We need gio-unix for the gdbus-codegen generated files.
Import it in GLib2::glib so we don't have to link to it manually in the
rp-thumbnail-dbus project. (TODO: Make this a GIO library target instead
when doing the main commit)

TODO:
- Split the RpThumbnail object from the main code.
- Move rp-thumbnail-dbus out of the xfce directory?
2017-06-03 22:23:12 -04:00
David Korth
164b96687c [cmake] msvc.cmake: Enable control flow guard if it's available.
Release build sizes: (MSVC 2017)
- rom-properties.dll: 655,360 -> 676,864 (+21,504 bytes)
- rpcli.exe: 480,768 -> 496,128 (+15,360 bytes)

It's not that much overhead, so I'll keep it enabled for all builds.
2017-05-26 22:43:24 -04:00
David Korth
d226125dda Use CMake's CONFIGURE_FILE() to automatically update manifest versions.
The manifest files are now .in files. They have replacement tags for
the `version` and `processorArchitecture` fields, which are filled in
by CMake's CONFIGURE_FILE() at configure time.

This will ensure that I don't forget to update the manifest version
numbers before release (which I did for rpcli in v1.0).

[cmake] win32.cmake: Set WIN32_MANIFEST_PROCESSOR_ARCHITECTURE to the
correct value for the manifest's `processorArchitecture` field.
2017-05-22 21:24:32 -04:00
David Korth
73704cee49 [librpbase] TextFuncs: Added a memmem() implementation.
Reference: https://opensource.apple.com/source/Libc/Libc-1044.1.2/string/FreeBSD/memmem.c

[cmake] gcc.cmake: -D_GNU_SOURCE=1 is required for memmem().
Interestingly, it seems to work fine in C++ code without this, but it
doesn't work in C code, and cmake compiles as C when checking for the
existence of memmem(). (CheckSymbolExists)
2017-05-21 22:11:13 -04:00
David Korth
8bacc2c71b [cmake] options.cmake: Disable LTO by default in clang builds.
-flto isn't working right, so disable it for now until I figure out
how to use LTO with clang correctly.
2017-05-20 01:21:47 -04:00
David Korth
4d19631829 [cmake] msvc.cmake: Use '/' style options instead of '-' style.
win32-msvc.cmake: Likewise.
2017-05-20 00:02:24 -04:00
David Korth
b8bf1ba343 [cmake] gcc.cmake: Re-add the LTO option for the gcc build.
FIXME: Running CMake with -DENABLE_LTO=ON, then -DENABLE_LTO=OFF
doesn't seem to work right... (The flags aren't removed properly.)
[Kubuntu 17.04, cmake-3.7.2]
2017-05-20 00:00:59 -04:00
David Korth
50d1af2580 [cmake] libs/: Handle disabling the internal libraries correctly.
This fixes switching between e.g. USE_INTERNAL_ZLIB=ON and
USE_INTERNAL_ZLIB=OFF.
2017-05-19 23:47:59 -04:00
David Korth
07a453bfe2 [cmake] options.cmake: Show a warning if USE_INTERNAL_JPEG is specified on Linux.
This isn't supported at the moment.
2017-05-19 00:28:42 -04:00
David Korth
8ce3c4bf1e Re-add the LTO option for MSVC for release builds.
Enabled by default.
2017-05-19 00:11:51 -04:00
David Korth
164e7bcc76 Merge branch 'merge/DankRank/svrplus'
Now used for installation on Windows instead of the two batch files.
2017-05-18 23:36:15 -04:00
David Korth
fd432ef5ac [libromdata] CMakeLists.txt: Link to TinyXML2 only if it was found.
Changed XML_FOUND to TinyXML2_FOUND to match PkgConfig's variables.
2017-05-18 22:14:40 -04:00
David Korth
7ee86b9779 [cmake] ConfigureMSVCRuntime.cmake: Added parameters.
- _crt: If "static", use the static CRT. Otherwise, use the DLL CRT.
- Other parameters for specifying the configuration. If not specified,
  applies to all configurations.

[svrplus] Only use the static CRT in the various Release builds.

TODO: We aren't using MinSizeRel or RelWithDebInfo right now.
Maybe we should...
2017-05-18 21:48:31 -04:00
David Korth
7151381b77 [svrplus] Use the static CRT.
This is needed in case the user doesn't have MSVCRT installed.
MSVCRT is still needed for the actual DLL, so svrplus will prompt the
user to download and install it.

ConfigureMSVCRuntime.cmake: CMake macro for setting the CRT.
References:
- http://stackoverflow.com/q/10113017
- http://stackoverflow.com/questions/10113017/setting-the-msvc-runtime-in-cmake
2017-05-18 21:28:48 -04:00
David Korth
7f84c707b9 [tinyxml2] CMakeLists.txt: Enable DLL builds.
Rebased CMakeLists.txt on the original TinyXML2 CMakeLists.txt,
but with lots of stuff disabled and some changes.

- Disable installation of everything except the DLL.
- Disable testing.
- Set TINYXML2_IMPORT as an interface definition when building
  as a DLL.
- Remove TINYXML2_EXPORT in the static library build, which didn't
  work anyway due to a typo.
- Added a debug postfix for debug DLLs.
- Disabled MSVC configuration that's alread yset in the platform
  configuration.
- Added other MSVC options, including split debug settings.
2017-05-14 13:35:02 -04:00
David Korth
ac4f95c401 Merge branch 'feature/EXE-manifest'
This may help with #51. (EXE: Icon thumbnailing, and LX support.)
No specific issue was filed for manifests, though.
2017-05-14 02:33:54 -04:00
David Korth
780029ea61 Fixed some compile issues with MinGW-w64 5.0.2 / gcc-7.1.0.
- win32-gcc.cmake: Enable the "secure" API functions: *_s()
  - FIXME: May not work on XP with MinGW's implementation, since it
    uses MSVCRT.DLL.
- c99-compat.msvcrt.h: Don't redefine some functions on MinGW,
  since gcc complains about missing dllimport attributes It also
  causes problems with C++ namespace imports.
2017-05-13 23:39:01 -04:00
David Korth
8462cea59d [cmake] msvc.cmake: Handle warning C4013 as an error.
C4013 occurs in C code if an undefined function is referenced. This is
technically not an error in C, but it is in C++, so I'm forcing it to
be an error in order to prevent linker errors later on.
2017-05-13 18:10:34 -04:00
David Korth
a307b1c1ba [cmake] Fix internal library name setting. (CACHE is needed for INTERNAL.) 2017-05-09 00:17:35 -04:00
David Korth
23b6b36e7a [cmake] Force the USE_INTERNAL_* variables.
This should definitely fix the TinyXML2 issue on travis-ci.
2017-05-09 00:11:36 -04:00
David Korth
a999261bb1 [cmake] Set internal library names as INTERNAL.
This should fix an issue on travis-ci where it didn't fall back to the
internal tinyxml2 if a system version wasn't installed.
2017-05-09 00:00:10 -04:00
David Korth
9cb2ca9977 [cmake] Actually commit the TinyXML2 CMake files to the repository. 2017-05-08 23:54:50 -04:00
David Korth
093da371d5 Use the system TinyXML2 on Linux if it's present.
USE_INTERNAL_XML can be used to force usage of the internal TinyXML2.

TODO: Build TinyXML2 as a DLL on Windows.
2017-05-08 23:45:20 -04:00
David Korth
5807243805 [tinyxml2] Initial import of tinyxml2-4.0.1.
TinyXML2 will be used to parse Windows manifests.

The Ubuntu 17.04 64-bit dynamic library build is around 83 KB, so
this won't add too much to the executable size.

TODO:
- Use the system TinyXML2 if available.
- Compile as a DLL? (with delay loading on Windows, maybe)
2017-05-08 22:53:18 -04:00
David Korth
c52df506cb Miscellaneous build system changes.
CMakeLists.txt: Use the top-level CMake directories.

cmake/platform/win32*.cmake: Define the Windows SDK version in
win32.cmake. Use the same version (Windows XP) regardless of
the target operating system in order to keep everything consistent.

[libpng] CMakeLists.txt: Fix MSVC debug paths for png_static.
2017-05-04 01:16:17 -04:00
David Korth
1d694fe4d7 travis-ci: Fixed builds of the GTK+ frontends.
There were several issues caused by travis-ci using cmake-3.2.2
instead of what I have locally, cmake-3.7.2:

- FIND_PACKAGE(PkgConfig) sets PKG_CONFIG_FOUND, not PkgConfig_FOUND.
- Set cache internal variables instead of parent scope. (Probably not
  needed, but it's a good idea.)
- Older PkgConfig CMake modules don't support PKG_GET_VARIABLE(), so use
  defaults for Nautilus and Thunar extension directories in that case.
- Added diagnostic messages for older PkgConfig.
- Print the cmake version in travis-ci.

Squashed commit of the bugfix/travis-ci-gtk branch.
2017-04-09 13:59:23 -04:00
David Korth
cb965db2b6 [platform] win32-msvc.cmake: Consolidate some stuff.
- Always use Windows XP (0x0501) for the SDK OS version.
- Check CMAKE_CL_64 for 64-bit MSVC.
- Use subsystem 5.02 (2003) for 64-bit and 5.01 (XP) for 32-bit.
2017-03-14 23:10:23 -04:00
David Korth
1ec21a34a9 [cmake] platform.cmake: stdint.h is required. 2017-03-14 23:06:16 -04:00
David Korth
8ede4e897f [cmake] CheckStackProtectorCompilerFlag.cmake: Fix flag checks on MinGW-w64.
MinGW-w64 only links in libssp if a function needs stack protection.
Since my toolchain doesn't have libssp enabled, this results in the
previous check passing (-fstack-protector-strong with a nearly empty
test program does nothing), but other tests end up failing because
libssp isn't available.

Use a test program with varargs, based on the C99 vsnprintf() wrapper
for older versions of MSVC.
2017-03-14 22:33:04 -04:00
David Korth
a59181c460 Fixed several issues in the MinGW-w64 build.
Using MinGW-w64 4.0.6 with gcc-6.2.0.

Note that it still doesn't compile successfully due to missing
functionality in MinGW-w64 4.0.6. I'll try it again with 5.0.1 later.
Note that MinGW-w64 5.0.1 is still missing isolation-aware functionality,
so it won't be able to handle XP theming correctly.

Summary of changes:

- cmake/platform.cmake: MinGW-w64 uses separate crt*.o files for Unicode
  instead of a separate entry point. Handle this by removing the "w" from
  the Unicode entry point and passing the "-municode" option instead.

- libpng, rpcli, win32: CMake-3.7.2 doesn't add include paths to windres.
  Add the include paths manually in order to fix .rc compilation.

- c++11-compat.h: Moved the case-insensitive string comparison macros
  from c++11-compat.msvc.h. MinGW-w64 doesn't have the wcs*() functions,
  but it does have macros for str*(), so we have to define the macros
  only if said macros don't already exist.

- [libcachemgr] CacheManager: gettimeofday() is in time.h on MSVC,
  and sys/time.h on MinGW-w64 and other platforms. sys/types.h is
  no longer needed.

libromdata:
- RpWin32.cpp: Added more conditionals to the error list in order to
  fix compilation with MinGW-w64.
- RpWin32.hpp: Use reinterpret_cast<> for the atomic memory access
  functions.

rpcli:
- time_r.h: #define _POSIX_C_SOURCE is required on MinGW-w64 in order
  to use the *_r() functions.
- properties.cpp: #include "time_r.h" earlier to prevent time.h from
  being included before _POSIX_C_SOURCE is defined.

win32:
- QITab.h: Split the QISearch() defines out of RP_ComBase.h and added
  definitions that are missing on MinGW-w64.
- Added an extra '0' in QITAB instances in order to suppress gcc's
  "missing initializer" warning. [-Wmissing-field-initializers]
- Moved all COM smart pointers to the top of the file. Disabled some of
  them in MSVC builds because they're already defined in comdefsp.h.
- rom-properties.def: Removed the comment and "LIBRARY" statement, since
  GNU ld doesn't recognize them.
2017-03-05 03:18:45 -05:00
David Korth
80c05b10cc Merge branch 'feature/multiple-image-sizes'
This partially fixes #50. (Add support for multiple image sizes.)

Multiple image sizes are now supported for external image databases, but
not for internal images. This will need to be added for EXE icons, and
possibly also Nintendo 3DS icons (48x48 and 24x24).
2017-02-28 23:11:44 -05:00
David Korth
b407d1622a [libromdata] Added an option to disable JPEG support at compile time.
This removes the dependency on libjpeg at the expense of being unable
to support JPEG downloads from external image databases.
2017-02-26 20:03:32 -05:00
David Korth
ec17510bf8 [cmake] options.cmake: Don't allow the user to set USE_INTERNAL_JPEG on non-Windows platforms. 2017-02-26 19:36:07 -05:00
David Korth
3eac1674c2 [cmake] CheckJPEG: The internal libjpeg-turbo can only be used on Windows right now. 2017-02-26 19:35:00 -05:00
David Korth
bd4ed0f043 [libjpeg-turbo] Added libjpeg-turbo 1.5.1.
The internal version of libjpeg-turbo currently only builds on Windows.
(The bundled CMakeLists.txt is Windows only.)

All example and demo executables have been disabled, and the autoconf
build system has been removed. The only target that builds now is
jpeg62.dll.
2017-02-26 19:07:19 -05:00
David Korth
db65c984e1 [libromdata] RpJpeg: Initial JPEG image loader.
Currently supports RGB, YCbCr, and grayscale images. (YCbCr is handled
using libjpeg's built-in colorspace conversion.)

NOTE: libjpeg's RGB support outputs 24-bit RGB, so we have to manually
expand it to 32-bit ARGB with an opaque alpha channel.

Tested with Nintendo DS cover art and it works:
- ASME (Super Mario 64 DS) (RGB)
- BXSE (Sonic Colors) (YCbCr)

I manually converted the images to grayscale and those worked as well.

TODO: CMYK/YCCK. (libjpeg has automatic YCCK->CMYK colorspace conversion,
but not CMYK->RGB.)

[cmake] Added libjpeg detection and options.

TODO:
- Add an internal copy of libjpeg-turbo.
- Make libjpeg support optional?
2017-02-26 17:34:27 -05:00
David Korth
8d0b9d6e79 [cmake] CheckPNG.cmake: s/zlib/PNG/ 2017-02-26 15:22:48 -05:00
David Korth
c355fe8db1 [cmake] platform.cmake: Added an option to link in setargv.obj/wsetargv.obj.
This enables automatic wildcard expansion of argv[].
Reference: https://msdn.microsoft.com/en-us/library/8bch7bkk.aspx

NOTE: This might not work on MinGW-w64, and the arguments aren't sorted.
Maybe we should implement our own _setargv...

For information on implementing _setargv:
- https://msdn.microsoft.com/en-us/library/zay8tzh6.aspx
- https://msdn.microsoft.com/en-us/library/e1w828yy.aspx
2017-02-26 13:53:24 -05:00
David Korth
1585e81835 [cmake] platform.cmake: New function SET_WINDOWS_ENTRYPOINT().
This is needed because the entry point must be specified manually when
building with MinGW with ASLR enabled.

The entry point should be wmain for Unicode console applications,
so we need to specify wmainCRTStartup instead of mainCRTStartup.

[rpcli] SET_WINDOWS_ENTRYPOINT(rpcli wmain)
2017-02-26 13:30:39 -05:00
David Korth
7d74167d1b [cmake] CheckLargeFileSupport.cmake: Change this from a macro to a function. 2017-02-25 18:12:39 -05:00
David Korth
187b68b502 [cmake] Check64BitTimeSupport.cmake: Check for 64-bit time_t.
Supported by MSVC 2005, MinGW-w64, 64-bit glibc, and 64-bit Mac OS X.

glibc is working on adding 64-bit time_t for 32-bit software.
Support for that has been added using -D_TIME_BITS=64.

32-bit Mac OS X doesn't, and won't, support 64-bit time_t.

References:
- https://lwn.net/Articles/715242/
- https://sourceware.org/glibc/wiki/Y2038ProofnessDesign
2017-02-25 18:02:57 -05:00
David Korth
2137bc6cad [cmake] options.cmake: Set BUILD_GTK2 and BUILD_GTK3 as internal variables.
This might fix the issue where travis-ci isn't building the GTK+ frontends.
2017-02-09 21:03:46 -05:00