Merge branch 'qPCR4vir-workarounds_MinWG481' into develop

This commit is contained in:
Jinhao 2015-12-27 13:15:14 +08:00
commit fec3aa3c8e
6 changed files with 311 additions and 73 deletions

1
.gitignore vendored
View File

@ -38,6 +38,7 @@ lib/
*.ninja*
CMakeCache.txt
CMakeFiles/
.idea/
cmake_install.cmake
*.DS_Store
.idea/

View File

@ -3,6 +3,23 @@
# Contributor:
# Robert Hauck - Enable support for PNG/Freetype
# Qiangqiang Wu - Add biicode support
# Ariel Vina-Rodriguez (qPCR4vir)
#https://cmake.org/cmake-tutorial/
#https://cmake.org/cmake/help/v3.3/module/CMakeDependentOption.html?highlight=cmakedependentoption
# use CACHE FORCE or set(USE_meganz_mingw_std_threads ON) or delete CMakecache.txt or the entirely build dir
# if your changes don't execute
option(USE_meganz_mingw_std_threads "replaced boost.thread with meganz's mingw-std-threads." OFF)
option(USE_UNICODE "Use Unicode Character Set" ON)
option(ENABLE_PNG "Enable the use of PNG" OFF)
option(LIBPNG_FROM_OS "Use libpng from operating system." ON)
option(ENABLE_JPEG "Enable the use of JPEG" OFF)
option(LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
option(CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." OFF)
option(CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." ON)
option(BUILD_NANA_DEMOS "Build all the demos form the nana_demo repository." OFF)
option(CMAKE_STD_make_unique_NOT_SUPPORTED "Add support for make_unique<>()." OFF)
#set(CMAKE_STD_make_unique_NOT_SUPPORTED OFF)
# set compile flags
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
@ -18,37 +35,47 @@ if(BIICODE)
add_biicode_targets()
return()
endif()
endif(BIICODE)
project(nana)
cmake_minimum_required(VERSION 2.8)
#Global MSVC definitions
if(WIN32)
if(MSVC)
add_definitions(-DWIN32)
#Global MSVC definitions
if(MSVC)
option(WIN32_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
# ??
if(WIN32_USE_MP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
endif(WIN32_USE_MP)
endif(MSVC)
if(MINGW)
add_definitions(-DMINGW)
#Find PNG
if(USE_meganz_mingw_std_threads)
add_definitions(-DUSE_github_com_meganz_mingw_std_threads)
# remove_definitions()
endif(USE_meganz_mingw_std_threads)
endif(MINGW)
endif(WIN32)
#Unicode
option(USE_UNICODE "Use Unicode Character Set")
if(USE_UNICODE)
add_definitions(-DNANA_UNICODE)
endif()
endif(USE_UNICODE)
if(APPLE)
add_definitions(-DAPPLE)
include_directories(/opt/X11/include/)
elseif(UNIX)
add_definitions(-Dlinux)
endif()
endif(APPLE)
@ -56,19 +83,10 @@ if(UNIX)
find_package(Freetype)
if (FREETYPE_FOUND)
include_directories( ${FREETYPE_INCLUDE_DIRS})
endif()
endif()
if(WIN32)
add_definitions(-DWIN32)
if(MINGW)
add_definitions(-DMINGW)
endif()
endif()
endif(FREETYPE_FOUND)
endif(UNIX)
#Find PNG
option(ENABLE_PNG "Enable the use of PNG")
option(LIBPNG_FROM_OS "Use libpng from operating system.")
if(ENABLE_PNG)
add_definitions(-DNANA_ENABLE_PNG)
if(LIBPNG_FROM_OS)
@ -76,13 +94,11 @@ if(ENABLE_PNG)
if (PNG_FOUND)
include_directories( ${PNG_INCLUDE_DIRS})
add_definitions(-DUSE_LIBPNG_FROM_OS)
endif()
endif()
endif()
endif(PNG_FOUND)
endif(LIBPNG_FROM_OS)
endif(ENABLE_PNG)
#Find JPEG
option(ENABLE_JPEG "Enable the use of JPEG")
option(LIBJPEG_FROM_OS "Use libjpeg from operating system.")
if(ENABLE_JPEG)
add_definitions(-DNANA_ENABLE_JPEG)
if(LIBJPEG_FROM_OS)
@ -90,12 +106,23 @@ if(ENABLE_JPEG)
if (JPEG_FOUND)
include_directories( ${JPEG_INCLUDE_DIRS})
add_definitions(-DUSE_LIBJPEG_FROM_OS)
endif()
endif()
endif()
endif(JPEG_FOUND)
endif(LIBJPEG_FROM_OS)
endif(ENABLE_JPEG)
#Unicode
if(CMAKE_VERBOSE_PREPROCESSOR)
add_definitions(-DVERBOSE_PREPROCESSOR)
endif(CMAKE_VERBOSE_PREPROCESSOR)
# STD_make_unique_NOT_SUPPORTED
if(CMAKE_STD_make_unique_NOT_SUPPORTED)
add_definitions(-DSTD_make_unique_NOT_SUPPORTED)
endif(CMAKE_STD_make_unique_NOT_SUPPORTED)
set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source)
set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
@ -116,13 +143,16 @@ aux_source_directory(${NANA_SOURCE_DIR}/paint/detail NANA_PAINT_DETAIL_SOURCE)
aux_source_directory(${NANA_SOURCE_DIR}/system NANA_SYSTEM_SOURCE)
aux_source_directory(${NANA_SOURCE_DIR}/threads NANA_THREADS_SOURCE)
#To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library
#and Use SOURCE_GROUP if all your sources are in the same directory
add_library(${PROJECT_NAME} ${NANA_SOURCE}
${NANA_DETAIL_SOURCE}
${NANA_FILESYSTEM_SOURCE}
#if(NOT APPLE)
if(NOT APPLE)
${NANA_AUDIO_SOURCE}
${NANA_AUDIO_DETAIL_SOURCE}
#endif
endif (NOT APPLE)
${NANA_GUI_SOURCE}
${NANA_GUI_DETAIL_SOURCE}
${NANA_GUI_WIDGETS_SOURCE}
@ -132,17 +162,82 @@ add_library(${PROJECT_NAME} ${NANA_SOURCE}
${NANA_SYSTEM_SOURCE}
${NANA_THREADS_SOURCE})
#if(APPLE)
target_link_libraries(${PROJECT_NAME} -L/opt/X11/lib/ -lX11 -lXft -lpng -liconv)
#endif()
if(APPLE)
#Headers: use INCLUDE_DIRECTORIES
# Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES
target_link_libraries(${PROJECT_NAME} -L/opt/X11/lib/ -lX11 -lXft -lpng -liconv)
endif(APPLE)
install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
# ??
install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include)
set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 )
add_executable(nana_test test.cpp)
set_property( TARGET nana_test PROPERTY CXX_STANDARD 14 )
target_link_libraries(nana_test ${PROJECT_NAME})
if (BUILD_NANA_DEMOS)
set (CMAKE_INSTALL_PREFIX ${DEMO_BIN})
set(DEMO_BIN ${NANA_SOURCE_DIR}../nana-demo/bin)
set(CMAKE_INSTALL_PREFIX )
add_executable(file_explorer ../nana-demo/file_explorer.cpp)
set_property( TARGET file_explorer PROPERTY CXX_STANDARD 14 )
target_link_libraries(file_explorer ${PROJECT_NAME})
install(TARGETS file_explorer RUNTIME DESTINATION &{DEMO_BIN})
add_executable(calculator ../nana-demo/calculator.cpp)
set_property( TARGET calculator PROPERTY CXX_STANDARD 14 )
target_link_libraries(calculator ${PROJECT_NAME})
install(TARGETS calculator RUNTIME DESTINATION &{DEMO_BIN})
add_executable(FreeMe ../nana-demo/FreeMe.cpp)
set_property( TARGET FreeMe PROPERTY CXX_STANDARD 14 )
target_link_libraries(FreeMe ${PROJECT_NAME})
install(TARGETS FreeMe RUNTIME DESTINATION &{DEMO_BIN})
add_executable(notepad ../nana-demo/notepad.cpp)
set_property( TARGET notepad PROPERTY CXX_STANDARD 14 )
target_link_libraries(notepad ${PROJECT_NAME})
install(TARGETS notepad RUNTIME DESTINATION &{DEMO_BIN})
add_executable(widget_show ../nana-demo/widget_show.cpp)
set_property( TARGET widget_show PROPERTY CXX_STANDARD 14 )
target_link_libraries(widget_show ${PROJECT_NAME})
install(TARGETS widget_show RUNTIME DESTINATION &{DEMO_BIN})
add_executable(widget_show2 ../nana-demo/widget_show2.cpp)
set_property( TARGET widget_show2 PROPERTY CXX_STANDARD 14 )
target_link_libraries(widget_show2 ${PROJECT_NAME})
install(TARGETS widget_show2 RUNTIME DESTINATION &{DEMO_BIN})
add_executable(a_group_impl ../nana-demo/Examples/a_group_impl.cpp)
set_property( TARGET a_group_impl PROPERTY CXX_STANDARD 14 )
target_link_libraries(a_group_impl ${PROJECT_NAME})
add_executable(animate-bmp ../nana-demo/Examples/animate-bmp.cpp)
set_property( TARGET animate-bmp PROPERTY CXX_STANDARD 14 )
target_link_libraries(animate-bmp ${PROJECT_NAME})
add_executable(audio_player ../nana-demo/Examples/audio_player.cpp)
set_property( TARGET audio_player PROPERTY CXX_STANDARD 14 )
target_link_libraries(audio_player ${PROJECT_NAME})
#add_executable(nana_test test.cpp)
#set_property( TARGET nana_test PROPERTY CXX_STANDARD 14 )
#target_link_libraries(nana_test ${PROJECT_NAME})
#set(NANA_DEMOS_DIR ${CMAKE_SOURCE_DIR}/../nana-demo)
#set(NANA_EXAMPLES_DIR ${CMAKE_SOURCE_DIR}/../Examples/nana-demo/)
# https://cmake.org/cmake/help/v3.3/command/file.html?highlight=glob#file
#file( GLOB_RECURSE DEMO_SOURCES RELATIVE ../nana-demo *.cpp )
#foreach( demofile ${DEMO_SOURCES} )
# string( REPLACE ".cpp" "" demoname ${demofile} )
# add_executable( ${demoname} ${demofile} )
# set_property( TARGET ${demoname} PROPERTY CXX_STANDARD 14 )
# target_link_libraries(${demoname} ${PROJECT_NAME})
#endforeach( demofile ${DEMO_SOURCES} )
endif(BUILD_NANA_DEMOS)

View File

@ -7,7 +7,39 @@
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/config.hpp
* @file nana/config.hpp
*
* @brief Provide switches to adapt to the target OS, use of external libraries or workarounds compiler errors or lack of std C++ support.
*
* To control target OS/compiler:
* - NANA_WINDOWS
* - NANA_MINGW
* - NANA_POSIX
* - NANA_LINUX
* - NANA_MACOS
* - NANA_X11
* - NANA_UNICODE
*
* External libraries:
* - NANA_LIBPNG, USE_LIBPNG_FROM_OS
* - NANA_LIBJPEG, USE_LIBJPEG_FROM_OS
*
* (see: Feature-testing recommendations for C++
* in http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0096r0.html
* for example: __cpp_lib_experimental_filesystem = 201406 in <experimental/filesystem)
*
* Workaround to known compiler errors, unnecessary warnings or lack of C++11/14/17 support:
* - _SCL_SECURE_NO_WARNNGS, _CRT_SECURE_NO_DEPRECATE (VC)
* - STD_CODECVT_NOT_SUPPORTED (VC RC, <codecvt> is a known issue on libstdc++, it works on libc++)
* - STD_THREAD_NOT_SUPPORTED (GCC < 4.8.1)
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
* - USE_github_com_meganz_mingw_std_threads (MinGW with GCC < 4.8.1)
* - STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
* - STD_TO_STRING_NOT_SUPPORTED (MinGW with GCC < 4.8)
* - VERBOSE_PREPROCESSOR, STOP_VERBOSE_PREPROCESSOR
* - STD_make_unique_NOT_SUPPORTED (MinGW with GCC < 4.8.1)
* or __cpp_lib_make_unique
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0096r0.html#detail.cpp14.n3656
*/
#ifndef NANA_CONFIG_HPP
@ -18,31 +50,27 @@
// Windows:
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#define NANA_WINDOWS
#define NANA_WINDOWS
// MINGW ...
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(MINGW)
#define NANA_MINGW
#endif // MINGW
// end Windows
// end Windows
// MacOS: who define APPLE ??
//#define APPLE
#elif defined(APPLE)
#define NANA_MACOS
#define NANA_X11
// MacOS: who define APPLE ??
//#define APPLE
#elif defined(APPLE)
#define NANA_MACOS
#define NANA_X11
// how to add this: include_directories(/opt/X11/include/)
// end MacOS
// end MacOS
// Linux: (not sure about __GNU__ ??)
#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC)
#define NANA_LINUX
#define NANA_X11
// end Linux
#else
# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
// Linux: (not sure about __GNU__ ??)
#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC)
#define NANA_LINUX
#define NANA_X11
// end Linux
#else
#error( "Only Windows and Unix are supported now (Mac OS is experimental)");
#endif // Select platform
#if defined(NANA_LINUX) || defined(NANA_MACOS)
@ -69,27 +97,30 @@
#endif // _MSC_VER == 1900
#endif // _MSVC
#if defined(__clang__)
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
//<codecvt> is a known issue on libstdc++, it works on libc++
#define STD_CODECVT_NOT_SUPPORTED
#endif
#if defined(__clang__)
#elif defined(__GNUC__) //GCC
#if defined(__GLIBCPP__) || defined(__GLIBCXX__)
//<codecvt> is a known issue on libstdc++, it works on libc++
#define STD_CODECVT_NOT_SUPPORTED
#endif
// MINGW ...
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(MINGW)
#define NANA_MINGW
#endif // MINGW
// support for GCC 4.8.1 will be discontinued. Please use v5 or newer.
#if (__GNUC__ == 4)
#if ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 1))
#if ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ <= 1))
#define STD_THREAD_NOT_SUPPORTED
//boost.thread is preferred
//but if USE_github_com_meganz_mingw_std_threads is enabled,
//boost.thread will be replaced with meganz's mingw-std-threads.
// https://github.com/meganz/mingw-std-threads
//#define USE_github_com_meganz_mingw_std_threads
#if !defined( USE_github_com_meganz_mingw_std_threads )
//#define USE_github_com_meganz_mingw_std_threads
#endif
#if !defined(STD_make_unique_NOT_SUPPORTED)
#define STD_make_unique_NOT_SUPPORTED
#endif //STD_make_unique_NOT_SUPPORTED
#endif
#if defined(NANA_MINGW)
@ -103,6 +134,10 @@
#endif
#endif
//<codecvt> is a known issue on libstdc++, it works on libc++
#if defined(__GLIBCPP__) || defined( __GLIBCXX__ )
#define STD_CODECVT_NOT_SUPPORTED
#endif // __GLIBCPP__ or __GLIBCXX__
// End compilers ...
@ -151,5 +186,13 @@
#endif
#endif
#if !defined(VERBOSE_PREPROCESSOR)
//#define VERBOSE_PREPROCESSOR
#endif
#endif //NANA_CONFIG_HPP
#if !defined(STOP_VERBOSE_PREPROCESSOR)
#define STOP_VERBOSE_PREPROCESSOR
#endif
#endif // NANA_CONFIG_HPP

View File

@ -15,9 +15,12 @@
#ifndef NANA_DEPLOY_HPP
#define NANA_DEPLOY_HPP
#include <stdexcept>
#include <nana/config.hpp>
#if defined(VERBOSE_PREPROCESSOR)
#include <nana/verbose_preprocessor.hpp>
#endif
#include <stdexcept>
#include <nana/charset.hpp>
@ -142,4 +145,44 @@ namespace nana
#define NANA_RGB(a) (((DWORD)(a) & 0xFF)<<16) | ((DWORD)(a) & 0xFF00) | (((DWORD)(a) & 0xFF0000) >> 16 )
#if defined(STD_make_unique_NOT_SUPPORTED)
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3656.htm
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>
namespace std {
template<class T> struct _Unique_if {
typedef unique_ptr<T> _Single_object;
};
template<class T> struct _Unique_if<T[]> {
typedef unique_ptr<T[]> _Unknown_bound;
};
template<class T, size_t N> struct _Unique_if<T[N]> {
typedef void _Known_bound;
};
template<class T, class... Args>
typename _Unique_if<T>::_Single_object
make_unique(Args&&... args) {
return unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template<class T>
typename _Unique_if<T>::_Unknown_bound
make_unique(size_t n) {
typedef typename remove_extent<T>::type U;
return unique_ptr<T>(new U[n]());
}
template<class T, class... Args>
typename _Unique_if<T>::_Known_bound
make_unique(Args&&...) = delete;
}
#endif //STD_make_unique_NOT_SUPPORTED
#endif //NANA_MACROS_HPP

View File

@ -0,0 +1,56 @@
/**
* Nana Verbose preprocessor
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file nana/verbose_preprocessor.hpp
*
* @brief show the values of configuration constants during compilation to facilitate build debugging.
*
* Set VERBOSE_PREPROCESSOR to 1 to show the messages or to 0 for a normal build.
* Normally set to 0. Set to 1 only in case you want to debug the build system because it is extremely repetitive and slow.
*
* @authors Ariel Vina-Rodriguez (qPCR4vir)
*
*/
// Created by ariel.rodriguez on 08.12.2015.
//
#ifndef NANA_VERBOSE_PREPROCESSOR_H
#define NANA_VERBOSE_PREPROCESSOR_H
#if defined(VERBOSE_PREPROCESSOR)
#define STRING2(x) #x
#define STRING(x) STRING2(x)
#pragma message ( "\nVerbose preprocessor =" STRING(VERBOSE_PREPROCESSOR)" , \n STOP_VERBOSE_PREPROCESSOR=" STRING(STOP_VERBOSE_PREPROCESSOR) )
#pragma message ( "\nWindows: \n _WIN32=" STRING(_WIN32) ", \n __WIN32__ =" STRING(__WIN32__) " , \n WIN32=" STRING(WIN32)" , \n NANA_WINDOWS=" STRING(NANA_WINDOWS) )
#pragma message ( "\nUNICODE: \n NANA_UNICODE=" STRING(NANA_UNICODE) ", \n _UNICODE =" STRING(_UNICODE) " , \n UNICODE=" STRING(UNICODE) )
#pragma message ( "\nMinGW: \n __MINGW32__=" STRING(__MINGW32__) ", \n __MINGW64__=" STRING(__MINGW64__) " , \n MINGW=" STRING(MINGW) )
#pragma message ( "\nGNU: \n __GNUC__=" STRING(__GNUC__) ", \n __GNUC_MINOR__=" STRING(__GNUC_MINOR__) " , \n __GNUC_PATCHLEVEL__=" STRING(__GNUC_PATCHLEVEL__) )
#pragma message ( "\nSTD: \nSTD_CODECVT_NOT_SUPPORTED=" STRING(STD_CODECVT_NOT_SUPPORTED) " , \nSTD_THREAD_NOT_SUPPORTED=" STRING(STD_THREAD_NOT_SUPPORTED) )
#pragma message ( "\nSTD: \nUSE_github_com_meganz_mingw_std_threads=" STRING(USE_github_com_meganz_mingw_std_threads) " , \nSTD_THREAD_NOT_SUPPORTED=" STRING(STD_THREAD_NOT_SUPPORTED) )
#pragma message ( "\nClang compiler: \n__clang__=" STRING(__clang__) ", \n__GLIBCPP__=" STRING(__GLIBCPP__) " , \n__GLIBCXX__=" STRING(__GLIBCXX__) )
#pragma message ( "\nMSC: \n_MSC_VER=" STRING(_MSC_VER) ", \n_MSC_FULL_VER=" STRING(_MSC_FULL_VER ) )
#if defined(STOP_VERBOSE_PREPROCESSOR)
#error ("\nCompilation stopped to avoid annoying messages")
#endif
#endif // VERBOSE_PREPROCESSOR
#endif //NANA_VERBOSE_PREPROCESSOR_H

View File

@ -58,12 +58,12 @@ namespace nana
cell::cell(nana::string text, const format& fmt)
: text(std::move(text)),
custom_format(new format{ fmt }) //make_unique
custom_format(std::make_unique<format>( fmt )) // or custom_format(new format{ fmt })
{}
cell::cell(nana::string text, const ::nana::color& bgcolor, const ::nana::color& fgcolor)
: text(std::move(text)),
custom_format{ new format{ bgcolor, fgcolor } } //make_unique
custom_format{std::make_unique<format>( bgcolor, fgcolor ) } //custom_format{ new format{ bgcolor, fgcolor } }
{}
cell& cell::operator=(const cell& rhs)