Im trying to use cmake and MXE to cross-compile for Windows.
Everything works fine on *nix. However I don't know how to get some of the dependencies (Grantlee5 and Qt5WebKitWidgets) to work with MinGW and cross compilation. Here is a (minimal) example of my CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.11)
project(MyProject)
set(QT_USE_QTXML TRUE)
set(QT_USE_QTWEBKIT TRUE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
# Instruct CMake to run moc automaticall when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#find packages
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Grantlee5 REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED)
find_package(Git)
#(...) add all sources
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Tell CMake to create the executable
add_executable(MyProjectExec ${SRCS})
target_link_libraries(MyProjectExec
Qt5::Widgets
Qt5::Xml
Grantlee5::Templates
Qt5::WebKitWidgets
)
It works fine if I just use "cmake". However, if I use MXE's toolchain to cross compile for Widnows (i686-w64-mingw32.static-cmake), Grantlee5 and Qt5WebKitWidgets fail with the following message:
Make Error at CMakeLists.txt:xx (find_package): Could not find a configuration file for package "Grantlee5" that is compatible with requested version "". [sic]
The following configuration files were considered but not accepted:
/usr/lib/cmake/Grantlee5/Grantlee5Config.cmake, version: 5.0.0 (64bit)
Of course, my Grantlee5-binaries are not compatible with Windows/MinGW.
ExternalProject_Add(Grantlee5 GIT_REPOSITORY https://github.com/steveire/grantlee.git) seems to cross compile grantlee, however it fails at the install-target (of course I cannot install a windows-binary on my system)
add_library(Grantlee5 /usr/local/src/grantlee/) breaks up the find_library statement. Grantlee gets build, but linking fails (include grantlee/engine.h not found)
How to tell cmake to build Grantlee and Qt5WebKitWidgets from source for the specific target (while using the available binaries for dynamic linking otherwise)? What is the "right" way to do it?