Skip to content

Commit

Permalink
Fix STATIC_CRT option
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm committed Aug 30, 2023
1 parent 4dcc41c commit 500836e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: Apache-2.0.

cmake_minimum_required(VERSION 3.0)
option(STATIC_CRT "Windows specific option that to specify static/dynamic run-time library" OFF)
option(ALLOW_CROSS_COMPILED_TESTS "Allow tests to be compiled via cross compile, for use with qemu" OFF)

project(aws-c-common LANGUAGES C VERSION 0.1.0)
Expand Down
15 changes: 8 additions & 7 deletions cmake/AwsCFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ option(LEGACY_COMPILER_SUPPORT "This enables builds with compiler versions such
option(AWS_SUPPORT_WIN7 "Restricts WINAPI calls to Win7 and older (This will have implications in downstream libraries that use TLS especially)" OFF)
option(AWS_WARNINGS_ARE_ERRORS "Compiler warning is treated as an error. Try turning this off when observing errors on a new or uncommon compiler" OFF)
option(AWS_ENABLE_TRACING "Enable tracing macros" OFF)
option(STATIC_CRT "Windows-specific option to specify static/dynamic run-time library" OFF)

# Check for Posix Large Files Support (LFS).
# On most 64bit systems, LFS is enabled by default.
Expand Down Expand Up @@ -80,17 +81,17 @@ function(aws_set_common_properties target)
list(APPEND AWS_C_FLAGS /DAWS_SUPPORT_WIN7=1)
endif()

string(TOUPPER "${CMAKE_BUILD_TYPE}" _CMAKE_BUILD_TYPE)
if(STATIC_CRT)
string(REPLACE "/MD" "/MT" _FLAGS "${CMAKE_C_FLAGS_${_CMAKE_BUILD_TYPE}}")
# Set MSVC runtime libary.
# Note, there are better ways of doing this if we bump our CMake minimum to 3.14+
# See: https://cmake.org/cmake/help/latest/policy/CMP0091.html
if (STATIC_CRT)
list(APPEND AWS_C_FLAGS "/MT$<$<CONFIG:Debug>:d>")
else()
string(REPLACE "/MT" "/MD" _FLAGS "${CMAKE_C_FLAGS_${_CMAKE_BUILD_TYPE}}")
list(APPEND AWS_C_FLAGS "/MD$<$<CONFIG:Debug>:d>")
endif()
string(REPLACE " " ";" _FLAGS "${_FLAGS}")
list(APPEND AWS_C_FLAGS "${_FLAGS}")

else()
list(APPEND AWS_C_FLAGS -Wall -Wstrict-prototypes)
lisD(APPEND AWS_C_FLAGS -Wall -Wstrict-prototypes)

if (NOT CMAKE_BUILD_TYPE STREQUAL Release)
list(APPEND AWS_C_FLAGS -fno-omit-frame-pointer)
Expand Down

0 comments on commit 500836e

Please sign in to comment.