2011-05-16 13:12:07 +00:00
|
|
|
|
2022-05-13 22:33:14 +00:00
|
|
|
macro(require_program varname execname)
|
|
|
|
find_program(${varname} ${execname})
|
|
|
|
if(NOT ${varname})
|
|
|
|
message(FATAL_ERROR "${execname} not found")
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2021-04-15 01:50:12 +00:00
|
|
|
# pass variables necessary for the toolchain (needed for try_compile)
|
|
|
|
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH)
|
|
|
|
|
2011-09-18 00:57:17 +00:00
|
|
|
# Choose the right MinGW toolchain prefix
|
2020-05-26 18:24:02 +00:00
|
|
|
if(NOT DEFINED MINGW_TOOLCHAIN_PREFIX)
|
2012-08-27 18:58:27 +00:00
|
|
|
if(ARCH STREQUAL "i386")
|
2011-09-18 00:57:17 +00:00
|
|
|
|
2013-02-06 22:10:51 +00:00
|
|
|
if(CMAKE_HOST_WIN32)
|
2011-09-18 00:57:17 +00:00
|
|
|
set(MINGW_TOOLCHAIN_PREFIX "" CACHE STRING "MinGW Toolchain Prefix")
|
|
|
|
else()
|
2020-06-24 18:41:44 +00:00
|
|
|
set(MINGW_TOOLCHAIN_PREFIX "i686-w64-mingw32-" CACHE STRING "MinGW-W64 Toolchain Prefix")
|
2012-12-14 21:56:11 +00:00
|
|
|
endif()
|
2011-09-18 00:57:17 +00:00
|
|
|
|
2012-08-27 18:58:27 +00:00
|
|
|
elseif(ARCH STREQUAL "amd64")
|
2011-09-18 00:57:17 +00:00
|
|
|
set(MINGW_TOOLCHAIN_PREFIX "x86_64-w64-mingw32-" CACHE STRING "MinGW Toolchain Prefix")
|
2012-08-27 18:58:27 +00:00
|
|
|
elseif(ARCH STREQUAL "arm")
|
2011-09-18 00:57:17 +00:00
|
|
|
set(MINGW_TOOLCHAIN_PREFIX "arm-mingw32ce-" CACHE STRING "MinGW Toolchain Prefix")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-05-26 18:24:02 +00:00
|
|
|
if(NOT DEFINED MINGW_TOOLCHAIN_SUFFIX)
|
2011-09-18 00:57:17 +00:00
|
|
|
set(MINGW_TOOLCHAIN_SUFFIX "" CACHE STRING "MinGW Toolchain Suffix")
|
2011-05-16 13:12:07 +00:00
|
|
|
endif()
|
|
|
|
|
2011-06-13 10:36:40 +00:00
|
|
|
# The name of the target operating system
|
2011-05-16 13:12:07 +00:00
|
|
|
set(CMAKE_SYSTEM_NAME Windows)
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR i686)
|
|
|
|
|
2011-09-18 00:57:17 +00:00
|
|
|
# Which tools to use
|
2022-05-13 22:33:14 +00:00
|
|
|
require_program(CMAKE_C_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX})
|
|
|
|
require_program(CMAKE_CXX_COMPILER ${MINGW_TOOLCHAIN_PREFIX}g++${MINGW_TOOLCHAIN_SUFFIX})
|
|
|
|
require_program(CMAKE_ASM_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX})
|
2011-09-28 11:13:53 +00:00
|
|
|
set(CMAKE_ASM_COMPILER_ID "GNU")
|
2022-05-13 22:33:14 +00:00
|
|
|
require_program(CMAKE_MC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windmc)
|
|
|
|
require_program(CMAKE_RC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windres)
|
|
|
|
require_program(CMAKE_DLLTOOL ${MINGW_TOOLCHAIN_PREFIX}dlltool)
|
2014-08-15 11:17:16 +00:00
|
|
|
#set(CMAKE_AR ${MINGW_TOOLCHAIN_PREFIX}gcc-ar${MINGW_TOOLCHAIN_SUFFIX})
|
2022-05-13 22:33:14 +00:00
|
|
|
require_program(CMAKE_OBJCOPY ${MINGW_TOOLCHAIN_PREFIX}objcopy)
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2014-08-15 11:12:09 +00:00
|
|
|
set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
|
2013-11-02 13:56:47 +00:00
|
|
|
set(CMAKE_CXX_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
|
|
|
|
set(CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
|
2011-06-01 22:18:48 +00:00
|
|
|
|
2011-06-13 10:36:40 +00:00
|
|
|
# Don't link with anything by default unless we say so
|
2011-05-16 13:12:07 +00:00
|
|
|
set(CMAKE_C_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries")
|
|
|
|
|
|
|
|
#MARK_AS_ADVANCED(CLEAR CMAKE_CXX_STANDARD_LIBRARIES)
|
2014-02-02 11:11:53 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C++ Libraries")
|
2011-05-16 13:12:07 +00:00
|
|
|
|
2021-04-06 17:28:47 +00:00
|
|
|
# This allows to have CMake test the compiler without linking
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|
|
|
|
2011-09-18 00:57:17 +00:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import")
|
2019-03-20 13:19:48 +00:00
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import")
|
2021-04-06 17:23:31 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import")
|
2012-02-25 22:01:20 +00:00
|
|
|
|
2018-08-19 20:01:31 +00:00
|
|
|
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_DIR}/overrides-gcc.cmake")
|
|
|
|
|
2012-02-25 22:01:20 +00:00
|
|
|
# Get GCC version
|
|
|
|
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
|