Clean up Windows build (#2562)

* APR_DECLARE_STATIC and APU_DECLARE_STATIC gets already defined in APR.cmake
* Move both _CRT_SECURE_NO_WARNINGS and _WINSOCK_DEPRECATED_NO_WARNINGS definitions to 00-Common.cmake
* Always define WIN32_LEAN_AND_MEAN and include subset of Windows API by default
* Remove llwin32headerslean.h and remove unnecessary WIN32_LEAN_AND_MEAN definition handling in llwin32headers.h
* Clean up includes of Windows API headers
* Get rid of workaround to link against IPHLPAPI.lib in lluuid.cpp - this seems to have been an issue in the past that has been fixed
master
Ansariel Hiller 2024-09-13 16:28:48 +02:00 committed by GitHub
parent c892ce9f5c
commit 74205607b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 31 additions and 104 deletions

View File

@ -68,9 +68,12 @@ if (WINDOWS)
/NODEFAULTLIB:LIBCMT
/IGNORE:4099)
add_definitions(
-DNOMINMAX
# /DDOM_DYNAMIC # For shared library colladadom
add_compile_definitions(
WIN32_LEAN_AND_MEAN
NOMINMAX
# DOM_DYNAMIC # For shared library colladadom
_CRT_SECURE_NO_WARNINGS # Allow use of sprintf etc
_WINSOCK_DEPRECATED_NO_WARNINGS # Disable deprecated WinSock API warnings
)
add_compile_options(
/Zo
@ -106,9 +109,6 @@ if (WINDOWS)
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
endif()
# Allow use of sprintf etc
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif (WINDOWS)

View File

@ -240,7 +240,6 @@ set(llcommon_HEADER_FILES
lluriparser.h
lluuid.h
llwin32headers.h
llwin32headerslean.h
llworkerthread.h
hbxxh.h
lockstatic.h

View File

@ -34,7 +34,7 @@
#endif
#include <boost/noncopyable.hpp>
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include "apr_thread_proc.h"
#include "apr_getopt.h"
#include "apr_signal.h"

View File

@ -34,7 +34,7 @@
#include "stringize.h"
#if LL_WINDOWS
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include <stdlib.h> // Windows errno
#include <vector>
#else

View File

@ -98,15 +98,6 @@
# define LL_THREAD_LOCAL __thread
#endif
// Static linking with apr on windows needs to be declared.
#if LL_WINDOWS && !LL_COMMON_LINK_SHARED
#ifndef APR_DECLARE_STATIC
#define APR_DECLARE_STATIC // For APR on Windows
#endif
#ifndef APU_DECLARE_STATIC
#define APU_DECLARE_STATIC // For APR util on Windows
#endif
#endif
#if defined(LL_WINDOWS)
#define BOOST_REGEX_NO_LIB 1
@ -119,13 +110,6 @@
// Deal with VC++ problems
#if LL_MSVC
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS // disable warnings for methods considered unsafe
#endif
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS // disable deprecated WinSock API warnings
#endif
// level 4 warnings that we need to disable:
#pragma warning (disable : 4251) // member needs to have dll-interface to be used by clients of class
#pragma warning (disable : 4275) // non dll-interface class used as base for dll-interface class

View File

@ -29,7 +29,6 @@
#include "llinitparam.h"
#include "llsdparam.h"
#include "llwin32headerslean.h"
#include "llexception.h"
#include "apr_thread_proc.h"
#include <boost/ptr_container/ptr_vector.hpp>
@ -38,7 +37,7 @@
#include <iosfwd> // std::ostream
#if LL_WINDOWS
#include "llwin32headerslean.h" // for HANDLE
#include "llwin32headers.h" // for HANDLE
#elif LL_LINUX
#if defined(Status)
#undef Status

View File

@ -34,7 +34,7 @@
//#include <memory>
#if LL_WINDOWS
# include "llwin32headerslean.h"
# include "llwin32headers.h"
# define _interlockedbittestandset _renamed_interlockedbittestandset
# define _interlockedbittestandreset _renamed_interlockedbittestandreset
# include <intrin.h>

View File

@ -32,8 +32,7 @@
#include <sstream>
#if LL_WINDOWS
# define WIN32_LEAN_AND_MEAN
# include <winsock2.h> // for htonl
# include "llwin32headers.h" // for htonl
#elif LL_LINUX
# include <netinet/in.h>
#elif LL_DARWIN

View File

@ -32,7 +32,7 @@
#include <iostream>
#include <sstream>
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include <dbghelp.h>
typedef USHORT NTAPI RtlCaptureStackBackTrace_Function(

View File

@ -33,8 +33,7 @@
#include <vector>
#if LL_WINDOWS
#include "llwin32headerslean.h"
#include <winnls.h> // for WideCharToMultiByte
#include "llwin32headers.h"
#endif
std::string ll_safe_string(const char* in)

View File

@ -59,7 +59,7 @@
using namespace llsd;
#if LL_WINDOWS
# include "llwin32headerslean.h"
# include "llwin32headers.h"
# include <psapi.h> // GetPerformanceInfo() et al.
# include <VersionHelpers.h>
#elif LL_DARWIN

View File

@ -34,7 +34,7 @@
#include <thread>
#if LL_WINDOWS
# include "llwin32headerslean.h"
# include "llwin32headers.h"
#elif LL_LINUX || LL_DARWIN
# include <errno.h>
# include <sys/time.h>

View File

@ -25,11 +25,8 @@
#include "linden_common.h"
// We can't use WIN32_LEAN_AND_MEAN here, needs lots of includes.
#if LL_WINDOWS
#include "llwin32headers.h"
// ugh, this is ugly. We need to straighten out our linking for this library
#pragma comment(lib, "IPHLPAPI.lib")
#include <iphlpapi.h>
#include <nb30.h>
#endif

View File

@ -28,15 +28,8 @@
#define LL_LLWINDOWS_H
#ifdef LL_WINDOWS
#ifndef NOMINMAX
#define NOMINMAX
#endif
#undef WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
// reset to default, which is lean
#define WIN32_LEAN_AND_MEAN
#undef NOMINMAX
#include <windows.h> // Does not include winsock.h because WIN32_LEAN_AND_MEAN is defined
#include <winsock2.h> // Requires windows.h
#endif
#endif

View File

@ -1,40 +0,0 @@
/**
* @file llwin32headerslean.h
* @brief sanitized include of windows header files
*
* $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#ifndef LL_LLWINDOWS_H
#define LL_LLWINDOWS_H
#ifdef LL_WINDOWS
#ifndef NOMINMAX
#define NOMINMAX
#endif
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <windows.h>
#undef NOMINMAX
#endif
#endif

View File

@ -38,8 +38,7 @@
#include "v4color.h"
#if LL_WINDOWS
# define WIN32_LEAN_AND_MEAN
# include <winsock2.h> // for htonl
# include "llwin32headers.h" // for htonl
#elif LL_LINUX
# include <netinet/in.h>
#elif LL_DARWIN

View File

@ -31,8 +31,7 @@
#include "llerror.h"
#if LL_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <winsock2.h>
#include <llwin32headers.h>
#else
#include <netdb.h>
#include <netinet/in.h> // ntonl()

View File

@ -30,7 +30,7 @@
#define LL_LLIOPIPE_H
#include <boost/intrusive_ptr.hpp>
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include "apr_poll.h"
#include "llsd.h"

View File

@ -38,7 +38,7 @@
*/
#include "lliopipe.h"
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include "apr_pools.h"
#include "apr_network_io.h"
#include "llchainio.h"

View File

@ -28,7 +28,6 @@
#include "llmail.h"
// APR on Windows needs full windows headers
#include "llwin32headers.h"
#include <string>
#include <sstream>

View File

@ -32,7 +32,7 @@
#include <stdexcept>
#if LL_WINDOWS
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#else
#include <sys/types.h>
#include <sys/socket.h>

View File

@ -46,7 +46,7 @@
// LL_WINDOWS
// windows gl headers depend on things like APIENTRY, so include windows.
#include "llwin32headerslean.h"
#include "llwin32headers.h"
//----------------------------------------------------------------------------
#include <GL/gl.h>

View File

@ -31,7 +31,7 @@
#ifndef LL_LLDRAGDROP32_H
#define LL_LLDRAGDROP32_H
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include <ole2.h>
class LLDragDropWin32
@ -54,7 +54,7 @@ class LLDragDropWin32
#ifndef LL_LLDRAGDROP32_H
#define LL_LLDRAGDROP32_H
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include <ole2.h>
// impostor class that does nothing

View File

@ -28,7 +28,7 @@
#include "linden_common.h"
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include "llkeyboardwin32.h"
#include "llwindowcallbacks.h"

View File

@ -28,7 +28,7 @@
#define LL_LLWINDOWWIN32_H
// Limit Windows API to small and manageable set.
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include "llwindow.h"
#include "llwindowcallbacks.h"

View File

@ -35,7 +35,7 @@
#include "lltrans.h"
#include "llwindow.h" // beforeDialog()
#include "llviewercontrol.h"
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#if LL_LINUX || LL_DARWIN
# include "llfilepicker.h"

View File

@ -28,7 +28,7 @@
#ifndef LLSECAPI_H
#define LLSECAPI_H
#include <vector>
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include <openssl/x509.h>
#include <ostream>
#include "llpointer.h"

View File

@ -28,7 +28,7 @@
#define LL_LLWINDEBUG_H
#include "stdtypes.h"
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include <dbghelp.h>

View File

@ -26,7 +26,7 @@
#include "llviewerprecompiledheaders.h"
// include this to get winsock2 because openssl attempts to include winsock1
#include "llwin32headerslean.h"
#include "llwin32headers.h"
#include <openssl/x509_vfy.h>
#include <openssl/ssl.h>
#include "llsecapi.h"