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
set(SYSROOT "")
if(WIN32)
set(SYSROOT "x86_64-w64-mingw32/")
endif()
if(NOT WIN32)
# fxsdk # fxsdk
install(PROGRAMS "${BIN}/fxsdk.sh" TYPE BIN RENAME fxsdk) install(PROGRAMS "${BIN}/fxsdk.sh" TYPE BIN RENAME fxsdk)
install(DIRECTORY fxsdk/assets DESTINATION share/fxsdk) install(DIRECTORY fxsdk/assets DESTINATION share/fxsdk)
install(DIRECTORY fxsdk/scripts DESTINATION share/fxsdk USE_SOURCE_PERMISSIONS) install(DIRECTORY fxsdk/scripts DESTINATION share/fxsdk USE_SOURCE_PERMISSIONS)
install(DIRECTORY fxsdk/cmake/ DESTINATION lib/cmake/fxsdk) install(DIRECTORY fxsdk/cmake/ DESTINATION lib/cmake/fxsdk)
if(NOT WIN32)
install(TARGETS fxsdk-gdb-bridge) install(TARGETS fxsdk-gdb-bridge)
endif()
# fxgxa, fxg1a # fxgxa, fxg1a
install(TARGETS fxgxa) install(TARGETS fxgxa)
install(FILES "${BIN}/fxg1a" TYPE BIN) install(FILES "${BIN}/fxg1a" TYPE BIN)
# fxconv # fxconv
install(PROGRAMS fxconv/fxconv-main.py TYPE BIN RENAME fxconv) install(PROGRAMS fxconv/fxconv-main.py TYPE BIN RENAME fxconv)
install(FILES fxconv/fxconv.py TYPE BIN) install(FILES fxconv/fxconv.py TYPE BIN)
# libfxlink
install(FILES "${BIN}/include/fxlink/config.h" DESTINATION include/fxlink/)
install(DIRECTORY libfxlink/include/ DESTINATION include
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY libfxlink/cmake/ DESTINATION lib/cmake)
install(TARGETS libfxlink DESTINATION lib)
# fxlink # fxlink
install(TARGETS fxlink) install(TARGETS fxlink)
else()
# fxlink
install(TARGETS fxlink DESTINATION "${SYSROOT}bin")
endif()
# libfxlink
install(FILES "${BIN}/include/fxlink/config.h"
DESTINATION "${SYSROOT}include/fxlink/")
install(DIRECTORY libfxlink/include/ DESTINATION "${SYSROOT}include"
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY libfxlink/cmake/ DESTINATION "${SYSROOT}lib/cmake")
install(TARGETS libfxlink DESTINATION "${SYSROOT}lib")

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,22 +1,37 @@
# 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
set(P1 "$ENV{HOME}/.local/${SYSROOT}lib/libfxlink.a")
set(P2 "$ENV{FXSDK_PATH}/${SYSROOT}lib/libfxlink.a")
if(EXISTS "${P1}")
set(LIBFXLINK_PATH "${P1}")
elseif(DEFINED "$ENV{FXSDK_PATH}" AND EXISTS "${P2}")
set(LIBFXLINK_PATH "${P2}")
else()
message(FATAL_ERROR
"Could not find libfxlink.a!\n" "Could not find libfxlink.a!\n"
"You can specify the install path with the environment variable " "You can specify the install path with the environment variable "
"FXSDK_PATH, such as FXSDK_PATH=$HOME/.local") "FXSDK_PATH, such as FXSDK_PATH=$HOME/.local")
else() endif()
endif()
get_filename_component(LIBFXLINK_PATH "${LIBFXLINK_PATH}/../.." ABSOLUTE) get_filename_component(LIBFXLINK_PATH "${LIBFXLINK_PATH}/../.." ABSOLUTE)
set(LIBFXLINK_LIB "${LIBFXLINK_PATH}/lib/libfxlink.a") set(LIBFXLINK_LIB "${LIBFXLINK_PATH}/lib/libfxlink.a")
set(LIBFXLINK_INCLUDE "${LIBFXLINK_PATH}/include") set(LIBFXLINK_INCLUDE "${LIBFXLINK_PATH}/include")
message("(libfxlink) Found libfxlink at: ${LIBFXLINK_LIB}") message("(libfxlink) Found libfxlink at: ${LIBFXLINK_LIB}")
message("(libfxlink) Will take includes from: ${LIBFXLINK_INCLUDE}") message("(libfxlink) Will take includes from: ${LIBFXLINK_INCLUDE}")
endif()
# Find library version # Find library version

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;