Commit Graph

437 Commits

Author SHA1 Message Date
David Korth
e405aed196 [kde] Enable KF6 builds.
With the previous minor changes, the KF6 build seems to be working
exactly like the KF5 build in KDE Neon.
2023-08-04 22:41:57 -04:00
David Korth
16554a91aa Fix some issues causing XFCE to be incorrectly enabled if GTK2 is missing.
BUILD_XFCE is an option; BUILD_GTK2 is not.

We should probably get rid of BUILD_GTK2 entirely, since I'm not planning
on adding support for GNOME 2 Nautilus anytime soon.

Also, don't attempt to build rom-properties-glib if none of the GTK UI
frontends are being built.

Fixes CMake issues when building on KDE Neon. (KF6 testing)
2023-08-04 21:54:03 -04:00
David Korth
afbf5fcf9b [cmake] msvc.cmake: Make C4477 an error.
C4477: 'function' : format string 'string' requires an argument of type
'type', but variadic argument number has type 'type'

Roughly equivalent to gcc's -Werror=format-security.
2023-08-01 18:07:32 -04:00
David Korth
9c1db18574 Remove half-hearted support for Windows versions older than XP.
Windows 2000 support only partially worked in rp-config. The actual
shell extension component didn't work.

Support for ANSI Windows was mostly just compile-tested, and it was
becoming a burden to support something almost no one will use.

Removed most `#ifdef UNICODE` and `#ifdef _UNICODE` branches in
favor of using the Unicode path exclusively.

Removed oldwincompat, which was an attempt to get things working
properly on Windows 9x and 2000 with the MSVC 2010 runtime.
rom-properties doesn't compile with MSVC 2010 anymore, so this
probably wasn't very useful anyways.

Consolidated tstring macros in tcharx.h.

Removed GUID_fns.c since it was only useful in ANSI builds.
2023-07-31 21:32:47 -04:00
David Korth
8923ae45c3 [cmake] options.cmake: Disable ENABLE_NLS if compiling with MSVC for non-i386/amd64 CPUs.
Leaving it enabled for MinGW-w64 for now because an MSYS environment
might have gettext available for other architectures.
2023-07-28 19:11:17 -04:00
David Korth
648c9d8915 [cmake] msvc.cmake: Consolidate "/guard:cf"; clean up some other checks.
The "/guard:cf" linker check was using the wrong variable, so it didn't
work correctly. Handle it in the compiler flag check instead.

Simplify the checks for "/CETCOMPAT".

Use two underscores in the "/Zc:throwingNew" check for consistency with
the other checks.

Only disable thread-safe statics on i386 for Windows XP compatibility.
We're supporting a minimum of Windows Vista for amd64, and for ARM CPUs,
the minimum is Windows 10.
2023-07-28 18:40:11 -04:00
David Korth
2fceae40f6 [cmake] platform.cmake: Fix UNSET()s of UNICODE_FLAG, ENTRY_POINT_FLAG, and SETARGV_FLAG. 2023-07-22 01:39:05 -04:00
David Korth
69b7eabbd7 [cmake] CPUInstructionSetFlags.cmake: Also check for "cortex" for ARM with non-MSVC compilers.
zlib-ng does this too.
2023-07-16 19:58:48 -04:00
David Korth
179ffd34e9 [cmake] CPUInstructionSetFlags.cmake: MSVC might have "ARMV7" for ARM.
zlib-ng checks for this, so we should, too.
2023-07-16 19:57:05 -04:00
David Korth
7d83cd50d2 [scripts] package.cmd: Add ARM, ARM64, and ARM64EC.
ARM and ARM64 require MSVC 2019.
ARM64EC requires MSVC 2019.

[cmake] Add toolchain files for ARM and ARM64 on MSVC 2019 and 2022.
(ARM64EC uses the ARM64 toolchain.)
2023-07-16 18:28:21 -04:00
David Korth
9c583ce628 [cmake] CheckGettext.cmake: ${arch} -> ${TARGET_CPU_ARCH}
The previous commit broke this.

Also, always use i386 executables regardless of target architecture.
Current Windows builds for non-x86 systems have i386 emulation.

Older non-x86 Windows builds, e.g. PowerPC and Alpha, will probably
not be supported anytime soon due to lack of other essential Windows
functionality.
2023-07-16 13:51:34 -04:00
David Korth
9c9dd100c4 Add some more ARM64EC checks and print the target CPU architecture in the summary.
ARM64EC is always checked before ARM64 (in case both are defined for
some reason) and AMD64 (because MSVC defines _M_AMD64 on ARM64EC builds).

