Simplify CMake file and config.h

This commit is contained in:
qPCR4vir 2015-12-03 16:54:13 +01:00
parent f9f70cf08b
commit 3ad8f5a641
13 changed files with 171 additions and 116 deletions

View File

@ -4,13 +4,13 @@
# Robert Hauck - Enable support for PNG/Freetype # Robert Hauck - Enable support for PNG/Freetype
# Qiangqiang Wu - Add biicode support # Qiangqiang Wu - Add biicode support
# set compile flags # set compile flags
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# move this to the end ??
if(BIICODE) if(BIICODE)
# prepare BII_LIB_SRC # prepare BII_LIB_SRC
set(LIB_SRC ${BII_LIB_SRC}) set(LIB_SRC ${BII_LIB_SRC})
@ -33,23 +33,25 @@ if(WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif() endif()
# More MSVC specific compilation flags
#add_definitions(-D_SCL_SECURE_NO_WARNINGS)
#add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif(MSVC) endif(MSVC)
endif(WIN32) endif(WIN32)
#Unicode #Unicode
option(NANA_UNICODE "Use Unicode Character Set" ON) option(NANA_UNICODE "Use Unicode Character Set" ON)
#if(NANA_UNICODE) if(NANA_UNICODE)
# add_definitions(-DNANA_UNICODE) add_definitions(-DNANA_UNICODE)
# if(WIN32) endif()
# add_definitions(-DUNICODE -D_UNICODE)
# endif() if(APPLE)
#endif() add_definitions(-DAPPLE)
include_directories(/opt/X11/include/)
elseif(UNIX)
add_definitions(-Dlinux)
endif()
#Find PNG
if(UNIX) if(UNIX)
find_package(Freetype) find_package(Freetype)
if (FREETYPE_FOUND) if (FREETYPE_FOUND)
@ -57,21 +59,36 @@ if(UNIX)
endif() endif()
endif() endif()
option(NANA_ENABLE_PNG "Enable the use of PNG" ON)
#Find PNG
option(NANA_ENABLE_PNG "Enable the use of PNG" OFF)
option(USE_LIBPNG_FROM_OS "Use libpng from operating system." OFF)
if(NANA_ENABLE_PNG) if(NANA_ENABLE_PNG)
add_definitions(-DNANA_ENABLE_PNG) add_definitions(-DNANA_ENABLE_PNG)
if(USE_LIBPNG_FROM_OS)
option(NANA_LIBPNG "Use the included libpng" ON)
if(NANA_LIBPNG)
add_definitions(-DNANA_LIBPNG)
else()
find_package(PNG) find_package(PNG)
if (PNG_FOUND) if (PNG_FOUND)
include_directories( ${PNG_INCLUDE_DIRS}) include_directories( ${PNG_INCLUDE_DIRS})
add_definitions(-DUSE_LIBPNG_FROM_OS)
endif() endif()
endif() endif()
endif() endif()
#Find JPEG
option(NANA_ENABLE_JPEG "Enable the use of JPEG" OFF)
option(USE_LIBJPEG_FROM_OS "Use libjpeg from operating system." OFF)
if(NANA_ENABLE_JPEG)
add_definitions(-DNANA_ENABLE_JPEG)
if(USE_LIBJPEG_FROM_OS)
find_package(JPEG)
if (JPEG_FOUND)
include_directories( ${JPEG_INCLUDE_DIRS})
add_definitions(-DUSE_LIBJPEG_FROM_OS)
endif()
endif()
endif()
set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source) set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source)
set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)

View File

@ -1,18 +0,0 @@
/*
* Nana Configuration
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 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/config.hpp
*/
#ifndef NANA_CONFIG_HPP
#define NANA_CONFIG_HPP
//All defines have been moved to the CMakelists.txt in the root directory.
#endif //NANA_CONFIG_HPP

View File

@ -3,7 +3,7 @@
#include <nana/deploy.hpp> #include <nana/deploy.hpp>
#include <nana/audio/detail/audio_stream.hpp> #include <nana/audio/detail/audio_stream.hpp>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_thread.hpp> #include <nana/std_thread.hpp>
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#include <nana/std_condition_variable.hpp> #include <nana/std_condition_variable.hpp>

View File

