diff options
author | Nicholas Corgan <nick.corgan@ettus.com> | 2015-07-22 14:46:31 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-07-23 14:37:16 -0700 |
commit | 86924e9cca30b3f4d61fa2d2697d742afa6f73b0 (patch) | |
tree | f561a61d773979198d24765aa3fa62037afb7e54 /host/cmake | |
parent | 62cd8c618ebeef0354b7f0d34ed2c0310f6f11dc (diff) | |
download | uhd-86924e9cca30b3f4d61fa2d2697d742afa6f73b0.tar.gz uhd-86924e9cca30b3f4d61fa2d2697d742afa6f73b0.tar.bz2 uhd-86924e9cca30b3f4d61fa2d2697d742afa6f73b0.zip |
cmake: MinGW improvements
* Improved toolchan file, accounts for different versions
* Don't force static runtime linking (was causing test errors)
* Include MinGW runtime in packaging
Diffstat (limited to 'host/cmake')
-rw-r--r-- | host/cmake/Modules/UHDPackage.cmake | 6 | ||||
-rw-r--r-- | host/cmake/Toolchains/mingw_cross.cmake | 92 |
2 files changed, 47 insertions, 51 deletions
diff --git a/host/cmake/Modules/UHDPackage.cmake b/host/cmake/Modules/UHDPackage.cmake index 298b9d33a..a17af9c61 100644 --- a/host/cmake/Modules/UHDPackage.cmake +++ b/host/cmake/Modules/UHDPackage.cmake @@ -210,10 +210,10 @@ SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_PATH\\\" ") -IF(MSVC) - #Install necessary MSVC runtime DLL's +IF(WIN32) + #Install necessary runtime DLL's INCLUDE(InstallRequiredSystemLibraries) -ENDIF(MSVC) +ENDIF(WIN32) ######################################################################## IF(NOT ${CPACK_GENERATOR} STREQUAL NSIS) diff --git a/host/cmake/Toolchains/mingw_cross.cmake b/host/cmake/Toolchains/mingw_cross.cmake index 7c5adb002..f1406ec46 100644 --- a/host/cmake/Toolchains/mingw_cross.cmake +++ b/host/cmake/Toolchains/mingw_cross.cmake @@ -1,56 +1,52 @@ -# Use this command: # -# cmake -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-mingw.cmake . +# Allow the user to specify a MinGW prefix, but fill in +# most likely default if none given. # -# or for out of source: -# -# cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw.cmake .. -# -# You will need at least CMake 2.6.0. -# -# Adjust the following paths to suit your environment. -# -# This file was based on http://www.cmake.org/Wiki/CmakeMingw -# the name of the target operating system -set(CMAKE_SYSTEM_NAME Windows) +SET(CMAKE_SYSTEM_NAME Windows) + +IF(NOT DEFINED MINGW_PREFIX) + SET(POSSIBLE_PREFIXES + i586-mingw32msvc + i686-pc-mingw32 + x86_64-pc-mingw32 + i686-w64-mingw32 + x86_64-w64-mingw32 + ) + + SET(MINGW_FOUND 0) + FOREACH(prefix ${POSSIBLE_PREFIXES}) + IF(EXISTS /usr/${prefix}) + SET(MINGW_PREFIX ${prefix}) + SET(MINGW_FOUND 1) + BREAK() + ENDIF(EXISTS /usr/${prefix}) + ENDFOREACH(prefix ${POSSIBLE_PREFIXES}) + + IF(NOT MINGW_FOUND) + MESSAGE(FATAL_ERROR "No MinGW type specified, but none detected in the usual locations.") + ENDIF(NOT MINGW_FOUND) +ENDIF(NOT DEFINED MINGW_PREFIX) + +SET(MINGW_PREFIX ${MINGW_PREFIX} CACHE STRING "MinGW prefix") + +SET(CMAKE_C_COMPILER ${MINGW_PREFIX}-gcc) +SET(CMAKE_CXX_COMPILER ${MINGW_PREFIX}-g++) +SET(CMAKE_RC_COMPILER ${MINGW_PREFIX}-windres) + +IF(NOT DEFINED CMAKE_FIND_ROOT_PATH) + SET(CMAKE_FIND_ROOT_PATH /usr/${MINGW_PREFIX}) +ENDIF(NOT DEFINED CMAKE_FIND_ROOT_PATH) -# Assume the target architecture. -# XXX for some reason the value set here gets cleared before we reach the -# main CMakeLists.txt; see that file for a workaround. -# set(CMAKE_SYSTEM_PROCESSOR i686) +SET(CMAKE_INCLUDE_PATH + ${CMAKE_FIND_ROOT_PATH}/local/include + ${CMAKE_FIND_ROOT_PATH}/include +) -# Which compilers to use for C and C++, and location of target -# environment. -if(EXISTS /usr/i586-mingw32msvc) - # First look in standard location as used by Debian/Ubuntu/etc. - set(CMAKE_C_COMPILER i586-mingw32msvc-gcc) - set(CMAKE_CXX_COMPILER i586-mingw32msvc-g++) - set(CMAKE_RC_COMPILER i586-mingw32msvc-windres) - set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc) -elseif(EXISTS /usr/i686-w64-mingw32) - # First look in standard location as used by Debian/Ubuntu/etc. - set(CMAKE_C_COMPILER i686-w64-mingw32-gcc) - set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) - set(CMAKE_RC_COMPILER i686-w64-mingw32-windres) - set(CMAKE_AR:FILEPATH /usr/bin/i686-w64-mingw32-ar) -elseif(EXISTS /opt/mingw) - # You can get a MinGW environment using the script at <http://mxe.cc>. - # It downloads and builds MinGW and most of the dependencies for you. - # You can use the toolchain file generated by MXE called `mxe-conf.cmake' - # or you can use this file by adjusting the above and following paths. - set(CMAKE_C_COMPILER /opt/mingw/usr/bin/i686-pc-mingw32-gcc) - set(CMAKE_CXX_COMPILER /opt/mingw/usr/bin/i686-pc-mingw32-g++) - set(CMAKE_RC_COMPILER /opt/mingw/usr/bin/i686-pc-mingw32-windres) - set(CMAKE_FIND_ROOT_PATH /opt/mingw/usr/i686-pc-mingw32) -else() - # Else fill in local path which the user will likely adjust. - # This is the location assumed by <http://www.libsdl.org/extras/win32/cross/> - set(CMAKE_C_COMPILER /usr/local/cross-tools/bin/i386-mingw32-gcc) - set(CMAKE_CXX_COMPILER /usr/local/cross-tools/bin/i386-mingw32-g++) - set(CMAKE_RC_COMPILER /usr/local/cross-tools/bin/i386-mingw32-windres) - set(CMAKE_FIND_ROOT_PATH /usr/local/cross-tools) -endif() +SET(CMAKE_LIBRARY_PATH + ${CMAKE_FIND_ROOT_PATH}/local/lib + ${CMAKE_FIND_ROOT_PATH}/lib +) # Adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search |