Commit Graph

437 Commits

Author SHA1 Message Date
David Korth
50d8ab0297 [zlib] Re-enable ASM optimizations for MSVC.
msvc.cmake: Specify MASM flags "/W0 /safeseh". This fixes the 32-bit masm
build when using MSBUILD with MSVC 2015. 64-bit wasn't affected, though
we're setting it for all MSVC platforms.
2016-09-18 18:08:17 -04:00
David Korth
64628991e6 Merge branch 'feature/RpImage.more-tests-and-backend'
The rp_image_backend for GDI+ hasn't been implemented yet, but it's good
enough to merge back into master.

This fixes:
- #3: Use pngcheck to verify downloaded PNG images.

This partially fixes:
- #4: rp_image subclasses with factory class

Conflicts:
	cmake/platform/gcc.cmake
	cmake/platform/msvc.cmake
	src/libromdata/CMakeLists.txt
	src/libromdata/file/IRpFile.hpp
2016-09-18 16:44:38 -04:00
David Korth
d73cd84739 Enable RTTI in the MSVC build.
We're going to use dynamic_cast<> for rp_image_backend, so RTTI needs
to be enabled. Otherwise, things will go haywire at runtime.

Also, removed the commented-out RTTI lines from gcc.cmake, since we're
not going to be reenabling it. (It was disabled for gcc builds because
KDE's thumbnail.so uses it for ThumbCreator subclasses.)
2016-09-18 13:08:31 -04:00
David Korth
be427f28ca Merge branch 'feature/decryption'
This fixes #7.

Five days of work, two encryption libraries, and a ton of custom formats,
all for a single field in the GameCube properties page. \o/

[libromdata/tests] CMakeLists.txt: Change ${GTEST_LIBRARY} to gtest.
This was done upstream, but AesCipherTest was still using the variable,
which no longer exists.

Conflicts:
	src/libromdata/GameCube.cpp
	src/libromdata/tests/CMakeLists.txt
2016-09-15 23:47:59 -04:00
David Korth
45491b4661 Simplify the Google Test build infrastructure a bit.
libromdata/tests/CMakeLists.txt:
- Link to gtest directly instead of ${GTEST_LIBRARY}.
- Removed INCLUDE_DIRECTORIES() for googletest, since it's added to
  TARGET_INCLUDE_DIRECTORIES() by googletest's CMakeLists.txt.

extlib/googletest/googletest/CMakeLists.txt:
- Uncommented gtest_hide_internal_symbols.

Removed cmake/gtest.cmake, since it doesn't have anything useful other
than INCLUDE(CTest), which is now present in the top-level CMakeLists.txt.
2016-09-14 23:18:20 -04:00
David Korth
aa41cbe210 [cmake] CheckStackProtectorCompilerFlag.cmake: Fix the ENDMACRO() argument. 2016-09-13 21:09:30 -04:00
David Korth
c87a1b2c23 [cmake] Added a check for stack smashing protection CFLAGS.
MSVC 2002 introduced the /GS flag, and it's enabled by default as of
MSVC 2005. Added a check for 2002/2003, even though those versions
definitely aren't supported.

gcc added -fstack-protector and -fstack-protector-all in gcc-4.1,
and -fstack-protector-strong in gcc-4.9. Prefer strong if it's available,
then fall back to -fstack-protector-all then -fstack-protector if
strong isn't available.
2016-09-12 22:18:11 -04:00
David Korth
77d3aa397d [libromdata] AesCipher_nettle.cpp: Added an AesCipher implementation using nettle-3.x.
FIXME: Add support for the older nettle-2.x API, since Ubuntu 14.04
still has nettle-2.7.1.

cmake/modules/FindNettle.cmake: CMake module to find Nettle.
Reference: 9fe71b1d77/cmake/FindNettle.cmake

FIXME: If ENABLE_DECRYPTION is enabled, and Nettle can't be found,
the build will fail. Maybe show a message advising the user to
set -DENABLE_DECRYPTION=0?
2016-09-11 14:55:01 -04:00
David Korth
9ea704601a [libromdata] Initial decryption functionality for Wii game discs.
crypto/AesCipher.hpp: New interface for AES ciphers.
crypto/AesCipher_CAPI.cpp: Windows CAPI implementation.

Currently supports ECB and CBC chaining modes.

GameCube: Create a WiiPartition object for the update partition.
This isn't currently used, but it will eventually be used to determine
the System Update version, if the update partition is present.

config.libromdata.h.in: Added #define ENABLE_DECRYPTION 1.

gcn_structs.h: Added Wii ticket and partition header structs.
Also added a uint34_rshift2_t typedef for values that are actually
34-bit but stored as a uint32_t, since the lower 2 bits aren't
significant.

cmake/platform/win32-*.cmake: Increase the minimum Windows version to
5.01 (Windows XP), since the AES provider was added in XP.

WiiPartition TODO:
- Share the AesCipher objects with a reference counter.
- Don't initialize AesCipher in the constructor, since we might
  only want the partition header information.

AesCipher_CAPI TODO:
- Share the HCRYPTPROV with reference counting.
2016-09-11 12:52:41 -04:00
David Korth
219e604d69 [libromdata] KeyManager: Initial encryption key manager class.
This class will be used to load encryption keys from the keys.conf file
in the user's configuration directory.

options.cmake: Added an option ENABLE_DECRYPTION. This is enabled by
default; if disabled, KeyManager won't be built, and decryption won't
be available for newer ROM and disc images that are either fully
encrypted or have encrypted sections.
2016-09-10 21:40:25 -04:00
David Korth
beb8d800c6 Added the Large File Support macros from Gens/GS II.
platform.cmake: Call CHECK_LARGE_FILE_SUPPORT(). Note that LFS is
required due to the size of Wii disc images, so if LFS isn't
available, CMake will fail with an error message.

c99-compat.msvcrt.h: #define fseeko() and ftello() to the MSVC
non-standard _fseeki64() and _ftelli64() functions. This was in
Gens/GS II's libcompat/W32U, but I'm not using W32U here.

RpFile_stdio.cpp: Use fseeko() and ftello().
2016-09-10 15:05:58 -04:00
David Korth
0b469bef44 [cmake] SplitDebugInformation.cmake: Make sure the .debug file is removed on make clean.
Other changes:
- Changed from a macro to a function.
- Handle targets with custom OUTPUT_NAME properties.
2016-09-09 22:04:38 -04:00
David Korth
001893e88b Merge branch 'feature/RpImage-rework'
This fixes issue #2.

In addition to reworking RpImage to use libpng and/or GDI+ directly,
this branch adds AppVeyor support for Windows CI. This required
fixing the build system to work with CMake's Visual Studio project
generator, which uses msbuild instead of nmake.

Conflicts:
	.travis.yml
	CMakeLists.txt
2016-09-05 22:58:52 -04:00
David Korth
168792dac9 [cmake] platform.cmake: New function SET_WINDOWS_NO_MANIFEST().
This adds "/MANIFEST:NO" to an individual target. This allows us to use
MSVC's automatic manifest generation for unit tests, while also enabling
custom manifests for the actual rom-properties.dll project.

msvc.cmake: Removed "/MANIFEST:NO" from the default CFLAGS.

[win32] CMakeLists.txt: Use SET_WINDOWS_NO_MANIFEST().
2016-09-04 02:23:44 -04:00
David Korth
9581ca37c5 [cmake] msvc.cmake: Disable /NOLOGO for RC and MASM; use uppercase switches.
Only CL explicitly requires /nologo to be lowercase. The rest of them
are supported better by CMake if they're uppercase.

CMake's MSBUILD generator was already adding /NOLOGO to RC, so adding
it again caused RC to go crazy and think that we specified "-ologo".

Also disabled /NOLOGO for MASM, just in case.
2016-09-04 02:14:45 -04:00
David Korth
0dee38d5ea Reworked Win32 subsystem settings to work correctly with msbuild.
With nmake, CMake's default /SUBSYSTEM is added after our linker flags.
With msbuild, it's added before, which caused console programs like
RpImageLoaderTest to be linked as /SUBSYSTEM:WINDOWS, which failed
due to no WinMain() function.

AppVeyor, a Windows-based CI service, mostly (only?) works with
msbuild instead of nmake, so I need to get everything working.

TODO: /MANIFEST:NO is causing problems with programs that don't have
a manifest resource (RpImageLoaderTest), and RC isn't accepting the
-nologo option for some reason.

Notable changes:
- win32-msvc.cmake: Set RP_LINKER_FLAGS_${_subsystem}_EXE. This variable
  is used by a new function to add to target-specific LINK_FLAGS.
- platform.cmake: New function SET_WINDOWS_SUBSYSTEM. This adds the
  relevant linker flags. Note that it's only used for MSVC.
- Added SET_WINDOWS_SUBSYSTEM() to all EXE and DLL projects. Note that
  the WIN32 flag is not available in ADD_LIBRARY(), so we're not setting
  it for the Win32 rom-properties.dll.
- [win32] Append to the target LINK_FLAGS instead of resetting it.
  Otherwise, we lose the /SUBSYSTEM flag.
2016-09-04 02:05:20 -04:00
David Korth
26e2fc9f70 [cmake] gtest.cmake: Actually add this to the repository. 2016-09-02 22:22:39 -04:00
David Korth
bea1c867df [cmake] SetMSVCDebugPath.cmake: Use generator expressions.
Basically the same as SplitDebugInformation.cmake.

See commit 4735dfd989.
([cmake] SplitDebugInformation.cmake: Use generator expressions.)
2016-09-02 20:33:12 -04:00
David Korth
4735dfd989 [cmake] SplitDebugInformation.cmake: Use generator expressions.
The reason why this didn't work before is because generator expressions
are unknown at configure time; they're expanded when compiling.
Hence, attempting to split pathname components didn't work.

We can use the generator expression TARGET_FILE_DIR to get the target's
directory instead of manually splitting pathname components. This should
work on CMake 2.8.x, and it gets rid of policy CMP0026 warnings on
CMake 3.0 and later.
2016-09-02 20:28:22 -04:00
David Korth
1dfe1e4a44 [cmake] platform.cmake: Use CMake's built-in visibility functions.
Removed the manual CFLAG testing from platform/gcc.cmake.

Other required changes:
- Removed CMAKE_MINIMUM_REQUIRED() from everything except the
  top-level CMakeLists.txt. This interfered with setting the
  CMake policy, since each invocation reset the policies to
  match the specified minimum version.
- Added NO_POLICY_SCOPE to the cmake/platform.cmake include
  in order to allow policy changes within platform.cmake to
  propagate to the rest of the project.
2016-09-02 20:10:49 -04:00
David Korth
0c9c8e0529 [cmake] platform/win32-gcc.cmake: Don't set an entry point for DLLs.
This is only needed when enabling ASLR on EXEs due to a bug in GNU ld.
DLLs are always compiled with relocation information, and they don't
have an entry point in the sense of an EXE entry point.
2016-08-31 23:22:10 -04:00
David Korth
f4316664bd [win32] Improved compatibility with older MinGW a bit.
Older MinGW (gcc-4.5.2) now mostly compiles rom-properties.dll, but its
w32api implementation is missing lots of stuff, including IExtractImage.

Changes:
- CheckCXX11CompilerFlag.cmake: Check for static_assert(), not nullptr.
  nullptr was added in gcc-4.6, while static_assert() was added in
  gcc-4.3.
- stdafx.h: Removed #include <comdef.h>. This header provides some
  COM utility classes that we aren't using.
- uvector.h: Added checks for gcc functionality.
- [libromdata] #include <stdlib.h> for free().
2016-08-31 21:22:02 -04:00
David Korth
83c55df677 [cmake] msvc.cmake: Restore "/manifest:no".
I removed this while testing some stuff, but forgot to readd it before
pushing commit bacab39c08.
([cmake] Set CMAKE_MODULE_LINKER_FLAGS variables.)
2016-08-29 22:42:05 -04:00
David Korth
bacab39c08 [cmake] Set CMAKE_MODULE_LINKER_FLAGS variables.
We're linking the DLLs and SOs as "MODULE", since they're always loaded
as plugins instead of directly linked into applications. Hence, we need
to set CMAKE_MODULE_LINKER_FLAGS in order to get linker flags to apply
to the modules.

This fixes an issue where "/manifest:no" wasn't being passed to MSVC's
linker, which caused a conflict when adding an isolation-aware manifest
file in order to properly support theming on Windows XP: (MSVC 2010)

CVTRES : fatal error CVT1100: duplicate resource.  type:MANIFEST, name:2, language:0x0409
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
LINK Pass 1 failed. with 1105
2016-08-29 22:31:39 -04:00
David Korth
2f3f18e1e4 [cmake] x86_64-w64-mingw32.cmake: New toolchain file for 64-bit MinGW-w64.
RP_ComBase.hpp: MinGW-w64 does actually provide overloads for the atomic
functions, but only if _WIN32_WINNT >= 0x0502, which is set in the 64-bit
version but not the 32-bit version. Disable our overloads for the 32-bit
build, since we're still supporting 32-bit XP (0x0501).

Added file header comments to RP_ComBase.hpp and RP_ClassFactory.hpp.
2016-08-23 20:36:37 -04:00
David Korth
a80b69e738 [cmake] toolchain/i686-w64-mingw32.cmake: CMake toolchain file for i686-w64-mingw32. 2016-08-04 00:54:57 -04:00
David Korth
3cf2e46483 [cmake] Set WINVER, _WIN32_WINNT, and _WIN32_IE.
Define UNICODE and _UNICODE in all Windows builds, since we're
only supporting Unicode Windows.
2016-07-27 22:21:26 -04:00
David Korth
dfec31ff50 [cmake] gcc.cmake: Don't disable RTTI.
KDE's kio_thumbnail.so uses RTTI for ThumbCreator, since that isn't
a QObject. Disabling RTTI completely breaks thumbnailing.

I'm leaving RTTI disabled in the MSVC build for now, since the Windows
equivalent uses COM, not RTTI.
2016-07-23 15:36:54 -04:00
David Korth
4274f50c3d [libromdata] Added preliminary Nintendo GameCube and Wii disc image support.
The disc header is read, and some basic information is displayed.

The company code is decoded and looked up using a hard-coded list
of company codes from GameTDB:
- http://www.gametdb.com/Wii
- http://www.gametdb.com/Wii/Downloads

gcc.cmake: Added -Wno-multichar, since I'm using multi-character
constants in NintendoPublishers::ms_thirdPartyList[].
2016-07-22 00:15:43 -04:00
David Korth
138ee725d5 Fixed several issues in the Windows build.
- options.cmake, src/CMakeLists.txt: Only attempt to build the
  KDE4 and KDE5 plugins on Unix/Linux systems.

- TextFuncs:
  - Fixed various wchar_t/char16_t issues.
  - Implemented cp1252 fallback for Windows in cp1252_sjis_to_rp_string().
    The W32U_mbs_to_UTF16() function now has a dwFlags parameter, which
    is used by cp1252_sjis_to_rp_string() to ensure it fails if the string
    contains invalid Shift-JIS sequences. (MB_ERR_INVALID_CHARS)
  - Renamed 'n' variables to 'len'.
2016-07-21 21:40:19 -04:00
David Korth
3551eacc42 [cmake] Fixed various platform definitions for Windows.
msvc.cmake: s/GENS_/RP_/g

win32-gcc.cmake: Use the entry point code from mcrecover, since we
don't have CheckSystemX8632 in rom-properties.
2016-07-21 21:31:18 -04:00
David Korth
4c5122d7de Added preliminary KDE5 support.
Split RomPropertiesDialogPluginFactory into separate files. Note that
separate files are needed for KDE4 and KDE5 due to changes in automoc.
automoc4 complains if it has an #include for .moc, whereas automoc5
doesn't recognize that K_PLUGIN_FACTORY() has a Q_OBJECT macro, so it
fails to link due to undefined references to a vtable.

cmake/options.cmake: Added BUILD_KDE4 and BUILD_KDE5 options.
Both default to ON, but if the dependencies are missing, then their
respective plugins won't be built.
2016-07-20 22:53:31 -04:00
David Korth
d28469d3b4 SplitDebugInformation.cmake: Fix the GNU debug link parameter.
KDE4_ADD_PLUGIN() builds the library in build/lib/ instead of
build/src/kde/, so objcopy couldn't find the .debug file.

Note that objcopy only embeds the filename portion, not the full path,
so this won't cause any problems when debugging.
2016-07-20 22:32:15 -04:00
David Korth
8829aab9c6 Install debug files if INSTALL_DEBUG is specified.
Use GET_TARGET_PROPERTY() instead of GET_PROPERTY().

Various other adjustments to improve debug file installation.
2016-07-20 02:27:03 -04:00
David Korth
734bd7de97 SplitDebugInformation.cmake: Set a target property containing the debug filename. 2016-07-20 02:19:29 -04:00
David Korth
f351549a94 Enable split debug symbols.
Minor change in SplitDebugInformation to handle CMake linking the
shared library in build/lib/ instead of build/src/kde/.

Added options for SPLIT_DEBUG and INSTALL_DEBUG, though INSTALL_DEBUG
isn't currently used.
2016-07-20 02:16:38 -04:00
David Korth
5b8fb8e945 Added CMake macros and C++ 2011 compatibility files from Gens/GS.
Some stuff was stripped out, including support for ANSI Windows.
The minimum version I'm officially going to support once I add
Windows support is XP, though 2000 might "just work".
2016-07-19 23:47:51 -04:00