CMake: CXXFLAGS environment wasn't being read because C++ compiler was enabled after settings warnings.

pull/630/head
Brad House 1 year ago
parent ecf7a7f166
commit 33ee6c0573
  1. 14
      CMakeLists.txt
  2. 7
      test/CMakeLists.txt

@ -14,8 +14,6 @@ INCLUDE (CheckLibraryExists)
PROJECT (c-ares LANGUAGES C VERSION "1.22.1" )
INCLUDE (EnableWarnings)
# Set this version before release
SET (CARES_VERSION "${PROJECT_VERSION}")
@ -46,13 +44,23 @@ OPTION (CARES_SYMBOL_HIDING "Hide private symbols in shared libraries"
SET (CARES_RANDOM_FILE "/dev/urandom" CACHE STRING "Suitable File / Device Path for entropy, such as /dev/urandom")
# Tests require a C++ compiler
IF (CARES_BUILD_TESTS OR CARES_BUILD_CONTAINER_TESTS)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
enable_language(CXX)
ENDIF ()
# Tests require static to be enabled on Windows to be able to access otherwise hidden symbols
IF (CARES_BUILD_TESTS AND (NOT CARES_STATIC) AND WIN32)
IF ((CARES_BUILD_TESTS OR CARES_BUILD_CONTAINER_TESTS) AND (NOT CARES_STATIC) AND WIN32)
SET (CARES_STATIC ON)
SET (CARES_STATIC_PIC ON)
MESSAGE (WARNING "Static building was requested be disabled, but reenabled to support tests")
ENDIF ()
INCLUDE (EnableWarnings)
# allow linking against the static runtime library in msvc
IF (MSVC)
OPTION (CARES_MSVC_STATIC_RUNTIME "Link against the static runtime library" OFF)

@ -1,10 +1,5 @@
# Copyright (C) The c-ares project and its contributors
# SPDX-License-Identifier: MIT
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)
enable_language(CXX)
# Get rid of: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
IF (MSVC)
@ -25,8 +20,6 @@ target_include_directories(caresinternal
"${CMAKE_INSTALL_INCLUDEDIR}"
)
IF (CARES_STATIC)
target_link_libraries(caresinternal INTERFACE ${PROJECT_NAME}::cares_static)
ELSE ()

Loading…
Cancel
Save