diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b7bcc3..71dad1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,22 +2,27 @@ cmake_minimum_required(VERSION 3.1.0) project(webcc) +# Output directories +set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${BUILD_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BUILD_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BUILD_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${BUILD_DIR}/bin/debug) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${BUILD_DIR}/bin/debug) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${BUILD_DIR}/bin/debug) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${BUILD_DIR}/bin/release) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${BUILD_DIR}/bin/release) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${BUILD_DIR}/bin/release) + option(WEBCC_ENABLE_AUTOTEST "Build automation test?" OFF) option(WEBCC_ENABLE_UNITTEST "Build unit test?" OFF) option(WEBCC_ENABLE_EXAMPLES "Build examples?" OFF) -if(WIN32) - option(WEBCC_ENABLE_VLD "Enable VLD (Visual Leak Detector)?" OFF) - if(WEBCC_ENABLE_VLD) - add_definitions(-DWEBCC_ENABLE_VLD) - endif() -endif() - -set(WEBCC_ENABLE_LOG 1 CACHE STRING "Enable logging? (1:Yes, 0:No)") -set(WEBCC_LOG_LEVEL 2 CACHE STRING "Log level (0:VERB, 1:INFO, 2:USER, 3:WARN or 4:ERRO)") +set(WEBCC_ENABLE_LOG 1 CACHE STRING "Enable logging? (1:Yes, 0:No)") +set(WEBCC_ENABLE_SSL 0 CACHE STRING "Enable SSL/HTTPS (need OpenSSL)? (1:Yes, 0:No)") +set(WEBCC_ENABLE_GZIP 0 CACHE STRING "Enable gzip compression (need Zlib)? (1:Yes, 0:No)") -set(WEBCC_ENABLE_SSL 0 CACHE STRING "Enable SSL/HTTPS (need OpenSSL)? (1:Yes, 0:No)") -set(WEBCC_ENABLE_GZIP 0 CACHE STRING "Enable gzip compression (need Zlib)? (1:Yes, 0:No)") +set(WEBCC_LOG_LEVEL 2 CACHE STRING "Log level (0:VERB, 1:INFO, 2:USER, 3:WARN or 4:ERRO)") if(WEBCC_ENABLE_UNITTEST) enable_testing() @@ -42,8 +47,8 @@ find_package(Threads REQUIRED) if(WEBCC_ENABLE_SSL) # Commented on 20190529. # The static libs have linkage issues with VS2015 on Win10. - # set(OPENSSL_USE_STATIC_LIBS ON) - # set(OPENSSL_MSVC_STATIC_RT ON) + # set(OPENSSL_USE_STATIC_LIBS ON) + # set(OPENSSL_MSVC_STATIC_RT ON) find_package(OpenSSL) if(OPENSSL_FOUND) include_directories(${OPENSSL_INCLUDE_DIR}) @@ -63,11 +68,7 @@ set(THIRD_PARTY_DIR ${PROJECT_SOURCE_DIR}/third_party) # For Asio include_directories(${THIRD_PARTY_DIR}/include) -if(WIN32) - include_directories(${THIRD_PARTY_DIR}/win32/include) - link_directories(${THIRD_PARTY_DIR}/win32/lib) -endif() - +# For jsoncpp include_directories(${THIRD_PARTY_DIR}/src) if(WEBCC_ENABLE_GZIP) @@ -109,10 +110,10 @@ if(WEBCC_ENABLE_AUTOTEST) add_subdirectory(autotest) endif() -if(WEBCC_ENABLE_EXAMPLES) - add_subdirectory(examples) -endif() - if(WEBCC_ENABLE_UNITTEST) add_subdirectory(unittest) endif() + +if(WEBCC_ENABLE_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/doc/screenshots/vs_cmd_prompts_win10.png b/doc/screenshots/vs_cmd_prompts_win10.png deleted file mode 100644 index 320760e..0000000 Binary files a/doc/screenshots/vs_cmd_prompts_win10.png and /dev/null differ diff --git a/doc/screenshots/vs_cmd_prompts_win7.png b/doc/screenshots/vs_cmd_prompts_win7.png deleted file mode 100644 index 28fc3d1..0000000 Binary files a/doc/screenshots/vs_cmd_prompts_win7.png and /dev/null differ diff --git a/doc/screenshots/win_cmake_config.png b/doc/screenshots/win_cmake_config.png index 6d6ad12..6d97408 100644 Binary files a/doc/screenshots/win_cmake_config.png and b/doc/screenshots/win_cmake_config.png differ diff --git a/doc/screenshots/win_cmake_config_gtest.png b/doc/screenshots/win_cmake_config_gtest.png new file mode 100644 index 0000000..d041579 Binary files /dev/null and b/doc/screenshots/win_cmake_config_gtest.png differ diff --git a/doc/screenshots/win_cmake_config_openssl.png b/doc/screenshots/win_cmake_config_openssl.png index 1238aaa..6ee102f 100644 Binary files a/doc/screenshots/win_cmake_config_openssl.png and b/doc/screenshots/win_cmake_config_openssl.png differ diff --git a/doc/screenshots/win_cmake_generator.png b/doc/screenshots/win_cmake_generator.png index 3a76bcd..9275d9d 100644 Binary files a/doc/screenshots/win_cmake_generator.png and b/doc/screenshots/win_cmake_generator.png differ diff --git a/doc/screenshots/win_cmake_prefix_path.png b/doc/screenshots/win_cmake_prefix_path.png new file mode 100644 index 0000000..f42930f Binary files /dev/null and b/doc/screenshots/win_cmake_prefix_path.png differ diff --git a/third_party/win32/bin/debug/vld/Microsoft.DTfW.DHL.manifest b/third_party/win32/bin/debug/vld/Microsoft.DTfW.DHL.manifest deleted file mode 100644 index e61222f..0000000 --- a/third_party/win32/bin/debug/vld/Microsoft.DTfW.DHL.manifest +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/third_party/win32/bin/debug/vld/dbghelp.dll b/third_party/win32/bin/debug/vld/dbghelp.dll deleted file mode 100644 index 62d8508..0000000 Binary files a/third_party/win32/bin/debug/vld/dbghelp.dll and /dev/null differ diff --git a/third_party/win32/bin/debug/vld/vld_x86.dll b/third_party/win32/bin/debug/vld/vld_x86.dll deleted file mode 100644 index 2b08acd..0000000 Binary files a/third_party/win32/bin/debug/vld/vld_x86.dll and /dev/null differ diff --git a/third_party/win32/include/vld/vld.h b/third_party/win32/include/vld/vld.h deleted file mode 100644 index a24a09f..0000000 --- a/third_party/win32/include/vld/vld.h +++ /dev/null @@ -1,307 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Visual Leak Detector - Import Library Header -// Copyright (c) 2005-2013 VLD Team -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// -// See COPYING.txt for the full terms of the GNU Lesser General Public License. -// -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "vld_def.h" - -#if defined _DEBUG || defined VLD_FORCE_ENABLE - -#include - -#pragma comment(lib, "vld.lib") - -// Force a symbolic reference to the global VisualLeakDetector class object from -// the DLL. This ensures that the DLL is loaded and linked with the program, -// even if no code otherwise imports any of the DLL's exports. -#pragma comment(linker, "/include:__imp_?g_vld@@3VVisualLeakDetector@@A") - -//////////////////////////////////////////////////////////////////////////////// -// -// Visual Leak Detector APIs -// - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -// VLDDisable - Disables Visual Leak Detector's memory leak detection at -// runtime. If memory leak detection is already disabled, then calling this -// function has no effect. -// -// Note: In multithreaded programs, this function operates on a per-thread -// basis. In other words, if you call this function from one thread, then -// memory leak detection is only disabled for that thread. If memory leak -// detection is enabled for other threads, then it will remain enabled for -// those other threads. It was designed to work this way to insulate you, -// the programmer, from having to ensure thread synchronization when calling -// VLDEnable() and VLDDisable(). Without this, calling these two functions -// unsynchronized could result in unpredictable and unintended behavior. -// But this also means that if you want to disable memory leak detection -// process-wide, then you need to call this function from every thread in -// the process. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDDisable (); - -// VLDEnable - Enables Visual Leak Detector's memory leak detection at runtime. -// If memory leak detection is already enabled, which it is by default, then -// calling this function has no effect. -// -// Note: In multithreaded programs, this function operates on a per-thread -// basis. In other words, if you call this function from one thread, then -// memory leak detection is only enabled for that thread. If memory leak -// detection is disabled for other threads, then it will remain disabled for -// those other threads. It was designed to work this way to insulate you, -// the programmer, from having to ensure thread synchronization when calling -// VLDEnable() and VLDDisable(). Without this, calling these two functions -// unsynchronized could result in unpredictable and unintended behavior. -// But this also means that if you want to enable memory leak detection -// process-wide, then you need to call this function from every thread in -// the process. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDEnable (); - -// VLDRestore - Restore Visual Leak Detector's previous state. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDRestore (); - -// VLDGlobalDisable - Disables Visual Leak Detector's memory leak detection at -// runtime in all threads. If memory leak detection is already disabled, -// then calling this function has no effect. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDGlobalDisable (); - -// VLDGlobalEnable - Enables Visual Leak Detector's memory leak detection -// at runtime in all threads. If memory leak detection is already enabled, -// which it is by default, then calling this function has no effect. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDGlobalEnable (); - -// VLDReportLeaks - Report leaks up to the execution point. -// -// Return Value: -// -// None. -// -__declspec(dllimport) UINT VLDReportLeaks (); - -// VLDGetLeaksCount - Return memory leaks count to the execution point. -// -// Return Value: -// -// None. -// -__declspec(dllimport) UINT VLDGetLeaksCount (); - -// VLDMarkAllLeaksAsReported - Mark all leaks as reported. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDMarkAllLeaksAsReported (); - - -// VLDRefreshModules - Look for recently loaded DLLs and patch them if necessary. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDRefreshModules(); - - -// VLDEnableModule - Enable Memory leak checking on the specified module. -// -// module: module handle. -// -// Return Value: -// -// None. -// - -__declspec(dllimport) void VLDEnableModule(HMODULE module); - - -// VLDDisableModule - Disable Memory leak checking on the specified module. -// -// module: module handle. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDDisableModule(HMODULE module); - -// VLDGetOptions - Return all current options. -// -// Return Value: -// -// Mask of current options. -// -__declspec(dllimport) UINT VLDGetOptions(); - -// VLDGetReportFilename - Return current report filename. -// -// filename: current report filename (max characters - MAX_PATH). -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDGetReportFilename(WCHAR *filename); - -// VLDSetOptions - Update the report options via function call rather than INI file. -// -// option_mask: Only the following flags are checked -// VLD_OPT_AGGREGATE_DUPLICATES -// VLD_OPT_MODULE_LIST_INCLUDE -// VLD_OPT_SAFE_STACK_WALK -// VLD_OPT_SLOW_DEBUGGER_DUMP -// VLD_OPT_TRACE_INTERNAL_FRAMES -// VLD_OPT_START_DISABLED -// VLD_OPT_SKIP_HEAPFREE_LEAKS -// VLD_OPT_VALIDATE_HEAPFREE -// -// maxDataDump: maximum number of user-data bytes to dump for each leaked block. -// -// maxTraceFrames: maximum number of frames per stack trace for each leaked block. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDSetOptions(UINT option_mask, SIZE_T maxDataDump, UINT maxTraceFrames); - -// VLDSetModulesList - Set list of modules included/excluded in leak detection -// depending on parameter "includeModules". -// -// modules: list of modules to be forcefully included/excluded in leak detection. -// -// includeModules: include or exclude that modules. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDSetModulesList(CONST WCHAR *modules, BOOL includeModules); - -// VLDGetModulesList - Return current list of included/excluded modules -// depending on flag VLD_OPT_TRACE_INTERNAL_FRAMES. -// -// modules: destination string for list of included/excluded modules (maximum length 512 characters). -// -// size: maximum string size. -// -// Return Value: -// -// BOOL: TRUE if include modules, otherwise FALSE. -// -__declspec(dllimport) BOOL VLDGetModulesList(WCHAR *modules, UINT size); - -// VLDSetReportOptions - Update the report options via function call rather than INI file. -// -// Only the following flags are checked -// VLD_OPT_REPORT_TO_DEBUGGER -// VLD_OPT_REPORT_TO_FILE -// VLD_OPT_REPORT_TO_STDOUT -// VLD_OPT_UNICODE_REPORT -// -// filename is optional and can be NULL. -// -// Return Value: -// -// None. -// -__declspec(dllimport) void VLDSetReportOptions(UINT option_mask, CONST WCHAR *filename); - -// VLDSetReportHook - Installs or uninstalls a client-defined reporting function by hooking it -// into the C run-time debug reporting process (debug version only). -// -// mode: The action to take: VLD_RPTHOOK_INSTALL or VLD_RPTHOOK_REMOVE. -// -// pfnNewHook: Report hook to install or remove. -// -// Return Value: -// -// int: 0 if success. -// -__declspec(dllimport) int VLDSetReportHook(int mode, VLD_REPORT_HOOK pfnNewHook); - -// VLDResolveCallstacks - Performs symbol resolution for all saved extent CallStack's that have -// been tracked by Visual Leak Detector. This function is necessary for applications that -// dynamically load and unload modules, and through which memory leaks might be included. -// If this is NOT called, stack traces may have stack frames with no symbol information. This -// happens because the symbol API's cannot look up symbols for a binary / module that has been unloaded -// from the process. -// -// Return Value: -// -// None. -// -__declspec(dllexport) void VLDResolveCallstacks(); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#else // !_DEBUG - -#define VLDEnable() -#define VLDDisable() -#define VLDRestore() -#define VLDReportLeaks() 0 -#define VLDGetLeaksCount() 0 -#define VLDMarkAllLeaksAsReported() -#define VLDRefreshModules() -#define VLDEnableModule(a) -#define VLDDisableModule(b) -#define VLDGetOptions() 0 -#define VLDGetReportFilename(a) -#define VLDSetOptions(a, b, c) -#define VLDSetReportHook(a, b) -#define VLDSetModulesList(a) -#define VLDGetModulesList(a, b) FALSE -#define VLDSetReportOptions(a, b) - -#endif // _DEBUG diff --git a/third_party/win32/include/vld/vld_def.h b/third_party/win32/include/vld/vld_def.h deleted file mode 100644 index 93bbfaf..0000000 --- a/third_party/win32/include/vld/vld_def.h +++ /dev/null @@ -1,45 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Visual Leak Detector - Import Library Header -// Copyright (c) 2005-2013 VLD Team -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// -// See COPYING.txt for the full terms of the GNU Lesser General Public License. -// -//////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#define VLD_OPT_AGGREGATE_DUPLICATES 0x0001 // If set, aggregate duplicate leaks in the leak report. -#define VLD_OPT_MODULE_LIST_INCLUDE 0x0002 // If set, modules in the module list are included, all others are excluded. -#define VLD_OPT_REPORT_TO_DEBUGGER 0x0004 // If set, the memory leak report is sent to the debugger. -#define VLD_OPT_REPORT_TO_FILE 0x0008 // If set, the memory leak report is sent to a file. -#define VLD_OPT_SAFE_STACK_WALK 0x0010 // If set, the stack is walked using the "safe" method (StackWalk64). -#define VLD_OPT_SELF_TEST 0x0020 // If set, perform a self-test to verify memory leak self-checking. -#define VLD_OPT_SLOW_DEBUGGER_DUMP 0x0040 // If set, inserts a slight delay between sending output to the debugger. -#define VLD_OPT_START_DISABLED 0x0080 // If set, memory leak detection will initially disabled. -#define VLD_OPT_TRACE_INTERNAL_FRAMES 0x0100 // If set, include useless frames (e.g. internal to VLD) in call stacks. -#define VLD_OPT_UNICODE_REPORT 0x0200 // If set, the leak report will be encoded UTF-16 instead of ASCII. -#define VLD_OPT_VLDOFF 0x0400 // If set, VLD will be completely deactivated. It will not attach to any modules. -#define VLD_OPT_REPORT_TO_STDOUT 0x0800 // If set, the memory leak report is sent to stdout. -#define VLD_OPT_SKIP_HEAPFREE_LEAKS 0x1000 // If set, VLD skip HeapFree memory leaks. -#define VLD_OPT_VALIDATE_HEAPFREE 0x2000 // If set, VLD verifies and reports heap consistency for HeapFree calls. -#define VLD_OPT_RELEASE_CRT_RUNTIME 0x4000 // If set, VLD treat CRT runtime as release version (use only with define VLD_FORCE_ENABLE). - -#define VLD_RPTHOOK_INSTALL 0 -#define VLD_RPTHOOK_REMOVE 1 - -typedef int (__cdecl * VLD_REPORT_HOOK)(int reportType, wchar_t *message, int *returnValue); diff --git a/third_party/win32/lib/debug/vld.lib b/third_party/win32/lib/debug/vld.lib deleted file mode 100644 index 0cf8962..0000000 Binary files a/third_party/win32/lib/debug/vld.lib and /dev/null differ diff --git a/webcc/CMakeLists.txt b/webcc/CMakeLists.txt index 927d49d..35a860d 100644 --- a/webcc/CMakeLists.txt +++ b/webcc/CMakeLists.txt @@ -1,3 +1,5 @@ +# webcc + # Don't use any deprecated definitions (e.g., io_service). add_definitions(-DASIO_NO_DEPRECATED) @@ -13,21 +15,28 @@ configure_file( # Adhere to GNU filesystem layout conventions. include(GNUInstallDirs) -file(GLOB SRCS - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cc +file(GLOB SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) + +file(GLOB HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h) if(NOT WEBCC_ENABLE_GZIP) - list(REMOVE_ITEM SRCS "gzip.h" "gzip.cc") + list(REMOVE_ITEM SOURCES "gzip.cc") + list(REMOVE_ITEM HEADERS "gzip.h") endif() +set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Add a postfix to the debug library") +mark_as_advanced(CMAKE_DEBUG_POSTFIX) + set(TARGET webcc) -add_library(${TARGET} STATIC ${SRCS}) +add_library(${TARGET} STATIC ${SOURCES} ${HEADERS}) # Install lib and header files. # On Linux, if CMAKE_INSTALL_PREFIX is ~, the lib (libwebcc.a) will be installed # to ~/lib and header files will be installed to ~/include. install(TARGETS ${TARGET} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webcc) +install(FILES ${PROJECT_BINARY_DIR}/webcc/config.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webcc) diff --git a/webcc/config.h.in b/webcc/config.h.in index a7dba13..3b84c81 100644 --- a/webcc/config.h.in +++ b/webcc/config.h.in @@ -11,7 +11,7 @@ #if WEBCC_ENABLE_LOG // 0:VERB, 1:INFO, 2:USER, 3:WARN or 4:ERRO #define WEBCC_LOG_LEVEL @WEBCC_LOG_LEVEL@ -#endif +#endif // WEBCC_ENABLE_LOG // Set 1/0 to enable/disable SSL/HTTPS. #define WEBCC_ENABLE_SSL @WEBCC_ENABLE_SSL@