Skip to content

Commit

Permalink
Merge pull request #111 from asamahy/main
Browse files Browse the repository at this point in the history
feat: added macOS build support
  • Loading branch information
bigbigmdm authored Sep 17, 2024
2 parents b5f3982 + fdfc9e6 commit 101a160
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 14 deletions.
17 changes: 13 additions & 4 deletions IMSProg_editor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

project(IMSProg_editor LANGUAGES CXX)

# Set the CMAKE_INSTALL_PREFIX to /usr if not specified
# Set the CMAKE_INSTALL_PREFIX to /usr if not specified and /usr/local for macOS
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "The default install prefix" FORCE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "The default install prefix on macOS" FORCE)
# Set Qt5 path for macOS
set(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}/opt/qt@5" CACHE PATH "Path to Qt5 on macOS" FORCE)
else()
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "The default install prefix" FORCE)
endif()
endif()

# Set the CMAKE_INSTALL_BINDIR to /bin if not specified
Expand Down Expand Up @@ -64,7 +69,11 @@ target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)

install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg_editor.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")

if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg_editor.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
endif()

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/chipEdit64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps")

install(FILES ${QM_FILES} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/imsprog")
Expand Down
23 changes: 16 additions & 7 deletions IMSProg_programmer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ project(IMSProg LANGUAGES C CXX)

# Set the CMAKE_INSTALL_PREFIX to /usr if not specified
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "The default install prefix" FORCE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "The default install prefix on macOS" FORCE)
# Set Qt5 path for macOS
set(CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}/opt/qt@5" CACHE PATH "Path to Qt5 on macOS" FORCE)
else()
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "The default install prefix" FORCE)
endif()
endif()

# Set the CMAKE_INSTALL_BINDIR to /bin if not specified
Expand All @@ -35,6 +41,7 @@ find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
find_package(Qt5Widgets REQUIRED)
find_package(LibUSB REQUIRED)

if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(UDEVDIR "/usr/lib/udev")
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr" OR CMAKE_INSTALL_PREFIX STREQUAL "/" )
# /usr and / install prefixes at treated by cmake GNUInstallDirs as
Expand All @@ -56,7 +63,7 @@ find_package(PkgConfig)
endif()
endif()
endif()
endif()
# Qt5LinguistTools
find_package(Qt5 REQUIRED COMPONENTS LinguistTools)

Expand Down Expand Up @@ -142,20 +149,23 @@ dialogabout.ui
recource.qrc
${QM_FILES}
)

target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets ${LibUSB_LIBRARIES})

install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/img/IMSProg64.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/database/IMSProg.Dat" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/imsprog")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/71-CH341.rules" DESTINATION "${UDEVDIR}/rules.d")

if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/71-CH341.rules" DESTINATION "${UDEVDIR}/rules.d")
endif()

install(FILES ${QM_FILES} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/imsprog")

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg_database_update"
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg_database_update"
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg_database_update.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
Expand All @@ -165,4 +175,3 @@ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/IMSProg_database_update.1.gz" D
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/index.html" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/imsprog/html")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/io.github.bigbigmdm.imsprog.metainfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/other/io.github.bigbigmdm.imsprog_database_update.metainfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")

36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ These commands are included in the `build_all.sh` file.

## System software requirements

### Linux

For build are needed:
- g++ or clang
- CMake
Expand Down Expand Up @@ -90,10 +92,44 @@ Optionally if you want to use IMSProg_database_update script:
:information_source: Debian < 11 and Ubuntu < 20.04 are not supported, you may
unable to have it working on them.

### macOS
if using Homebrew then Xcode Command Line Tools will install by default, if not then install manually from terminal:

```
xcode-select --install
```

install the required packages

using brew:

```
brew install qt@5 libusb cmake pkgconf
```

if not using the [build_all.sh](build_all.sh) script then make sure `libusb` is in your `C_INCLUDE_PATH`

```
export C_INCLUDE_PATH=/usr/local/opt/libusb/include
```
Optionally if you want to use IMSProg_database_update script:
```
brew install wget zenity
```


## How to use:

Note: for macOS use CMD `` instead of CTRL for keyboard shortcuts.

## Chip programmer

### Launching
Can be launched from Terminal by running the command
```
$ IMSProg
```

### Connecting
- Insert the chip into the appropriate slot of the CH341A programmer. The
`24xxx` and `25xxx` series chips must be inserted directly, according to the
Expand Down
8 changes: 5 additions & 3 deletions build_all.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash

[[ "$OSTYPE" == "darwin"* ]] && export C_INCLUDE_PATH=/usr/local/opt/libusb/include
if [ "$EUID" -ne 0 ]
then echo "Please run as root! (sudo ./build_all.sh)"
exit
Expand All @@ -8,15 +10,15 @@ rm -rf build/
mkdir build/
cmake -S . -B build/
cmake --build build/ --parallel
sudo cmake --install build/
cmake --install build/
rm -rf build/
cd .. #IMSProg
cd IMSProg_editor
rm -rf build/
mkdir build/
cmake -S . -B build/
cmake --build build/ --parallel
sudo cmake --install build/
cmake --install build/
rm -rf build/
# Reloading the USB rules
sudo udevadm control --reload-rules
[[ "$OSTYPE" != "darwin"* ]] && udevadm control --reload-rules

0 comments on commit 101a160

Please sign in to comment.