xref: /OK3568_Linux_fs/buildroot/support/misc/toolchainfile.cmake.in (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun# Automatically generated file; DO NOT EDIT.
3*4882a593Smuzhiyun# CMake toolchain file for Buildroot
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun# In order to allow the toolchain to be relocated, we calculate the
7*4882a593Smuzhiyun# HOST_DIR based on this file's location: $(HOST_DIR)/share/buildroot
8*4882a593Smuzhiyun# and store it in RELOCATED_HOST_DIR.
9*4882a593Smuzhiyun# All the other variables that need to refer to HOST_DIR will use the
10*4882a593Smuzhiyun# RELOCATED_HOST_DIR variable.
11*4882a593Smuzhiyunstring(REPLACE "/share/buildroot" "" RELOCATED_HOST_DIR @@RELOCATED_HOST_DIR@@)
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun# Point cmake to the location where we have our custom modules,
14*4882a593Smuzhiyun# so that it can find our custom platform description.
15*4882a593Smuzhiyunlist(APPEND CMAKE_MODULE_PATH @@RELOCATED_HOST_DIR@@)
16*4882a593Smuzhiyun
17*4882a593Smuzhiyunif(NOT DEFINED CMAKE_SYSTEM_NAME)
18*4882a593Smuzhiyun  set(CMAKE_SYSTEM_NAME Buildroot)
19*4882a593Smuzhiyunendif()
20*4882a593Smuzhiyunif(NOT DEFINED CMAKE_SYSTEM_VERSION)
21*4882a593Smuzhiyun  set(CMAKE_SYSTEM_VERSION 1)
22*4882a593Smuzhiyunendif()
23*4882a593Smuzhiyunif(NOT DEFINED CMAKE_SYSTEM_PROCESSOR)
24*4882a593Smuzhiyun  set(CMAKE_SYSTEM_PROCESSOR @@CMAKE_SYSTEM_PROCESSOR@@)
25*4882a593Smuzhiyunendif()
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun# Set the {C,CXX}FLAGS appended by CMake depending on the build type
28*4882a593Smuzhiyun# defined by Buildroot. CMake defaults these variables with -g and/or
29*4882a593Smuzhiyun# -O options, and they are appended at the end of the argument list,
30*4882a593Smuzhiyun# so the Buildroot options are overridden. Therefore these variables
31*4882a593Smuzhiyun# have to be cleared, so that the options passed in CMAKE_C_FLAGS do
32*4882a593Smuzhiyun# apply.
33*4882a593Smuzhiyun#
34*4882a593Smuzhiyun# Note:
35*4882a593Smuzhiyun#   if the project forces some of these flag variables, Buildroot is
36*4882a593Smuzhiyun#   screwed up and there is nothing Buildroot can do about that :(
37*4882a593Smuzhiyunif(NOT DEFINED CMAKE_C_FLAGS_DEBUG)
38*4882a593Smuzhiyun  set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "Debug CFLAGS")
39*4882a593Smuzhiyunendif()
40*4882a593Smuzhiyunif(NOT DEFINED CMAKE_C_FLAGS_RELEASE)
41*4882a593Smuzhiyun  set(CMAKE_C_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release CFLAGS")
42*4882a593Smuzhiyunendif()
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun# Build type from the Buildroot configuration
45*4882a593Smuzhiyunif(NOT DEFINED CMAKE_BUILD_TYPE)
46*4882a593Smuzhiyun  set(CMAKE_BUILD_TYPE @@CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
47*4882a593Smuzhiyunendif()
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun# Buildroot defaults flags.
50*4882a593Smuzhiyun# If you are using this toolchainfile.cmake file outside of Buildroot and
51*4882a593Smuzhiyun# want to customize the compiler/linker flags, then:
52*4882a593Smuzhiyun# * set them all on the cmake command line, e.g.:
53*4882a593Smuzhiyun#     cmake -DCMAKE_C_FLAGS="@@TARGET_CFLAGS@@ -Dsome_custom_flag" ...
54*4882a593Smuzhiyun# * and make sure the project's CMake code extends them like this if needed:
55*4882a593Smuzhiyun#     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dsome_definitions")
56*4882a593Smuzhiyunif(NOT DEFINED CMAKE_C_FLAGS)
57*4882a593Smuzhiyun  set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@" CACHE STRING "Buildroot CFLAGS")
58*4882a593Smuzhiyunendif()
59*4882a593Smuzhiyunif(NOT DEFINED CMAKE_EXE_LINKER_FLAGS)
60*4882a593Smuzhiyun  set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@" CACHE STRING "Buildroot LDFLAGS for executables")
61*4882a593Smuzhiyunendif()
62*4882a593Smuzhiyunif(NOT DEFINED CMAKE_SHARED_LINKER_FLAGS)
63*4882a593Smuzhiyun  set(CMAKE_SHARED_LINKER_FLAGS "@@TARGET_LDFLAGS@@" CACHE STRING "Buildroot LDFLAGS for shared libraries")
64*4882a593Smuzhiyunendif()
65*4882a593Smuzhiyunif(NOT DEFINED CMAKE_MODULE_LINKER_FLAGS)
66*4882a593Smuzhiyun  set(CMAKE_MODULE_LINKER_FLAGS "@@TARGET_LDFLAGS@@" CACHE STRING "Buildroot LDFLAGS for module libraries")
67*4882a593Smuzhiyunendif()
68*4882a593Smuzhiyun
69*4882a593Smuzhiyunif(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
70*4882a593Smuzhiyun  set(CMAKE_INSTALL_SO_NO_EXE 0)
71*4882a593Smuzhiyunendif()
72*4882a593Smuzhiyun
73*4882a593Smuzhiyunif(NOT DEFINED CMAKE_PROGRAM_PATH)
74*4882a593Smuzhiyun  set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/bin")
75*4882a593Smuzhiyunendif()
76*4882a593Smuzhiyunif(NOT DEFINED CMAKE_SYSROOT)
77*4882a593Smuzhiyun  set(CMAKE_SYSROOT "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
78*4882a593Smuzhiyunendif()
79*4882a593Smuzhiyunif(NOT DEFINED CMAKE_FIND_ROOT_PATH)
80*4882a593Smuzhiyun  set(CMAKE_FIND_ROOT_PATH "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
81*4882a593Smuzhiyunendif()
82*4882a593Smuzhiyunif(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
83*4882a593Smuzhiyun  set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
84*4882a593Smuzhiyunendif()
85*4882a593Smuzhiyunif(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
86*4882a593Smuzhiyun  set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
87*4882a593Smuzhiyunendif()
88*4882a593Smuzhiyunif(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
89*4882a593Smuzhiyun  set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
90*4882a593Smuzhiyunendif()
91*4882a593Smuzhiyunif(NOT DEFINED CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
92*4882a593Smuzhiyun  set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
93*4882a593Smuzhiyunendif()
94*4882a593Smuzhiyunset(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
95*4882a593Smuzhiyun
96*4882a593Smuzhiyun# This toolchain file can be used both inside and outside Buildroot.
97*4882a593Smuzhiyunif(NOT DEFINED CMAKE_C_COMPILER)
98*4882a593Smuzhiyun  set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
99*4882a593Smuzhiyunendif()
100*4882a593Smuzhiyunif(@@TOOLCHAIN_HAS_CXX@@)
101*4882a593Smuzhiyun  if(NOT DEFINED CMAKE_CXX_FLAGS_DEBUG)
102*4882a593Smuzhiyun    set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "Debug CXXFLAGS")
103*4882a593Smuzhiyun  endif()
104*4882a593Smuzhiyun  if(NOT DEFINED CMAKE_CXX_FLAGS_RELEASE)
105*4882a593Smuzhiyun    set(CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release CXXFLAGS")
106*4882a593Smuzhiyun  endif()
107*4882a593Smuzhiyun  if(NOT DEFINED CMAKE_CXX_FLAGS)
108*4882a593Smuzhiyun    set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@" CACHE STRING "Buildroot CXXFLAGS")
109*4882a593Smuzhiyun  endif()
110*4882a593Smuzhiyun  if(NOT DEFINED CMAKE_CXX_COMPILER)
111*4882a593Smuzhiyun    set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
112*4882a593Smuzhiyun  endif()
113*4882a593Smuzhiyunendif()
114*4882a593Smuzhiyunif(@@TOOLCHAIN_HAS_FORTRAN@@)
115*4882a593Smuzhiyun  if(NOT DEFINED CMAKE_Fortran_FLAGS_DEBUG)
116*4882a593Smuzhiyun    set(CMAKE_Fortran_FLAGS_DEBUG "" CACHE STRING "Debug Fortran FLAGS")
117*4882a593Smuzhiyun  endif()
118*4882a593Smuzhiyun  if(NOT DEFINED CMAKE_Fortran_FLAGS_RELEASE)
119*4882a593Smuzhiyun    set(CMAKE_Fortran_FLAGS_RELEASE " -DNDEBUG" CACHE STRING "Release Fortran FLAGS")
120*4882a593Smuzhiyun  endif()
121*4882a593Smuzhiyun  if(NOT DEFINED CMAKE_Fortran_FLAGS)
122*4882a593Smuzhiyun    set(CMAKE_Fortran_FLAGS "@@TARGET_FCFLAGS@@" CACHE STRING "Buildroot FCFLAGS")
123*4882a593Smuzhiyun  endif()
124*4882a593Smuzhiyun  if(NOT DEFINED CMAKE_Fortran_COMPILER)
125*4882a593Smuzhiyun    set(CMAKE_Fortran_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_FC@@")
126*4882a593Smuzhiyun  endif()
127*4882a593Smuzhiyunendif()
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun# For Qt6
130*4882a593Smuzhiyunif(NOT DEFINED QT_HOST_PATH)
131*4882a593Smuzhiyun  set(QT_HOST_PATH "${RELOCATED_HOST_DIR}")
132*4882a593Smuzhiyunendif()
133*4882a593Smuzhiyun
134*4882a593Smuzhiyunif(NOT DEFINED QT_HOST_PATH_CMAKE_DIR)
135*4882a593Smuzhiyun  set(QT_HOST_PATH_CMAKE_DIR "${RELOCATED_HOST_DIR}/lib/cmake")
136*4882a593Smuzhiyunendif()
137*4882a593Smuzhiyun
138*4882a593Smuzhiyunset(CMAKE_AR "${RELOCATED_HOST_DIR}/@@TARGET_AR@@")
139*4882a593Smuzhiyunset(CMAKE_AS "${RELOCATED_HOST_DIR}/@@TARGET_AS@@")
140*4882a593Smuzhiyunset(CMAKE_LINKER "${RELOCATED_HOST_DIR}/@@TARGET_LD@@")
141*4882a593Smuzhiyunset(CMAKE_NM "${RELOCATED_HOST_DIR}/@@TARGET_NM@@")
142*4882a593Smuzhiyunset(CMAKE_RANLIB "${RELOCATED_HOST_DIR}/@@TARGET_RANLIB@@")
143*4882a593Smuzhiyunset(CMAKE_READELF "${RELOCATED_HOST_DIR}/@@TARGET_READELF@@")
144*4882a593Smuzhiyunset(CMAKE_STRIP "${RELOCATED_HOST_DIR}/@@TARGET_STRIP@@")
145*4882a593Smuzhiyunset(CMAKE_OBJCOPY "${RELOCATED_HOST_DIR}/@@TARGET_OBJCOPY@@")
146*4882a593Smuzhiyunset(CMAKE_OBJDUMP "${RELOCATED_HOST_DIR}/@@TARGET_OBJDUMP@@")
147