CPUInstructionSetFlags.cmake: Set both CPU_arm64 and CPU_arm64ec.
TODO: Does the Win32 manifest processor architecture change for ARM64EC?

DirInstallPaths.cmake: Set TARGET_CPU_ARCH. This is now used by the
summary at the end of the root CMakeLists.txt.

i18n.c, DelayLoadHelper.c: Add ARM64EC.

CMakeLists.txt: Print ${TARGET_CPU_ARCH}.
2023-07-16 13:47:45 -04:00
David Korth
4a223eadf8 [kf5,kf6] Fix metadata extraction on KF5 (and presumably KF6).
v2.2 added JSON plugin metadata to the forwarder plugins. Unfortunately,
KFileMetaData uses a completely different format than other KDE plugins,
which broke metadata extraction.

This was broken in v2.2.
2023-07-15 15:39:39 -04:00
David Korth
19ebf20e9b [cmake,librpcpu] Handle ARM64EC as ARM64.
MSVC, in its infinite wisdom, defines _M_AMD64 and _M_ARM64EC when
compiling for ARM64EC (which is "emulation-compatible" ARM64), so
we have to check for _M_ARM64EC and handle it as ARM64, not AMD64.
2023-07-14 20:10:09 -04:00
David Korth
fab48c546b Allow getpid() in coverage builds.
gcov uses getpid() in gcov_open() if GCOV_LOCKED is defined when
compiling gcc.

I'm not sure why this didn't cause any problems before...

[cmake] options.cmake: Define -DGCOV if building with coverage enabled.
This is used to determine if getpid() should be added to syscall
whitelists, assuming it hasn't been added already for other reasons.
2023-07-09 18:26:58 -04:00
David Korth
551cccf218 [svrplus] Make (most) strings localizable using Win32 string tables.
svrplus is Windows only, so instead of gettext, we can use
string tables in resource files.

NOTE: Due to differences between MSVC's rc.exe and binutils's windres,
strings in the string table must be NULL-terminated.

- rc.exe ignores the explicit NULL-termination, but has an option "/n"
  that automatically adds NULL terminators to strings.

- windres.exe doesn't have an equivalent to "/n", but it *does* allow
  adding '\0' to strings to NULL-terminate them.

Updated msvc.cmake to add "/n" to CMAKE_RC_FLAGS.

NOTE: The '\0's in VS_VERSION_INFO doesn't actually do anything in the
resulting resource section with either rc.exe or windres.exe, so get
rid of them. I think this was mentioned on The Old New Thing before.

Renamed resource.rc to res-en_US.rc and added en_US identifiers.

Compiled executable size doesn't change much.

MSVC 2019, 32-bit release build: (both LTO and no-LTO are identical)

svrplus.exe: 114176 -> 114176 (no change)

   text    data     bss     dec     hex filename
 109644    2048       0  111692   1b44c svrplus.exe [before]
 110650    2048       0  112698   1b83a svrplus.exe [after]
  +1006       0       0   +1006    +3ee Difference
2023-07-08 15:31:14 -04:00
David Korth
3dc11589f6 Fix various issues when compiling with MSVC for ARM CPUs.
- /CETCOMPAT is i386/amd64 only.

- Explicitly link to certain Win32 SDK libraries that are implicitly
  linked on i386/amd64, but aren't on ARM.
2023-07-08 12:14:15 -04:00
David Korth
bab1772d49 Don't allow enabling LTO at all if not using at least gcc-6.1.
The gcc-5 workaround stopped working properly due to some recent change.
I can't be bothered to figure out what broke it, and gcc-5 is rather old.

Just don't allow enabling LTO at all.

Removed the GCC_5xx_LTO_ISSUES workarounds in all CMakeLists files.

Reworked the -lgcc workaround to check the compiler version instead
of GCC_5xx_LTO_ISSUES.
2023-07-01 16:25:15 -04:00
David Korth
dd87260759 [libpng] Update: v1.6.39 -> v1.6.40 2023-06-26 18:01:52 -04:00
David Korth
4b4ee6236e Very preliminary support for RISC-V.
Untested. Merely adds definitions for paths and cpu_dispatch.h.
2023-06-24 18:58:07 -04:00
David Korth
089d692cc0 [zstd] Update: 1.5.4 -> 1.5.5
CheckZSTD.cmake: Update the version number here, too.
2023-04-23 11:08:39 -04:00
David Korth
27cb626964 [cmake] Handle "powerpc" and "ppc64le".
Not likely to be encountered, but eh...
2023-03-10 18:12:31 -05:00
David Korth
e3f9bd12d3 [cmake] msvc.cmake: Add /MP for multi-processor compilation. 2023-03-07 21:54:07 -05:00
David Korth
6c1021aa0a [cmake] gcc.cmake: Add coverage flags to the linker flags.
This lets us remove "-lgcov", since gcc will automatically add the
coverage library when linking with coverage.

