Skip to content

Commit

Permalink
Stop using CMAKE_BUILD_TYPE in CMake scripts (#628)
Browse files Browse the repository at this point in the history
CMake scripts should use `$<CONFIG>` generator expressions, instead of checking `${CMAKE_BUILD_TYPE}`. Multi-config generators like Visual Studio ignore `CMAKE_BUILD_TYPE`, so many users (and IDEs like VSCode with the CMake Tools plugin) don't bother setting `CMAKE_BUILD_TYPE`. See: https://cmake.org/cmake/help/v3.22/manual/cmake-buildsystem.7.html#build-configurations
  • Loading branch information
graebm authored Sep 1, 2023
1 parent c0f552c commit 1ddf4ab
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 25 deletions.
4 changes: 1 addition & 3 deletions devicedefender/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ else ()
target_compile_options(IotDeviceDefender-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(IotDeviceDefender-cpp PRIVATE "-DDEBUG_BUILD")
endif ()
target_compile_definitions(IotDeviceDefender-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(IotDeviceDefender-cpp PUBLIC "-DAWS_IOTDEVICEDEFENDER_USE_IMPORT_EXPORT")
Expand Down
4 changes: 1 addition & 3 deletions discovery/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ else ()
target_compile_options(Discovery-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(Discovery-cpp PRIVATE "-DDEBUG_BUILD")
endif ()
target_compile_definitions(Discovery-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(Discovery-cpp PUBLIC "-DAWS_DISCOVERY_USE_IMPORT_EXPORT")
Expand Down
4 changes: 1 addition & 3 deletions eventstream_rpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ else ()
target_compile_options(EventstreamRpc-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(EventstreamRpc-cpp PRIVATE "-DDEBUG_BUILD")
endif ()
target_compile_definitions(EventstreamRpc-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(EventstreamRpc-cpp PUBLIC "-DAWS_EVENTSTREAMRPC_USE_IMPORT_EXPORT")
Expand Down
5 changes: 1 addition & 4 deletions greengrass_ipc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ if (MSVC)
target_compile_options(GreengrassIpc-cpp PRIVATE /bigobj)
endif ()


if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(GreengrassIpc-cpp PRIVATE "-DDEBUG_BUILD")
endif ()
target_compile_definitions(GreengrassIpc-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(GreengrassIpc-cpp PUBLIC "-DAWS_GREENGRASSIPC_USE_IMPORT_EXPORT")
Expand Down
4 changes: 1 addition & 3 deletions identity/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ else ()
target_compile_options(IotIdentity-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(IotIdentity-cpp PRIVATE "-DDEBUG_BUILD")
endif ()
target_compile_definitions(IotIdentity-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(IotIdentity-cpp PUBLIC "-DAWS_IOTIDENTITY_USE_IMPORT_EXPORT")
Expand Down
4 changes: 1 addition & 3 deletions iotdevicecommon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ else ()
target_compile_options(IotDeviceCommon-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(IotDeviceCommon-cpp PRIVATE "-DDEBUG_BUILD")
endif ()
target_compile_definitions(IotDeviceCommon-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(IotDeviceCommon-cpp PUBLIC "-DAWS_IOTDEVICECOMMON_USE_IMPORT_EXPORT")
Expand Down
4 changes: 1 addition & 3 deletions secure_tunneling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ else ()
target_compile_options(IotSecureTunneling-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(IotSecureTunneling-cpp PRIVATE "-DDEBUG_BUILD")
endif ()
target_compile_definitions(IotSecureTunneling-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(IotSecureTunneling-cpp PUBLIC "-DAWS_IOTSECURETUNNELING_USE_IMPORT_EXPORT")
Expand Down
4 changes: 1 addition & 3 deletions shadow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ else ()
target_compile_options(IotShadow-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
endif ()

if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(IotShadow-cpp PRIVATE "-DDEBUG_BUILD")
endif ()
target_compile_definitions(IotShadow-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)

if (BUILD_SHARED_LIBS)
target_compile_definitions(IotShadow-cpp PUBLIC "-DAWS_IOTSHADOW_USE_IMPORT_EXPORT")
Expand Down

0 comments on commit 1ddf4ab

Please sign in to comment.