diff --git a/.travis.yml b/.travis.yml index e81bb117..fd737985 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,8 +43,12 @@ matrix: - llvm-toolchain-precise before_install: + # donwload nana-demo first + # we are in: 'user'/nana/ - cd .. + # we are in: 'user'/ - git clone --depth=1 --branch=master https://github.com/qPCR4vir/nana-demo.git nana-demo + # now we have 'user'/nana-demo, 'user'/nana/ and we are in: 'user'/ - export PATH="$HOME/bin:$PATH" - wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.12/cmake-3.12.0-rc3-Linux-x86_64.sh || true - chmod -R +x /tmp/tools @@ -53,76 +57,24 @@ install: - /tmp/tools/cmake --prefix="$HOME" --exclude-subdir before_script : - # travis don't have a physical monitor. We need to install an emulator: https://docs.travis-ci.com/user/gui-and-headless-browsers/ - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - sleep 3 # give xvfb some time to start - # we have: qPCR4vir/nana/../nana-demo and now we are in: qPCR4vir/nana/ our executable tests will access: ../nana-demo/Examples/*.bmp etc.(need to be in parallel with nana-demo/Examples) - #- cd ../nana-demo - - mkdir demo-build + - mkdir demo-build - cd demo-build + # now we have 'user'/nana-demo, 'user'/nana/ , 'user'/demo-build/ and we are in: 'user'/demo-build/ + +services: + # travis don't have a physical monitor. We need to install an emulator: + # https://docs.travis-ci.com/user/gui-and-headless-browsers/ + - xvfb script: - cmake -G"Unix Makefiles" ../nana-demo -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON -DNANA_CMAKE_INSTALL=OFF - make install + - ctest --verbose # todo set correct working directory, and show output + # we have installed in 'user'/ ('user'/demo-build/..), and cmake created 'user'/nana-test/ # todo: separate resources from sources (a directory for images) - ls + # we were still in: 'user'/demo-build/ - cd ../nana-test/bin - - ls - - ./a_group_impl - - ./animate-bmp - - ./audio_player - - ./background-effects - #- ./calculator # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1159 - - ./categ - - ./clicked - - ./decore - - ./dock - - ./drag-button - - ./draw - - ./file_explorer - #- ./example_menu # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1348 - - ./example_listbox - #- ./example_combox # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1378 - - ./example.button - #- ./filebox-txt # https://travis-ci.org/qPCR4vir/nana/jobs/140250744#L1393 - - ./folder_tree - #- ./folder_tree_nana # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1408 - #- ./folder_tree_std # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1421 - - ./framework_design_1 - - ./framework_design_2 - - ./framework_design_3 - - ./group - - ./HelloWord - #- ./helloword_quit # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1572 - #- ./inputbox # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1585 - - ./label_listener - - ./lambda_event.Cpp11 - - ./listbox_inline_widget - - ./listbox_Resolver - - ./loader_1 - #- ./loader_2 # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1732 - - ./mbox - - ./main - - ./menu_debug - #- ./modal_form # https://travis-ci.org/qPCR4vir/nana/jobs/140250744#L1736 - #- ./MontiHall # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1775 - #- ./helloworld_demo # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1786 - #- ./notepad # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1799 - - ./menu_debug - - ./menu_popuper - #- ./modal_form # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1846 - #- ./widget_show2 # https://travis-ci.org/qPCR4vir/nana/jobs/140245437#L1730 - #- ./widget_show # https://travis-ci.org/qPCR4vir/nana/jobs/140245437#L1740 - - ./place_login - - ./png - #- ./screen # https://travis-ci.org/qPCR4vir/nana/jobs/140238537#L1909 - - ./stretch_image - #- ./threading # https://travis-ci.org/qPCR4vir/nana/jobs/140245437#L1826 ? - #- ./thread-pool # https://travis-ci.org/qPCR4vir/nana/jobs/140247564#L1782 - - ./various_events - #- ./window-dragger # https://travis-ci.org/qPCR4vir/nana/jobs/140245438#L1820 - - ./windows-subclassing - - ./textbox_line_number + - ls -lh diff --git a/CMakeLists.txt b/CMakeLists.txt index 69e1de1d..e9a9ee48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ # cmake 3.12 have more better modern c++ support cmake_minimum_required(VERSION 3.12 FATAL_ERROR) -project(nana VERSION 1.7.1 +project(nana VERSION 1.7.3 DESCRIPTION "C++ GUI library" HOMEPAGE_URL http://nanapro.org LANGUAGES CXX ) @@ -32,6 +32,7 @@ project(nana VERSION 1.7.1 add_library(nana) add_library(nana::nana ALIAS nana) target_compile_features(nana PUBLIC cxx_std_17) +# set(CMAKE_CXX_STANDARD 17) # need after cxx_std_14 or cxx_std_17 ?? target_compile_features(nana @@ -116,7 +117,7 @@ option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread wi ######## Nana options -target_compile_definitions(nana PRIVATE NANA_IGNORE_CONF) # really ? +target_compile_definitions(nana PRIVATE NANA_IGNORE_CONF) # really ?? if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) target_compile_definitions(nana PUBLIC NANA_AUTOMATIC_GUI_TESTING) # todo: enable_testing() # ?? diff --git a/README.md b/README.md index f8e7c0ed..c233c5ac 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Nana C++ Library -[Linux (gcc 5.4.0 and 4.9.2)![TravisCI build status](https://travis-ci.org/cnjinhao/nana.svg)](https://travis-ci.org/cnjinhao/nana) including [(nana-demos)](https://github.com/qPCR4vir/nana-demo) +[Linux (gcc 8.3.0 and 9.2)![TravisCI build status](https://travis-ci.org/cnjinhao/nana.svg)](https://travis-ci.org/cnjinhao/nana) including [(nana-demos)](https://github.com/qPCR4vir/nana-demo) -[Windows (Microsoft (R) Build Engine version 14.0.24720.0) ![AppVeyor build status](https://ci.appveyor.com/api/projects/status/5j79p9fi887usv7h?svg=true)](https://ci.appveyor.com/project/qPCR4vir/nana) +[Windows (Microsoft (R) Build Engine version 15.9.21) ![AppVeyor build status](https://ci.appveyor.com/api/projects/status/5j79p9fi887usv7h?svg=true)](https://ci.appveyor.com/project/qPCR4vir/nana) [![Licence](https://img.shields.io/badge/license-BSL-blue.svg?style=flat)](LICENSE) -Nana is a C++ library designed to allow developers to easily create cross-platform GUI applications with modern C++11 style. Currently it can work on Linux(X11) and Windows. The [nana repository](https://github.com/cnjinhao/nana) contains the entire source of the library. You can browse the source code and submit your pull request for contributing. +Nana is a C++ standard-like GUI library designed to allow developers to easily create cross-platform GUI applications with modern C++ style. Currently it is regularly tested on Linux(X11) and Windows, and experimentally on macOS and FreeBSD. The [nana repository](https://github.com/cnjinhao/nana) contains the entire source of the library. You can browse the source code and submit your pull request for contributing. ## License diff --git a/build/cmake/compilers.cmake b/build/cmake/compilers.cmake index c8db4976..07729e3c 100644 --- a/build/cmake/compilers.cmake +++ b/build/cmake/compilers.cmake @@ -38,13 +38,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AN endif() -if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # APPLE Clang - target_compile_options(nana PUBLIC -stdlib=libstdc++) -endif () - - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") target_compile_options(nana PRIVATE -fmax-errors=3) endif() - diff --git a/build/cmake/install_nana.cmake b/build/cmake/install_nana.cmake index 45636484..7c949646 100644 --- a/build/cmake/install_nana.cmake +++ b/build/cmake/install_nana.cmake @@ -1,4 +1,4 @@ -option(NANA_CMAKE_INSTALL "Install nana when compile the library (to be consumed without cmake)" ON) +option(NANA_CMAKE_INSTALL "Install nana after compiling the library (to be consumed WITHOUT cmake!!)" OFF) # Install the include directories too. if(NANA_CMAKE_INSTALL) @@ -6,8 +6,11 @@ if(NANA_CMAKE_INSTALL) # Is your responsability to ensure all compiler options are compatible with the compilation # of the project linking to the nana lib here generated target_sources(nana PRIVATE ${HEADERS}) - target_include_directories(nana PRIVATE ${NANA_INCLUDE_DIR}) message("The compiled Nana library will be installed in ${CMAKE_INSTALL_PREFIX}/lib") + message("WARNING !!! You are using the 'installed' nana! Not recommended! ") + message("If this was not your intention, please tern OFF option NANA_CMAKE_INSTALL ") + message("for example by adding: -DNANA_CMAKE_INSTALL=OFF to your call to cmake. ") + # Actually in DESTDIR/CMAKE_INSTALL_PREFIX/lib but in windows there is no DESTDIR/ part. install(TARGETS nana ARCHIVE DESTINATION lib @@ -15,8 +18,13 @@ if(NANA_CMAKE_INSTALL) RUNTIME DESTINATION bin) install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include) # in ${CMAKE_INSTALL_PREFIX}/include/nana message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include") + target_include_directories(nana PUBLIC $ + $ ) else() # this is the prefered method to consume nana with cmake + message("You are using nana directly from original sources. (Recommended!) " + "If this was not your intention, and what you want is to install precomplied nana first, then " + "please tern ON option NANA_CMAKE_INSTALL ") target_sources(nana PUBLIC ${HEADERS}) target_include_directories(nana PUBLIC ${NANA_INCLUDE_DIR}) endif() diff --git a/build/cmake/select_filesystem.cmake b/build/cmake/select_filesystem.cmake index 7b2163de..abd82cb4 100644 --- a/build/cmake/select_filesystem.cmake +++ b/build/cmake/select_filesystem.cmake @@ -1,30 +1,36 @@ # The ISO C++ File System Technical Specification (ISO-TS, or STD) was optional. # http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf # It is part of c++17. -# The library may be not available or working correctly in the std library in use. As a workaround we may try -# to "implement" it (ab)using Boost (almost compatible) +# The library may be not available or working correctly in the std library you use. +# As a workaround we will use Nana own partial, but functional implementation. +# You may opt to try to "implement" the std filesystem it (ab)using 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 or -# the selected option will be set by nana into std::filesystem -# By default Nana will try to use the STD. If STD is not available and NANA_CMAKE_FIND_BOOST_FILESYSTEM -# is set to ON nana will try to use boost if available. Nana own implementation will be use if none of -# the previus were selected or available. +# By ncluding the file or +# the selected option is inlined by nana into std::filesystem. +# By default Nana will try to use the STD. If STD is not available Nana own implementation will be used. # 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_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) +set (TEST_FS_LIB OFF) + if(NANA_CMAKE_NANA_FILESYSTEM_FORCE) + if(NANA_CMAKE_STD_FILESYSTEM_FORCE) + message (FATAL_ERROR "Defined NANA_CMAKE_NANA_FILESYSTEM_FORCE and NANA_CMAKE_STD_FILESYSTEM_FORCE") + endif() + if(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) + message (FATAL_ERROR "Defined NANA_CMAKE_NANA_FILESYSTEM_FORCE and NANA_CMAKE_BOOST_FILESYSTEM_FORCE") + endif() + target_compile_definitions(nana PUBLIC NANA_FILESYSTEM_FORCE) -elseif(NANA_CMAKE_STD_FILESYSTEM_FORCE) - target_compile_definitions(nana PUBLIC STD_FILESYSTEM_FORCE) - target_link_libraries (nana PUBLIC stdc++fs) - elseif(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) + if(NANA_CMAKE_STD_FILESYSTEM_FORCE) + message (FATAL_ERROR "Defined NANA_CMAKE_BOOST_FILESYSTEM_FORCE and NANA_CMAKE_STD_FILESYSTEM_FORCE") + endif() + target_compile_definitions(nana PUBLIC 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, @@ -43,14 +49,131 @@ elseif(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) set(Boost_USE_STATIC_RUNTIME ON) else() - # todo test for std (for now just force nana or boost if there no std) - target_link_libraries (nana PUBLIC stdc++fs) - - # todo if not test for boost - # if not add nana filesystem -endif() - + if(NANA_CMAKE_STD_FILESYSTEM_FORCE) + target_compile_definitions(nana PUBLIC STD_FILESYSTEM_FORCE) + endif() + + check_include_file_cxx (filesystem NANA_HAVE_FILESYSTEM) + if (NANA_HAVE_FILESYSTEM) + message (STATUS "C++ Filesystem header: ") + set (TEST_FS_LIB ON) + set (CXXSTD_FS_TEST_SOURCE + "#include + int main() + { + std::filesystem::path p{\"\tmp/\"}; + throw std::filesystem::filesystem_error(\"Empty file name!\", std::make_error_code(std::errc::invalid_argument)); + }") + else() + check_include_file_cxx (experimental/filesystem NANA_HAVE_EXP_FILESYSTEM) + if (NANA_HAVE_EXP_FILESYSTEM) + message (STATUS "C++ Filesystem header: ") + set (TEST_FS_LIB ON) + set (CXXSTD_FS_TEST_SOURCE + "#include + int main() + { + std::experimental::filesystem::path p{\"/tmp/\"}; + throw std::experimental::filesystem::filesystem_error(\"Empty file name!\", std::make_error_code(std::errc::invalid_argument)); + }") + else () + message (WARNING "No std::filesystem include file found: nana::filesystem will be used. + Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.") + target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED) + set (TEST_FS_LIB OFF) + endif () + endif () + + if (TEST_FS_LIB) + include (FindPackageMessage) + include (CheckIncludeFileCXX) + include (CheckCXXSourceCompiles) + # CMAKE_REQUIRED_FLAGS = string of compile command line flags + # CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) + # CMAKE_REQUIRED_INCLUDES = list of include directories + set (CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH}) + set (CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS}) + set (CMAKE_REQUIRED_FLAGS_ORIGINAL ${CMAKE_REQUIRED_FLAGS}) + set (CMAKE_REQUIRED_LIBRARIES_ORIGINAL ${CMAKE_REQUIRED_LIBRARIES}) + + # c++: builtin + set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL}") + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_BuiltIn) + if (CXXBuiltIn_FS_BuiltIn) + message (STATUS "C++ Filesystem library: builtin") + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_stdcppfs) + if (CXXBuiltIn_FS_stdcppfs) + message (STATUS "C++ Filesystem library: stdc++fs") + target_link_libraries (nana PUBLIC stdc++fs) + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXXBuiltIn_FS_cppfs) + if (CXXBuiltIn_FS_cppfs) + message (STATUS "C++ Filesystem library: c++fs") + target_link_libraries (nana PUBLIC c++fs) + else() + + # c++: -std=c++17 + set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL} -std=c++17") + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_BuiltIn) + if (CXX_std__cpp17_FS_BuiltIn) + message (STATUS "C++: -std=c++17; Filesystem library: builtin") + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_stdcppfs) + if (CXX_std__cpp17_FS_stdcppfs) + message (STATUS "C++: -std=c++17; Filesystem library: stdc++fs") + target_link_libraries (nana PUBLIC stdc++fs) + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std__cpp17_FS_cppfs) + if (CXX_std__cpp17_FS_cppfs) + message (STATUS "C++: -std=c++17; Filesystem library: c++fs") + target_link_libraries (nana PUBLIC c++fs) + else() + + # c++: /std:c++17 + set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL} /std:c++17") + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_BuiltIn) + if (CXX_std_cpp17_FS_BuiltIn) + message (STATUS "C++: /std:c++17; Filesystem library: builtin") + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} stdc++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_stdcppfs) + if (CXX_std_cpp17_FS_stdcppfs) + message (STATUS "C++: /std:c++17; Filesystem library: stdc++fs") + target_link_libraries (nana PUBLIC stdc++fs) + else() + set (CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES_ORIGINAL} c++fs") + check_cxx_source_compiles ("${CXXSTD_FS_TEST_SOURCE}" CXX_std_cpp17_FS_cppfs) + if (CXX_std_cpp17_FS_cppfs) + message (STATUS "C++: /std:c++17; Filesystem library: c++fs") + target_link_libraries (nana PUBLIC c++fs) + + else () + message (WARNING "No std::filesystem library found: nana::filesystem will be used. + Set NANA_CMAKE_NANA_FILESYSTEM_FORCE to ON to avoid this warning.") + target_compile_definitions(nana PUBLIC STD_FILESYSTEM_NOT_SUPPORTED) + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_ORIGINAL}) + set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_ORIGINAL}") + endif () + endif () + endif () + endif () + endif () + endif () + endif () + endif () + endif () + + endif (TEST_FS_LIB) +endif () diff --git a/build/cmake/shared_libs.cmake b/build/cmake/shared_libs.cmake index febb3b42..a158317d 100644 --- a/build/cmake/shared_libs.cmake +++ b/build/cmake/shared_libs.cmake @@ -1,5 +1,6 @@ option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF) +option(NANA_STATIC_STDLIB "Link nana statically to C++ standard library" ON) if(BUILD_SHARED_LIBS) # todo test @@ -35,12 +36,11 @@ if(BUILD_SHARED_LIBS) # todo test endif() endif() -if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW?? +if(NANA_STATIC_STDLIB) + target_link_libraries(nana + PUBLIC + $<$:-static-libgcc -static-libstdc++> + $<$:-static-libgcc -static-libstdc++> + ) +endif() - if(BUILD_SHARED_LIBS) - target_compile_options(nana PUBLIC -lgcc -lstdc++) - else() - target_link_libraries(nana PUBLIC -static-libgcc -static-libstdc++) - endif(BUILD_SHARED_LIBS) - -endif() \ No newline at end of file diff --git a/build/codeblocks/nana.cbp b/build/codeblocks/nana.cbp index 188c964d..5beaa6f0 100644 --- a/build/codeblocks/nana.cbp +++ b/build/codeblocks/nana.cbp @@ -14,8 +14,8 @@