NOTE: Remember to set LD_LIBRARY_PATH when testing code coverage.
Otherwise, the system-wide libromdata.so.2 will be tested, and
that won't have coverage instrumentation.
2023-02-11 10:19:54 -05:00
David Korth
61e57cbf73 Revert "[cmake] platform/gcc.cmake: Specify the gcov library as "gcov", not "-lgcov"."
Turns out CMake was *not* doing the right thing for us, and it was
failing to find the gcov target.

This reverts commit 6cfcf08f61.
2023-02-11 10:08:50 -05:00
David Korth
e7867b7d21 [cmake] options.cmake: Add an option to disable installation of documentation.
Some distributions install documentation using distro-specific build
scripts, so add an option to allow our documentation install to be
disabled.

Specify -DINSTALL_DOC=OFF on the CMake command line.
2023-02-10 18:49:46 -05:00
David Korth
019a0470de Fix some build issues on macOS.
- Split debug symbols doesn't work properly due to an issue with `strip`:
  error: symbols referenced by indirect symbol table entries that can't be stripped in: [library]

- Add "arm64" for M1/M2 Macs.

- zstd: "-fdeclspec" is needed for Clang due to use of __declspec() even
  on non-MS compilers or OSes. Note that we have to check for both
  "Clang" and "AppleClang", since Apple uses its own customized version
  of LLVM/clang.

- msvc.cmake: Make sure "Clang" is quoted when STREQUAL is used.
2023-02-03 19:46:59 -05:00
David Korth
eeebb80f93 [gtk] LibNautilusExtension for GTK4 installs its pkgconfig file as libnautilus-extension-4.pc.
Need to explicitly check for v4. Otherwise, the v3 check will fail,
and it'll just use defaults.

[cmake] FindLibNautilusExtension4.cmake: Add a v4 check file.
2022-10-03 01:07:29 -04:00
David Korth
3ee3388996 Enable GTK4 builds.
COMPILING.md: Added packages required for GTK4 (GNOME 43).
2022-10-01 21:08:37 -04:00
David Korth
f55617c5da Move RegKey from libwin32common to libwin32ui.
RegKey is only used by win32/ (Win32 UI frontend), so it doesn't need to
be in libwin32common, which results in it getting exported by
romdata-2.dll.

NOTE: In theory, we can remove the HINSTANCE parameter from
RegisterComObject() now, since RegKey is always statically-linked into
rom-properties.dll, but we're better off keeping it there.

[doc/abi] RegKey has been removed from the Windows version.
2022-09-28 19:06:39 -04:00
David Korth
b68e576275 [cmake] FindGTKx.cmake: Remove -pthread from GTKx_DEFINITIONS.
This sometimes causes -D-pthread to be added, resulting in build failures.

librpthreads depends on pthreads on Linux, so removing -pthread from
FindGTKx.cmake shouldn't cause any problems.
2022-09-17 16:33:19 -04:00
David Korth
cac47ba6ed [cmake] FindGTK4.cmake: GTK4 version of CMake's FindGTK2.cmake.
No `gdk` target since libgdk was merged into libgtk.

Added libgraphene-1.0, a dependency of libgtk-4.

Removed FindPango.cmake since it's no longer needed.

[gtk4] CMakeLists.txt: Use the new GTK4 targets and get rid of the
now-unnecessary FIND_PACKAGE() calls.
2022-09-17 13:32:48 -04:00
David Korth
1d5e92bf1f [cmake] FindGTK3.cmake: s/_gtk2_arch_dir/_gtk3_arch_dir/ 2022-09-17 13:32:48 -04:00
David Korth
5430fef250 [cmake] FindGTK3.cmake: Remove even *more* _append_version remnants. 2022-09-17 13:32:48 -04:00
David Korth
646b5d326e [cmake] FindGTK3.cmake: Remove some more _append_version remnants. 2022-09-17 13:32:48 -04:00
David Korth
df707c8061 [cmake] FindGTK3.cmake: Remove some debugging code. 2022-09-17 13:32:48 -04:00
David Korth
95dafeed24 [cmake] FindGTK3.cmake: Fix _GTK3_FIND_LIBRARY() call for libsigc++. 2022-09-17 13:32:48 -04:00
David Korth
fe5b201dbd [cmake] FindGTK3: glibmm/gtkmm versions should be 2.4, not 3.0. 2022-09-17 13:32:48 -04:00
David Korth
a9ad63691e [cmake] FindGTK3.cmake: It's a modified version of FindGTK2.cmake.
Search/replace error...
2022-09-17 13:32:48 -04:00
David Korth
47e3eae558 [cmake] FindGTK3.cmake: GTK3 version of CMake's FindGTK2.cmake.
_GTK3_FIND_LIBRARY(): Remove _append_version, since GTK's versioning
has stabilized. Instead, append the version number to the library name.
This prevents mismatched version numbers betwen various GTK versions.

