libfxlink, fxlink: install rules for MinGW build [Windows]

This commit is contained in:
Lephenixnoir 2024-08-27 11:21:25 +02:00
parent 9de441d0f4
commit efcd6ec241
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
4 changed files with 68 additions and 35 deletions

View file

@ -108,25 +108,35 @@ endif()
# Install rules # Install rules
# fxsdk set(SYSROOT "")
install(PROGRAMS "${BIN}/fxsdk.sh" TYPE BIN RENAME fxsdk) if(WIN32)
install(DIRECTORY fxsdk/assets DESTINATION share/fxsdk) set(SYSROOT "x86_64-w64-mingw32/")
install(DIRECTORY fxsdk/scripts DESTINATION share/fxsdk USE_SOURCE_PERMISSIONS)
install(DIRECTORY fxsdk/cmake/ DESTINATION lib/cmake/fxsdk)
if(NOT WIN32)
install(TARGETS fxsdk-gdb-bridge)
endif() endif()
# fxgxa, fxg1a
install(TARGETS fxgxa) if(NOT WIN32)
install(FILES "${BIN}/fxg1a" TYPE BIN) # fxsdk
# fxconv install(PROGRAMS "${BIN}/fxsdk.sh" TYPE BIN RENAME fxsdk)
install(PROGRAMS fxconv/fxconv-main.py TYPE BIN RENAME fxconv) install(DIRECTORY fxsdk/assets DESTINATION share/fxsdk)
install(FILES fxconv/fxconv.py TYPE BIN) install(DIRECTORY fxsdk/scripts DESTINATION share/fxsdk USE_SOURCE_PERMISSIONS)
install(DIRECTORY fxsdk/cmake/ DESTINATION lib/cmake/fxsdk)
install(TARGETS fxsdk-gdb-bridge)
# fxgxa, fxg1a
install(TARGETS fxgxa)
install(FILES "${BIN}/fxg1a" TYPE BIN)
# fxconv
install(PROGRAMS fxconv/fxconv-main.py TYPE BIN RENAME fxconv)
install(FILES fxconv/fxconv.py TYPE BIN)
# fxlink
install(TARGETS fxlink)
else()
# fxlink
install(TARGETS fxlink DESTINATION "${SYSROOT}bin")
endif()
# libfxlink # libfxlink
install(FILES "${BIN}/include/fxlink/config.h" DESTINATION include/fxlink/) install(FILES "${BIN}/include/fxlink/config.h"
install(DIRECTORY libfxlink/include/ DESTINATION include DESTINATION "${SYSROOT}include/fxlink/")
install(DIRECTORY libfxlink/include/ DESTINATION "${SYSROOT}include"
FILES_MATCHING PATTERN "*.h") FILES_MATCHING PATTERN "*.h")
install(DIRECTORY libfxlink/cmake/ DESTINATION lib/cmake) install(DIRECTORY libfxlink/cmake/ DESTINATION "${SYSROOT}lib/cmake")
install(TARGETS libfxlink DESTINATION lib) install(TARGETS libfxlink DESTINATION "${SYSROOT}lib")
# fxlink
install(TARGETS fxlink)

View file

@ -184,9 +184,9 @@ Install the cross-compiler and cross-libraries from AUR.
mingw-w64-ncurses mingw-w64-ncurses
``` ```
Configure and build. Configure and build. Install to get libfxlink.
```bash ```bash
% x86_64-w64-mingw32-cmake -B build-win64 -DFXLINK_DISABLE_UDISKS2=1 -DFXLINK_DISABLE_POLL=1 % x86_64-w64-mingw32-cmake -B build-win64 -DCMAKE_INSTALL_PREFIX="$HOME/.local" -DFXLINK_DISABLE_UDISKS2=1 -DFXLINK_DISABLE_POLL=1
% make -C build-win64 % make -C build-win64 install
``` ```

View file

@ -1,23 +1,38 @@
# Locate the library file and includes # Locate the library file and includes
if(WIN32)
set(SYSROOT "x86_64-w64-mingw32/")
else()
set(SYSROOT)
endif()
find_library( find_library(
LIBFXLINK_PATH "fxlink" LIBFXLINK_PATH "fxlink" "libfxlink.a"
HINTS "$ENV{HOME}/.local/lib" "$ENV{FXSDK_PATH}/lib" HINTS "$ENV{HOME}/.local/${SYSROOT}lib" "$ENV{FXSDK_PATH}/${SYSROOT}lib"
) )
if(LIBFXLINK_PATH STREQUAL "LIBFXLINK_PATH-NOTFOUND") if(LIBFXLINK_PATH STREQUAL "LIBFXLINK_PATH-NOTFOUND")
message(SEND_ERROR # Try the paths directly
"Could not find libfxlink.a!\n" set(P1 "$ENV{HOME}/.local/${SYSROOT}lib/libfxlink.a")
"You can specify the install path with the environment variable " set(P2 "$ENV{FXSDK_PATH}/${SYSROOT}lib/libfxlink.a")
"FXSDK_PATH, such as FXSDK_PATH=$HOME/.local") if(EXISTS "${P1}")
else() set(LIBFXLINK_PATH "${P1}")
get_filename_component(LIBFXLINK_PATH "${LIBFXLINK_PATH}/../.." ABSOLUTE) elseif(DEFINED "$ENV{FXSDK_PATH}" AND EXISTS "${P2}")
set(LIBFXLINK_LIB "${LIBFXLINK_PATH}/lib/libfxlink.a") set(LIBFXLINK_PATH "${P2}")
set(LIBFXLINK_INCLUDE "${LIBFXLINK_PATH}/include") else()
message(FATAL_ERROR
message("(libfxlink) Found libfxlink at: ${LIBFXLINK_LIB}") "Could not find libfxlink.a!\n"
message("(libfxlink) Will take includes from: ${LIBFXLINK_INCLUDE}") "You can specify the install path with the environment variable "
"FXSDK_PATH, such as FXSDK_PATH=$HOME/.local")
endif()
endif() endif()
get_filename_component(LIBFXLINK_PATH "${LIBFXLINK_PATH}/../.." ABSOLUTE)
set(LIBFXLINK_LIB "${LIBFXLINK_PATH}/lib/libfxlink.a")
set(LIBFXLINK_INCLUDE "${LIBFXLINK_PATH}/include")
message("(libfxlink) Found libfxlink at: ${LIBFXLINK_LIB}")
message("(libfxlink) Will take includes from: ${LIBFXLINK_INCLUDE}")
# Find library version # Find library version
if(NOT EXISTS "${LIBFXLINK_INCLUDE}/fxlink/config.h") if(NOT EXISTS "${LIBFXLINK_INCLUDE}/fxlink/config.h")

View file

@ -17,6 +17,14 @@
# include <poll.h> # include <poll.h>
#endif #endif
#ifdef min
# undef min
#endif
#ifdef max
# undef max
#endif
static inline int min(int x, int y) static inline int min(int x, int y)
{ {
return (x < y) ? x : y; return (x < y) ? x : y;