]> granicus.if.org Git - esp-idf/blob - CMakeLists.txt
Merge branch 'bugfix/fix_mesh_proxy_adv_with_wrong_dev_name' into 'master'
[esp-idf] / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.5)
2 project(esp-idf C CXX ASM)
3
4 unset(compile_options)
5 unset(c_compile_options)
6 unset(cxx_compile_options)
7 unset(compile_definitions)
8
9 # Add the following build specifications here, since these seem to be dependent
10 # on config values on the root Kconfig.
11
12 if(CONFIG_COMPILER_OPTIMIZATION_SIZE)
13     list(APPEND compile_options "-Os")
14     list(APPEND compile_options "-freorder-blocks")
15 elseif(CONFIG_COMPILER_OPTIMIZATION_DEFAULT)
16     list(APPEND compile_options "-Og")
17 elseif(CONFIG_COMPILER_OPTIMIZATION_NONE)
18     list(APPEND compile_options "-O0")
19 elseif(CONFIG_COMPILER_OPTIMIZATION_PERF)
20     list(APPEND compile_options "-O2")
21
22 endif()
23
24 if(CONFIG_COMPILER_CXX_EXCEPTIONS)
25     list(APPEND cxx_compile_options "-fexceptions")
26 else()
27     list(APPEND cxx_compile_options "-fno-exceptions")
28 endif()
29
30 if(CONFIG_COMPILER_CXX_RTTI)
31     list(APPEND cxx_compile_options "-frtti")
32 else()
33     list(APPEND cxx_compile_options "-fno-rtti")
34 endif()
35
36 if(CONFIG_COMPILER_DISABLE_GCC8_WARNINGS)
37     list(APPEND compile_options "-Wno-parentheses"
38                                 "-Wno-sizeof-pointer-memaccess"
39                                 "-Wno-clobbered")
40
41     # doesn't use GCC_NOT_5_2_0 because idf_set_global_variables was not called before
42     if(GCC_NOT_5_2_0)
43         list(APPEND compile_options "-Wno-format-overflow"
44                                     "-Wno-stringop-truncation"
45                                     "-Wno-misleading-indentation"
46                                     "-Wno-cast-function-type"
47                                     "-Wno-implicit-fallthrough"
48                                     "-Wno-unused-const-variable"
49                                     "-Wno-switch-unreachable"
50                                     "-Wno-format-truncation"
51                                     "-Wno-memset-elt-size"
52                                     "-Wno-int-in-bool-context")
53     endif()
54 endif()
55
56 if(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE)
57     list(APPEND compile_definitions "-DNDEBUG")
58 endif()
59
60 if(CONFIG_COMPILER_STACK_CHECK_MODE_NORM)
61     list(APPEND compile_options "-fstack-protector")
62 elseif(CONFIG_COMPILER_STACK_CHECK_MODE_STRONG)
63     list(APPEND compile_options "-fstack-protector-strong")
64 elseif(CONFIG_COMPILER_STACK_CHECK_MODE_ALL)
65     list(APPEND compile_options "-fstack-protector-all")
66 endif()
67
68
69 idf_build_set_property(COMPILE_OPTIONS "${compile_options}" APPEND)
70 idf_build_set_property(C_COMPILE_OPTIONS "${c_compile_options}" APPEND)
71 idf_build_set_property(CXX_COMPILE_OPTIONS "${cxx_compile_options}" APPEND)
72 idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND)
73
74 idf_build_get_property(build_component_targets __BUILD_COMPONENT_TARGETS)
75
76 # Add each component as a subdirectory, processing each component's CMakeLists.txt
77 foreach(component_target ${build_component_targets})
78     __component_get_property(dir ${component_target} COMPONENT_DIR)
79     __component_get_property(_name ${component_target} COMPONENT_NAME)
80     __component_get_property(prefix ${component_target} __PREFIX)
81     __component_get_property(alias ${component_target} COMPONENT_ALIAS)
82     set(COMPONENT_NAME ${_name})
83     set(COMPONENT_DIR ${dir})
84     set(COMPONENT_ALIAS ${alias})
85     set(COMPONENT_PATH ${dir}) # for backward compatibility only, COMPONENT_DIR is preferred
86     idf_build_get_property(build_prefix __PREFIX)
87     set(__idf_component_context 1)
88     if(NOT prefix STREQUAL build_prefix)
89         add_subdirectory(${dir} ${prefix}_${_name})
90     else()
91         add_subdirectory(${dir} ${_name})
92     endif()
93     set(__idf_component_context 0)
94 endforeach()