[gtk3] CMakeLists.txt: Use the new GTK3 targets and get rid of the
now-unnecessary FIND_PACKAGE() calls.
2022-09-17 13:32:48 -04:00
David Korth
ecd93c837b Fix underlinking in the GTK UI frontends.
Add the following linker options:
- --no-undefined
- --no-allow-shlib-undefined

GTK UI frontends: Link to Pango, GDK, and other libraries directly if
we're using symbols from those libraries.

NOTE: CMake's FindGTK2 seems to do this already, but we'll add the extra
linking ourselves just in case.

This fixes errors similar to the following after adding the
linker options:

/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld:
	src/gtk/gtk3/CMakeFiles/rom-properties-gtk3.dir/__/config/CacheTab.cpp.o:
	undefined reference to symbol 'gdk_window_set_cursor'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld:
	/usr/lib64/libgdk-3.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
2022-09-17 13:32:45 -04:00
David Korth
18257fd2f5 [cmake] gcc.cmake: Reorder DT_RELR detection to show the status message before checking ld. 2022-08-06 02:06:10 -04:00
David Korth
7afa618c3b [cmake] gcc.cmake: No need to set SHARED and MODULE flags here. 2022-08-05 00:42:43 -04:00
David Korth
d732fbc010 [cmake] platform/gcc.cmake: Initial support for detecting DT_RELR.
Currently only supported if using glibc-2.36 and binutils-2.38.

TODO:
- Detect more systems with DT_RELR.
- Handle cross-compiling better?
2022-08-05 00:40:45 -04:00
David Korth
72ed5fcf80 [xdg] Add an AppStream metainfo XML file.
NOTE: `appstream-util verify` requires the XML file to have the correct
name in the source tree, so we can't simply have it as "metainfo.xml"
and rename on installation.

Other changes:

- rp-config.desktop: Rename on installation to:
  com.gerbilsoft.rom-properties.rp-config.desktop

- DIR_INSTALL_MIME -> DIR_INSTALL_XDG_MIME; don't set it on Windows
  or Linux.

- [xdg] CMakeLists.txt: Install based on the presence of the
  DIR_INSTALL_XDG_* variables instead of the OS.
2022-07-30 12:42:15 -04:00
David Korth
dc4666b672 [cmake] msvc.cmake: Don't set /Zc:externC or /Zc:noexceptTypes on clang-cl.
clang-cl prints a warning, not an error, for these, so it doesn't get
detected by CHECK_CXX_COMPILER_FLAG():

  clang-cl : warning : argument unused during compilation: '/Zc:externC' [-Wunused-command-line-argument]
  clang-cl : warning : argument unused during compilation: '/Zc:noexceptTypes' [-Wunused-command-line-argument]
2022-07-16 15:21:40 -04:00
Egor
7beab8c176 [cmake] FindThunarX3.cmake: s/X2/X3/g
This fixes an error that occurs on CMake <3.4:

CMake Warning at cmake/libs/FindThunarX3.cmake:28 (MESSAGE):
  ThunarX3_EXTENSIONS_DIR is not set; using defaults.
Call Stack (most recent call first):
  src/gtk/gtk3/CMakeLists.txt:49 (FIND_PACKAGE)

CMake Error at src/gtk/gtk3/CMakeLists.txt:213 (INSTALL):
  install FILES given no DESTINATION!
2022-07-14 21:23:03 +03:00
David Korth
124eb941a8 [cmake] msvc.cmake: Fix duplicate "/guard:cf" check.
It's already checked once for CFLAGS, so use the same variable name to
get the cached value instead of having to recheck it.
2022-07-12 18:24:28 -04:00
David Korth
9352044ac6 [cmake] msvc.cmake: -"and" 2022-07-12 18:07:45 -04:00
David Korth
cb3b70ea47 [cmake] DirInstallPaths.cmake: Use ${PACKAGE_NAME} instead of "rom-properties" everywhere. 2022-07-12 18:04:15 -04:00
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