Skip to content

Commit

Permalink
Fix MinGW builds (#113)
Browse files Browse the repository at this point in the history
* use ole32 when compiling with MINGW in Windows for UUIDs

* use winresrc.h instead of winres.h

* remove ole32 link dependency

* add mingw shell script

* add mingw support to travis-cli

* fix travis before_script

* add cmake cross compile support to cmake

* remove tobydox dependency

* use mingw from /usr instead of  /opt

* remove test from travis mingw build

* remove tets generation for linux mingw

* fix mingw cmake script

* add LIB3MF_TESTS at cmake toolchain

* reenable tests in mingw cmake
  • Loading branch information
qmuntal authored and martinweismann committed Dec 19, 2018
1 parent aaba714 commit 5dbdbb6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
15 changes: 13 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@ matrix:
compiler: gcc
- os: osx
osx_image: xcode7.2
- os: linux
compiler: x86_64-w64-mingw32-g++
env: BUILDMODE=cmake-mingw32
addons:
apt:
packages:
- gcc-mingw-w64-base
- binutils-mingw-w64-x86-64
- gcc-mingw-w64-x86-64
- gcc-mingw-w64
- g++-mingw-w64-x86-64

before_script:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install ossp-uuid ; fi
- sh cmake/GenerateMake.sh
- if [[ "$BUILDMODE" = "cmake-mingw32" ]]; then sh cmake/GenerateMinGW.sh ; else sh cmake/GenerateMake.sh ; fi
- cd build

script:
- cmake --build .
- ctest -V
- if ![[ "$BUILDMODE" = "cmake-mingw32" ]]; then ctest -V ; fi

10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ if (UNIX OR MINGW)
if (NOT APPLE)
SET_TARGET_PROPERTIES(${PROJECT_NAME}_s PROPERTIES LINK_FLAGS -s)
endif()
find_library(LIBUUID_PATH uuid)
if(NOT LIBUUID_PATH)
message(FATAL_ERROR "libuuid not found")
if (NOT WIN32)
find_library(LIBUUID_PATH uuid)
if(NOT LIBUUID_PATH)
message(FATAL_ERROR "libuuid not found")
endif()
target_link_libraries(${PROJECT_NAME}_s ${LIBUUID_PATH})
endif()
target_link_libraries(${PROJECT_NAME}_s ${LIBUUID_PATH})
else()
# wd4996 masks the deprecated-warning
target_compile_options(${PROJECT_NAME}_s PUBLIC "$<$<CONFIG:DEBUG>:/Od;/Ob0;/Gm;/sdl;/W3;/WX;/FC;/wd4996>")
Expand Down
2 changes: 1 addition & 1 deletion Release/VersionInfo/VersionResource.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "VersionInfo.h"
#include "winres.h"
#include "winresrc.h"

// IDI_ICON1 ICON PRODUCT_ICON

Expand Down
15 changes: 15 additions & 0 deletions cmake/GenerateMinGW.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

basepath="$(cd "$(dirname "$0")" && pwd)"
builddir="$basepath/../build"
mkdir -p "$builddir"
cd "$builddir"
echo "SET(CMAKE_SYSTEM_NAME Windows)" > toolchain.cmake &&
echo "SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)" >> toolchain.cmake &&
echo "SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)" >> toolchain.cmake &&
echo "SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)" >> toolchain.cmake &&
echo "SET(CMAKE_FIND_ROOT_PATH /usr/mingw64)" >> toolchain.cmake &&
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> toolchain.cmake &&
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> toolchain.cmake &&
echo "SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> toolchain.cmake &&
cmake .. -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake "$@"

0 comments on commit 5dbdbb6

Please sign in to comment.