Skip to content

Commit 52b2d39

Browse files
stephanosionashif
authored andcommitted
cmake: extensions: Add corresponding ifndef for all ifdef functions
This commit adds the corresponding '_ifndef' functions for all the existing '_ifdef' functions. Signed-off-by: Stephanos Ioannidis <[email protected]>
1 parent 877239a commit 52b2d39

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

cmake/extensions.cmake

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,48 @@ function(set_ifndef variable value)
14851485
endif()
14861486
endfunction()
14871487

1488+
function(add_subdirectory_ifndef feature_toggle source_dir)
1489+
if(NOT ${feature_toggle})
1490+
add_subdirectory(${source_dir} ${ARGN})
1491+
endif()
1492+
endfunction()
1493+
1494+
function(target_sources_ifndef feature_toggle target scope item)
1495+
if(NOT ${feature_toggle})
1496+
target_sources(${target} ${scope} ${item} ${ARGN})
1497+
endif()
1498+
endfunction()
1499+
1500+
function(target_compile_definitions_ifndef feature_toggle target scope item)
1501+
if(NOT ${feature_toggle})
1502+
target_compile_definitions(${target} ${scope} ${item} ${ARGN})
1503+
endif()
1504+
endfunction()
1505+
1506+
function(target_include_directories_ifndef feature_toggle target scope item)
1507+
if(NOT ${feature_toggle})
1508+
target_include_directories(${target} ${scope} ${item} ${ARGN})
1509+
endif()
1510+
endfunction()
1511+
1512+
function(target_link_libraries_ifndef feature_toggle target item)
1513+
if(NOT ${feature_toggle})
1514+
target_link_libraries(${target} ${item} ${ARGN})
1515+
endif()
1516+
endfunction()
1517+
1518+
function(add_compile_option_ifndef feature_toggle option)
1519+
if(NOT ${feature_toggle})
1520+
add_compile_options(${option})
1521+
endif()
1522+
endfunction()
1523+
1524+
function(target_compile_option_ifndef feature_toggle target scope option)
1525+
if(NOT ${feature_toggle})
1526+
target_compile_options(${target} ${scope} ${option})
1527+
endif()
1528+
endfunction()
1529+
14881530
function(target_cc_option_ifndef feature_toggle target scope option)
14891531
if(NOT ${feature_toggle})
14901532
target_cc_option(${target} ${scope} ${option})
@@ -1509,12 +1551,78 @@ function(zephyr_cc_option_ifndef feature_toggle)
15091551
endif()
15101552
endfunction()
15111553

1554+
function(zephyr_ld_option_ifndef feature_toggle)
1555+
if(NOT ${feature_toggle})
1556+
zephyr_ld_options(${ARGN})
1557+
endif()
1558+
endfunction()
1559+
1560+
function(zephyr_link_libraries_ifndef feature_toggle)
1561+
if(NOT ${feature_toggle})
1562+
zephyr_link_libraries(${ARGN})
1563+
endif()
1564+
endfunction()
1565+
15121566
function(zephyr_compile_options_ifndef feature_toggle)
15131567
if(NOT ${feature_toggle})
15141568
zephyr_compile_options(${ARGN})
15151569
endif()
15161570
endfunction()
15171571

1572+
function(zephyr_compile_definitions_ifndef feature_toggle)
1573+
if(NOT ${feature_toggle})
1574+
zephyr_compile_definitions(${ARGN})
1575+
endif()
1576+
endfunction()
1577+
1578+
function(zephyr_include_directories_ifndef feature_toggle)
1579+
if(NOT ${feature_toggle})
1580+
zephyr_include_directories(${ARGN})
1581+
endif()
1582+
endfunction()
1583+
1584+
function(zephyr_library_compile_definitions_ifndef feature_toggle item)
1585+
if(NOT ${feature_toggle})
1586+
zephyr_library_compile_definitions(${item} ${ARGN})
1587+
endif()
1588+
endfunction()
1589+
1590+
function(zephyr_library_include_directories_ifndef feature_toggle)
1591+
if(NOT ${feature_toggle})
1592+
zephyr_library_include_directories(${ARGN})
1593+
endif()
1594+
endfunction()
1595+
1596+
function(zephyr_library_compile_options_ifndef feature_toggle item)
1597+
if(NOT ${feature_toggle})
1598+
zephyr_library_compile_options(${item} ${ARGN})
1599+
endif()
1600+
endfunction()
1601+
1602+
function(zephyr_link_interface_ifndef feature_toggle interface)
1603+
if(NOT ${feature_toggle})
1604+
target_link_libraries(${interface} INTERFACE zephyr_interface)
1605+
endif()
1606+
endfunction()
1607+
1608+
function(zephyr_library_link_libraries_ifndef feature_toggle item)
1609+
if(NOT ${feature_toggle})
1610+
zephyr_library_link_libraries(${item})
1611+
endif()
1612+
endfunction()
1613+
1614+
function(zephyr_linker_sources_ifndef feature_toggle)
1615+
if(NOT ${feature_toggle})
1616+
zephyr_linker_sources(${ARGN})
1617+
endif()
1618+
endfunction()
1619+
1620+
macro(list_append_ifndef feature_toggle list)
1621+
if(NOT ${feature_toggle})
1622+
list(APPEND ${list} ${ARGN})
1623+
endif()
1624+
endmacro()
1625+
15181626
# 3.3. *_option Compiler-compatibility checks
15191627
#
15201628
# Utility functions for silently omitting compiler flags when the

0 commit comments

Comments
 (0)