Merge branch 'qPCR4vir-cmake-dev' into develop-1.7
This commit is contained in:
commit
68c6e67d08
1
.gitignore
vendored
1
.gitignore
vendored
@ -42,6 +42,7 @@ lib/
|
||||
CMakeCache.txt
|
||||
CMakeFiles/
|
||||
cmake-build-debug/
|
||||
cmake-build-*/
|
||||
.idea/
|
||||
cmake_install.cmake
|
||||
*.DS_Store
|
||||
|
28
.travis.yml
28
.travis.yml
@ -41,10 +41,10 @@ matrix:
|
||||
- llvm-toolchain-precise
|
||||
|
||||
before_install:
|
||||
- git clone --depth=1 --branch=develop https://github.com/qPCR4vir/nana-demo.git ../nana-demo
|
||||
- cd ..
|
||||
- git clone --depth=1 --branch=cmake-dev https://github.com/qPCR4vir/nana-demo.git nana-demo
|
||||
- export PATH="$HOME/bin:$PATH"
|
||||
#- mkdir ~/bin #it seemd that a bin already exists from 20170901
|
||||
- wget --no-check-certificate --no-clobber -O /tmp/tools/cmake https://cmake.org/files/v3.4/cmake-3.4.0-rc3-Linux-x86_64.sh || true
|
||||
- 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
|
||||
|
||||
install:
|
||||
@ -57,27 +57,11 @@ before_script :
|
||||
- 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 ../nana_lib
|
||||
- mkdir ../nana_demo_bin
|
||||
- cd ../nana_lib
|
||||
- mkdir bin
|
||||
- cd bin
|
||||
- mkdir demo-build
|
||||
- cd demo-build
|
||||
|
||||
script:
|
||||
# Installing: the static "nana lib" will be in DESTDIR/CMAKE_INSTALL_PREFIX/lib/
|
||||
# and the includes files "nana" in DESTDIR/CMAKE_INSTALL_PREFIX/include/
|
||||
# we are in "... nana/../nana_lib/bin/" we need "../../nana" to get the CMakeList.txt of nana.
|
||||
# Thus, make install will put the nana.lib in "... nana/../nana_lib/lib/"
|
||||
# and the includes in "... nana/../nana_lib/include/"
|
||||
- cmake -G"Unix Makefiles" ../../nana -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_BOOST_FILESYSTEM_FORCE=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON
|
||||
- make install
|
||||
- ls
|
||||
- cd ..
|
||||
- ls
|
||||
- cd ..
|
||||
- ls
|
||||
- cd nana_demo_bin
|
||||
- cmake -G"Unix Makefiles" ../nana-demo -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_ENABLE_PNG=OFF -DNANA_CMAKE_BUILD_DEMOS=ON -DNANA_CMAKE_ENABLE_AUDIO=OFF -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_BOOST_FILESYSTEM_FORCE=OFF -DNANA_CMAKE_INCLUDE_EXPERIMENTAL_DEMOS=OFF -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON
|
||||
- cmake -G"Unix Makefiles" ../nana-demo -DCMAKE_INSTALL_PREFIX=.. -DNANA_CMAKE_ENABLE_JPEG=ON -DNANA_CMAKE_FIND_BOOST_FILESYSTEM=ON -DNANA_CMAKE_AUTOMATIC_GUI_TESTING=ON
|
||||
- make install
|
||||
# todo: separate resources from sources (a directory for images)
|
||||
- ls
|
||||
|
476
CMakeLists.txt
476
CMakeLists.txt
@ -1,368 +1,177 @@
|
||||
# CMake configuration for Nana
|
||||
# Author: Andrew Kornilov(https://github.com/ierofant)
|
||||
# Contributors:
|
||||
# Andrew Kornilov (ierofant) - original version
|
||||
# Jinhao
|
||||
# Robert Hauck - Enable support for PNG/Freetype
|
||||
# Qiangqiang Wu - Add biicode support
|
||||
# Ariel Vina-Rodriguez (qPCR4vir)
|
||||
# (King_DuckZ)
|
||||
# Robert Hauck - Enable support for PNG/Freetype
|
||||
# Pavel O. - fix compilation with boost::filesystem (#281)
|
||||
# Frostbane - Add option for compiling a shared library (#263,#265)
|
||||
# Qiangqiang Wu - Add biicode support: todo migrate to https://conan.io/
|
||||
#
|
||||
# Nana uses some build systems: MS-VS solution, MAKE, bakefile, codeblock, etc. manually optimized.
|
||||
# In the future CMake could be the prefered, and maybe will be used to generate the others and the central nana repo
|
||||
# will distribute all of them. But by now CMake is just one of them and all the other distributed build system
|
||||
# files/projects are manually write. This current CMakeList.txt reflect this fact and that is why we don't
|
||||
# Maybe CMake will be used in the future to generate some of them in the central nana repository.
|
||||
# But by now CMake is just one option and all the other build system
|
||||
# files/projects distributed are manually writen. This current CMakeList.txt reflect this fact and that is why we don't
|
||||
# generate here configurated *.h files or explicitly enumerate the sources files: anyway this CM-list
|
||||
# will be "touched" to force a re-run of cmake.
|
||||
|
||||
#https://cmake.org/cmake-tutorial/
|
||||
#https://cmake.org/cmake/help/v3.3/module/CMakeDependentOption.html?highlight=cmakedependentoption
|
||||
# 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
|
||||
# It seems that project() defines essential system variables like CMAKE_FIND_LIBRARY_PREFIXES.
|
||||
# https://bbs.archlinux.org/viewtopic.php?id=84967
|
||||
# https://cliutils.gitlab.io/modern-cmake/
|
||||
# https://cmake.org/cmake-tutorial/
|
||||
# https://cmake.org/cmake/help/v3.12/module/CMakeDependentOption.html?highlight=cmakedependentoption
|
||||
# cmake 3.12 have more better modern c++ support
|
||||
|
||||
project(nana)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
|
||||
project(nana VERSION 1.6.2
|
||||
DESCRIPTION "C++ GUI library"
|
||||
HOMEPAGE_URL http://nanapro.org
|
||||
LANGUAGES CXX )
|
||||
|
||||
option(NANA_CMAKE_INSTALL_INCLUDES "Install nana includes when compile the library" ON)
|
||||
option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF)
|
||||
option(NANA_CMAKE_ENABLE_PNG "Enable the use of PNG" OFF)
|
||||
option(NANA_CMAKE_LIBPNG_FROM_OS "Use libpng from operating system." ON)
|
||||
option(NANA_CMAKE_ENABLE_JPEG "Enable the use of JPEG" OFF)
|
||||
option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
||||
option(NANA_CMAKE_ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
||||
option(NANA_CMAKE_SHARED_LIB "Compile nana as a shared library." OFF)
|
||||
option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." ON)
|
||||
####################### Main setting of Nana targets, sources and installs #####################
|
||||
|
||||
add_library(nana)
|
||||
target_compile_features(nana PUBLIC cxx_std_17)
|
||||
|
||||
# need after cxx_std_14 or cxx_std_17 ??
|
||||
target_compile_features(nana
|
||||
PUBLIC cxx_nullptr
|
||||
PUBLIC cxx_range_for
|
||||
PUBLIC cxx_lambdas
|
||||
PUBLIC cxx_decltype_auto
|
||||
PUBLIC cxx_defaulted_functions
|
||||
PUBLIC cxx_deleted_functions
|
||||
PUBLIC cxx_auto_type
|
||||
PUBLIC cxx_decltype_incomplete_return_types
|
||||
PUBLIC cxx_defaulted_move_initializers
|
||||
PUBLIC cxx_noexcept
|
||||
PUBLIC cxx_rvalue_references
|
||||
)
|
||||
|
||||
### collect all source sub-directories in a list to avoid duplication ###
|
||||
|
||||
# By using CMAKE_CURRENT_LIST_DIR here you can compile and consume nana by just:
|
||||
# add_subdirectory(../nana ../cmake-nana-build-${CONFIG} ) or simmilar
|
||||
# in your own CMakeLists.txt, and them :
|
||||
# target_link_libraries(yourApp PRIVATE nana )
|
||||
|
||||
set(NANA_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/source)
|
||||
|
||||
set(NANA_SOURCE_SUBDIRS
|
||||
/.
|
||||
/detail
|
||||
/filesystem
|
||||
/gui
|
||||
/gui/detail
|
||||
/gui/widgets
|
||||
/gui/widgets/skeletons
|
||||
/paint
|
||||
/paint/detail
|
||||
/system
|
||||
/threads
|
||||
)
|
||||
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||
list(APPEND NANA_SOURCE_SUBDIRS
|
||||
/audio
|
||||
/audio/detail
|
||||
)
|
||||
endif()
|
||||
|
||||
# collect all source files in the source-sub-dir
|
||||
foreach(subdir ${NANA_SOURCE_SUBDIRS})
|
||||
aux_source_directory(${NANA_SOURCE_DIR}${subdir} SOURCES) # todo: use GLOB to add headers too ??
|
||||
endforeach()
|
||||
|
||||
target_sources(nana PRIVATE ${SOURCES})
|
||||
|
||||
### collect all headers sub-directories in a list to avoid duplication ###
|
||||
# To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library / target_sources
|
||||
# and Use SOURCE_GROUP if all your sources are in the same directory
|
||||
set(NANA_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
|
||||
set(NANA_INCLUDE_SUBDIRS
|
||||
/.
|
||||
/filesystem
|
||||
/gui
|
||||
/gui/detail
|
||||
/gui/widgets
|
||||
/gui/widgets/skeletons
|
||||
/paint
|
||||
/paint/detail
|
||||
/pat
|
||||
/system
|
||||
/threads
|
||||
)
|
||||
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||
list(APPEND NANA_INCLUDE_SUBDIRS
|
||||
/audio
|
||||
/audio/detail
|
||||
)
|
||||
endif()
|
||||
|
||||
foreach(subdir ${NANA_INCLUDE_SUBDIRS})
|
||||
aux_source_directory(${NANA_INCLUDE_DIR}/nana${subdir} HEADERS) # todo: use GLOB to add headers too !!!!!!!
|
||||
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_CLION "Activate some CLion specific workarounds" OFF)
|
||||
|
||||
# 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 <nana/filesystem/filesystem.hpp> or <nana/filesystem/filesystem_ext.hpp>
|
||||
# the selected option will be set by nana into std::experimental::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.
|
||||
# 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)
|
||||
|
||||
########### Compatibility with CMake 3.1
|
||||
if(POLICY CMP0054)
|
||||
# http://www.cmake.org/cmake/help/v3.1/policy/CMP0054.html
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
endif()
|
||||
|
||||
########### OS
|
||||
|
||||
if(WIN32)
|
||||
add_definitions(-DWIN32)
|
||||
# Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository.
|
||||
if(MSVC)
|
||||
option(MSVC_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
|
||||
option(MSVC_USE_STATIC_RUNTIME "Set to ON to build nana with the /MT(d) option." ON)
|
||||
|
||||
# Change the MSVC Compiler flags
|
||||
if(MSVC_USE_MP)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
endif()
|
||||
|
||||
if(MSVC_USE_STATIC_RUNTIME)
|
||||
foreach(flag
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MINGW)
|
||||
if(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||
add_definitions(-DSTD_THREAD_NOT_SUPPORTED)
|
||||
add_definitions(-DNANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(DLLTOOL OFF)
|
||||
else()
|
||||
# mingw: If dlltool is found the def and lib file will be created
|
||||
find_program (DLLTOOL dlltool)
|
||||
if(NOT DLLTOOL)
|
||||
message(WARNING "dlltool not found. Skipping import library generation.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
add_definitions(-DAPPLE)
|
||||
include_directories(/opt/X11/include/)
|
||||
list(APPEND NANA_LINKS -L/opt/X11/lib/ -liconv)
|
||||
set(ENABLE_AUDIO OFF)
|
||||
elseif(UNIX)
|
||||
add_definitions(-Dlinux)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND NANA_LINKS -lX11)
|
||||
include(FindFreetype)
|
||||
if(FREETYPE_FOUND)
|
||||
include_directories( ${FREETYPE_INCLUDE_DIRS})
|
||||
list(APPEND NANA_LINKS -lXft -lfontconfig)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
########### Compilers
|
||||
#
|
||||
# Using gcc: gcc 4.8 don't support C++14 and make_unique. You may want to update at least to 4.9.
|
||||
# gcc 5.3 and 5.4 include filesytem, but you need to add the link flag: -lstdc++fs
|
||||
#
|
||||
# In Windows, the gcc which come with CLion was 4.8 from MinGW.
|
||||
# CLion was updated to MinGW with gcc 6.3 ? Allways check this in File/Settings.../toolchains
|
||||
# You could install MinGW-w64 from the TDM-GCC Compiler Suite for Windows which will update you to gcc 5.1.
|
||||
# It is posible to follow https://computingabdn.com/softech/mingw-howto-install-gcc-for-windows/
|
||||
# and install MinGW with gcc 7.1 with has STD_THREADS and fs, from: https://sourceforge.net/projects/mingw-w64/files/
|
||||
#
|
||||
#
|
||||
# see at end of: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html
|
||||
#
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
|
||||
set(CMAKE_CXX_FLAGS "-std=gnu++14 -Wall -I/usr/local/include")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "-std=gnu++14 -Wall")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "-std=c++14 -Wall")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
if(NANA_CMAKE_SHARED_LIB)
|
||||
list(APPEND NANA_LINKS -lgcc -lstdc++ -pthread)
|
||||
else()
|
||||
if(MINGW)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static -pthread")
|
||||
else()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread")
|
||||
endif()
|
||||
endif(NANA_CMAKE_SHARED_LIB)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
|
||||
# GCC 4.9
|
||||
list(APPEND NANA_LINKS "-lboost_system -lboost_thread")
|
||||
elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3)
|
||||
# IS_GNUCXX < 5.3
|
||||
else()
|
||||
list(APPEND NANA_LINKS -lstdc++fs)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # APPLE Clang
|
||||
list(APPEND NANA_LINKS -stdlib=libstdc++)
|
||||
endif ()
|
||||
|
||||
|
||||
############# Optional libraries
|
||||
|
||||
# Find PNG
|
||||
if(NANA_CMAKE_ENABLE_PNG)
|
||||
if(NANA_CMAKE_LIBPNG_FROM_OS)
|
||||
find_package(PNG)
|
||||
if(PNG_FOUND)
|
||||
include_directories(${PNG_INCLUDE_DIRS})
|
||||
list(APPEND NANA_LINKS ${PNG_LIBRARIES})
|
||||
add_definitions(-DNANA_ENABLE_PNG -DUSE_LIBPNG_FROM_OS)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DNANA_ENABLE_PNG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find JPEG
|
||||
if(NANA_CMAKE_ENABLE_JPEG)
|
||||
add_definitions(-DNANA_ENABLE_JPEG)
|
||||
if(NANA_CMAKE_LIBJPEG_FROM_OS)
|
||||
find_package(JPEG)
|
||||
if(JPEG_FOUND)
|
||||
include_directories( ${JPEG_INCLUDE_DIR})
|
||||
list(APPEND NANA_LINKS ${JPEG_LIBRARY})
|
||||
add_definitions(-DNANA_ENABLE_JPEG -DUSE_LIBJPEG_FROM_OS)
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DNANA_ENABLE_JPEG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find ASOUND
|
||||
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||
add_definitions(-DNANA_ENABLE_AUDIO)
|
||||
if(UNIX)
|
||||
find_package(ASOUND)
|
||||
if(ASOUND_FOUND)
|
||||
include_directories(${ASOUND_INCLUDE_DIRS})
|
||||
list(APPEND NANA_LINKS -lasound)
|
||||
else()
|
||||
message(FATAL_ERROR "libasound is not found")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Find/Select filesystem
|
||||
if(NANA_CMAKE_NANA_FILESYSTEM_FORCE)
|
||||
add_definitions(-DNANA_FILESYSTEM_FORCE)
|
||||
elseif(NANA_CMAKE_STD_FILESYSTEM_FORCE)
|
||||
add_definitions(-DSTD_FILESYSTEM_FORCE)
|
||||
elseif(NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||
if(NANA_CMAKE_BOOST_FILESYSTEM_FORCE)
|
||||
add_definitions(-DBOOST_FILESYSTEM_FORCE)
|
||||
endif()
|
||||
# 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(-DBOOST_FILESYSTEM_AVAILABLE)
|
||||
include_directories(SYSTEM "${Boost_INCLUDE_DIR}")
|
||||
list(APPEND NANA_LINKS ${Boost_LIBRARIES})
|
||||
endif()
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
set(Boost_USE_STATIC_RUNTIME ON)
|
||||
endif()
|
||||
|
||||
option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF) # deprecate?
|
||||
|
||||
######## Nana options
|
||||
|
||||
add_definitions(-DNANA_IGNORE_CONF)
|
||||
target_compile_definitions(nana PRIVATE NANA_IGNORE_CONF) # really ?
|
||||
if(NANA_CMAKE_VERBOSE_PREPROCESSOR)
|
||||
add_definitions(-DVERBOSE_PREPROCESSOR)
|
||||
target_compile_definitions(nana PRIVATE VERBOSE_PREPROCESSOR)
|
||||
endif()
|
||||
if(NANA_CMAKE_AUTOMATIC_GUI_TESTING)
|
||||
add_definitions(-DNANA_AUTOMATIC_GUI_TESTING)
|
||||
enable_testing()
|
||||
target_compile_definitions(nana PUBLIC NANA_AUTOMATIC_GUI_TESTING)
|
||||
# todo: enable_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
|
||||
|
||||
####################### Main setting of Nana sources, targets and install
|
||||
|
||||
set(NANA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
|
||||
set(NANA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
# collect all source sub-directories in a list to avoid duplication here
|
||||
set(NANA_SOURCE_SUBDIRS /.
|
||||
/detail
|
||||
/filesystem
|
||||
/gui
|
||||
/gui/detail
|
||||
/gui/widgets
|
||||
/gui/widgets/skeletons
|
||||
/paint
|
||||
/paint/detail
|
||||
/system
|
||||
/threads
|
||||
)
|
||||
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||
list(APPEND NANA_SOURCE_SUBDIRS /audio
|
||||
/audio/detail
|
||||
)
|
||||
endif()
|
||||
# collect all source files in the source-sub-dir
|
||||
# To show .h files in Visual Studio, add them to the list of sources in add_executable / add_library
|
||||
# and Use SOURCE_GROUP if all your sources are in the same directory
|
||||
foreach(subdir ${NANA_SOURCE_SUBDIRS})
|
||||
aux_source_directory(${NANA_SOURCE_DIR}${subdir} SOURCES)
|
||||
endforeach()
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
add_definitions(-fmax-errors=3)
|
||||
endif()
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX "_d")
|
||||
|
||||
if(NANA_CMAKE_SHARED_LIB)
|
||||
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||
else()
|
||||
add_library(${PROJECT_NAME} STATIC ${SOURCES})
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ${NANA_INCLUDE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${NANA_LINKS})
|
||||
|
||||
# Headers: use INCLUDE_DIRECTORIES
|
||||
# Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES)
|
||||
|
||||
# Installing: the static "nana lib" will be in DESTDIR/CMAKE_INSTALL_PREFIX/lib/
|
||||
# and the includes files "include/nana/" in DESTDIR/CMAKE_INSTALL_PREFIX/include/nana/
|
||||
# unfortunatelly install() is still ignored by CLion:
|
||||
# https://intellij-support.jetbrains.com/hc/en-us/community/posts/205822949-CMake-install-isn-t-supported-
|
||||
install(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin)
|
||||
|
||||
# http://stackoverflow.com/questions/33788729/how-do-i-get-clion-to-run-an-install-target
|
||||
if(NANA_CLION) # the Clion IDE don't reconize the install target
|
||||
add_custom_target(install_${PROJECT_NAME}
|
||||
$(MAKE) install
|
||||
DEPENDS ${PROJECT_NAME}
|
||||
COMMENT "Installing ${PROJECT_NAME}")
|
||||
endif()
|
||||
|
||||
if(NANA_CMAKE_SHARED_LIB)
|
||||
if(WIN32)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
if(DLLTOOL)
|
||||
#generate the lib and def files needed by msvc
|
||||
set_target_properties (${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}"
|
||||
ARCHIVE_OUTPUT_NAME "${PROJECT_NAME}"
|
||||
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--output-def=${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.def")
|
||||
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
COMMAND echo " Generating import library"
|
||||
COMMAND "${DLLTOOL}" --dllname "lib${PROJECT_NAME}.dll"
|
||||
--input-def "lib${PROJECT_NAME}.def"
|
||||
--output-lib "lib${PROJECT_NAME}.lib")
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.def"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.lib" DESTINATION lib)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message("")
|
||||
message("The compiled Nana library will be installed in ${CMAKE_INSTALL_PREFIX}/lib")
|
||||
# Install the include directories too.
|
||||
if(NANA_CMAKE_INSTALL_INCLUDES)
|
||||
install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include)
|
||||
message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include")
|
||||
endif()
|
||||
############# 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)
|
||||
|
||||
|
||||
### 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)
|
||||
|
||||
|
||||
# Just for information:
|
||||
message ("")
|
||||
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 ( "NANA_LINKS = " ${NANA_LINKS})
|
||||
|
||||
message ( "DESTDIR = " ${DESTDIR})
|
||||
message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX})
|
||||
message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR})
|
||||
@ -373,6 +182,7 @@ 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})
|
||||
|
@ -1,12 +0,0 @@
|
||||
# Minimal layout, with all auxiliary folders inside "bii" and
|
||||
# The binary "bin" folder as is, and enabled code edition in the project root
|
||||
cmake: bii/cmake
|
||||
lib: bii/lib
|
||||
build: bii/build
|
||||
|
||||
deps: bii/deps
|
||||
# Setting this to True enables directly editing in the project root
|
||||
# instead of blocks/youruser/yourblock
|
||||
# the block will be named as your project folder
|
||||
auto-root-block: True
|
||||
root-block: qiangwu/nana
|
@ -1,11 +0,0 @@
|
||||
# This file configures your finds of dependencies.
|
||||
#
|
||||
# It is an ordered list of rules, which will be evaluated in order, of the form:
|
||||
# block_pattern: TAG
|
||||
#
|
||||
# For each possible block that could resolve your dependencies,
|
||||
# only versions with tag >= TAG will be accepted
|
||||
|
||||
qiangwu/* : DEV
|
||||
* : STABLE
|
||||
|
@ -1,2 +0,0 @@
|
||||
cmake: {generator: MinGW Makefiles}
|
||||
os: {arch: 32bit, family: Windows, subfamily: '7', version: 6.1.7601}
|
49
biicode.conf
49
biicode.conf
@ -1,49 +0,0 @@
|
||||
# Biicode configuration file
|
||||
|
||||
[requirements]
|
||||
glenn/png: 6
|
||||
|
||||
[parent]
|
||||
# The parent version of this block. Must match folder name. E.g.
|
||||
# user/block # No version number means not published yet
|
||||
# You can change it to publish to a different track, and change version, e.g.
|
||||
# user/block(track): 7
|
||||
qiangwu/nana: 0
|
||||
|
||||
[paths]
|
||||
# Local directories to look for headers (within block)
|
||||
# /
|
||||
include
|
||||
|
||||
[dependencies]
|
||||
# Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=)
|
||||
# hello.h + hello_imp.cpp hello_imp2.cpp
|
||||
# *.h + *.cpp
|
||||
include/nana/config.hpp + include/*
|
||||
include/nana/config.hpp + source/*
|
||||
|
||||
[mains]
|
||||
# Manual adjust of files that define an executable
|
||||
# !main.cpp # Do not build executable from this file
|
||||
# main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it)
|
||||
|
||||
[tests]
|
||||
# Manual adjust of files that define a CTest test
|
||||
# test/* pattern to evaluate this test/ folder sources like tests
|
||||
|
||||
[hooks]
|
||||
# These are defined equal to [dependencies],files names matching bii*stage*hook.py
|
||||
# will be launched as python scripts at stage = {post_process, clean}
|
||||
# CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py
|
||||
|
||||
[includes]
|
||||
# Mapping of include patterns to external blocks
|
||||
# hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h
|
||||
png.h: glenn/png
|
||||
|
||||
[data]
|
||||
# Manually define data files dependencies, that will be copied to bin for execution
|
||||
# By default they are copied to bin/user/block/... which should be taken into account
|
||||
# when loading from disk such data
|
||||
# image.cpp + image.jpg # code should write open("user/block/image.jpg")
|
||||
|
69
build/cmake/Modules/FindFontconfig.cmake
Normal file
69
build/cmake/Modules/FindFontconfig.cmake
Normal file
@ -0,0 +1,69 @@
|
||||
# - Try to find the Fontconfig
|
||||
# Once done this will define
|
||||
#
|
||||
# FONTCONFIG_FOUND - system has Fontconfig
|
||||
# FONTCONFIG_INCLUDE_DIR - The include directory to use for the fontconfig headers
|
||||
# FONTCONFIG_LIBRARIES - Link these to use FONTCONFIG
|
||||
# FONTCONFIG_DEFINITIONS - Compiler switches required for using FONTCONFIG
|
||||
|
||||
# Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
if (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
|
||||
|
||||
# in cache already
|
||||
set(FONTCONFIG_FOUND TRUE)
|
||||
|
||||
else (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
|
||||
|
||||
if (NOT WIN32)
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(PC_FONTCONFIG fontconfig)
|
||||
|
||||
set(FONTCONFIG_DEFINITIONS ${PC_FONTCONFIG_CFLAGS_OTHER})
|
||||
endif (NOT WIN32)
|
||||
|
||||
find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h
|
||||
PATHS
|
||||
${PC_FONTCONFIG_INCLUDEDIR}
|
||||
${PC_FONTCONFIG_INCLUDE_DIRS}
|
||||
/usr/X11/include
|
||||
)
|
||||
|
||||
find_library(FONTCONFIG_LIBRARIES NAMES fontconfig
|
||||
PATHS
|
||||
${PC_FONTCONFIG_LIBDIR}
|
||||
${PC_FONTCONFIG_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Fontconfig DEFAULT_MSG FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR )
|
||||
|
||||
mark_as_advanced(FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)
|
||||
|
||||
endif (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
|
70
build/cmake/OS.cmake
Normal file
70
build/cmake/OS.cmake
Normal file
@ -0,0 +1,70 @@
|
||||
########### OS
|
||||
# https://blog.kowalczyk.info/article/j/guide-to-predefined-macros-in-c-compilers-gcc-clang-msvc-etc..html
|
||||
# http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions(nana PUBLIC WIN32) # todo: why not simple test for _WIN32 in code??
|
||||
set(CMAKE_DEBUG_POSTFIX "_d") # ??
|
||||
# Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository.
|
||||
if(MSVC)
|
||||
option(MSVC_USE_MP "Set to ON to build nana with the /MP option (Visual Studio 2005 and above)." ON)
|
||||
option(MSVC_USE_STATIC_RUNTIME "Set to ON to build nana with the /MT(d) option." ON)
|
||||
|
||||
# Change the MSVC Compiler flags
|
||||
if(MSVC_USE_MP)
|
||||
target_compile_options(nana PUBLIC "/MP" )
|
||||
endif()
|
||||
|
||||
if(MSVC_USE_STATIC_RUNTIME)
|
||||
foreach(flag
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MINGW)
|
||||
if(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) # deprecated ?????
|
||||
target_compile_definitions(nana PUBLIC STD_THREAD_NOT_SUPPORTED
|
||||
PUBLIC NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ )
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
target_compile_definitions(nana PUBLIC APPLE) # ??? not added by compilers? use __APPLE__ ?
|
||||
target_include_directories(nana PUBLIC /opt/X11/include/)
|
||||
target_link_libraries(nana PRIVATE iconv)
|
||||
set(ENABLE_AUDIO OFF)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
|
||||
find_package(X11 REQUIRED) # X11 - todo test PRIVATE
|
||||
target_link_libraries(nana
|
||||
PUBLIC ${X11_LIBRARIES}
|
||||
PUBLIC ${X11_Xft_LIB}
|
||||
)
|
||||
target_include_directories(nana SYSTEM
|
||||
PUBLIC ${X11_Xft_INCLUDE_PATH}
|
||||
PUBLIC ${X11_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
find_package(Freetype) # Freetype - todo test PRIVATE
|
||||
if (FREETYPE_FOUND)
|
||||
find_package(Fontconfig REQUIRED)
|
||||
target_include_directories(nana SYSTEM
|
||||
PUBLIC ${FREETYPE_INCLUDE_DIRS}
|
||||
PUBLIC ${FONTCONFIG_INCLUDE_DIR}
|
||||
)
|
||||
target_link_libraries(nana
|
||||
PUBLIC ${FREETYPE_LIBRARIES}
|
||||
PUBLIC ${FONTCONFIG_LIBRARIES}
|
||||
)
|
||||
endif(FREETYPE_FOUND)
|
||||
endif(UNIX)
|
48
build/cmake/compilers.cmake
Normal file
48
build/cmake/compilers.cmake
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
########### Compilers
|
||||
#
|
||||
# Using gcc: gcc 4.8 don't support C++14 and make_unique. You may want to update at least to 4.9.
|
||||
# gcc 5.3 and 5.4 include filesytem, but you need to add the link flag: -lstdc++fs
|
||||
#
|
||||
# In Windows, with CLion Allways check in File/Settings.../toolchains
|
||||
# You could install MinGW-w64 from the TDM-GCC Compiler Suite for Windows which will update you to gcc 5.1.
|
||||
# It is posible to follow https://computingabdn.com/softech/mingw-howto-install-gcc-for-windows/
|
||||
# and install MinGW with gcc 7.1 with has STD_THREADS and fs, from: https://sourceforge.net/projects/mingw-w64/files/
|
||||
#
|
||||
# see at end of: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html
|
||||
#
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW??
|
||||
|
||||
target_compile_options(nana PRIVATE -Wall
|
||||
PUBLIC -g )
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON) # todo - test this
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(nana PRIVATE Threads::Threads)
|
||||
# target_compile_options(nana PUBLIC -pthread)
|
||||
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD")
|
||||
target_compile_options(nana PUBLIC -I/usr/local/include)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# target_link_libraries(nana PRIVATE stdc++fs) # ??
|
||||
|
||||
|
||||
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()
|
||||
|
15
build/cmake/enable_audio.cmake
Normal file
15
build/cmake/enable_audio.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
option(NANA_CMAKE_ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF)
|
||||
|
||||
# todo: decide - PUBLIC vs PRIVATE
|
||||
if(NANA_CMAKE_ENABLE_AUDIO)
|
||||
target_compile_definitions(nana PUBLIC NANA_ENABLE_AUDIO)
|
||||
if(UNIX)
|
||||
find_package(ASOUND) # ? https://github.com/hintjens/demidi/blob/master/Findasound.cmake
|
||||
if(ASOUND_FOUND)
|
||||
target_include_directories(nana PUBLIC ${ASOUND_INCLUDE_DIRS})
|
||||
target_link_libraries(nana PUBLIC ${ASOUND_LIBRARIES})
|
||||
else()
|
||||
message(FATAL_ERROR "libasound is not found")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
24
build/cmake/enable_jpeg.cmake
Normal file
24
build/cmake/enable_jpeg.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
option(NANA_CMAKE_ENABLE_JPEG "Enable the use of JPEG" OFF)
|
||||
option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON)
|
||||
option(JPEG_HAVE_BOOLEAN "Defining HAVE_BOOLEAN before including jpeglib.h" OFF)
|
||||
|
||||
# todo: decide - PUBLIC vs PRIVATE
|
||||
|
||||
if(NANA_CMAKE_ENABLE_JPEG)
|
||||
target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG)
|
||||
if(NANA_CMAKE_LIBJPEG_FROM_OS)
|
||||
find_package(JPEG)
|
||||
if(JPEG_FOUND)
|
||||
target_include_directories(nana PUBLIC ${JPEG_INCLUDE_DIRS})
|
||||
target_link_libraries (nana PUBLIC ${JPEG_LIBRARIES})
|
||||
target_compile_definitions(nana PUBLIC USE_LIBJPEG_FROM_OS)
|
||||
endif()
|
||||
else()
|
||||
target_compile_definitions(nana PUBLIC -ljpeg)
|
||||
endif()
|
||||
if(JPEG_HAVE_BOOLEAN)
|
||||
# ... Defining HAVE_BOOLEAN before including jpeglib.h should make it work...
|
||||
target_compile_definitions(nana PUBLIC HAVE_BOOLEAN)
|
||||
endif()
|
||||
|
||||
endif()
|
20
build/cmake/enable_png.cmake
Normal file
20
build/cmake/enable_png.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
option(NANA_CMAKE_ENABLE_PNG "Enable the use of PNG" OFF)
|
||||
option(NANA_CMAKE_LIBPNG_FROM_OS "Use libpng from operating system." ON)
|
||||
|
||||
# todo: decide - PUBLIC vs PRIVATE
|
||||
|
||||
if(NANA_CMAKE_ENABLE_PNG)
|
||||
target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG)
|
||||
if(NANA_CMAKE_LIBPNG_FROM_OS)
|
||||
find_package(PNG)
|
||||
if(PNG_FOUND)
|
||||
target_include_directories(nana PUBLIC ${PNG_INCLUDE_DIRS})
|
||||
target_link_libraries (nana PUBLIC ${PNG_LIBRARIES})
|
||||
target_compile_definitions(nana PUBLIC USE_LIBPNG_FROM_OS ${PNG_DEFINITIONS})
|
||||
# target_include_directories (nana SYSTEM PUBLIC PNG::PNG) # ??
|
||||
# target_compile_definitions (nana PUBLIC USE_LIBPNG_FROM_OS)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(nana PUBLIC png) # provided by nana?
|
||||
endif()
|
||||
endif()
|
23
build/cmake/install_nana.cmake
Normal file
23
build/cmake/install_nana.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
option(NANA_CMAKE_INSTALL "Install nana when compile the library (to be consumed without cmake)" OFF)
|
||||
|
||||
# Install the include directories too.
|
||||
if(NANA_CMAKE_INSTALL)
|
||||
# this is the prefered method to consume nana directly with some specific bulid system
|
||||
# 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")
|
||||
# Actually in DESTDIR/CMAKE_INSTALL_PREFIX/lib but in windows there is no DESTDIR/ part.
|
||||
install(TARGETS nana
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
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")
|
||||
else()
|
||||
# this is the prefered method to consume nana with cmake
|
||||
target_sources(nana PUBLIC ${HEADERS})
|
||||
target_include_directories(nana PUBLIC ${NANA_INCLUDE_DIR})
|
||||
endif()
|
||||
|
53
build/cmake/select_filesystem.cmake
Normal file
53
build/cmake/select_filesystem.cmake
Normal file
@ -0,0 +1,53 @@
|
||||
# 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 <nana/filesystem/filesystem.hpp> or <nana/filesystem/filesystem_ext.hpp>
|
||||
# the selected option will be set by nana into std::experimental::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.
|
||||
# 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)
|
||||
|
||||
if(NANA_CMAKE_NANA_FILESYSTEM_FORCE)
|
||||
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)
|
||||
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,
|
||||
# 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 REQUIRED COMPONENTS filesystem)
|
||||
if(Boost_FOUND)
|
||||
target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_AVAILABLE)
|
||||
target_include_directories(nana PUBLIC "${Boost_INCLUDE_DIR}") # ?? SYSTEM
|
||||
target_link_libraries (nana PUBLIC ${Boost_LIBRARIES})
|
||||
# target_link_libraries (nana PUBLIC Boost::Boost)
|
||||
endif()
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
51
build/cmake/shared_libs.cmake
Normal file
51
build/cmake/shared_libs.cmake
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF)
|
||||
|
||||
if(BUILD_SHARED_LIBS) # todo test
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
if(MSVC)
|
||||
set(DLLTOOL OFF)
|
||||
else()
|
||||
# mingw: If dlltool is found the def and lib file will be created
|
||||
find_program (DLLTOOL dlltool)
|
||||
if(NOT DLLTOOL)
|
||||
message(WARNING "dlltool not found. Skipping import library generation.")
|
||||
endif()
|
||||
endif()
|
||||
if(DLLTOOL)
|
||||
#generate the lib and def files needed by msvc
|
||||
set_target_properties (nana PROPERTIES
|
||||
OUTPUT_NAME nana
|
||||
ARCHIVE_OUTPUT_NAME nana
|
||||
LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--output-def=${CMAKE_CURRENT_BINARY_DIR}/libnana.def"
|
||||
)
|
||||
|
||||
add_custom_command(TARGET nana POST_BUILD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
COMMAND echo " Generating import library"
|
||||
COMMAND "${DLLTOOL}" --dllname "libnana.dll"
|
||||
--input-def "libnana.def"
|
||||
--output-lib "libnana.lib")
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnana.def"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libnana.lib" DESTINATION lib)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW??
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_options(nana PUBLIC -lgcc -lstdc++)
|
||||
else()
|
||||
|
||||
if(MINGW)
|
||||
target_compile_options(nana PUBLIC -static) # -static ?? cmake knows BUILD_SHARED_LIBS
|
||||
else()
|
||||
target_compile_options(nana PUBLIC -static-libgcc -static-libstdc++)
|
||||
endif()
|
||||
endif(BUILD_SHARED_LIBS)
|
||||
|
||||
endif()
|
@ -1,13 +1,13 @@
|
||||
/*
|
||||
/**
|
||||
* Basic Types definition
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2018 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/basic_types.hpp
|
||||
* @file nana/basic_types.hpp
|
||||
*/
|
||||
|
||||
#ifndef NANA_BASIC_TYPES_HPP
|
||||
|
@ -71,7 +71,7 @@
|
||||
///////////////////
|
||||
// Support of PCM playback
|
||||
//
|
||||
#define NANA_ENABLE_AUDIO
|
||||
//#define NANA_ENABLE_AUDIO
|
||||
|
||||
///////////////////
|
||||
// Support for PNG
|
||||
|
@ -13,7 +13,7 @@
|
||||
* and need VC2015 or a C++11 compiler. With a few correction can be compiler by VC2013
|
||||
*/
|
||||
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf --- last pdf of std draft N4100 <filesystem> 2014-07-04
|
||||
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf --- pdf of std draft N4100 <filesystem> 2014-07-04
|
||||
// http://en.cppreference.com/w/cpp/experimental/fs
|
||||
// http://cpprocks.com/introduction-to-tr2-filesystem-library-in-vs2012/ --- TR2 filesystem in VS2012
|
||||
// https://msdn.microsoft.com/en-us/library/hh874694%28v=vs.140%29.aspx --- C++ 14, the <filesystem> header VS2015
|
||||
@ -55,36 +55,6 @@
|
||||
#define NANA_USING_BOOST_FILESYSTEM 1
|
||||
# include <chrono>
|
||||
# include <boost/filesystem.hpp>
|
||||
// dont include generic_u8string
|
||||
// http://www.boost.org/doc/libs/1_66_0/boost/filesystem/path.hpp
|
||||
// enable directory_iterator C++11 range-base for
|
||||
// http://www.boost.org/doc/libs/1_66_0/boost/filesystem/operations.hpp
|
||||
// but travis come with an oooold version of boost
|
||||
// NOT enable directory_iterator C++11 range-base for
|
||||
// http://www.boost.org/doc/libs/1_54_0/boost/filesystem/operations.hpp
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
|
||||
// enable directory_iterator C++11 range-base for statement use --------------------//
|
||||
|
||||
// begin() and end() are only used by a range-based for statement in the context of
|
||||
// auto - thus the top-level const is stripped - so returning const is harmless and
|
||||
// emphasizes begin() is just a pass through.
|
||||
inline const directory_iterator& begin(const directory_iterator& iter) BOOST_NOEXCEPT
|
||||
{
|
||||
return iter;
|
||||
}
|
||||
|
||||
inline directory_iterator end(const directory_iterator&) BOOST_NOEXCEPT
|
||||
{
|
||||
return directory_iterator();
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
}
|
||||
|
||||
|
||||
// add boost::filesystem into std::experimental::filesystem
|
||||
namespace std {
|
||||
@ -105,16 +75,32 @@ namespace std {
|
||||
socket = boost::filesystem::file_type::socket_file,
|
||||
unknown = boost::filesystem::file_type::type_unknown,
|
||||
};
|
||||
/// enable directory_iterator range-based for statements
|
||||
//inline directory_iterator begin(directory_iterator iter) noexcept
|
||||
//{
|
||||
// return iter;
|
||||
//}
|
||||
// Boost dont include generic_u8string
|
||||
// http://www.boost.org/doc/libs/1_66_0/boost/filesystem/path.hpp
|
||||
//
|
||||
// Boost versions: 1.67.0, 1.66.0, ... 1.56.0 enable directory_iterator C++11 range-base for
|
||||
// http://www.boost.org/doc/libs/1_66_0/boost/filesystem/operations.hpp
|
||||
// but travis come with an oooold version of boost
|
||||
// 1.55.0 NOT enable directory_iterator C++11 range-base for
|
||||
// http://www.boost.org/doc/libs/1_54_0/boost/filesystem/operations.hpp
|
||||
#if BOOST_VERSION < 105600
|
||||
namespace boost
|
||||
// enable directory_iterator C++11 range-base for statement use --------------------//
|
||||
|
||||
// begin() and end() are only used by a range-based for statement in the context of
|
||||
// auto - thus the top-level const is stripped - so returning const is harmless and
|
||||
// emphasizes begin() is just a pass through.
|
||||
inline const directory_iterator& begin(const directory_iterator& iter) BOOST_NOEXCEPT
|
||||
{
|
||||
return iter;
|
||||
}
|
||||
|
||||
inline directory_iterator end(const directory_iterator&) BOOST_NOEXCEPT
|
||||
{
|
||||
return directory_iterator();
|
||||
}
|
||||
#endif
|
||||
|
||||
//inline directory_iterator end(const directory_iterator&) noexcept
|
||||
//{
|
||||
// return {};
|
||||
//}
|
||||
} // filesystem
|
||||
} // experimental
|
||||
} // std
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/**
|
||||
* Platform Specification Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
@ -7,7 +7,7 @@
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/detail/platform_spec.hpp
|
||||
* @file nana/detail/platform_spec.hpp
|
||||
*
|
||||
* This file provides basis class and data structrue that required by nana
|
||||
* This file should not be included by any header files.
|
||||
|
Loading…
x
Reference in New Issue
Block a user