Skip to content

Commit 290f3c9

Browse files
authored
Merge pull request #236 from riptano/CPP-772
CPP-772 Remove per cpp file LOG_FILE attribute to speed up Windows build
2 parents 657e8fa + 95d6e15 commit 290f3c9

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

cpp-driver/cmake/modules/CppDriver.cmake

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -796,25 +796,6 @@ macro(CassSetCompilerFlags)
796796
add_definitions("/MP")
797797
endif()
798798

799-
# Enable link time optimization for all MSVC build configurations
800-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL")
801-
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /LTCG")
802-
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
803-
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
804-
805-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /GL")
806-
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO}")
807-
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
808-
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}")
809-
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
810-
string(REGEX REPLACE "[-/]INCREMENTAL" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
811-
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG")
812-
813-
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /GL")
814-
set(CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL "${CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL} /LTCG")
815-
set(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /LTCG")
816-
set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /LTCG")
817-
818799
# On Visual C++ -pedantic flag is not used,
819800
# -fPIC is not used on Windows platform (all DLLs are
820801
# relocable), -Wall generates about 30k stupid warnings
@@ -987,12 +968,6 @@ macro(CassFindSourceFiles)
987968
endif()
988969

989970
set(CASS_ALL_SOURCE_FILES ${CASS_SRC_FILES} ${CASS_API_HEADER_FILES} ${CASS_INC_FILES})
990-
991-
# Shorten the source file pathing for log messages
992-
foreach(SRC_FILE ${CASS_SRC_FILES})
993-
string(REPLACE "${CASS_ROOT_DIR}/" "" LOG_FILE_ ${SRC_FILE})
994-
set_source_files_properties(${SRC_FILE} PROPERTIES COMPILE_FLAGS -DLOG_FILE_=\\\"${LOG_FILE_}\\\")
995-
endforeach()
996971
endmacro()
997972

998973
#------------------------

cpp-driver/src/logger.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "get_time.hpp"
2222
#include "string.hpp"
2323

24+
#include <cstring>
2425
#include <stdarg.h>
2526
#include <stdio.h>
2627

@@ -83,12 +84,19 @@ class Logger {
8384
TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, \
8485
TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, TWOORMORE, ONE, throwaway)
8586

86-
// Using __FILE__ returns the whole absolute path of the file, this
87-
// allows something more concise to be used via -DLOG_FILE_=<path>
88-
#ifndef LOG_FILE_
89-
#define LOG_FILE_ __FILE__
87+
#ifdef WIN32
88+
#define LOG_FILE_SEPARATOR_STR_ "\\"
89+
#define LOG_FILE_SEPARATOR_CHAR_ '\\'
90+
#else
91+
#define LOG_FILE_SEPARATOR_STR_ "/"
92+
#define LOG_FILE_SEPARATOR_CHAR_ '/'
9093
#endif
9194

95+
// Compiles away on most compilers (not MSVC, but it's still fast). This adds the seperator to the
96+
// front to guarantee a match is found, but it's then removed by moving the pointer to the next
97+
// position.
98+
#define LOG_FILE_ (strrchr(LOG_FILE_SEPARATOR_STR_ __FILE__, LOG_FILE_SEPARATOR_CHAR_) + 1)
99+
92100
#if defined(_MSC_VER)
93101
#define LOG_FUNCTION_ __FUNCSIG__
94102
#elif defined(__clang__) || defined(__GNUC__) || defined(__INTEL_COMPILER)

0 commit comments

Comments
 (0)