- tidy up two `MATCHES` expression by avoiding macros expansion and adding quotes. Then convert then to `STREQUAL` to match other places in the code doing the same checks. - fix setting `_ALL_SOURCE` for AIX to match what autotools does. - delete stray `_ALL_SOURCE` reference from `lib/config_riscos.h` - simplify/fix two `STREQUAL ""` checks. The one in the `openssl_check_symbol_exists()` macro succeeded regardless of the value. The other could return TRUE when `CMAKE_OSX_SYSROOT` was undefined. - delete code for CMake versions (<3.7) we no longer support. - prefer `LIST(APPEND ...)` to extend `CURL_LIBS`. - use `CURL_LIBS` to add the `network` lib for Haiku. Before this patch it was done via raw C flags. I could not test this. - move `_WIN32_WINNT`-related code next to each other. It also moves detection to the top, allowing more code to use the result. - merge two `WIN32` blocks. - rename internal variables to underscore + lowercase. - unwrap a line, indent, whitespace. Closes #14450
81 lines
3.3 KiB
CMake
81 lines
3.3 KiB
CMake
#***************************************************************************
|
|
# _ _ ____ _
|
|
# Project ___| | | | _ \| |
|
|
# / __| | | | |_) | |
|
|
# | (__| |_| | _ <| |___
|
|
# \___|\___/|_| \_\_____|
|
|
#
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
#
|
|
# This software is licensed as described in the file COPYING, which
|
|
# you should have received as part of this distribution. The terms
|
|
# are also available at https://curl.se/docs/copyright.html.
|
|
#
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
#
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
# KIND, either express or implied.
|
|
#
|
|
# SPDX-License-Identifier: curl
|
|
#
|
|
###########################################################################
|
|
include(CheckCSourceCompiles)
|
|
|
|
option(CURL_HIDDEN_SYMBOLS "Set to ON to hide libcurl internal symbols (=hide all symbols that are not officially external)." ON)
|
|
mark_as_advanced(CURL_HIDDEN_SYMBOLS)
|
|
|
|
if(WIN32 AND (ENABLE_DEBUG OR ENABLE_CURLDEBUG))
|
|
# We need to export internal debug functions,
|
|
# e.g. curl_easy_perform_ev() or curl_dbg_*(),
|
|
# so disable symbol hiding for debug builds and for memory tracking.
|
|
set(CURL_HIDDEN_SYMBOLS OFF)
|
|
endif()
|
|
|
|
if(CURL_HIDDEN_SYMBOLS)
|
|
set(_supports_symbol_hiding FALSE)
|
|
|
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT MSVC)
|
|
set(_supports_symbol_hiding TRUE)
|
|
set(_symbol_extern "__attribute__ ((__visibility__ (\"default\")))")
|
|
set(_cflag_symbols_hide "-fvisibility=hidden")
|
|
elseif(CMAKE_COMPILER_IS_GNUCC)
|
|
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4)
|
|
# Note: This is considered buggy prior to 4.0 but the autotools do not care, so let us ignore that fact
|
|
set(_supports_symbol_hiding TRUE)
|
|
set(_symbol_extern "__attribute__ ((__visibility__ (\"default\")))")
|
|
set(_cflag_symbols_hide "-fvisibility=hidden")
|
|
endif()
|
|
elseif(CMAKE_C_COMPILER_ID MATCHES "SunPro" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0)
|
|
set(_supports_symbol_hiding TRUE)
|
|
set(_symbol_extern "__global")
|
|
set(_cflag_symbols_hide "-xldscope=hidden")
|
|
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0)
|
|
# Note: This should probably just check for version 9.1.045 but I am not 100% sure
|
|
# so let us do it the same way autotools do.
|
|
set(_supports_symbol_hiding TRUE)
|
|
set(_symbol_extern "__attribute__ ((__visibility__ (\"default\")))")
|
|
set(_cflag_symbols_hide "-fvisibility=hidden")
|
|
check_c_source_compiles("#include <stdio.h>
|
|
int main(void) { printf(\"icc fvisibility bug test\"); return 0; }" _no_bug)
|
|
if(NOT _no_bug)
|
|
set(_supports_symbol_hiding FALSE)
|
|
set(_symbol_extern "")
|
|
set(_cflag_symbols_hide "")
|
|
endif()
|
|
elseif(MSVC)
|
|
set(_supports_symbol_hiding TRUE)
|
|
endif()
|
|
|
|
set(HIDES_CURL_PRIVATE_SYMBOLS ${_supports_symbol_hiding})
|
|
else()
|
|
if(MSVC)
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
|
endif()
|
|
set(HIDES_CURL_PRIVATE_SYMBOLS FALSE)
|
|
endif()
|
|
|
|
set(CURL_CFLAG_SYMBOLS_HIDE ${_cflag_symbols_hide})
|
|
set(CURL_EXTERN_SYMBOL ${_symbol_extern})
|