| 1 |
# Add C or C++ compile definitions to the current scope |
| 2 |
# |
| 3 |
# dolphin_compile_definitions(def [def ...] [DEBUG_ONLY | RELEASE_ONLY]) |
| 4 |
# |
| 5 |
# Can optionally add the definitions to Debug or Release configurations only, use this so we can |
| 6 |
# target multi-configuration generators like Visual Studio or Xcode. |
| 7 |
# Release configurations means NOT Debug, so it will work for RelWithDebInfo or MinSizeRel too. |
| 8 |
# The definitions are added to the COMPILE_DEFINITIONS folder property. |
| 9 |
# Supports generator expressions, unlike add_definitions() |
| 10 |
# |
| 11 |
# Examples: |
| 12 |
# dolphin_compile_definitions(FOO) -> -DFOO |
| 13 |
# dolphin_compile_definitions(_DEBUG DEBUG_ONLY) -> -D_DEBUG |
| 14 |
# dolphin_compile_definitions(NDEBUG RELEASE_ONLY) -> -DNDEBUG |
| 15 |
# dolphin_compile_definitions($<$<COMPILE_LANGUAGE:C>:THISISONLYFORC>) |
| 16 |
|
| 17 |
function(dolphin_compile_definitions) |
| 18 |
set(defs ${ARGN}) |
| 19 |
|
| 20 |
list(GET defs -1 last_def) |
| 21 |
list(REMOVE_AT defs -1) |
| 22 |
|
| 23 |
set(genexp_config_test "1") |
| 24 |
if(last_def STREQUAL "DEBUG_ONLY") |
| 25 |
set(genexp_config_test "$<CONFIG:Debug>") |
| 26 |
elseif(last_def STREQUAL "RELEASE_ONLY") |
| 27 |
set(genexp_config_test "$<NOT:$<CONFIG:Debug>>") |
| 28 |
else() |
| 29 |
list(APPEND defs ${last_def}) |
| 30 |
endif() |
| 31 |
|
| 32 |
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS |
| 33 |
"$<${genexp_config_test}:${defs}>") |
| 34 |
endfunction() |