| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  | cmake_minimum_required(VERSION 3.5)
 | 
					
						
							|  |  |  | project(esp-idf C CXX ASM)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-07 17:39:36 +08:00
										 |  |  | if(CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR)
 | 
					
						
							|  |  |  |     message(FATAL_ERROR "Current directory '${CMAKE_CURRENT_LIST_DIR}' is not buildable. " | 
					
						
							|  |  |  |     "Change directories to one of the example projects in '${CMAKE_CURRENT_LIST_DIR}/examples' and try "
 | 
					
						
							|  |  |  |     "again.")
 | 
					
						
							|  |  |  | endif()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  | unset(compile_options)
 | 
					
						
							|  |  |  | unset(c_compile_options)
 | 
					
						
							|  |  |  | unset(cxx_compile_options)
 | 
					
						
							|  |  |  | unset(compile_definitions)
 | 
					
						
							| 
									
										
										
										
											2019-11-20 14:18:28 +01:00
										 |  |  | unset(link_options)
 | 
					
						
							| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  | # Add the following build specifications here, since these seem to be dependent
 | 
					
						
							|  |  |  | # on config values on the root Kconfig.
 | 
					
						
							| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-26 14:19:32 +11:00
										 |  |  | if(NOT BOOTLOADER_BUILD)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(CONFIG_COMPILER_OPTIMIZATION_SIZE)
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-Os")
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-freorder-blocks")
 | 
					
						
							|  |  |  |     elseif(CONFIG_COMPILER_OPTIMIZATION_DEFAULT)
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-Og")
 | 
					
						
							|  |  |  |     elseif(CONFIG_COMPILER_OPTIMIZATION_NONE)
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-O0")
 | 
					
						
							|  |  |  |     elseif(CONFIG_COMPILER_OPTIMIZATION_PERF)
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-O2")
 | 
					
						
							|  |  |  |     endif()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | else()  # BOOTLOADER_BUILD
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE)
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-Os")
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-freorder-blocks")
 | 
					
						
							|  |  |  |     elseif(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG)
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-Og")
 | 
					
						
							|  |  |  |     elseif(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE)
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-O0")
 | 
					
						
							|  |  |  |     elseif(CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF)
 | 
					
						
							|  |  |  |         list(APPEND compile_options "-O2")
 | 
					
						
							|  |  |  |     endif()
 | 
					
						
							| 
									
										
										
										
											2019-09-03 13:12:58 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  | endif()
 | 
					
						
							| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-24 15:02:25 +02:00
										 |  |  | if(CONFIG_COMPILER_CXX_EXCEPTIONS)
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  |     list(APPEND cxx_compile_options "-fexceptions")
 | 
					
						
							|  |  |  | else()
 | 
					
						
							|  |  |  |     list(APPEND cxx_compile_options "-fno-exceptions")
 | 
					
						
							| 
									
										
										
										
											2018-12-13 13:48:34 +08:00
										 |  |  | endif()
 | 
					
						
							| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-06 16:53:26 +08:00
										 |  |  | if(CONFIG_COMPILER_CXX_RTTI)
 | 
					
						
							|  |  |  |     list(APPEND cxx_compile_options "-frtti")
 | 
					
						
							|  |  |  | else()
 | 
					
						
							|  |  |  |     list(APPEND cxx_compile_options "-fno-rtti")
 | 
					
						
							| 
									
										
										
										
											2019-11-21 10:41:34 +01:00
										 |  |  |     list(APPEND link_options "-fno-rtti")           # used to invoke correct multilib variant (no-rtti) during linking
 | 
					
						
							| 
									
										
										
										
											2019-06-06 16:53:26 +08:00
										 |  |  | endif()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-24 15:02:25 +02:00
										 |  |  | if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  |     list(APPEND compile_options "-Wno-parentheses" | 
					
						
							|  |  |  |                                 "-Wno-sizeof-pointer-memaccess"
 | 
					
						
							|  |  |  |                                 "-Wno-clobbered")
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-05 12:20:26 +01:00
										 |  |  |     list(APPEND compile_options "-Wno-format-overflow" | 
					
						
							|  |  |  |                                 "-Wno-stringop-truncation"
 | 
					
						
							|  |  |  |                                 "-Wno-misleading-indentation"
 | 
					
						
							|  |  |  |                                 "-Wno-cast-function-type"
 | 
					
						
							|  |  |  |                                 "-Wno-implicit-fallthrough"
 | 
					
						
							|  |  |  |                                 "-Wno-unused-const-variable"
 | 
					
						
							|  |  |  |                                 "-Wno-switch-unreachable"
 | 
					
						
							|  |  |  |                                 "-Wno-format-truncation"
 | 
					
						
							|  |  |  |                                 "-Wno-memset-elt-size"
 | 
					
						
							|  |  |  |                                 "-Wno-int-in-bool-context")
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  | endif()
 | 
					
						
							| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-24 15:02:25 +02:00
										 |  |  | if(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE)
 | 
					
						
							| 
									
										
										
										
											2019-06-07 21:23:42 +08:00
										 |  |  |     list(APPEND compile_definitions "-DNDEBUG")
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  | endif()
 | 
					
						
							| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-24 15:02:25 +02:00
										 |  |  | if(CONFIG_COMPILER_STACK_CHECK_MODE_NORM)
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  |     list(APPEND compile_options "-fstack-protector")
 | 
					
						
							| 
									
										
										
										
											2019-04-24 15:02:25 +02:00
										 |  |  | elseif(CONFIG_COMPILER_STACK_CHECK_MODE_STRONG)
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  |     list(APPEND compile_options "-fstack-protector-strong")
 | 
					
						
							| 
									
										
										
										
											2019-04-24 15:02:25 +02:00
										 |  |  | elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  |     list(APPEND compile_options "-fstack-protector-all")
 | 
					
						
							|  |  |  | endif()
 | 
					
						
							| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-20 14:18:28 +01:00
										 |  |  | list(APPEND link_options "-fno-lto")
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
 | 
					
						
							|  |  |  | idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
 | 
					
						
							|  |  |  | idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
 | 
					
						
							|  |  |  | idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
 | 
					
						
							| 
									
										
										
										
											2019-11-20 14:18:28 +01:00
										 |  |  | idf_build_set_property(LINK_OPTIONS "${link_options}" APPEND)
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Add each component as a subdirectory, processing each component's CMakeLists.txt
 | 
					
						
							|  |  |  | foreach(component_target ${build_component_targets})
 | 
					
						
							|  |  |  |     __component_get_property(dir ${component_target} COMPONENT_DIR)
 | 
					
						
							|  |  |  |     __component_get_property(_name ${component_target} COMPONENT_NAME)
 | 
					
						
							|  |  |  |     __component_get_property(prefix ${component_target} __PREFIX)
 | 
					
						
							|  |  |  |     __component_get_property(alias ${component_target} COMPONENT_ALIAS)
 | 
					
						
							|  |  |  |     set(COMPONENT_NAME ${_name})
 | 
					
						
							|  |  |  |     set(COMPONENT_DIR ${dir})
 | 
					
						
							|  |  |  |     set(COMPONENT_ALIAS ${alias})
 | 
					
						
							| 
									
										
										
										
											2019-07-12 16:02:47 +08:00
										 |  |  |     set(COMPONENT_PATH ${dir}) # for backward compatibility only, COMPONENT_DIR is preferred
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  |     idf_build_get_property(build_prefix __PREFIX)
 | 
					
						
							|  |  |  |     set(__idf_component_context 1)
 | 
					
						
							|  |  |  |     if(NOT prefix STREQUAL build_prefix)
 | 
					
						
							| 
									
										
										
										
											2019-05-31 15:27:11 +08:00
										 |  |  |         add_subdirectory(${dir} ${prefix}_${_name})
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  |     else()
 | 
					
						
							| 
									
										
										
										
											2019-05-31 15:27:11 +08:00
										 |  |  |         add_subdirectory(${dir} ${_name})
 | 
					
						
							| 
									
										
										
										
											2018-11-11 15:36:10 +08:00
										 |  |  |     endif()
 | 
					
						
							| 
									
										
										
										
											2019-04-26 13:42:10 +08:00
										 |  |  |     set(__idf_component_context 0)
 | 
					
						
							| 
									
										
										
										
											2019-07-04 11:02:20 +04:00
										 |  |  | endforeach()
 |