From 46ad0da66c04985abe76694046c51978113b7dbc Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 9 Jan 2023 03:23:12 +1100 Subject: [PATCH] Add install rule and update readme with new instructions --- CMakeLists.txt | 3 +++ README.md | 22 ++++++++++++++++++---- src/CMakeLists.txt | 11 +++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d2acd86..34b3b3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) project(tmx2gba) +# Options +option(TMX2GBA_DKP_INSTALL "Install into DEVKITPRO prefix" OFF) + # C++11 & C99 set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_STANDARD 99) diff --git a/README.md b/README.md index da0c543..e7c52ac 100644 --- a/README.md +++ b/README.md @@ -35,13 +35,27 @@ tmx2gba [-h] [-r offset] [-lyc name] [-p 0-15] <-i inpath> <-o outpath> Dependencies for building are CMake 3.x and a C++11 compliant compiler, all other dependencies are in-tree so you should be able to build with: ```bash -cmake -B build +cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo make -C build -j$(nproc --all) ``` -Optionally, to make it convenient for my dkp projects: +Optionally, you may install it to use it system wide: ```bash -sudo cp tmx2gba $DEVKITPRO/tools/bin/tmx2gba +sudo cmake --install build +``` +Which will copy the tmx2gba executable to /usr/local/bin/tmx2gba by default, +if you prefer to use /usr for some reason you may specify a prefix like so: +```bash +sudo cmake --install build --prefix /usr +``` +If you're a devkitPro user and would prefer to keep all your development tools compartmentalised +you may optionally install to the tools directory with the `TMX2GBA_DKP_INSTALL` option (OFF by default). +The build scripts will respect your `DEVKITPRO` environment variable but if not set will install to +`/opt/devkitpro/tools/bin/tmx2gba` directly, the `--prefix` argument has no effect in this mode. +```bash +cmake -B build -DCMAKE_BUILD_TYPE=Release -DTMX2GBA_DKP_INSTALL:BOOL=ON +cmake --build build +sudo cmake --install build ``` ### Todo list ### @@ -58,7 +72,7 @@ sudo cp tmx2gba $DEVKITPRO/tools/bin/tmx2gba [ultragetopt](https://github.com/kevinoid/ultragetopt) is licensed under the MIT license. ``` - Copyright (C) 2015-2022 a dinosaur + Copyright (C) 2015-2023 a dinosaur This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f36608c..ce6ecf2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,3 +9,14 @@ target_link_libraries(tmx2gba External::miniz External::rapidxml External::ultragetopt) + +if (TMX2GBA_DKP_INSTALL) + if (DEFINED ENV{DEVKITPRO}) + set(TMX2GBA_INSTALL_DESTINATION "$ENV{DEVKITPRO}/tools/bin") + else() + set(TMX2GBA_INSTALL_DESTINATION /opt/devkitpro/tools/bin) + endif() +else() + set(TMX2GBA_INSTALL_DESTINATION bin) +endif() +install(TARGETS tmx2gba RUNTIME DESTINATION "${TMX2GBA_INSTALL_DESTINATION}")