Skip to content

Commit

Permalink
Use argtable2 if found, but fall back to argtable3 if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
cynic authored and mrannanj committed Jul 13, 2024
1 parent 45cad2c commit 2ce75f7
Show file tree
Hide file tree
Showing 19 changed files with 106 additions and 5 deletions.
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ find_package(xmp)
find_package(enet)
find_package(confuse)
find_package(argtable2)
find_package(argtable3)
find_package(PNG)
find_package(ZLIB)

Expand Down Expand Up @@ -76,7 +77,6 @@ set(COREINCS
${CONFUSE_INCLUDE_DIR}
${XMP_INCLUDE_DIR}
${ENET_INCLUDE_DIR}
${ARGTABLE2_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
)
Expand All @@ -85,11 +85,24 @@ set(CORELIBS
${CONFUSE_LIBRARY}
${XMP_LIBRARY}
${ENET_LIBRARY}
${ARGTABLE2_LIBRARY}
${PNG_LIBRARY}
${ZLIB_LIBRARY}
)

if(ARGTABLE2_FOUND)
set(COREINCS ${COREINCS} ${ARGTABLE2_INCLUDE_DIR})
add_compile_definitions(ARGTABLE2_FOUND)
elseif(ARGTABLE3_FOUND)
set(COREINCS ${COREINCS} ${ARGTABLE3_INCLUDE_DIR})
add_compile_definitions(ARGTABLE3_FOUND)
endif()

if(ARGTABLE2_FOUND)
set(CORELIBS ${CORELIBS} ${ARGTABLE2_LIBRARY})
elseif(ARGTABLE3_FOUND)
set(CORELIBS ${CORELIBS} ${ARGTABLE3_LIBRARY})
endif()

# MingW build should add mingw32 lib
if(MINGW)
set(CORELIBS mingw32 ${CORELIBS})
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Required:
* SDL2 (>=2.0.16): http://www.libsdl.org/download-2.0.php
* confuse: http://www.nongnu.org/confuse/
* Enet: http://enet.bespin.org/
* libargtable2: http://argtable.sourceforge.net/
* libargtable2 or libargtable3: http://argtable.sourceforge.net/ or http://www.argtable.org/
* libpng: http://www.libpng.org/pub/png/libpng.html
* zlib: http://www.zlib.net/ (for libpng)
* SDL2_Mixer (>=2.0.4): https://github.com/libsdl-org/SDL_mixer
Expand Down
2 changes: 0 additions & 2 deletions cmake-scripts/Findargtable2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ if(ARGTABLE2_FOUND)
set(ARGTABLE2_LIBRARIES ${ARGTABLE2_LIBRARY})
set(ARGTABLE2_INCLUDE_DIRS ${ARGTABLE2_INCLUDE_DIR})
message(STATUS "Found Argtable2: ${ARGTABLE2_LIBRARIES}")
else()
message(WARNING "Could not find Argtable2")
endif()

mark_as_advanced(ARGTABLE2_INCLUDE_DIR ARGTABLE2_LIBRARY ARGTABLE2_SEARCH_PATHS)
30 changes: 30 additions & 0 deletions cmake-scripts/Findargtable3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
set(ARGTABLE3_SEARCH_PATHS
/usr/local
/usr
/opt
)

find_path(ARGTABLE3_INCLUDE_DIR argtable3.h
HINTS
PATH_SUFFIXES include
PATHS ${ARGTABLE3_SEARCH_PATHS}
)
find_library(ARGTABLE3_LIBRARY argtable3
HINTS
PATH_SUFFIXES lib64 lib
PATHS ${ARGTABLE3_SEARCH_PATHS}
)

if(ARGTABLE3_INCLUDE_DIR AND ARGTABLE3_LIBRARY)
set(ARGTABLE3_FOUND TRUE)
endif()

if(ARGTABLE3_FOUND)
set(ARGTABLE3_LIBRARIES ${ARGTABLE3_LIBRARY})
set(ARGTABLE3_INCLUDE_DIRS ${ARGTABLE3_INCLUDE_DIR})
message(STATUS "Found Argtable3: ${ARGTABLE3_LIBRARIES}")
else()
message(WARNING "Could not find Argtable3")
endif()

mark_as_advanced(ARGTABLE3_INCLUDE_DIR ARGTABLE3_LIBRARY ARGTABLE3_SEARCH_PATHS)
4 changes: 4 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
#include "utils/msgbox.h"
#include "utils/random.h"
#include <SDL.h>
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <enet/enet.h>
#include <stdio.h>
#include <string.h>
Expand Down
4 changes: 4 additions & 0 deletions tools/afdiff/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
* @license MIT
*/

#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <string.h>

Expand Down
4 changes: 4 additions & 0 deletions tools/aftool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#include "formats/af.h"
#include "formats/error.h"
#include <SDL.h>
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <string.h>

Expand Down
4 changes: 4 additions & 0 deletions tools/altpaltool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

#include "formats/altpal.h"
#include "formats/error.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 4 additions & 0 deletions tools/bktool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
#include "formats/bk.h"
#include "formats/error.h"
#include <SDL.h>
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <string.h>

Expand Down
4 changes: 4 additions & 0 deletions tools/chrtool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include "formats/bk.h"
#include "formats/chr.h"
#include "formats/error.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 4 additions & 0 deletions tools/fonttool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include "formats/error.h"
#include "formats/fonts.h"
#include <SDL2/SDL.h>
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <string.h>

Expand Down
4 changes: 4 additions & 0 deletions tools/languagetool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

#include "formats/error.h"
#include "formats/language.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif

int main(int argc, char *argv[]) {
// commandline argument parser options
Expand Down
4 changes: 4 additions & 0 deletions tools/pictool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include "formats/bk.h"
#include "formats/error.h"
#include "formats/pic.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif

int main(int argc, char *argv[]) {
// commandline argument parser options
Expand Down
4 changes: 4 additions & 0 deletions tools/rectool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
#include "../shared/pilot.h"
#include "formats/error.h"
#include "formats/rec.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 4 additions & 0 deletions tools/scoretool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

#include "formats/error.h"
#include "formats/score.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif

const char *page_name[] = {"ONE ROUND", "BEST 2 OF 3", "BEST 3 OF 5", "BEST 4 OF 7"};

Expand Down
4 changes: 4 additions & 0 deletions tools/setuptool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
#include "../shared/pilot.h"
#include "formats/error.h"
#include "formats/setup.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 4 additions & 0 deletions tools/soundtool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include "formats/error.h"
#include "formats/sounds.h"
#include <SDL.h>
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif

typedef struct _streamer {
char *data;
Expand Down
4 changes: 4 additions & 0 deletions tools/stringparser/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

#include "formats/error.h"
#include "formats/script.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <string.h>

Expand Down
4 changes: 4 additions & 0 deletions tools/trntool/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#include "../shared/pilot.h"
#include "formats/error.h"
#include "formats/tournament.h"
#if ARGTABLE2_FOUND
#include <argtable2.h>
#elif ARGTABLE3_FOUND
#include <argtable3.h>
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down

0 comments on commit 2ce75f7

Please sign in to comment.