Skip to content

Commit

Permalink
fix: add some msvc specific fixes (#60)
Browse files Browse the repository at this point in the history
* fix: add some msvc specifi fixes

* fix: MSVC runtime library got overridden

* fix: further msvc specific fixes

* fix: formatting fail
  • Loading branch information
codedwrench authored Jan 12, 2024
1 parent edb778c commit 8985d6a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if (WIN32)
)
else()
# MSVC specific steps
list(APPEND PLATFORM_SPECIFIC_LIBRARIES "delayimp.lib")
list(APPEND PLATFORM_SPECIFIC_LIBRARIES "delayimp.lib" "winmm.lib")

# We need to load wpcap
add_link_options(/DELAYLOAD:wpcap.dll)
Expand All @@ -90,6 +90,7 @@ if (WIN32)
# We have no GUI anyway!
add_definitions(-DNOGDI)

set(BOOST_ROOT "c:/boost" CACHE STRING "Where boost is located")
set(PCAP_ROOT_DIR "c:/npcapsdk" CACHE STRING "Where the npcap sdk is located")
set(PDCURSES_ROOT_DIR "c:/pdcurses/" CACHE STRING "Where the pdcurses directory is located")

Expand Down
3 changes: 2 additions & 1 deletion Sources/UserInterface/AboutWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* Copyright (c) 2021 [Rick de Bondt] - AboutWindow.cpp */

#include "UserInterface/AboutWindow.h"

#include <algorithm>

#include "UserInterface/Button.h"
#include "UserInterface/DefaultElements.h"

Expand Down
3 changes: 2 additions & 1 deletion Sources/UserInterface/HUDWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* Copyright (c) 2021 [Rick de Bondt] - HUDWindow.cpp */

#include "UserInterface/HUDWindow.h"

#include <algorithm>

#include "UserInterface/Button.h"
#include "UserInterface/CheckBox.h"
#include "UserInterface/DefaultElements.h"
Expand Down
8 changes: 7 additions & 1 deletion Sources/WifiInterfaceWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#define UNICODE
#endif

#ifndef _MSC_VER
#define STDCALL __attribute__((stdcall))
#else
#define STDCALL __stdcall
#endif

// available network flags
#define WLAN_AVAILABLE_NETWORK_CONNECTED 0x00000001 // This network is currently connected
#define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 0x00000002 // There is a profile for this network
Expand Down Expand Up @@ -105,7 +111,7 @@ static std::wstring GenerateXML(const std::wstring& aSSID)
return lFirst + aSSID + lSecond;
}

static void __attribute__((stdcall)) WlanCallback(WLAN_NOTIFICATION_DATA* aScanNotificationData, PVOID aContext)
static void STDCALL WlanCallback(WLAN_NOTIFICATION_DATA* aScanNotificationData, PVOID aContext)
{
// Get the data from my struct. If it's null, nothing to do
auto* lCallbackInfo = static_cast<WLAN_CALLBACK_INFO*>(aContext);
Expand Down
1 change: 1 addition & 0 deletions cmake/addcompilerandlinkerflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /MT")
set(CMAKE_CXX_FLAGS_DEBUG "/Od /MTd /ZI")
set(PROJECT_COMPILE_WARNING_FLAGS /Wall /sdl /WX)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
else()
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
Expand Down
5 changes: 4 additions & 1 deletion cmake/wrapfindboost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@

# wrapfindboost.cmake - Finds boost under our terms.
# Usage: Set Boost_ARCHITECTURE if the default arch is not OK, set BOOST_ROOT as well.

if (BUILD_STATIC)
set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_USE_STATIC_LIBS ON)
endif ()

if (MSVC)
set(Boost_USE_STATIC_RUNTIME ON)
endif ()

# Needed because otherwise the libraries cannot be found.
if (BUILD_X32)
set(Boost_ARCHITECTURE "-x32")
Expand Down

0 comments on commit 8985d6a

Please sign in to comment.