-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to CMAKE and add Windows Build Instructions (#45)
* Oh no I broke the build * update packages * Upgrading to Lua 5.4 breaks my plugin at luaL_openlibs * Man this kinda sucks * checkpoint * checkpoint * Linux build WOMM * Add version requirement for Xournalpp * update cmake * update cmakelists * Fix Windows cmake script * Get build working on Windows again. Need Lua 54. Version skew causes a segfault. Exiting the program also segfaults? * Update Dockerfile and remove old targets from Makefile * Update readme and add win_configure_path
- Loading branch information
1 parent
7a2dca1
commit f4daf33
Showing
11 changed files
with
193 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
cmake_minimum_required(VERSION 3.22.1) | ||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) | ||
PROJECT(inkpath) | ||
|
||
# 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() | ||
|
||
# Define our sources | ||
file(GLOB CV_SOURCES src/cv/*.cpp) | ||
file(GLOB PLUGIN_SOURCES src/ipcv_obj/*.cpp) | ||
|
||
# Locate dependent packages | ||
FIND_PACKAGE(OpenCV REQUIRED) | ||
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) | ||
|
||
FIND_PACKAGE(Lua 5.4 REQUIRED) | ||
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) | ||
|
||
# We link OpenCV statically in Linux, | ||
# but link totally dynamically and redistribute dlls in Windows | ||
IF(WIN32) | ||
# FIXME (wdn): Fix FIND_PACKAGE behavior for Lua on Windows | ||
set(LUA_INCLUDE_DIR "C:/msys64/mingw64/include") | ||
set(LUA_LIBRARIES "C:/msys64/mingw64/lib") | ||
|
||
ADD_LIBRARY(inkpath SHARED ${CV_SOURCES} ${PLUGIN_SOURCES}) | ||
target_link_libraries(inkpath ${LUA_LIBRARIES}/liblua.a) | ||
ELSE() | ||
# Compile the CV component of Inkpath separately. This is mostly so that we | ||
# can build our debug program and such. | ||
ADD_LIBRARY(ipcv STATIC ${CV_SOURCES}) | ||
target_link_libraries(ipcv ${OpenCV_LIBRARIES}) | ||
|
||
# Compile plugin component of Inkpath. | ||
ADD_LIBRARY(inkpath SHARED ${PLUGIN_SOURCES}) | ||
target_compile_options(inkpath PRIVATE) | ||
target_link_libraries(inkpath ipcv) | ||
ENDIF() | ||
|
||
# OpenCV Gets linked the same way for both platforms | ||
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() | ||
|
||
IF(WIN32) | ||
#add_custom_command( | ||
# OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/lib | ||
# COMMAND bash -c "echo chom && ldd ${LIBRARY_OUTPUT_NAME} | grep mingw64 | awk '{ print $3 }' | xargs -I {} cp {} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" | ||
#) | ||
|
||
#install(CODE "execute_process(COMMAND ../scripts/copy_dlls.sh)") | ||
|
||
install(CODE "execute_process(COMMAND bash \"${CMAKE_SOURCE_DIR}/scripts/copy_dlls.sh\")") | ||
ENDIF() | ||
|
||
# Finally, set an install target. | ||
install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} DESTINATION ${INSTALL_DESTINATION}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
INKPATH_LIB=libinkpath.dll | ||
echo "Copying $INKPATH_LIB dependencies..." | ||
ldd ImageTranscription/$INKPATH_LIB | grep mingw64 | awk '{ print $3 }' | xargs -I {} cp {} ./ImageTranscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Inkpath stores its dependencies in the plugin folder on Windows. To make this work, we need to update the path to allow Xournal++ to see the dependencies, so we use this Powershell script to do that. | ||
|
||
$inkpathLibPath = "C:\Program Files\Xournal++\share\xournalpp\plugins\ImageTranscription" | ||
|
||
$userPath = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::User) | ||
|
||
if (-not ($userPath -split ";" | ForEach-Object { $_.Trim() } | Where-Object { $_ -eq $inkpathLibPath })) { | ||
$newPath = $userPath + ";" + $inkpathLibPath | ||
[Environment]::SetEnvironmentVariable("PATH", $newPath, [EnvironmentVariableTarget]::User) | ||
Write-Host "Configured Path." | ||
} else { | ||
Write-Host "Path already updated." | ||
} | ||
|
||
Write-Host "Press any key to continue..." | ||
[void][System.Console]::ReadKey($true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters