Skip to content

Commit

Permalink
fixed windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Apr 8, 2021
1 parent a79416b commit efc341d
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 119 deletions.
24 changes: 11 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,6 @@ if (HAVE_PTHREAD)
target_link_libraries (glog PUBLIC ${CMAKE_THREAD_LIBS_INIT})
endif (HAVE_PTHREAD)

if (WIN32 AND HAVE_SNPRINTF)
set_property (SOURCE src/windows/port.cc APPEND PROPERTY COMPILE_DEFINITIONS
HAVE_SNPRINTF)
endif (WIN32 AND HAVE_SNPRINTF)

if (gflags_FOUND)
target_link_libraries (glog PUBLIC gflags)

Expand Down Expand Up @@ -614,12 +609,12 @@ if (WIN32)
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/windows)
endif (WIN32)

set_target_properties (glog PROPERTIES DEFINE_SYMBOL GOOGLE_GLOG_IS_A_DLL)

generate_export_header (glog
EXPORT_MACRO_NAME GOOGLE_GLOG_DLL_DECL
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/glog/export.h)

set_target_properties (glog PROPERTIES DEFINE_SYMBOL GOOGLE_GLOG_IS_A_DLL)

# Unit testing

if (BUILD_TESTING)
Expand Down Expand Up @@ -737,12 +732,14 @@ if (BUILD_TESTING)
)

add_test (NAME cmake_package_config_generate COMMAND ${CMAKE_COMMAND}
-DPATH=$ENV{PATH}
-DGENERATOR=${CMAKE_GENERATOR}
-DGENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DGENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
-DINITIAL_CACHE=${_INITIAL_CACHE}
-DTEST_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/test_package_config/working_config
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src/package_config_unittest/working_config
-DPACKAGE_DIR=${CMAKE_CURRENT_BINARY_DIR}
-DGENERATOR=${CMAKE_GENERATOR}
-DPATH=$ENV{PATH}
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/src/package_config_unittest/working_config
-DTEST_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/test_package_config/working_config
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/TestPackageConfig.cmake
)

Expand Down Expand Up @@ -806,8 +803,9 @@ configure_package_config_file (glog-config.cmake.in
INSTALL_DESTINATION ${_glog_CMake_INSTALLDIR}
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

write_basic_package_version_file (glog-config-version.cmake VERSION
${PROJECT_VERSION} COMPATIBILITY SameMajorVersion)
write_basic_package_version_file (
${CMAKE_CURRENT_BINARY_DIR}/glog-config-version.cmake
COMPATIBILITY SameMajorVersion)

export (TARGETS glog NAMESPACE glog:: FILE glog-targets.cmake)
export (PACKAGE glog)
Expand Down
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Google Logging Library
======================

|Build Status| |Grunt status|
|Build Status| |Grunt status| |Github actions|

Google Logging (glog) is a C++98 library that implements application-level
logging. The library provides logging APIs based on C++-style streams and
Expand Down Expand Up @@ -811,3 +811,5 @@ Submitting a Patch
:target: https://travis-ci.org/google/glog/builds
.. |Grunt status| image:: https://img.shields.io/appveyor/ci/google-admin/glog/master.svg?label=Appveyor
:target: https://ci.appveyor.com/project/google-admin/glog/history
.. |Github actions| image:: https://github.com/google/glog/actions/workflows/windows-builds.yml/badge.svg
:target: https://github.com/google/glog/actions
8 changes: 4 additions & 4 deletions bazel/glog.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):

common_copts = [
"-DGLOG_BAZEL_BUILD",
# Inject a C++ namespace.
"-DGOOGLE_NAMESPACE='%s'" % namespace,
"-DHAVE_STDINT_H",
"-DHAVE_STRING_H",
"-DHAVE_UNWIND_H",
"-I%s/glog_internal" % gendir,
] + (["-DHAVE_LIB_GFLAGS"] if with_gflags else [])

wasm_copts = [
Expand All @@ -59,8 +62,6 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
"-Wno-unused-function",
"-Wno-unused-local-typedefs",
"-Wno-unused-variable",
# Inject a C++ namespace.
"-DGOOGLE_NAMESPACE='%s'" % namespace,
# Allows src/base/mutex.h to include pthread.h.
"-DHAVE_PTHREAD",
# Allows src/logging.cc to determine the host name.
Expand All @@ -72,7 +73,6 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
# For logging.cc.
"-DHAVE_PREAD",
"-DHAVE___ATTRIBUTE__",
"-I%s/glog_internal" % gendir,
]

