[FREELDR] debug.h: Add an explicit VOID parameter type (#4133)
[reactos.git] / toolchain-gcc.cmake
1
2 # pass variables necessary for the toolchain (needed for try_compile)
3 set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH)
4
5 # Choose the right MinGW toolchain prefix
6 if(NOT DEFINED MINGW_TOOLCHAIN_PREFIX)
7 if(ARCH STREQUAL "i386")
8
9 if(CMAKE_HOST_WIN32)
10 set(MINGW_TOOLCHAIN_PREFIX "" CACHE STRING "MinGW Toolchain Prefix")
11 else()
12 set(MINGW_TOOLCHAIN_PREFIX "i686-w64-mingw32-" CACHE STRING "MinGW-W64 Toolchain Prefix")
13 endif()
14
15 elseif(ARCH STREQUAL "amd64")
16 set(MINGW_TOOLCHAIN_PREFIX "x86_64-w64-mingw32-" CACHE STRING "MinGW Toolchain Prefix")
17 elseif(ARCH STREQUAL "arm")
18 set(MINGW_TOOLCHAIN_PREFIX "arm-mingw32ce-" CACHE STRING "MinGW Toolchain Prefix")
19 endif()
20 endif()
21
22 if(NOT DEFINED MINGW_TOOLCHAIN_SUFFIX)
23 set(MINGW_TOOLCHAIN_SUFFIX "" CACHE STRING "MinGW Toolchain Suffix")
24 endif()
25
26 # The name of the target operating system
27 set(CMAKE_SYSTEM_NAME Windows)
28 set(CMAKE_SYSTEM_PROCESSOR i686)
29
30 # Which tools to use
31 set(CMAKE_C_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX} CACHE FILEPATH "The C Compiler")
32 set(CMAKE_CXX_COMPILER ${MINGW_TOOLCHAIN_PREFIX}g++${MINGW_TOOLCHAIN_SUFFIX} CACHE FILEPATH "The C++ Compiler")
33 set(CMAKE_ASM_COMPILER ${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX} CACHE FILEPATH "The ASM Compiler")
34 set(CMAKE_ASM_COMPILER_ID "GNU")
35 set(CMAKE_MC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windmc)
36 set(CMAKE_RC_COMPILER ${MINGW_TOOLCHAIN_PREFIX}windres)
37 set(CMAKE_DLLTOOL ${MINGW_TOOLCHAIN_PREFIX}dlltool)
38 #set(CMAKE_AR ${MINGW_TOOLCHAIN_PREFIX}gcc-ar${MINGW_TOOLCHAIN_SUFFIX})
39 set(CMAKE_OBJCOPY ${MINGW_TOOLCHAIN_PREFIX}objcopy)
40
41 set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
42 set(CMAKE_CXX_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
43 set(CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
44
45 # Don't link with anything by default unless we say so
46 set(CMAKE_C_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries")
47
48 #MARK_AS_ADVANCED(CLEAR CMAKE_CXX_STANDARD_LIBRARIES)
49 set(CMAKE_CXX_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C++ Libraries")
50
51 # This allows to have CMake test the compiler without linking
52 set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
53
54 set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import")
55 set(CMAKE_MODULE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import")
56 set(CMAKE_EXE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import")
57
58 set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_DIR}/overrides-gcc.cmake")
59
60 # Get GCC version
61 execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)