1 cmake_minimum_required(VERSION 3.5)
2 project(esp-idf C CXX ASM)
5 unset(c_compile_options)
6 unset(cxx_compile_options)
7 unset(compile_definitions)
9 # Add the following build specifications here, since these seem to be dependent
10 # on config values on the root Kconfig.
12 if(CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE)
13 list(APPEND compile_options "-Os")
15 list(APPEND compile_options "-Og")
18 if(CONFIG_COMPILER_CXX_EXCEPTIONS)
19 list(APPEND cxx_compile_options "-fexceptions")
21 list(APPEND cxx_compile_options "-fno-exceptions")
24 if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
25 list(APPEND compile_options "-Wno-parentheses"
26 "-Wno-sizeof-pointer-memaccess"
29 # doesn't use GCC_NOT_5_2_0 because idf_set_global_variables was not called before
31 list(APPEND compile_options "-Wno-format-overflow"
32 "-Wno-stringop-truncation"
33 "-Wno-misleading-indentation"
34 "-Wno-cast-function-type"
35 "-Wno-implicit-fallthrough"
36 "-Wno-unused-const-variable"
37 "-Wno-switch-unreachable"
38 "-Wno-format-truncation"
39 "-Wno-memset-elt-size"
40 "-Wno-int-in-bool-context")
44 if(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE)
45 list(APPEND compile_definitions "-DNDEBUG")
48 if(CONFIG_COMPILER_STACK_CHECK_MODE_NORM)
49 list(APPEND compile_options "-fstack-protector")
50 elseif(CONFIG_COMPILER_STACK_CHECK_MODE_STRONG)
51 list(APPEND compile_options "-fstack-protector-strong")
52 elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
53 list(APPEND compile_options "-fstack-protector-all")
57 idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
58 idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
59 idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
60 idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
62 idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
64 # Add each component as a subdirectory, processing each component's CMakeLists.txt
65 foreach(component_target ${build_component_targets})
66 __component_get_property(dir ${component_target} COMPONENT_DIR)
67 __component_get_property(_name ${component_target} COMPONENT_NAME)
68 __component_get_property(prefix ${component_target} __PREFIX)
69 __component_get_property(alias ${component_target} COMPONENT_ALIAS)
70 set(COMPONENT_NAME ${_name})
71 set(COMPONENT_DIR ${dir})
72 set(COMPONENT_ALIAS ${alias})
73 set(COMPONENT_PATH ${dir}) # also deprecated, see comment in previous loop
74 idf_build_get_property(build_prefix __PREFIX)
75 set(__idf_component_context 1)
76 if(NOT prefix STREQUAL build_prefix)
77 add_subdirectory(${dir} ${prefix}_${_name})
79 add_subdirectory(${dir} ${_name})
81 set(__idf_component_context 0)