linux_or_darwin_copts = wasm_copts + [
Expand All @@ -93,13 +93,13 @@ def glog_library(namespace = "google", with_gflags = 1, **kwargs):
]

windows_only_copts = [
"-DGLOG_NO_ABBREVIATED_SEVERITIES",
"-DHAVE_SNPRINTF",
"-I" + src_windows,
]

windows_only_srcs = [
"src/glog/log_severity.h",
"src/windows/config.h",
"src/windows/dirent.h",
"src/windows/port.cc",
"src/windows/port.h",
Expand Down
6 changes: 5 additions & 1 deletion cmake/GetCacheVariables.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ function (get_cache_variables _CACHEVARS)
string (REPLACE "\"" "\\\"" _CACHEVARDOC "${_CACHEVARDOC}")
# Escape ; in values
string (REPLACE ";" "\\\;" _CACHEVARVAL "${_CACHEVARVAL}")
# Escape backslash in values
# Escape backslashes in values except those that are followed by a
# quote.
string (REGEX REPLACE "\\\\([^\"])" "\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}")
# Escape backslashes in values that are followed by a letter to avoid
# invalid escape sequence errors.
string (REGEX REPLACE "\\\\([a-zA-Z])" "\\\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}")

if (NOT "${_CACHEVARTYPE}" STREQUAL BOOL)
set (_CACHEVARVAL "\"${_CACHEVARVAL}\"")
Expand Down
1 change: 0 additions & 1 deletion cmake/TestInitPackageConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)

file (WRITE ${INITIAL_CACHE} "${CACHEVARS}")

25 changes: 16 additions & 9 deletions cmake/TestPackageConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,28 @@ if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
message (FATAL_ERROR "Failed to create build directory")
endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)

# Capture the PATH environment variable content set during project
# generation stage. This is required because later during the build stage
# the PATH is modified again (e.g., for MinGW AppVeyor CI builds) by adding
# back the directory containing git.exe. Incidently, the Git installation
# directory also contains sh.exe which causes MinGW Makefile generation to
# fail.
set (ENV{PATH} ${PATH})
if (GENERATOR_TOOLSET)
list (APPEND _ADDITIONAL_ARGS -T ${GENERATOR_TOOLSET})
endif (GENERATOR_TOOLSET)

if (GENERATOR_PLATFORM)
list (APPEND _ADDITIONAL_ARGS -A ${GENERATOR_PLATFORM})
endif (GENERATOR_PLATFORM)

# Run CMake
execute_process (
COMMAND ${CMAKE_COMMAND} -C ${INITIAL_CACHE}
# Capture the PATH environment variable content set during project generation
# stage. This is required because later during the build stage the PATH is
# modified again (e.g., for MinGW AppVeyor CI builds) by adding back the
# directory containing git.exe. Incidently, the Git installation directory
# also contains sh.exe which causes MinGW Makefile generation to fail.
COMMAND ${CMAKE_COMMAND} env PATH=${PATH}
${CMAKE_COMMAND} -C ${INITIAL_CACHE}
-G ${GENERATOR}
-DCMAKE_PREFIX_PATH=${PACKAGE_DIR}
${_ADDITIONAL_ARGS}
-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON
-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON
-DCMAKE_PREFIX_PATH=${PACKAGE_DIR}
${SOURCE_DIR}
WORKING_DIRECTORY ${TEST_BINARY_DIR}
RESULT_VARIABLE _GENERATE_SUCCEEDED
Expand Down
66 changes: 0 additions & 66 deletions src/config_for_unittests.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/logging_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//
// Author: Ray Sidney

#include "config_for_unittests.h"
#include "config.h"
#include "utilities.h"

#include <fcntl.h>
Expand Down
4 changes: 2 additions & 2 deletions src/package_config_unittest/working_config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.1)
project (glog_package_config)
cmake_minimum_required (VERSION 3.0)
project (glog_package_config LANGUAGES CXX)

find_package (glog REQUIRED NO_MODULE)

Expand Down
21 changes: 0 additions & 21 deletions src/windows/config.h

This file was deleted.

2 changes: 2 additions & 0 deletions src/windows/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
* used by both C and C++ code, so we put all the C++ together.
*/

#include "glog/logging.h"

#ifdef _MSC_VER

/* 4244: otherwise we get problems when substracting two size_t's to an int
Expand Down

0 comments on commit efc341d

Please sign in to comment.