From 5213c2e8b92177e5e99823b85ad43f435837df49 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 4 Oct 2018 10:14:58 +0200 Subject: [PATCH 1/5] reuse NANA_CMAKE_VERBOSE_PREPROCESSOR --- CMakeLists.txt | 84 ++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e427ee6..c6017cfe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,50 +142,54 @@ include(build/cmake/enable_audio.cmake) include(build/cmake/select_filesystem.cmake) -### Just for information: ######################################## -include(CMakePrintHelpers) -# see: https://cmake.org/cmake/help/v3.12/manual/cmake-properties.7.html#properties-on-targets -cmake_print_properties(TARGETS nana PROPERTIES - COMPILE_DEFINITIONS COMPILE_OPTIONS COMPILE_FLAGS LINK_LIBRARIES - INCLUDE_DIRECTORIES INSTALL_NAME_DIR LINK_FLAGS VERSION - ) +if (NANA_CMAKE_VERBOSE_PREPROCESSOR) - #message ("") -# cmake_print_variables(SOURCES) -cmake_print_variables(HEADERS) -cmake_print_variables(PUBLIC_HEADERS) -cmake_print_variables(NANA_CMAKE_INSTALL) + ### Just for information: ######################################## + include(CMakePrintHelpers) + # see: https://cmake.org/cmake/help/v3.12/manual/cmake-properties.7.html#properties-on-targets + cmake_print_properties(TARGETS nana PROPERTIES + COMPILE_DEFINITIONS COMPILE_OPTIONS COMPILE_FLAGS LINK_LIBRARIES + INCLUDE_DIRECTORIES INSTALL_NAME_DIR LINK_FLAGS VERSION + ) -cmake_print_variables(Boost_INCLUDE_DIR) -cmake_print_variables(Boost_LIBRARIES) -cmake_print_variables(Boost::filesystem) + #message ("") + # cmake_print_variables(SOURCES) + cmake_print_variables(HEADERS) + cmake_print_variables(PUBLIC_HEADERS) + cmake_print_variables(NANA_CMAKE_INSTALL) -cmake_print_variables(PNG_INCLUDE_DIRS) -cmake_print_variables(PNG_LIBRARIES) -cmake_print_variables(PNG::PNG) + cmake_print_variables(Boost_INCLUDE_DIR) + cmake_print_variables(Boost_LIBRARIES) + cmake_print_variables(Boost::filesystem) + + cmake_print_variables(PNG_INCLUDE_DIRS) + cmake_print_variables(PNG_LIBRARIES) + cmake_print_variables(PNG::PNG) -message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID}) -message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG}) -message ( "CMAKE_COMPILER_IS_GNUCXX = " ${CMAKE_COMPILER_IS_GNUCXX}) -message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS}) -message ( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS}) -message ( "CMAKE_STATIC_LINKER_FLAGS = " ${CMAKE_STATIC_LINKER_FLAGS}) + message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID}) + message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG}) + message ( "CMAKE_COMPILER_IS_GNUCXX = " ${CMAKE_COMPILER_IS_GNUCXX}) + message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS}) + message ( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS}) + message ( "CMAKE_STATIC_LINKER_FLAGS = " ${CMAKE_STATIC_LINKER_FLAGS}) -message ( "DESTDIR = " ${DESTDIR}) -message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) -message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR}) -message ( "CMAKE_CURRENT_SOURCE_DIR = " ${CMAKE_CURRENT_SOURCE_DIR}) -message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO}) -message ( "NANA_CMAKE_SHARED_LIB = " ${NANA_CMAKE_SHARED_LIB}) -message ( "NANA_CLION = " ${NANA_CLION}) -message ( "CMAKE_MAKE_PROGRAM = " ${CMAKE_MAKE_PROGRAM}) -message ( "CMAKE_CXX_COMPILER_VERSION = " ${CMAKE_CXX_COMPILER_VERSION}) + message ( "DESTDIR = " ${DESTDIR}) + message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) + message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR}) + message ( "CMAKE_CURRENT_SOURCE_DIR = " ${CMAKE_CURRENT_SOURCE_DIR}) + message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO}) + message ( "NANA_CMAKE_SHARED_LIB = " ${NANA_CMAKE_SHARED_LIB}) + message ( "NANA_CLION = " ${NANA_CLION}) + message ( "CMAKE_MAKE_PROGRAM = " ${CMAKE_MAKE_PROGRAM}) + message ( "CMAKE_CXX_COMPILER_VERSION = " ${CMAKE_CXX_COMPILER_VERSION}) -message ( "NANA_CMAKE_NANA_FILESYSTEM_FORCE = " ${NANA_CMAKE_NANA_FILESYSTEM_FORCE}) -message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM}) -message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE}) -message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}) -message ( "NANA_CMAKE_BOOST_FILESYSTEM_LIB = " ${NANA_CMAKE_BOOST_FILESYSTEM_LIB}) -message ( "NANA_CMAKE_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_AUTOMATIC_GUI_TESTING}) -message ( "NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING}) + message ( "NANA_CMAKE_NANA_FILESYSTEM_FORCE = " ${NANA_CMAKE_NANA_FILESYSTEM_FORCE}) + message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM}) + message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE}) + message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}) + message ( "NANA_CMAKE_BOOST_FILESYSTEM_LIB = " ${NANA_CMAKE_BOOST_FILESYSTEM_LIB}) + message ( "NANA_CMAKE_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_AUTOMATIC_GUI_TESTING}) + message ( "NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING}) + +endif() \ No newline at end of file From 3c672c4a53c6b90ce41c617c53430d404c6c86d8 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Fri, 5 Oct 2018 12:06:06 +0200 Subject: [PATCH 2/5] fix to full path ? CLion ? CMake ? me ? have problem with relative path? --- CMakeLists.txt | 16 ++++++++-------- build/cmake/select_filesystem.cmake | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c6017cfe..080b2952 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,16 +130,16 @@ if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) endif() list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/build/cmake/Modules) -include(build/cmake/install_nana.cmake) # includes and libs, or just expose the nana target -include(build/cmake/OS.cmake) # windows, unix, linux, apple, ... -include(build/cmake/shared_libs.cmake) # static and shared -include(build/cmake/compilers.cmake) # VC, gcc, clang +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/install_nana.cmake) # includes and libs, or just expose the nana target +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/OS.cmake) # windows, unix, linux, apple, ... +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/shared_libs.cmake) # static and shared +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/compilers.cmake) # VC, gcc, clang ############# Optional libraries ##################### -include(build/cmake/enable_png.cmake) -include(build/cmake/enable_jpeg.cmake) -include(build/cmake/enable_audio.cmake) -include(build/cmake/select_filesystem.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/enable_png.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/enable_jpeg.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/enable_audio.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/select_filesystem.cmake) if (NANA_CMAKE_VERBOSE_PREPROCESSOR) diff --git a/build/cmake/select_filesystem.cmake b/build/cmake/select_filesystem.cmake index 036cf050..974ae7d1 100644 --- a/build/cmake/select_filesystem.cmake +++ b/build/cmake/select_filesystem.cmake @@ -11,10 +11,10 @@ # the previus were selected or 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(NANA_CMAKE_FIND_BOOST_FILESYSTEM "Search: Is Boost filesystem available?" OFF) option(NANA_CMAKE_NANA_FILESYSTEM_FORCE "Force nana filesystem over ISO and boost?" OFF) option(NANA_CMAKE_STD_FILESYSTEM_FORCE "Use of STD filesystem?(a compilation error will ocurre if not available)" OFF) option(NANA_CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over STD)?" OFF) +option(NANA_CMAKE_FIND_BOOST_FILESYSTEM "Search: Is Boost filesystem available?" OFF) if(NANA_CMAKE_NANA_FILESYSTEM_FORCE) target_compile_definitions(nana PUBLIC NANA_FILESYSTEM_FORCE) From 9792b1ed2fe3b6b3c26f0e4097b6208922706490 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 6 Oct 2018 20:31:58 +0200 Subject: [PATCH 3/5] verbose.cmake # Just for information --- CMakeLists.txt | 60 +---------------------------- build/cmake/select_filesystem.cmake | 6 ++- build/cmake/verbose.cmake | 57 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 60 deletions(-) create mode 100644 build/cmake/verbose.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 080b2952..896e4134 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,17 +113,12 @@ foreach(subdir ${NANA_INCLUDE_SUBDIRS}) endforeach() ### Some nana compilation options ### -option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." OFF) -option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." OFF) option(NANA_CMAKE_AUTOMATIC_GUI_TESTING "Activate automatic GUI testing?" OFF) option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF) # deprecate? ######## Nana options target_compile_definitions(nana PRIVATE NANA_IGNORE_CONF) # really ? -if(NANA_CMAKE_VERBOSE_PREPROCESSOR) - target_compile_definitions(nana PRIVATE VERBOSE_PREPROCESSOR) -endif() if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) target_compile_definitions(nana PUBLIC NANA_AUTOMATIC_GUI_TESTING) # todo: enable_testing() # ?? @@ -132,7 +127,7 @@ endif() list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/build/cmake/Modules) include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/install_nana.cmake) # includes and libs, or just expose the nana target include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/OS.cmake) # windows, unix, linux, apple, ... -include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/shared_libs.cmake) # static and shared +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/shared_libs.cmake) # static vs shared include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/compilers.cmake) # VC, gcc, clang ############# Optional libraries ##################### @@ -140,56 +135,5 @@ include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/enable_png.cmake) include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/enable_jpeg.cmake) include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/enable_audio.cmake) include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/select_filesystem.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/build/cmake/verbose.cmake) # Just for information - -if (NANA_CMAKE_VERBOSE_PREPROCESSOR) - - ### Just for information: ######################################## - include(CMakePrintHelpers) - # see: https://cmake.org/cmake/help/v3.12/manual/cmake-properties.7.html#properties-on-targets - cmake_print_properties(TARGETS nana PROPERTIES - COMPILE_DEFINITIONS COMPILE_OPTIONS COMPILE_FLAGS LINK_LIBRARIES - INCLUDE_DIRECTORIES INSTALL_NAME_DIR LINK_FLAGS VERSION - ) - - #message ("") - # cmake_print_variables(SOURCES) - cmake_print_variables(HEADERS) - cmake_print_variables(PUBLIC_HEADERS) - cmake_print_variables(NANA_CMAKE_INSTALL) - - cmake_print_variables(Boost_INCLUDE_DIR) - cmake_print_variables(Boost_LIBRARIES) - cmake_print_variables(Boost::filesystem) - - cmake_print_variables(PNG_INCLUDE_DIRS) - cmake_print_variables(PNG_LIBRARIES) - cmake_print_variables(PNG::PNG) - - - message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID}) - message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG}) - message ( "CMAKE_COMPILER_IS_GNUCXX = " ${CMAKE_COMPILER_IS_GNUCXX}) - message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS}) - message ( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS}) - message ( "CMAKE_STATIC_LINKER_FLAGS = " ${CMAKE_STATIC_LINKER_FLAGS}) - - message ( "DESTDIR = " ${DESTDIR}) - message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) - message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR}) - message ( "CMAKE_CURRENT_SOURCE_DIR = " ${CMAKE_CURRENT_SOURCE_DIR}) - message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO}) - message ( "NANA_CMAKE_SHARED_LIB = " ${NANA_CMAKE_SHARED_LIB}) - message ( "NANA_CLION = " ${NANA_CLION}) - message ( "CMAKE_MAKE_PROGRAM = " ${CMAKE_MAKE_PROGRAM}) - message ( "CMAKE_CXX_COMPILER_VERSION = " ${CMAKE_CXX_COMPILER_VERSION}) - - message ( "NANA_CMAKE_NANA_FILESYSTEM_FORCE = " ${NANA_CMAKE_NANA_FILESYSTEM_FORCE}) - message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM}) - message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE}) - message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}) - message ( "NANA_CMAKE_BOOST_FILESYSTEM_LIB = " ${NANA_CMAKE_BOOST_FILESYSTEM_LIB}) - message ( "NANA_CMAKE_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_AUTOMATIC_GUI_TESTING}) - message ( "NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING}) - -endif() \ No newline at end of file diff --git a/build/cmake/select_filesystem.cmake b/build/cmake/select_filesystem.cmake index 974ae7d1..10c9836f 100644 --- a/build/cmake/select_filesystem.cmake +++ b/build/cmake/select_filesystem.cmake @@ -32,9 +32,11 @@ elseif(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) find_package(Boost REQUIRED COMPONENTS filesystem) if(Boost_FOUND) target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_AVAILABLE) - target_include_directories(nana PUBLIC "${Boost_INCLUDE_DIR}") # ?? SYSTEM + # SYSTEM - ignore warnings from here + target_include_directories(nana SYSTEM PUBLIC "${Boost_INCLUDE_DIR}") # ?? SYSTEM target_link_libraries (nana PUBLIC ${Boost_LIBRARIES}) - # target_link_libraries (nana PUBLIC Boost::Boost) + # target_include_directories (nana SYSTEM PUBLIC Boost::Boost) + # message("boost found true") endif() set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_RUNTIME ON) diff --git a/build/cmake/verbose.cmake b/build/cmake/verbose.cmake new file mode 100644 index 00000000..6d95eb9e --- /dev/null +++ b/build/cmake/verbose.cmake @@ -0,0 +1,57 @@ +option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." OFF) +option(NANA_CMAKE_STOP_VERBOSE_PREPROCESSOR "Stop compilation after showing the annoying debug messages." OFF) + + +if (NANA_CMAKE_VERBOSE_PREPROCESSOR) + + target_compile_definitions(nana PRIVATE VERBOSE_PREPROCESSOR) + + ### Just for information: ######################################## + include(CMakePrintHelpers) + # see: https://cmake.org/cmake/help/v3.12/manual/cmake-properties.7.html#properties-on-targets + cmake_print_properties(TARGETS nana PROPERTIES + COMPILE_DEFINITIONS COMPILE_OPTIONS COMPILE_FLAGS LINK_LIBRARIES + INCLUDE_DIRECTORIES INSTALL_NAME_DIR LINK_FLAGS VERSION + ) + + #message ("") + # cmake_print_variables(SOURCES) + cmake_print_variables(HEADERS) + cmake_print_variables(PUBLIC_HEADERS) + cmake_print_variables(NANA_CMAKE_INSTALL) + + cmake_print_variables(Boost_INCLUDE_DIR) + cmake_print_variables(Boost_LIBRARIES) + cmake_print_variables(Boost::filesystem) + + cmake_print_variables(PNG_INCLUDE_DIRS) + cmake_print_variables(PNG_LIBRARIES) + cmake_print_variables(PNG::PNG) + + cmake_print_variables(CMAKE_BUILD_TYPE) + cmake_print_variables(CMAKE_CONFIGURATION_TYPES) + message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID}) + message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG}) + message ( "CMAKE_COMPILER_IS_GNUCXX = " ${CMAKE_COMPILER_IS_GNUCXX}) + message ( "CMAKE_CXX_FLAGS = " ${CMAKE_CXX_FLAGS}) + message ( "CMAKE_EXE_LINKER_FLAGS = " ${CMAKE_EXE_LINKER_FLAGS}) + message ( "CMAKE_STATIC_LINKER_FLAGS = " ${CMAKE_STATIC_LINKER_FLAGS}) + + message ( "DESTDIR = " ${DESTDIR}) + message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) + message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR}) + message ( "CMAKE_CURRENT_SOURCE_DIR = " ${CMAKE_CURRENT_SOURCE_DIR}) + message ( "NANA_CMAKE_ENABLE_AUDIO = " ${NANA_CMAKE_ENABLE_AUDIO}) + message ( "NANA_CMAKE_SHARED_LIB = " ${NANA_CMAKE_SHARED_LIB}) + message ( "CMAKE_MAKE_PROGRAM = " ${CMAKE_MAKE_PROGRAM}) + message ( "CMAKE_CXX_COMPILER_VERSION = " ${CMAKE_CXX_COMPILER_VERSION}) + + message ( "NANA_CMAKE_NANA_FILESYSTEM_FORCE = " ${NANA_CMAKE_NANA_FILESYSTEM_FORCE}) + message ( "NANA_CMAKE_FIND_BOOST_FILESYSTEM = " ${NANA_CMAKE_FIND_BOOST_FILESYSTEM}) + message ( "NANA_CMAKE_BOOST_FILESYSTEM_FORCE = " ${NANA_CMAKE_BOOST_FILESYSTEM_FORCE}) + message ( "NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT = " ${NANA_CMAKE_BOOST_FILESYSTEM_INCLUDE_ROOT}) + message ( "NANA_CMAKE_BOOST_FILESYSTEM_LIB = " ${NANA_CMAKE_BOOST_FILESYSTEM_LIB}) + message ( "NANA_CMAKE_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_AUTOMATIC_GUI_TESTING}) + message ( "NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING = " ${NANA_CMAKE_ADD_DEF_AUTOMATIC_GUI_TESTING}) + +endif(NANA_CMAKE_VERBOSE_PREPROCESSOR) \ No newline at end of file From 5258b7ce8f81eb2c24de74fb76309224d105d924 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 9 Oct 2018 17:54:39 +0200 Subject: [PATCH 4/5] update project from 8.1 to 10 ?? --- build/vc2017/nana.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/vc2017/nana.vcxproj b/build/vc2017/nana.vcxproj index cc3c70dc..0c4323de 100644 --- a/build/vc2017/nana.vcxproj +++ b/build/vc2017/nana.vcxproj @@ -23,7 +23,7 @@ {42D0520F-EFA5-4831-84FE-2B9085301C5D} Win32Proj nana - 8.1 + 10.0.17134.0 From c0862ba666d662e71a13a761e77877810373fe19 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 25 Oct 2018 00:56:09 +0200 Subject: [PATCH 5/5] FIX folderbox with canonical make_prefered and add title --- include/nana/gui/filebox.hpp | 15 +++++--- source/gui/filebox.cpp | 75 ++++++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 34 deletions(-) diff --git a/include/nana/gui/filebox.hpp b/include/nana/gui/filebox.hpp index f6729318..812770ee 100644 --- a/include/nana/gui/filebox.hpp +++ b/include/nana/gui/filebox.hpp @@ -9,7 +9,7 @@ * * @file nana/gui/filebox.hpp * @author Jinhao - * @brief a dialog to chose file(s), implemented "native" in windows but using nana for X11 + * @brief dialogs to chose file(s) or a directory, implemented "native" in windows but using nana for X11 */ #ifndef NANA_GUI_FILEBOX_HPP @@ -31,7 +31,7 @@ namespace nana public: using filters = std::vector>; - filebox(bool is_open_mode); + explicit filebox(bool is_open_mode); filebox(window owner, bool is_open_mode); filebox(const filebox&); ~filebox(); @@ -56,8 +56,8 @@ namespace nana /// \brief Add a filetype filter. /// To specify multiple filter in a single description, use a semicolon to separate the patterns(for example,"*.TXT;*.DOC;*.BAK"). - filebox& add_filter(const ::std::string& description, ///< for example. "Text File" - const ::std::string& filetype ///< filter pattern(for example, "*.TXT") + filebox& add_filter(const ::std::string& description, ///< for example: "Text File" + const ::std::string& filetype ///< filter pattern(for example: "*.TXT") ); filebox& add_filter(const filters &ftres) @@ -94,7 +94,7 @@ namespace nana public: using path_type = std::experimental::filesystem::path; - folderbox(window owner = nullptr, const path_type& init_path = {}); + explicit folderbox(window owner = nullptr, const path_type& init_path = {}, std::string title={}); ~folderbox(); std::optional show() const; @@ -103,6 +103,11 @@ namespace nana { return show(); } + + /// Set a new title for the dialog + /// @param string a text for title + /// @return the old title. + ::std::string title( ::std::string new_title); private: implement* impl_; }; diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index fcaba515..16c69d0f 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -10,6 +10,8 @@ * @file: nana/gui/filebox.cpp */ +#include + #include #include #include @@ -1114,29 +1116,29 @@ namespace nana for(auto & f : impl_->filters) { filter_holder += to_wstring(f.des); - filter_holder += static_cast('\0'); - std::wstring fs = to_wstring(f.type); + filter_holder += static_cast('\0'); // separator + std::wstring ff = to_wstring(f.type); std::size_t pos = 0; - while(true) + while(true) // eliminate spaces { - pos = fs.find(L" ", pos); - if(pos == fs.npos) + pos = ff.find(L" ", pos); + if(pos == ff.npos) break; - fs.erase(pos); + ff.erase(pos); } - filter_holder += fs; - filter_holder += static_cast('\0'); + filter_holder += ff; + filter_holder += static_cast('\0'); // separator - //Get the default file extentsion + //Get the default file extension if (default_extension.empty()) { - pos = fs.find_last_of('.'); - if (pos != fs.npos) + pos = ff.find_last_of('.'); + if (pos != ff.npos) { - fs = fs.substr(pos + 1); - if (fs != L"*") + ff = ff.substr(pos + 1); + if (ff != L"*") { - default_extension = fs; + default_extension = ff; ofn.lpstrDefExt = default_extension.data(); } } @@ -1207,25 +1209,33 @@ namespace nana }//end class filebox - //class directory_picker + //class directory picker struct folderbox::implement { window owner; path_type init_path; + std::string title; + }; - folderbox::folderbox(window owner, const path_type& init_path) - : impl_(new implement) - { - impl_->owner = owner; - impl_->init_path = init_path; - } + folderbox::folderbox(window owner, const path_type& init_path, std::string title) + : impl_(new implement{ owner, fs::canonical(init_path).make_preferred(), title }) + {} + folderbox::~folderbox() { delete impl_; } + + std::string folderbox::title(std::string s) + { + impl_->title.swap(s); + return s; + } + + #ifdef NANA_MINGW static int CALLBACK browse_folder_callback(HWND hwnd, UINT msg, LPARAM lparam, LPARAM data) { @@ -1235,7 +1245,9 @@ namespace nana { case BFFM_INITIALIZED: if (data) + { SendMessage(hwnd, BFFM_SETSELECTION, TRUE, data); + } break; } @@ -1278,17 +1290,22 @@ namespace nana fd->Release(); } #else - BROWSEINFO brw = { 0 }; wchar_t display_text[MAX_PATH]; - brw.hwndOwner = reinterpret_cast(API::root(impl_->owner)); - brw.pszDisplayName = display_text; - brw.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; - brw.lpfn = browse_folder_callback; - + auto title = to_wstring( impl_->title ) ; std::wstring init_path = impl_->init_path.wstring(); - brw.lParam = reinterpret_cast(init_path.c_str()); - auto pidl = ::SHBrowseForFolder(&brw); + // https://docs.microsoft.com/en-us/windows/desktop/api/shlobj_core/ns-shlobj_core-_browseinfoa + BROWSEINFO brw = { 0 }; + brw.hwndOwner = reinterpret_cast(API::root(impl_->owner)); + //brw.pidlRoot; // specifies the location of the root folder from which to start browsing. + brw.pszDisplayName = display_text; // buffer to receive the display name of the folder selected by the user. + brw.lpszTitle = title.data(); + brw.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; // | BIF_EDITBOX; + brw.lpfn = browse_folder_callback; + brw.lParam = reinterpret_cast(init_path.c_str()); + //brw.iImage; // + + auto pidl = ::SHBrowseForFolder(&brw); if (pidl) { wchar_t folder_path[MAX_PATH];