Skip to content

Commit

Permalink
Works on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
barche committed Mar 27, 2016
1 parent c69903b commit 82fede6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
3 changes: 3 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ provides(BuildProcess,
end
end),qml_wrapper)

deps = [qml_wrapper]
provides(Binaries, Dict(URI("https://github.com/barche/QML.jl/releases/download/v0.1.0/QML.zip") => deps), os = :Windows)

@BinDeps.install

@windows_only pop!(BinDeps.defaults)
21 changes: 14 additions & 7 deletions deps/src/qml_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ project(QML)

cmake_minimum_required(VERSION 3.1)

if(WIN32)
add_definitions(-DWIN32_LEAN_AND_MEAN)
endif(WIN32)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
list(APPEND CMAKE_CXX_FLAGS "-std=c++11")
Expand All @@ -19,13 +15,24 @@ get_target_property(QtCore_location Qt5::Core LOCATION)
get_filename_component(QtCore_location ${QtCore_location} DIRECTORY)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${CxxWrap_DIR}/../;${QtCore_location}")

add_library(qml_wrapper SHARED wrap_qml.hpp wrap_qml.cpp ${MOC_BUILT_SOURCES} ${UI_BUILT_SOURCES})
target_link_libraries(qml_wrapper Qt5::Core Qt5::Quick Qt5::Widgets CxxWrap::cxx_wrap)

if(WIN32)
add_definitions(-DWIN32_LEAN_AND_MEAN)
get_filename_component(VC_DIR "${CMAKE_LINKER}" DIRECTORY) # Visual studio dir is 3 levels up from the linker
get_filename_component(VC_DIR "${VC_DIR}" DIRECTORY)
get_filename_component(VC_DIR "${VC_DIR}" DIRECTORY)
get_filename_component(QML_DIR "${CMAKE_SOURCE_DIR}" DIRECTORY) # Go up to the package test dir for QML examples
get_filename_component(QML_DIR "${QML_DIR}" DIRECTORY)
get_filename_component(QML_DIR "${QML_DIR}" DIRECTORY)
set(QML_DIR "${QML_DIR}/test/qml")
configure_file("${CMAKE_SOURCE_DIR}/cmake/WinDeployQt.cmake" "${CMAKE_BINARY_DIR}/WinDeployQt.cmake")
configure_file("${CMAKE_SOURCE_DIR}/resources/resources.qrc" "${CMAKE_BINARY_DIR}/resources/resources.qrc" COPYONLY)
configure_file("${CMAKE_SOURCE_DIR}/resources/qt.conf" "${CMAKE_BINARY_DIR}/resources/qt.conf")
qt5_add_resources(RESOURCES ${CMAKE_BINARY_DIR}/resources/resources.qrc)
endif(WIN32)

add_library(qml_wrapper SHARED wrap_qml.hpp wrap_qml.cpp ${MOC_BUILT_SOURCES} ${UI_BUILT_SOURCES} ${RESOURCES})
target_link_libraries(qml_wrapper Qt5::Core Qt5::Quick Qt5::Widgets CxxWrap::cxx_wrap)

install(TARGETS
qml_wrapper
LIBRARY DESTINATION lib
Expand Down
5 changes: 2 additions & 3 deletions deps/src/qml_wrapper/cmake/WinDeployQt.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
get_filename_component(VC_DIR "${CMAKE_LINKER}" DIRECTORY)
set(ENV{VCINSTALLDIR} "${VC_DIR}/../../")
execute_process(COMMAND ${QtCore_location}/windeployqt --qmldir "${CMAKE_SOURCE_DIR}../../../test/qml/main.qml" "${CMAKE_INSTALL_PREFIX}/lib/qml_wrapper.dll")
set(ENV{VCINSTALLDIR} "${VC_DIR}")
execute_process(COMMAND ${QtCore_location}/windeployqt --qmldir "${QML_DIR}" "${CMAKE_INSTALL_PREFIX}/lib/qml_wrapper.dll")
5 changes: 5 additions & 0 deletions deps/src/qml_wrapper/resources/qt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Paths]
Prefix = ${CMAKE_INSTALL_PREFIX}
Binaries = lib
Plugins = lib
Qml2Imports = lib
5 changes: 5 additions & 0 deletions deps/src/qml_wrapper/resources/resources.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/qt/etc/">
<file>qt.conf</file>
</qresource>
</RCC>
4 changes: 3 additions & 1 deletion deps/src/qml_wrapper/wrap_qml.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <QApplication>
#include <QFileInfo>
#include <QLibraryInfo>
#include <QQmlApplicationEngine>
#include <QQmlComponent>
Expand Down Expand Up @@ -160,7 +161,8 @@ struct ConvertToCpp<QUrl, false, false, false>
}

QString qstr(jl_bytestring_ptr(julia_string));
if(qstr.contains(':'))
QFileInfo finfo(qstr);
if(!finfo.exists())
{
return QUrl(qstr);
}
Expand Down

0 comments on commit 82fede6

Please sign in to comment.