From 73a5352796fac3a17d4d2d5fc6a73884dba15233 Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 13:23:01 +0100 Subject: [PATCH 1/5] fix for libpng --- build/cmake/CMakeLists.txt => CMakeLists.txt | 20 +++++++- build/cmake/config.hpp | 50 ++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) rename build/cmake/CMakeLists.txt => CMakeLists.txt (78%) create mode 100644 build/cmake/config.hpp diff --git a/build/cmake/CMakeLists.txt b/CMakeLists.txt similarity index 78% rename from build/cmake/CMakeLists.txt rename to CMakeLists.txt index e04ee417..8bdb64e4 100644 --- a/build/cmake/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,24 @@ project(nana) cmake_minimum_required(VERSION 2.8) -string(REGEX REPLACE "/[^/]*$" "" CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}) -string(REGEX REPLACE "/[^/]*$" "" CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}) + +option(NANA_ENABLE_PNG "Enable the use of PNG" ON) +if(NANA_ENABLE_PNG) + add_definitions(-DNANA_ENABLE_PNG) +endif() + +option(NANA_LIBPNG "Use the system installed libpng" OFF) +if(NANA_LIBPNG) + find_package(PNG) + if (PNG_FOUND) + include_directories( ${PNG_INCLUDE_DIRS}) + add_definitions(-DNANA_LIBPNG) + endif() +endif() + +#copy our new config.hpp (with removed PNG defines) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/build/cmake/config.hpp ${CMAKE_SOURCE_DIR}/include/nana/) + set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source) set(NANA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include) diff --git a/build/cmake/config.hpp b/build/cmake/config.hpp new file mode 100644 index 00000000..1436e7dc --- /dev/null +++ b/build/cmake/config.hpp @@ -0,0 +1,50 @@ +/* + * 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 + +//Select platform automatically +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +//Windows: + #define NANA_WINDOWS 1 + #define PLATFORM_SPEC_HPP + + //Test if it is MINGW + #if defined(__MINGW32__) + #define NANA_MINGW + #define STD_CODECVT_NOT_SUPPORTED + //#define STD_THREAD_NOT_SUPPORTED //Use this flag if MinGW version is older than 4.8.1 + #endif +#elif (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && !defined(_CRAYC) +//Linux: + #define NANA_LINUX 1 + #define NANA_X11 1 + #define PLATFORM_SPEC_HPP + #define STD_CODECVT_NOT_SUPPORTED +#endif + +//Here defines some flags that tell Nana what features will be supported. + +#define NANA_UNICODE + +#if defined(NANA_UNICODE) && defined(NANA_WINDOWS) + #ifndef _UNICODE + #define _UNICODE + #endif + + #ifndef UNICODE + #define UNICODE + #endif +#endif + +#endif //NANA_CONFIG_HPP From 5afe02cdd457a76666e39d9e3f198f085fc8131b Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 13:32:27 +0100 Subject: [PATCH 2/5] wrong defines --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8bdb64e4..2ce5400c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,12 +10,13 @@ if(NANA_ENABLE_PNG) add_definitions(-DNANA_ENABLE_PNG) endif() -option(NANA_LIBPNG "Use the system installed libpng" OFF) +option(NANA_LIBPNG "Use the included libpng" ON) if(NANA_LIBPNG) + add_definitions(-DNANA_LIBPNG) +else() find_package(PNG) if (PNG_FOUND) include_directories( ${PNG_INCLUDE_DIRS}) - add_definitions(-DNANA_LIBPNG) endif() endif() From 68caee5c2b57f8a80f7d5159d6bed632d22297bf Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 13:48:59 +0100 Subject: [PATCH 3/5] fix for linux build (Fedora 21) --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ce5400c..3834f2a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,10 @@ project(nana) cmake_minimum_required(VERSION 2.8) +#find dependencies +if(UNIX) + find_package(Freetype) +endif() option(NANA_ENABLE_PNG "Enable the use of PNG" ON) if(NANA_ENABLE_PNG) From 0464e8e5d71196f176a43088fc72beb4e8ff3b20 Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 13:57:48 +0100 Subject: [PATCH 4/5] missing include --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3834f2a1..ccca4c4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ cmake_minimum_required(VERSION 2.8) #find dependencies if(UNIX) find_package(Freetype) + if (FREETYPE_FOUND) + include_directories( ${FREETYPE_INCLUDE_DIRS}) + endif() endif() option(NANA_ENABLE_PNG "Enable the use of PNG" ON) From 0fa61b0c955ee218340340549484ffcb8510ecc0 Mon Sep 17 00:00:00 2001 From: Robert Hauck Date: Wed, 11 Feb 2015 14:02:55 +0100 Subject: [PATCH 5/5] make libpng only selectable when using png --- CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccca4c4c..c85b7303 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,18 +15,20 @@ endif() option(NANA_ENABLE_PNG "Enable the use of PNG" ON) if(NANA_ENABLE_PNG) add_definitions(-DNANA_ENABLE_PNG) -endif() -option(NANA_LIBPNG "Use the included libpng" ON) -if(NANA_LIBPNG) - add_definitions(-DNANA_LIBPNG) -else() - find_package(PNG) - if (PNG_FOUND) - include_directories( ${PNG_INCLUDE_DIRS}) + option(NANA_LIBPNG "Use the included libpng" ON) + if(NANA_LIBPNG) + add_definitions(-DNANA_LIBPNG) + else() + find_package(PNG) + if (PNG_FOUND) + include_directories( ${PNG_INCLUDE_DIRS}) + endif() endif() endif() + + #copy our new config.hpp (with removed PNG defines) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/build/cmake/config.hpp ${CMAKE_SOURCE_DIR}/include/nana/)