Skip to content

Commit

Permalink
Merge pull request #2 from zig-for/zig/static
Browse files Browse the repository at this point in the history
static linking
  • Loading branch information
zig-for authored Jul 8, 2022
2 parents c67c596 + 0ee1922 commit 4cd62ad
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
24 changes: 9 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
cmake_minimum_required(VERSION 3.22)

cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
project(snfm)
# vcpkg install protobuf protobuf:x64-windows grpc
# TODO: maybe use magic cmake FetchContent
# grpc install is really really slow :(
# I miss linux
# freaking antimalware exec using up 50 percent cpu
# "-DCMAKE_TOOLCHAIN_FILE=D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
# tested on VS 2022 toolchain and newest cmake :)

# include(../vcpkg/scripts/buildsystems/vcpkg.cmake)
include(FindProtobuf)

# include(FindProtobuf)
set ( Protobuf_USE_STATIC_LIBS ON )
find_package(Protobuf REQUIRED)
find_package(gRPC CONFIG REQUIRED)
find_package(wxWidgets REQUIRED COMPONENTS core base)

set(CMAKE_CXX_STANDARD 20)
find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin) # Get full path to plugin


function(PROTOBUF_GENERATE_GRPC_CPP SRCS HDRS)
if(NOT ARGN)
message(SEND_ERROR "Error: PROTOBUF_GENERATE_GRPC_CPP() called without any proto files")
Expand Down Expand Up @@ -81,7 +76,7 @@ PROTOBUF_GENERATE_GRPC_CPP(PROTO_GRPC_SRCS PROTO_GRPC_HDRS sni/protos/sni/sni.pr
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} include %)

add_library(snfm_common ${PROTO_SRCS} ${PROTO_HDRS} ${PROTO_GRPC_SRCS} ${PROTO_GRPC_HDRS})
target_link_libraries(snfm_common protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite gRPC::grpc++_unsecure)
target_link_libraries(snfm_common protobuf::libprotoc protobuf::libprotobuf gRPC::grpc++_unsecure)

add_executable(send_file "src/send_file.cpp")
target_link_libraries(send_file PRIVATE snfm_common)
Expand All @@ -93,14 +88,13 @@ target_include_directories(manage_files PRIVATE ${wxWidgets_INCLUDE_DIRS})
target_link_libraries(manage_files PRIVATE ${wxWidgets_LIBRARIES})

# Magic bits to enable MFC
add_definitions(-D_AFXDLL)
set(CMAKE_MFC_FLAG 1)
# add_definitions(-D_AFXDLL)
set(CMAKE_MFC_FLAG 2)
set_target_properties(manage_files PROPERTIES WIN32_EXECUTABLE TRUE)





#add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
#add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"CMAKE_TOOLCHAIN_FILE": {
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"type": "FILEPATH"
}
},
"VCPKG_TARGET_TRIPLET": "x64-windows-static"
},
"condition": {
"type": "equals",
Expand Down
3 changes: 2 additions & 1 deletion include/win_dnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define WIN_DROP_SOURCE
#endif
#ifdef WIN_DROP_SOURCE
#include <afx.h>
#include <afxole.h> // MFC OLE classes

#include <shlobj.h>
Expand Down Expand Up @@ -30,7 +31,7 @@ class CDummyWindow : public CWnd

struct SNIAfxDropSource : COleDataSource
{
DECLARE_DYNAMIC(SNIAfxDropSource)
//DECLARE_DYNAMIC(SNIAfxDropSource)
// todo stop drag

using GetFileHandler = std::function<
Expand Down
2 changes: 1 addition & 1 deletion src/win_dnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifdef WIN_DROP_SOURCE


IMPLEMENT_DYNAMIC(SNIAfxDropSource, COleDataSource);
//IMPLEMENT_DYNAMIC(SNIAfxDropSource, COleDataSource);

SCODE SNWinDropFeedback::QueryContinueDrag(
BOOL bEscapePressed,
Expand Down
7 changes: 6 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"version": "0.0.1",
"dependencies": [
"protobuf",
"grpc",
{
"name": "grpc",
"features": [
"codegen"
]
},
"wxwidgets"
]
}

0 comments on commit 4cd62ad

Please sign in to comment.