Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ out*
*.out
build/
*.svg
dist
do.sh
ImageTranscription/inkpath.so
ImageTranscription/ipcvobj.so
Expand Down
49 changes: 33 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ cmake_minimum_required(VERSION 3.22.1)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
PROJECT(inkpath)

set(PLUGIN_NAME "ImageTranscription")
set(PLUGIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plugin")
set(CMAKE_INSTALL_PREFIX_PLUGIN "${CMAKE_INSTALL_PREFIX}")

# Options
set(CMAKE_INSTALL_PREFIX_ICONS "" CACHE PATH "Installation path for icons")

# Send artifacts to /build/ImageTranscription. That will be the final artifact.
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/ImageTranscription)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/ImageTranscription)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/ImageTranscription)

# Things work a little differently on Windows vs Linux.
IF(WIN32)
message("Building for Windows")
set(INSTALL_DESTINATION "C:/Program Files/Xournal++/share/xournalpp/plugins")
ELSE()
# Need position-independent code flag enabled to make Lua work
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(INSTALL_DESTINATION /usr/share/xournalpp/plugins)
ENDIF()
if(UNIX AND NOT APPLE)
# For dynamic libraries enabling a -fPIC (Position-Independent Code) flag is
# required when compiling code into shared libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

# Define our sources
file(GLOB CV_SOURCES src/cv/*.cpp)
Expand All @@ -25,7 +29,7 @@ file(GLOB DEBUG_SOURCES src/cv/debug/*.cpp)
# Locate dependent packages
FIND_PACKAGE(OpenCV REQUIRED)
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})

FIND_PACKAGE(Lua 5.4 REQUIRED)
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})

Expand Down Expand Up @@ -54,14 +58,27 @@ ENDIF()
target_link_libraries(inkpath ${OpenCV_LIBRARIES})


# Copy the script and manifest into the build artifact
file(GLOB PLUGIN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/plugin/*")
FOREACH(FILE ${PLUGIN_FILES})
file(COPY ${FILE} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
ENDFOREACH()

# Finally, set an install target.
install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DESTINATION ${INSTALL_DESTINATION})
install(
DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DESTINATION ${CMAKE_INSTALL_PREFIX_PLUGIN}
)
# Copy plugin directory files to the install prefix
install(
DIRECTORY ${PLUGIN_DIR}/
DESTINATION ${CMAKE_INSTALL_PREFIX_PLUGIN}/${PLUGIN_NAME}
FILES_MATCHING
PATTERN "*"
)
# Copy icon files to the install prefix for icons
if(CMAKE_INSTALL_PREFIX_ICONS)
install(
DIRECTORY ${PLUGIN_DIR}/
DESTINATION ${CMAKE_INSTALL_PREFIX_ICONS}
FILES_MATCHING
PATTERN "*.svg"
)
endif()

# Also set up debugging target
add_executable(inkpath-debug EXCLUDE_FROM_ALL ${CV_SOURCES} ${DEBUG_SOURCES})
Expand Down
30 changes: 25 additions & 5 deletions PreLoad.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
IF (WIN32)
# Need to specify specific generator b/c building on MSYS2 MINGW64
set (CMAKE_GENERATOR "MinGW Makefiles" CACHE INTERNAL "" FORCE)
message("generator is set to ${CMAKE_GENERATOR}")
ENDIF()
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type")
endif()

if(WIN32)
set(CMAKE_GENERATOR "MinGW Makefiles" CACHE STRING "Default to MinGW cross compilation")
message("Force CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "$ENV{LOCALAPPDATA}/xournalpp/plugins" CACHE PATH "Default user Xournal++ plugins directory on Windows")
if(NOT DEFINED CMAKE_INSTALL_PREFIX_ICONS)
set(CMAKE_INSTALL_PREFIX_ICONS "$ENV{LOCALAPPDATA}/icons" CACHE PATH "Default user GTK icons directory on Windows")
endif()
endif()
else()
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.config/xournalpp/plugins" CACHE PATH "Default user Xournal++ plugins directory on Linux")
if(NOT DEFINED CMAKE_INSTALL_PREFIX_ICONS)
set(CMAKE_INSTALL_PREFIX_ICONS "$ENV{HOME}/.local/share/icons" CACHE PATH "Default user GTK icons directory on Linux")
endif()
endif()
endif()

message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_INSTALL_PREFIX_ICONS: ${CMAKE_INSTALL_PREFIX_ICONS}")
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ cmake ..
make
```

To install the plugin to the local `dist` directory instead of the system specific Xournal++ User directory:

```sh
cmake -B build -S . -DCMAKE_INSTALL_PREFIX="dist"
```

### Arch

```BASH
Expand Down