From c499c351dce565c87b0fdeb23373699fdea22f01 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 25 Feb 2016 19:21:29 +0100 Subject: [PATCH] cleanup selection of std, boost or nana filesystem and install it in travis, with detection in cmake todo: check namespaces and compatibility of boost filesystem --- .travis.yml | 4 +- CMakeLists.txt | 71 +++++++++++++------ include/nana/config.hpp | 38 ++++++---- .../nana/filesystem/filesystem_selector.hpp | 60 ++++++++-------- 4 files changed, 107 insertions(+), 66 deletions(-) diff --git a/.travis.yml b/.travis.yml index d411b4b0..a688d416 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,10 +65,12 @@ install: - /tmp/tools/cmake --prefix="$HOME" --exclude-subdir before_script : + - sudo apt-get update -qq + - sudo apt-get install libboost-filesystem-dev - mkdir bld - cd bld script: - - cmake -G"Unix Makefiles" .. -DENABLE_JPEG=ON -DENABLE_PNG=OFF -DBUILD_NANA_DEMOS=ON -DENABLE_AUDIO=OFF + - cmake -G"Unix Makefiles" .. -DENABLE_JPEG=ON -DENABLE_PNG=OFF -DBUILD_NANA_DEMOS=ON -DENABLE_AUDIO=OFF -DCMAKE_FIND_BOOST_FILESYSTEM=ON -DINCLUDE_EXPERIMENTAL_DEMOS=ON - make diff --git a/CMakeLists.txt b/CMakeLists.txt index 261fe97d..1a4b6852 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ # use CACHEĀ FORCE or set(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ ON) or delete CMakecache.txt or the entirely build dir # if your changes don't execute +set(NANA_LINKS) + option(ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF) option(ENABLE_PNG "Enable the use of PNG" OFF) option(LIBPNG_FROM_OS "Use libpng from operating system." ON) @@ -20,8 +22,9 @@ option(ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF) 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(INCLUDE_EXPERIMENTAL_DEMOS "" OFF) -# The ISO C++ File System Technical Specification is optional. +# The ISO C++ File System Technical Specification (ISO-TS, or STD) is optional. # http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf # This is not a workaround, but an user option. # The library maybe available in the std library in use or from Boost (almost compatible) @@ -29,28 +32,51 @@ option(BUILD_NANA_DEMOS "Build all the demos form the nana_demo repository." OFF # or you can choose to use the (partial, but functional) implementation provided by nana. # If you include the file # The selected option will be set by nana into std::experimental::filesystem -# By default Nana will use the ISO TS if available, or nana if not. -# Boost will be use only if you change one of the following: -option(CMAKE_BOOST_FILESYSTEM_AVAILABLE "Is Boost filesystem available?" OFF) -option(NANA_BOOST_FILESYSTEM_PREFERRED "Is Boost filesystem preferred over nana?" ON) -option(CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over ISO)?" OFF) -option(CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find ?" "../") -option(CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs") +# By default Nana will try to use the STD. If not available will try +# to use boost if available. Nana own implementation will be use only none of them are available. +# You can change that default if you change one of the following +# (please don't define more than one of the _XX_FORCE options): +option(CMAKE_FIND_BOOST_FILESYSTEM "Search: Is Boost filesystem available?" ON) +option(CMAKE_NANA_FILESYSTEM_FORCE "Force nana filesystem over ISO and boost?" OFF) +option(CMAKE_STD_FILESYSTEM_FORCE "Use of STD filesystem?(a compilation error will ocurre if not available)" OFF) +option(CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over STD)?" OFF) +# cmake will find the package self, if don't works set the following (please find the correct values): +#option(CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find ?" "../") +#option(CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs") +#include_directories("${CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}") +#list(APPEND NANA_LINKS "${CMAKE_BOOST_FILESYSTEM_LIB}") -set(NANA_LINKS) -if (CMAKE_BOOST_FILESYSTEM_AVAILABLE) - if (CMAKE_BOOST_FILESYSTEM_PREFERED OR CMAKE_BOOST_FILESYSTEM_FORCE) + +if (CMAKE_NANA_FILESYSTEM_FORCE) + add_definitions(-DNANA_FILESYSTEM_FORCE) + +elseif (CMAKE_STD_FILESYSTEM_FORCE) + add_definitions(-DSTD_FILESYSTEM_FORCE) + +elseif (CMAKE_FIND_BOOST_FILESYSTEM OR CMAKE_BOOST_FILESYSTEM_FORCE) + + if (CMAKE_BOOST_FILESYSTEM_FORCE) + add_definitions(-DNANA_BOOST_FILESYSTEM_FORCE) + endif(CMAKE_BOOST_FILESYSTEM_FORCE) + + # https://cmake.org/cmake/help/git-master/module/FindBoost.html + # Implicit dependencies such as Boost::filesystem requiring Boost::system will be automatically detected and satisfied, + # even if system is not specified when using find_package and if Boost::system is not added to target_link_libraries. + # If using Boost::thread, then Thread::Thread will also be added automatically. + find_package(Boost COMPONENTS filesystem) + if (Boost_FOUND) add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE) - if (CMAKE_BOOST_FILESYSTEM_FORCE) - add_definitions(-DNANA_BOOST_FILESYSTEM_FORCE) - else() - add_definitions(-DNANA_BOOST_FILESYSTEM_PREFERED) - endif() - include_directories("${CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}") - list(APPEND NANA_LINKS "${CMAKE_BOOST_FILESYSTEM_LIB}") - endif (CMAKE_BOOST_FILESYSTEM_PREFERED OR CMAKE_BOOST_FILESYSTEM_FORCE) -endif (CMAKE_BOOST_FILESYSTEM_AVAILABLE) + include_directories(SYSTEM "${Boost_INCLUDE_DIR}") + list(APPEND NANA_LINKS "${Boost_LIBRARIES}") + endif (Boost_FOUND) + + set(Boost_USE_STATIC_LIBS ON) + set(Boost_USE_STATIC_RUNTIME ON) # ?? + #set(Boost_USE_MULTITHREADED ON) + +endif (CMAKE_FIND_BOOST_FILESYSTEM OR CMAKE_BOOST_FILESYSTEM_FORCE) + project(nana) cmake_minimum_required(VERSION 2.8) @@ -203,7 +229,10 @@ set_property( TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14 ) if (BUILD_NANA_DEMOS) - set (demos calculator file_explorer notepad widget_show widget_show2 ) + set (demos calculator notepad widget_show widget_show2 ) + if (INCLUDE_EXPERIMENTAL_DEMOS) + list(APPEND demos file_explorer) + endif (INCLUDE_EXPERIMENTAL_DEMOS) # Pending: FreeMe foreach ( demo ${demos}) diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 6335f2e2..2c1d3c83 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -39,20 +39,30 @@ // https://github.com/meganz/mingw-std-threads //#define NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ -//////////////////////////// -// The ISO C++ File System Technical Specification is optional. -// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf -// This is not a workaround, but an user option. -// The library maybe available in the std library in use or from Boost (almost compatible) -// http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm -// or you can choose to use the (partial, but functional) implementation provided by nana. -// If you include the file -// The selected option will be set by nana into std::experimental::filesystem -// By default Nana will use the ISO TS if available, or nana if not. -// Boost will be use only if you change one of the following (set the includes and link correspondly): -//#define NANA_BOOST_FILESYSTEM_AVAILABLE // "Is Boost filesystem available?" -//#define NANA_BOOST_FILESYSTEM_PREFERRED // "Is Boost filesystem preferred over nana?" -//#define NANA_BOOST_FILESYSTEM_FORCE // "Force use of Boost filesystem if available (over ISO)? +//# The ISO C++ File System Technical Specification(ISO - TS, or STD) is optional. +//# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf +//# This is not a workaround, but an user option. +//# The library maybe available in the std library in use or from Boost(almost compatible) +//# http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm +//# or you can choose to use the(partial, but functional) implementation provided by nana. +//# If you include the file +//# the selected option will be set by nana into std::experimental::filesystem +//# By default Nana will try to use the STD.If not available will try +//# to use boost if available.Nana own implementation will be use only none of them are available. +//# You can change that default if you change one of the following +//# (please don't define more than one of the _XX_FORCE options): +// +//#define BOOST_FILESYSTEM_AVAILABLE // "Is Boost filesystem available?" +//#define BOOST_FILESYSTEM_FORCE // "Force use of Boost filesystem if available (over ISO and nana) +//#define STD_FILESYSTEM_FORCE // "Use of STD filesystem?(a compilation error will ocurre if not available)" OFF) +//#define NANA_FILESYSTEM_FORCE // "Force nana filesystem over ISO and boost?" OFF) +// +// Make sure you (cmake?) provide the following where correspond (please find the correct values): +// set CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT "Where to find ?" "../") +// set CMAKE_BOOST_FILESYSTEM_LIB "Flag for the compiler to link: " "-lboost/fs") +// include_directories CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT +// APPEND flag LINKS CMAKE_BOOST_FILESYSTEM_LIB + /////////////////// // Support of PCM playback diff --git a/include/nana/filesystem/filesystem_selector.hpp b/include/nana/filesystem/filesystem_selector.hpp index af4cf298..5b00e0c7 100644 --- a/include/nana/filesystem/filesystem_selector.hpp +++ b/include/nana/filesystem/filesystem_selector.hpp @@ -9,16 +9,17 @@ * @file nana\filesystem\filesystem_selector.hpp * @autor by Ariel Vina-Rodriguez: * @brief A "ISO C++" filesystem Implementation selector -* The ISO C++ File System Technical Specification is optional. -* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf -* This is not a workaround, but an user option. -* The library maybe available in the std library in use or from Boost (almost compatible) -* http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm -* or you can choose to use the (partial, but functional) implementation provided by nana. -* If you include the file -* The selected option will be set by nana into std::experimental::filesystem -* By default Nana will use the ISO TS if available, or nana if not. -* Boost will be use only if explicitily changed +* +* The ISO C++ File System Technical Specification(ISO - TS, or STD) is optional. +* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf +* This is not a workaround, but an user option. +* The library maybe available in the std library in use or from Boost(almost compatible) +* http://www.boost.org/doc/libs/1_60_0/libs/filesystem/doc/index.htm +* or you can choose to use the(partial, but functional) implementation provided by nana. +* If you include the file +* the selected option will be set by nana into std::experimental::filesystem +* By default Nana will try to use the STD. If not available will try +* to use boost if available. Nana own implementation will be use only if none of them are available. * nana Now mimic std::experimental::filesystem::v1 (boost v3) * */ @@ -28,7 +29,25 @@ #include -#if (!defined(NANA_FILESYSTEM_FORCE) && defined(NANA_BOOST_FILESYSTEM_AVAILABLE) && ( defined(NANA_BOOST_FILESYSTEM_FORCE) || (defined(STD_FILESYSTEM_NOT_SUPPORTED) && defined(NANA_BOOST_FILESYSTEM_PREFERRED) ) )) +#if (defined(NANA_FILESYSTEM_FORCE) || ( (defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(BOOST_FILESYSTEM_AVAILABLE)) && !(defined(BOOST_FILESYSTEM_FORCE) || defined(STD_FILESYSTEM_FORCE)) ) ) + +# include + +namespace std { + namespace experimental { + namespace filesystem { + +# ifdef CXX_NO_INLINE_NAMESPACE + using namespace nana::experimental::filesystem; +# else + using namespace nana::experimental::filesystem::v1; +# endif + + } // filesystem + } // experimental +} // std + +#elif (defined(BOOST_FILESYSTEM_AVAILABLE) && ( defined(BOOST_FILESYSTEM_FORCE) || ( defined(STD_FILESYSTEM_NOT_SUPPORTED) && !defined(STD_FILESYSTEM_FORCE) ) )) # include @@ -47,25 +66,6 @@ namespace std { } // experimental } // std - -#elif (defined(NANA_FILESYSTEM_FORCE) || defined(STD_FILESYSTEM_NOT_SUPPORTED)) - -# include - -namespace std { - namespace experimental { - namespace filesystem { - -# ifdef CXX_NO_INLINE_NAMESPACE - using namespace nana::experimental::filesystem; -# else - using namespace nana::experimental::filesystem::v1; -# endif - - } // filesystem - } // experimental -} // std - #else # include #endif