Skip to content

Commit

Permalink
Added tinyxml2 as submodule, updated build instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
spicyjpeg authored and CookiePLMonster committed Nov 7, 2021
1 parent 986bbf9 commit bc24ea8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tinyxml2"]
path = tinyxml2
url = https://github.com/leethomason/tinyxml2
37 changes: 17 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,30 @@ cmake_minimum_required(VERSION 3.21)
project(
mkpsxiso
LANGUAGES C CXX
VERSION 1.26
VERSION 1.27
DESCRIPTION "PlayStation ISO image maker"
HOMEPAGE_URL "https://github.com/Lameguy64/mkpsxiso"
)

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)

## External dependencies

# Let CMake attempt to find tinyxml2 on its own first. This avoids invoking
# pkg-config where it might not be installed, and allows usage of package
# managers like vcpkg. The path to tinyxml2 can also be specified manually by
# passing -Dtinyxml2_ROOT.
find_package(tinyxml2 CONFIG)
if(NOT EXISTS tinyxml2/tinyxml2.cpp)
message(FATAL_ERROR "The tinyxml2 directory is empty. Run 'git submodule update --init' to populate it.")
endif()

if(NOT tinyxml2_FOUND)
find_package(PkgConfig REQUIRED)
pkg_search_module(_tinyxml2 REQUIRED IMPORTED_TARGET tinyxml2)
# Build tinyxml2. I didn't bother with tinyxml2's actual CMake integration
# because it's far easier do do this. It is a single-file library after all.
add_library (tinyxml2 STATIC tinyxml2/tinyxml2.cpp)
target_include_directories(tinyxml2 PUBLIC tinyxml2)

add_library(tinyxml2::tinyxml2 ALIAS PkgConfig::_tinyxml2)
endif()
#add_subdirectory(tinyxml2)

## Executables

# This is required in order to properly link against tinyxml2 under MSVC.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_CXX_STANDARD 11)

function(_add_target name source_dir)
file(
GLOB _sources
Expand All @@ -42,16 +40,15 @@ function(_add_target name source_dir)

add_executable (${name} ${_sources})
target_compile_definitions(${name} PUBLIC VERSION="${PROJECT_VERSION}")
target_link_libraries (${name} tinyxml2::tinyxml2)
target_link_libraries (${name} tinyxml2)
endfunction()

_add_target(mkpsxiso src)
#_add_target(mkisoxml mkisoxml/src)

# Ensure the tinyxml2 DLL (if any) is installed alongside mkpsxiso.
install(
TARGETS mkpsxiso
RUNTIME_DEPENDENCIES
PRE_EXCLUDE_REGEXES ".*"
PRE_INCLUDE_REGEXES "tinyxml2"
#RUNTIME_DEPENDENCIES
#PRE_EXCLUDE_REGEXES ".*"
#PRE_INCLUDE_REGEXES "tinyxml2"
)
30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,25 @@ Older versions (probably going to be removed soon, there's no benefit to using t
## Compiling

1. Set up CMake and a compiler toolchain. Install the `cmake` and `build-essential` packages provided by your Linux distro, or one of the following kits on Windows:
* MSVC with vcpkg (do not install CMake through the Visual Studio installer, download it from [here](https://cmake.org/download) instead)
* MSys64 with the following packages: `make`, `cmake`, `mingw-w64-x86_64-gcc`, `mingw-w64-x86_64-tinyxml2`
* Cygwin64 with the following packages: `make`, `cmake`, `gcc`, `tinyxml2`
2. Install `tinyxml2` using vcpkg, your distro's package manager or build it manually from [its repo](https://github.com/leethomason/tinyxml2).
3. Run the following commands from the mkpsxiso directory:

```bash
cmake -S . -B build/ -DCMAKE_BUILD_TYPE=Release
cmake --build build/
cmake --install build/
```
* MSVC (do not install CMake through the Visual Studio installer, download it from [here](https://cmake.org/download) instead)
* MSys64 (use the "MinGW 64-bit" shell) with the following packages: `git`, `mingw-w64-x86_64-make`, `mingw-w64-x86_64-cmake`, `mingw-w64-x86_64-gcc`
* Cygwin64 with the following packages: `git`, `make`, `cmake`, `gcc`

2. Clone/download the repo, then run the following command from the mkpsxiso directory to ensure `tinyxml2` is also downloaded:

```bash
git submodule update --init
```

3. Run the following commands:

```bash
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release
cmake --build ./build
cmake --install ./build
```

**NOTE**: Add `sudo` to the install command if necessary. If you are using vcpkg, add `-DCMAKE_TOOLCHAIN_FILE` to the first command as explained [here](https://github.com/microsoft/vcpkg#using-vcpkg-with-cmake).
Add `sudo` to the install command if necessary.

The default installation path is `C:\Program Files\mkpsxiso\bin` on Windows or `/usr/local/bin` on Linux. You can change it to any directory by passing `--install-prefix` to the first command.

Expand Down
1 change: 1 addition & 0 deletions tinyxml2
Submodule tinyxml2 added at a97739

0 comments on commit bc24ea8

Please sign in to comment.