1# ----------------------------------------------------------------------------- 2# Set the paths in this file if you want to build Inkscape from a shell other than the 3# Windows built-in command line (i.e. MSYS) or IDEs such as CodeLite. These variables 4# will be used as default if no environment variables are set. 5# ----------------------------------------------------------------------------- 6 7# ----------------------------------------------------------------------------- 8# MinGW Configuration 9# ----------------------------------------------------------------------------- 10message(STATUS "Configuring MinGW environment:") 11 12if("$ENV{MSYSTEM_CHOST}" STREQUAL "") 13 message(WARNING " Could not detect MinGW build environment. We recommend building with MSYS2. Proceed at your own risk!") 14else() 15 message(STATUS " Detected MinGW environment provided by MSYS2") 16 set(MINGW_PATH $ENV{MINGW_PREFIX}) 17endif() 18 19# ----------------------------------------------------------------------------- 20# MINGW CHECKS 21# ----------------------------------------------------------------------------- 22 23# Try to determine the MinGW processor architecture. 24if(EXISTS "${MINGW_PATH}/i686-w64-mingw32") 25 set(HAVE_MINGW64 OFF) 26 set(MINGW_ARCH i686-w64-mingw32) 27elseif(EXISTS "${MINGW_PATH}/x86_64-w64-mingw32") 28 set(HAVE_MINGW64 ON) 29 set(MINGW_ARCH x86_64-w64-mingw32) 30else() 31 message(FATAL_ERROR "Unable to determine MinGW processor architecture. Are you using an unsupported MinGW version?") 32endif() 33 34# Path to processor architecture specific binaries and libs. 35set(MINGW_ARCH_PATH "${MINGW_PATH}/${MINGW_ARCH}") 36 37set(MINGW_BIN "${MINGW_PATH}/bin") 38 39if(NOT EXISTS ${MINGW_BIN}) 40 message(FATAL_ERROR "MinGW binary directory does not exist: ${MINGW_BIN}") 41endif() 42 43# Eliminate error messages when not having mingw in the environment path variable. 44list(APPEND CMAKE_PROGRAM_PATH ${MINGW_BIN}) 45 46set(MINGW_LIB "${MINGW_PATH}/lib") 47 48if(NOT EXISTS ${MINGW_LIB}) 49 message(FATAL_ERROR "MinGW library directory does not exist: ${MINGW_LIB}") 50endif() 51 52# Add MinGW libraries to linker path. 53link_directories(${MINGW_LIB}) 54 55set(MINGW_INCLUDE "${MINGW_PATH}/include") 56 57if(NOT EXISTS ${MINGW_INCLUDE}) 58 message(FATAL_ERROR "MinGW include directory does not exist: ${MINGW_INCLUDE}") 59endif() 60 61# Add MinGW headers to compiler include path. 62include_directories(SYSTEM ${MINGW_INCLUDE}) 63 64set(MINGW_ARCH_LIB "${MINGW_ARCH_PATH}/lib") 65 66if(NOT EXISTS ${MINGW_ARCH_LIB}) 67 message(FATAL_ERROR "MinGW-w64 toolchain libraries directory does not exist: ${MINGW_ARCH_LIB}") 68endif() 69 70# Add MinGW toolchain libraries to linker path. 71link_directories(${MINGW_ARCH_LIB}) 72 73set(MINGW_ARCH_INCLUDE "${MINGW_ARCH_PATH}/include") 74 75if(NOT EXISTS ${MINGW_ARCH_INCLUDE}) 76 message(FATAL_ERROR "MinGW-w64 toolchain include directory does not exist: ${MINGW_ARCH_INCLUDE}") 77endif() 78 79# Add MinGW toolchain headers to compiler include path. 80include_directories(${MINGW_ARCH_INCLUDE}) 81 82# ----------------------------------------------------------------------------- 83# MSYS CHECKS 84# ----------------------------------------------------------------------------- 85 86# Somehow the MSYS variable does not work as documented.. 87if("${CMAKE_GENERATOR}" STREQUAL "MSYS Makefiles") 88 set(HAVE_MSYS ON) 89else() 90 set(HAVE_MSYS OFF) 91endif() 92 93# Set the path to the 'ar' utility for the MSYS shell as it fails to detect it properly. 94if(HAVE_MSYS) 95 message(STATUS "Configuring MSYS environment:") 96 97 if(NOT EXISTS ${CMAKE_AR}) 98 set(MINGW_AR ${MINGW_BIN}/ar.exe) 99 100 if(EXISTS ${MINGW_AR}) 101 set(CMAKE_AR ${MINGW_AR} CACHE FILEPATH "Archive Utility") 102 else() 103 message(FATAL_ERROR "ar.exe not found.") 104 endif() 105 106 message(STATUS " Setting path to ar.exe: ${CMAKE_AR}") 107 endif() 108endif() 109 110# ----------------------------------------------------------------------------- 111# LIBRARY AND LINKER SETTINGS 112# ----------------------------------------------------------------------------- 113 114# Tweak CMake into using Unix-style library names. 115set(CMAKE_FIND_LIBRARY_PREFIXES "lib") 116set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a" ".dll") 117