@ -1,3 +1,17 @@
/**
* The charset Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 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/charset.hpp
*
*
*/
#ifndef NANA_CHARSET_HPP #ifndef NANA_CHARSET_HPP
#define NANA_CHARSET_HPP #define NANA_CHARSET_HPP
#include <string> #include <string>
@ -13,6 +27,7 @@ namespace nana
{ {
class charset_encoding_interface; class charset_encoding_interface;
} }
/// An intelligent charset class for character code conversion. /// An intelligent charset class for character code conversion.
class charset class charset
{ {

View File

@ -1,7 +1,7 @@
/* /**
* Nana Configuration * Nana Configuration
* Nana C++ Library(http://www.nanapro.org) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -13,63 +13,124 @@
#ifndef NANA_CONFIG_HPP #ifndef NANA_CONFIG_HPP
#define NANA_CONFIG_HPP #define NANA_CONFIG_HPP
#if defined(_MSC_VER) // Select platform ......
#define _SCL_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_DEPRECATE
#pragma warning(disable : 4996)
#if (_MSC_VER < 1900) // Windows:
// is this a good idea? #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#define NOT_IMPLEMENTED_KEYWORD_noexcept
#endif // _MSC_VER < 1900
#if (_MSC_VER == 1900)
// google: break any code that tries to use codecvt<char16_t> or codecvt<char32_t>.
// google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support.
// google: Those definitions are for codecvt<wchar_t>::id, codecvt<unsigned short>::id and codecvt<char>::id respectively.
// However, the codecvt<char16_t>::id and codecvt<char32_t>::id definitions aren't there, and indeed, if you look at locale0.cpp in the CRT source code you'll see they're not defined at all.
// google: That's a known issue, tracked by an active bug (DevDiv#1060849). We were able to update the STL's headers in response to char16_t/char32_t, but we still need to update the separately compiled sources.
#define STD_CODECVT_NOT_SUPPORTED
#endif // _MSC_VER == 1900
#endif // _MSVC
//Select platform automatically #define NANA_WINDOWS 1
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
//Windows:
#define NANA_WINDOWS 1
//Test if it is MINGW // compilers in Windows...
#if defined(__MINGW32__) || defined(__MINGW64__)
#define NANA_MINGW // MSVC++ versions
#define STD_CODECVT_NOT_SUPPORTED #if defined(_MSC_VER)
// https://github.com/meganz/mingw-std-threads #define _SCL_SECURE_NO_WARNNGS
//#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED #define _CRT_SECURE_NO_DEPRECATE
//#define _GLIBCXX_HAS_GTHREADS #pragma warning(disable : 4996)
//#define _GTHREAD_USE_MUTEX_TIMEDLOCK 1
//#define STD_THREAD_NOT_SUPPORTED #if (_MSC_VER == 1900)
#if ((__GNUC__ == 4) && ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 2))) // google: break any code that tries to use codecvt<char16_t> or codecvt<char32_t>.
// google: It appears the C++ libs haven't been compiled with native char16_t/char32_t support.
// google: Those definitions are for codecvt<wchar_t>::id, codecvt<unsigned short>::id and codecvt<char>::id respectively.
// However, the codecvt<char16_t>::id and codecvt<char32_t>::id definitions aren't there, and indeed, if you look at locale0.cpp in the CRT source code you'll see they're not defined at all.
// google: That's a known issue, tracked by an active bug (DevDiv#1060849). We were able to update the STL's headers in response to char16_t/char32_t, but we still need to update the separately compiled sources.
#define STD_CODECVT_NOT_SUPPORTED
#endif // _MSC_VER == 1900
#endif // _MSVC
// MINGW ...
#if defined(__MINGW32__) || defined(__MINGW64__)
#define NANA_MINGW
//Use this flag if MinGW version is older than 4.8.1 //Use this flag if MinGW version is older than 4.8.1
#define STD_THREAD_NOT_SUPPORTED #if ((__GNUC__ == 4) && ((__GNUC_MINOR__ < 8) || (__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ < 2)))
#define USE_github_com_meganz_mingw_std_threads
// ??
#define UNDEFINED_to_string
// https://github.com/meganz/mingw-std-threads
#define STD_THREAD_NOT_SUPPORTED
#define USE_github_com_meganz_mingw_std_threads
#endif
#endif // MINGW
// end Windows
// MacOS: who define APPLE ??
//#define APPLE
#elif defined(APPLE)
#define NANA_MACOS 1
#define NANA_X11 1
// how to add this: include_directories(/opt/X11/include/)
// MacOS
// Linux:
#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC)
#define NANA_LINUX 1
#define NANA_X11 1
// end Linux
#else
# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
#endif // Select platform
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#undef NANA_WINDOWS
#endif
// End Select platform ......
// compilers ...
// GCC ...
#if defined(__GNU__)
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ <= 1)
//GCC 4.7.0 does not implement the <codecvt> and codecvt_utfx classes ??
#define STD_CODECVT_NOT_SUPPORTED
//Some functions which are specified in 21.5 Numeric conversions in Strings library have not yet implemented
//Implement workarounds for GCC/MinGW which version is below 4.8.2
#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED
#endif #endif
#endif #endif // GCC
#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) // End compilers ...
//Linux:
#define NANA_LINUX 1
#define NANA_X11 1
#define STD_CODECVT_NOT_SUPPORTED
#else
# static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
#endif
#if defined(NANA_MINGW) || defined(NANA_LINUX)
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ <= 1) // Here defines some flags that tell Nana what features will be supported.
//Some functions which are specified in 21.5 Numeric conversions in Strings library have not yet implemented
#define STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED ///////////////////
//Support for PNG
// Define the NANA_ENABLE_PNG to enable the support of PNG.
//
//#define NANA_ENABLE_PNG //!
//#define USE_LIBPNG_FROM_OS // Un-Comment it to use libpng from operating system.
#if defined(NANA_ENABLE_PNG)
#if not defined(USE_LIBPNG_FROM_OS)
#define NANA_LIBPNG
#endif #endif
#endif #endif
//Here defines some flags that tell Nana what features will be supported. ///////////////////
//Support for JPEG
// Define the NANA_ENABLE_JPEG to enable the support of JPEG.
//
//#define NANA_ENABLE_JPEG //!
//#define USE_LIBJPEG_FROM_OS // Un-Comment it to use libjpeg from operating system.
#if defined(NANA_ENABLE_JPEG)
#if not defined(USE_LIBJPEG_FROM_OS)
#define NANA_LIBJPEG
#endif
#endif
//#ifndef NANA_UNICODE //#ifndef NANA_UNICODE
// always define NANA_UNICODE ?? it will be deprecated ?.
#define NANA_UNICODE #define NANA_UNICODE
#if defined(NANA_UNICODE) && defined(NANA_WINDOWS) #if defined(NANA_UNICODE) && defined(NANA_WINDOWS)
@ -82,23 +143,5 @@
#endif #endif
#endif #endif
///////////////////
//Support for PNG
// Define the NANA_ENABLE_PNG to enable the support of PNG.
//
//#define NANA_ENABLE_PNG //!
#if defined(NANA_ENABLE_PNG)
#define NANA_LIBPNG //Comment it to use libpng from operating system.
#endif
///////////////////
//Support for JPEG
// Define the NANA_ENABLE_JPEG to enable the support of JPEG.
//
//#define NANA_ENABLE_JPEG //!
#if defined(NANA_ENABLE_JPEG)
#define NANA_LIBJPEG //Comment this whole line to use libjpeg from operating system.
#endif
#endif //NANA_CONFIG_HPP #endif //NANA_CONFIG_HPP

View File

@ -19,9 +19,7 @@
#include <nana/config.hpp> #include <nana/config.hpp>
#include <nana/charset.hpp> #include <nana/charset.hpp>
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#undef NANA_WINDOWS
#endif
//Implement workarounds for GCC/MinGW which version is below 4.8.2 //Implement workarounds for GCC/MinGW which version is below 4.8.2
#if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED) #if defined(STD_NUMERIC_CONVERSIONS_NOT_SUPPORTED)

View File

@ -5,7 +5,7 @@
#include <unordered_set> #include <unordered_set>
#include <unordered_map> #include <unordered_map>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -17,7 +17,7 @@
#include <nana/traits.hpp> #include <nana/traits.hpp>
#include <nana/config.hpp> #include <nana/config.hpp>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -21,7 +21,7 @@
#include <map> #include <map>
#include <algorithm> #include <algorithm>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_thread.hpp> #include <nana/std_thread.hpp>
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#include <nana/std_condition_variable.hpp> #include <nana/std_condition_variable.hpp>
@ -29,7 +29,7 @@
#include <mutex> #include <mutex>
#include <condition_variable> #include <condition_variable>
#include <thread> #include <thread>
#endif //NANA_MINGW #endif // STD_THREAD_NOT_SUPPORTED
namespace nana namespace nana
{ {

View File

@ -14,7 +14,7 @@
#include <nana/gui/detail/native_window_interface.hpp> #include <nana/gui/detail/native_window_interface.hpp>
#include <nana/gui/screen.hpp> #include <nana/gui/screen.hpp>
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -20,7 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>

View File

@ -95,13 +95,13 @@ namespace nana
std::string pos_str() const std::string pos_str() const
{ {
#ifdef NANA_MINGW #ifdef UNDEFINED_to_string
std::stringstream ss; std::stringstream ss;
ss<<pos(); ss<<pos();
return ss.str(); return ss.str();
#else #else
return std::to_string(pos()); return std::to_string(pos());
#endif // NANA_MINGW #endif // UNDEFINED_to_string
} }
token read() token read()

View File

@ -19,7 +19,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) #if defined(STD_THREAD_NOT_SUPPORTED)
#include <nana/std_mutex.hpp> #include <nana/std_mutex.hpp>
#else #else
#include <mutex> #include <mutex>