diff --git a/CMakeLists.txt b/CMakeLists.txt index 054db11..be44759 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,25 +108,35 @@ endif() # Install rules -# fxsdk -install(PROGRAMS "${BIN}/fxsdk.sh" TYPE BIN RENAME fxsdk) -install(DIRECTORY fxsdk/assets DESTINATION share/fxsdk) -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) +set(SYSROOT "") +if(WIN32) + set(SYSROOT "x86_64-w64-mingw32/") endif() -# 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) + +if(NOT WIN32) + # fxsdk + install(PROGRAMS "${BIN}/fxsdk.sh" TYPE BIN RENAME fxsdk) + install(DIRECTORY fxsdk/assets DESTINATION share/fxsdk) + 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 -install(FILES "${BIN}/include/fxlink/config.h" DESTINATION include/fxlink/) -install(DIRECTORY libfxlink/include/ DESTINATION include +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 lib/cmake) -install(TARGETS libfxlink DESTINATION lib) -# fxlink -install(TARGETS fxlink) +install(DIRECTORY libfxlink/cmake/ DESTINATION "${SYSROOT}lib/cmake") +install(TARGETS libfxlink DESTINATION "${SYSROOT}lib") diff --git a/README.md b/README.md index 9c12eb8..2b8a908 100644 --- a/README.md +++ b/README.md @@ -184,9 +184,9 @@ Install the cross-compiler and cross-libraries from AUR. mingw-w64-ncurses ``` -Configure and build. +Configure and build. Install to get libfxlink. ```bash -% x86_64-w64-mingw32-cmake -B build-win64 -DFXLINK_DISABLE_UDISKS2=1 -DFXLINK_DISABLE_POLL=1 -% make -C build-win64 +% 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 install ``` diff --git a/libfxlink/cmake/FindLibFxlink.cmake b/libfxlink/cmake/FindLibFxlink.cmake index daf6ca2..2cf5f4f 100644 --- a/libfxlink/cmake/FindLibFxlink.cmake +++ b/libfxlink/cmake/FindLibFxlink.cmake @@ -1,23 +1,38 @@ # Locate the library file and includes +if(WIN32) + set(SYSROOT "x86_64-w64-mingw32/") +else() + set(SYSROOT) +endif() + find_library( - LIBFXLINK_PATH "fxlink" - HINTS "$ENV{HOME}/.local/lib" "$ENV{FXSDK_PATH}/lib" + LIBFXLINK_PATH "fxlink" "libfxlink.a" + HINTS "$ENV{HOME}/.local/${SYSROOT}lib" "$ENV{FXSDK_PATH}/${SYSROOT}lib" ) if(LIBFXLINK_PATH STREQUAL "LIBFXLINK_PATH-NOTFOUND") - message(SEND_ERROR - "Could not find libfxlink.a!\n" - "You can specify the install path with the environment variable " - "FXSDK_PATH, such as FXSDK_PATH=$HOME/.local") -else() - 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}") + # 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" + "You can specify the install path with the environment variable " + "FXSDK_PATH, such as FXSDK_PATH=$HOME/.local") + 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 if(NOT EXISTS "${LIBFXLINK_INCLUDE}/fxlink/config.h") diff --git a/libfxlink/include/fxlink/defs.h b/libfxlink/include/fxlink/defs.h index 2e4b83a..8f1d64e 100644 --- a/libfxlink/include/fxlink/defs.h +++ b/libfxlink/include/fxlink/defs.h @@ -17,6 +17,14 @@ # include #endif +#ifdef min +# undef min +#endif + +#ifdef max +# undef max +#endif + static inline int min(int x, int y) { return (x < y) ? x : y;