xref: /reactos/toolchain-clang.cmake (revision bbccad0e)
1
2if(DEFINED ENV{_ROSBE_ROSSCRIPTDIR})
3    set(CMAKE_SYSROOT $ENV{_ROSBE_ROSSCRIPTDIR}/$ENV{ROS_ARCH})
4endif()
5
6# pass variables necessary for the toolchain (needed for try_compile)
7set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES ARCH CLANG_VERSION)
8
9# The name of the target operating system
10set(CMAKE_SYSTEM_NAME Windows)
11# The processor we are targeting
12if (ARCH STREQUAL "i386")
13    set(CMAKE_SYSTEM_PROCESSOR i686)
14elseif (ARCH STREQUAL "amd64")
15    set(CMAKE_SYSTEM_PROCESSOR x86_64)
16elseif(ARCH STREQUAL "arm")
17    set(CMAKE_SYSTEM_PROCESSOR arm)
18else()
19    message(FATAL_ERROR "Unsupported ARCH: ${ARCH}")
20endif()
21
22if (DEFINED CLANG_VERSION)
23    set(CLANG_SUFFIX "-${CLANG_VERSION}")
24else()
25    set(CLANG_SUFFIX "")
26endif()
27
28# Which tools to use
29set(triplet ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32)
30if (CMAKE_HOST_WIN32)
31    set(GCC_TOOLCHAIN_PREFIX "")
32else()
33    set(GCC_TOOLCHAIN_PREFIX "${triplet}-")
34endif()
35
36set(CMAKE_C_COMPILER clang${CLANG_SUFFIX})
37set(CMAKE_C_COMPILER_TARGET ${triplet})
38set(CMAKE_CXX_COMPILER clang++${CLANG_SUFFIX})
39set(CMAKE_CXX_COMPILER_TARGET ${triplet})
40set(CMAKE_ASM_COMPILER ${GCC_TOOLCHAIN_PREFIX}gcc)
41set(CMAKE_ASM_COMPILER_ID GNU)
42set(CMAKE_MC_COMPILER ${GCC_TOOLCHAIN_PREFIX}windmc)
43set(CMAKE_RC_COMPILER ${GCC_TOOLCHAIN_PREFIX}windres)
44# set(CMAKE_AR ${triplet}-ar)
45# set(CMAKE_DLLTOOL ${triplet}-dlltool)
46
47# This allows to have CMake test the compiler without linking
48set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
49
50set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> crT <TARGET> <LINK_FLAGS> <OBJECTS>")
51set(CMAKE_CXX_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
52set(CMAKE_ASM_CREATE_STATIC_LIBRARY ${CMAKE_C_CREATE_STATIC_LIBRARY})
53
54set(CMAKE_C_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries")
55set(CMAKE_CXX_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C++ Libraries")
56
57find_program (LD_EXECUTABLE ${GCC_TOOLCHAIN_PREFIX}ld)
58message(STATUS "Using linker ${LD_EXECUTABLE}")
59
60set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${LD_EXECUTABLE}")
61set(CMAKE_MODULE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${LD_EXECUTABLE}")
62set(CMAKE_EXE_LINKER_FLAGS_INIT "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import -fuse-ld=${LD_EXECUTABLE}")
63
64set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_DIR}/overrides-gcc.cmake")
65