Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: determine when to use port.h #1037

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,14 @@ set (GLOG_SRCS
src/vlog_is_on.cc
)

if (CYGWIN OR WIN32)
# NOTE MSYS2 defines both WIN32 and UNIX. Do not use windows port in this case.
if ((CYGWIN OR WIN32) AND NOT UNIX)
list (APPEND GLOG_SRCS
src/windows/port.cc
src/windows/port.h
)
endif (CYGWIN OR WIN32)
set (_glog_USE_WINDOWS_PORT TRUE)
endif ((CYGWIN OR WIN32) AND NOT UNIX)

add_library (glog_internal OBJECT
${_glog_BINARY_CMake_MODULES}
Expand Down Expand Up @@ -399,6 +401,12 @@ set (glog_libraries_options_for_static_linking)
# CMake always uses the generated export header
target_compile_definitions (glog PUBLIC GLOG_USE_GLOG_EXPORT)

if (_glog_USE_WINDOWS_PORT)
target_compile_definitions (glog PRIVATE GLOG_USE_WINDOWS_PORT)
endif (_glog_USE_WINDOWS_PORT)

unset (_glog_USE_WINDOWS_PORT)

if (WIN32)
# Do not define min and max as macros
target_compile_definitions (glog PRIVATE NOMINMAX)
Expand Down
1 change: 1 addition & 0 deletions bazel/glog.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def glog_library(with_gflags = 1, **kwargs):
"-DGLOG_EXPORT=__declspec(dllexport)",
"-DGLOG_NO_EXPORT=",
"-DGLOG_NO_ABBREVIATED_SEVERITIES",
"-DGLOG_USE_WINDOWS_PORT",
"-DHAVE__CHSIZE_S",
"-I" + src_windows,
]
Expand Down
4 changes: 3 additions & 1 deletion src/stacktrace_windows-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
#include <dbghelp.h>

#include "config.h"
#include "port.h"
#if defined(GLOG_USE_WINDOWS_PORT)
# include "port.h"
#endif
#include "stacktrace.h"

namespace google {
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

#include "glog/logging.h"

#if defined(GLOG_OS_WINDOWS)
#if defined(GLOG_USE_WINDOWS_PORT)
# include "port.h"
#endif

Expand Down