From 00c923df8f7dd2a69ecb66b277b0373722b7d820 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 9 Nov 2017 23:04:52 +0000 Subject: [PATCH 01/39] Use target_compile_features instead of setting CXX_STANDARD. This allows child projects to just link to nana and automatically inherit the -std=c++14 setting. Minimum cmake version for this to work is 3.1. --- CMakeLists.txt | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a43b5b5..24793395 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,8 @@ # It seems that project() defines essential system variables like CMAKE_FIND_LIBRARY_PREFIXES. # https://bbs.archlinux.org/viewtopic.php?id=84967 -project(nana) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +project(nana VERSION 1.5.5 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) @@ -147,11 +147,9 @@ endif(UNIX) if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Clang || GNU if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 -Wall -g") # Clang - + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g") # Clang else ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -g") # GNU - + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g") # GNU endif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") @@ -354,6 +352,19 @@ if(NANA_CMAKE_INSTALL_INCLUDES) message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include") endif(NANA_CMAKE_INSTALL_INCLUDES) +target_compile_features(${PROJECT_NAME} + 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 +) # Just for information: message ("") From a09d23210f45f528abb38a950590346acbdf1d93 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 9 Nov 2017 23:35:17 +0000 Subject: [PATCH 02/39] Use target_include_directories instead of include_directories. Also change the linked libraries where necessary and link to fontconfig, which fixes my build error. --- CMakeLists.txt | 110 +++++++++++++++++------------ cmake/Modules/FindFontconfig.cmake | 69 ++++++++++++++++++ 2 files changed, 134 insertions(+), 45 deletions(-) create mode 100644 cmake/Modules/FindFontconfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 24793395..d71d267b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ # https://bbs.archlinux.org/viewtopic.php?id=84967 cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) project(nana VERSION 1.5.5 LANGUAGES CXX) option(NANA_CMAKE_INSTALL_INCLUDES "Install nana includes when compile the library" ON) @@ -64,6 +65,34 @@ if(POLICY CMP0004) # ignore leading space cmake_policy(SET CMP0004 OLD) endif() +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(NANA_CMAKE_ENABLE_AUDIO) +# 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) + # message("Subir: ${subdir}") # message("Files: ${sources}") +endforeach(subdir ${NANA_SOURCE_SUBDIRS}) + +add_library(${PROJECT_NAME} ${sources} ) ########### OS if(WIN32) @@ -120,6 +149,7 @@ if(APPLE) add_definitions(-DAPPLE) include_directories(/opt/X11/include/) list(APPEND NANA_LINKS -L/opt/X11/lib/ -liconv) + target_link_libraries(${PROJECT_NAME} PRIVATE iconv) set(ENABLE_AUDIO OFF) elseif(UNIX) add_definitions(-Dlinux) @@ -127,11 +157,28 @@ elseif(UNIX) endif(APPLE) if(UNIX) - list(APPEND NANA_LINKS -lX11) + find_package(X11 REQUIRED) + list(APPEND NANA_LINKS ${X11_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} + PRIVATE ${X11_LIBRARIES} + PRIVATE ${X11_Xft_LIB} + ) + target_include_directories(${PROJECT_NAME} SYSTEM + PRIVATE ${X11_Xft_INCLUDE_PATH} + PRIVATE ${X11_INCLUDE_DIR} + ) find_package(Freetype) if (FREETYPE_FOUND) - include_directories( ${FREETYPE_INCLUDE_DIRS}) - list(APPEND NANA_LINKS -lXft) + find_package(Fontconfig REQUIRED) + target_include_directories(${PROJECT_NAME} SYSTEM + PRIVATE ${FREETYPE_INCLUDE_DIRS} + PRIVATE ${FONTCONFIG_INCLUDE_DIR} + ) + list(APPEND NANA_LINKS ${FREETYPE_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} + PRIVATE ${FREETYPE_LIBRARIES} + PRIVATE ${FONTCONFIG_LIBRARIES} + ) endif(FREETYPE_FOUND) endif(UNIX) @@ -156,11 +203,14 @@ endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # enable static linkage # GNU || CLang not MinGW if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) if(NANA_CMAKE_SHARED_LIB) - list(APPEND NANA_LINKS -lgcc -lstdc++ -pthread) + list(APPEND NANA_LINKS -lgcc -lstdc++) else() - set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread") + set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") # message("Setting NANA_LINKS to -static-libgcc -static-libstdc++ -pthread or ${NANA_LINKS}") endif(NANA_CMAKE_SHARED_LIB) @@ -168,9 +218,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AN # IS_GNUCXX < 5.3 else(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3) - # set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++fs") # IS_GNUCXX 5.3 or more - list(APPEND NANA_LINKS -lstdc++fs) - + target_link_libraries(${PROJECT_NAME} PRIVATE stdc++fs) endif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3) endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AND NOT MINGW @@ -189,10 +237,9 @@ 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") + target_include_directories(${PROJECT_NAME} PRIVATE PNG::PNG) + target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBPNG_FROM_OS) endif(PNG_FOUND) else() add_definitions(-DNANA_ENABLE_PNG) @@ -205,10 +252,10 @@ if(NANA_CMAKE_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") + target_include_directories(${PROJECT_NAME PRIVATE ${JPEG_INCLUDE_DIR}) + list(APPEND NANA_LINKS ${JPEG_LIBRARIES}) + target_include_directories(${PROJECT_NAME} PRIVATE ${JPEG_LIBRARIES}) + target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBJPEG_FROM_OS) endif(JPEG_FOUND) else() add_definitions(-DNANA_ENABLE_JPEG) @@ -221,8 +268,9 @@ if(NANA_CMAKE_ENABLE_AUDIO) if(UNIX) find_package(ASOUND) if (ASOUND_FOUND) - include_directories( ${ASOUND_INCLUDE_DIRS}) + target_include_directories(${PROJECT_NAME PRIVATE ${ASOUND_INCLUDE_DIRS}) list(APPEND NANA_LINKS -lasound) + target_link_libraries(${PROJECT_NAME} PRIVATE ${ASOUND_LIBRARIES}) else(ASOUND_FOUND) message(FATAL_ERROR "libasound is not found") endif(ASOUND_FOUND) @@ -245,8 +293,8 @@ elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) find_package(Boost COMPONENTS filesystem) if (Boost_FOUND) add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE) - include_directories(SYSTEM "${Boost_INCLUDE_DIR}") list(APPEND NANA_LINKS ${Boost_LIBRARIES}) ###### FIRST !!!!!!!!!!!!!!!!! add is not first + target_link_libraries(${PROJECT_NAME} PUBLIC Boost::Boost) endif (Boost_FOUND) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_RUNTIME ON) # ?? @@ -267,33 +315,6 @@ endif(NANA_CMAKE_AUTOMATIC_GUI_TESTING) ####################### 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(NANA_CMAKE_ENABLE_AUDIO) -# 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) - # message("Subir: ${subdir}") # message("Files: ${sources}") -endforeach(subdir ${NANA_SOURCE_SUBDIRS}) - if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") add_definitions(-fmax-errors=3) endif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") @@ -305,7 +326,6 @@ else() endif(NANA_CMAKE_SHARED_LIB) 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) diff --git a/cmake/Modules/FindFontconfig.cmake b/cmake/Modules/FindFontconfig.cmake new file mode 100644 index 00000000..e6fa81d8 --- /dev/null +++ b/cmake/Modules/FindFontconfig.cmake @@ -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, +# +# 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) From 872ed69519fe36add89462de032d8fd873e7b86d Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 9 Nov 2017 23:35:28 +0000 Subject: [PATCH 03/39] Whitespace changes --- CMakeLists.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d71d267b..29627f96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -373,17 +373,17 @@ if(NANA_CMAKE_INSTALL_INCLUDES) endif(NANA_CMAKE_INSTALL_INCLUDES) target_compile_features(${PROJECT_NAME} - 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 + 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 ) # Just for information: From bfba8fa233e458590b36940d9f5cf304ac56b50d Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 9 Nov 2017 23:37:17 +0000 Subject: [PATCH 04/39] Fix typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29627f96..7e2d90d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,7 +254,7 @@ if(NANA_CMAKE_ENABLE_JPEG) if (JPEG_FOUND) target_include_directories(${PROJECT_NAME PRIVATE ${JPEG_INCLUDE_DIR}) list(APPEND NANA_LINKS ${JPEG_LIBRARIES}) - target_include_directories(${PROJECT_NAME} PRIVATE ${JPEG_LIBRARIES}) + target_link_libraries(${PROJECT_NAME} PRIVATE ${JPEG_LIBRARIES}) target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBJPEG_FROM_OS) endif(JPEG_FOUND) else() From 7f35b240b56862b2784520305b4749539557fc68 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 9 Nov 2017 23:37:55 +0000 Subject: [PATCH 05/39] Remove the NANA_LINKS variable since it's not tracking what's really happening anymore. --- CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e2d90d4..c0b48a52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,7 +148,6 @@ endif(WIN32) if(APPLE) add_definitions(-DAPPLE) include_directories(/opt/X11/include/) - list(APPEND NANA_LINKS -L/opt/X11/lib/ -liconv) target_link_libraries(${PROJECT_NAME} PRIVATE iconv) set(ENABLE_AUDIO OFF) elseif(UNIX) @@ -158,7 +157,6 @@ endif(APPLE) if(UNIX) find_package(X11 REQUIRED) - list(APPEND NANA_LINKS ${X11_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE ${X11_LIBRARIES} PRIVATE ${X11_Xft_LIB} @@ -174,7 +172,6 @@ if(UNIX) PRIVATE ${FREETYPE_INCLUDE_DIRS} PRIVATE ${FONTCONFIG_INCLUDE_DIR} ) - list(APPEND NANA_LINKS ${FREETYPE_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE ${FREETYPE_LIBRARIES} PRIVATE ${FONTCONFIG_LIBRARIES} @@ -208,10 +205,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AN target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) if(NANA_CMAKE_SHARED_LIB) - list(APPEND NANA_LINKS -lgcc -lstdc++) else() set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") - # message("Setting NANA_LINKS to -static-libgcc -static-libstdc++ -pthread or ${NANA_LINKS}") endif(NANA_CMAKE_SHARED_LIB) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3) @@ -237,7 +232,6 @@ if(NANA_CMAKE_ENABLE_PNG) if(NANA_CMAKE_LIBPNG_FROM_OS) find_package(PNG) if (PNG_FOUND) - list(APPEND NANA_LINKS ${PNG_LIBRARIES}) target_include_directories(${PROJECT_NAME} PRIVATE PNG::PNG) target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBPNG_FROM_OS) endif(PNG_FOUND) @@ -253,7 +247,6 @@ if(NANA_CMAKE_ENABLE_JPEG) find_package(JPEG) if (JPEG_FOUND) target_include_directories(${PROJECT_NAME PRIVATE ${JPEG_INCLUDE_DIR}) - list(APPEND NANA_LINKS ${JPEG_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE ${JPEG_LIBRARIES}) target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBJPEG_FROM_OS) endif(JPEG_FOUND) @@ -269,7 +262,6 @@ if(NANA_CMAKE_ENABLE_AUDIO) find_package(ASOUND) if (ASOUND_FOUND) target_include_directories(${PROJECT_NAME PRIVATE ${ASOUND_INCLUDE_DIRS}) - list(APPEND NANA_LINKS -lasound) target_link_libraries(${PROJECT_NAME} PRIVATE ${ASOUND_LIBRARIES}) else(ASOUND_FOUND) message(FATAL_ERROR "libasound is not found") @@ -293,7 +285,6 @@ elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) find_package(Boost COMPONENTS filesystem) if (Boost_FOUND) add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE) - list(APPEND NANA_LINKS ${Boost_LIBRARIES}) ###### FIRST !!!!!!!!!!!!!!!!! add is not first target_link_libraries(${PROJECT_NAME} PUBLIC Boost::Boost) endif (Boost_FOUND) set(Boost_USE_STATIC_LIBS ON) @@ -394,7 +385,6 @@ 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}) From b5c69dc3867be16f3d40ecbd70d0075adc854c72 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 9 Nov 2017 23:53:32 +0000 Subject: [PATCH 06/39] Use target_compile_definitions instead of add_definitions. This allows macro definitions to be inherited. There might be symbols that can be made private. This is likely breaking the build on non-linux systems. --- CMakeLists.txt | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c0b48a52..5bac756c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ add_library(${PROJECT_NAME} ${sources} ) ########### OS if(WIN32) - add_definitions(-DWIN32) + target_compile_definitions(${PROJECT_NAME} PUBLIC WIN32) set(CMAKE_DEBUG_POSTFIX "_d") #Global MSVC definitions. You may prefer the hand-tuned sln and projects from the nana repository. if(MSVC) @@ -123,8 +123,10 @@ if(WIN32) 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) + target_compile_definitions(${PROJECT_NAME} + PUBLIC STD_THREAD_NOT_SUPPORTED + PUBLIC NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ + ) endif(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) endif(MINGW) @@ -146,12 +148,12 @@ endif(WIN32) if(APPLE) - add_definitions(-DAPPLE) + target_compile_definitions(${PROJECT_NAME} PUBLIC APPLE) include_directories(/opt/X11/include/) target_link_libraries(${PROJECT_NAME} PRIVATE iconv) set(ENABLE_AUDIO OFF) elseif(UNIX) - add_definitions(-Dlinux) + target_compile_definitions(${PROJECT_NAME} PUBLIC linux) message("added -D linux") endif(APPLE) @@ -236,13 +238,13 @@ if(NANA_CMAKE_ENABLE_PNG) target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBPNG_FROM_OS) endif(PNG_FOUND) else() - add_definitions(-DNANA_ENABLE_PNG) + target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_ENABLE_PNG) endif(NANA_CMAKE_LIBPNG_FROM_OS) endif(NANA_CMAKE_ENABLE_PNG) # Find JPEG if(NANA_CMAKE_ENABLE_JPEG) - add_definitions(-DNANA_ENABLE_JPEG) + target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_ENABLE_JPEG) if(NANA_CMAKE_LIBJPEG_FROM_OS) find_package(JPEG) if (JPEG_FOUND) @@ -257,7 +259,7 @@ endif(NANA_CMAKE_ENABLE_JPEG) # Find ASOUND if(NANA_CMAKE_ENABLE_AUDIO) - add_definitions(-DNANA_ENABLE_AUDIO) + target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_ENABLE_AUDIO) if(UNIX) find_package(ASOUND) if (ASOUND_FOUND) @@ -271,12 +273,12 @@ endif(NANA_CMAKE_ENABLE_AUDIO) # Find/Select filesystem if (NANA_CMAKE_NANA_FILESYSTEM_FORCE) - add_definitions(-DNANA_FILESYSTEM_FORCE) + target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_FILESYSTEM_FORCE) elseif (NANA_CMAKE_STD_FILESYSTEM_FORCE) - add_definitions(-DSTD_FILESYSTEM_FORCE) + target_compile_definitions(${PROJECT_NAME} PUBLIC STD_FILESYSTEM_FORCE) elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) if (NANA_CMAKE_BOOST_FILESYSTEM_FORCE) - add_definitions(-DNANA_BOOST_FILESYSTEM_FORCE) + target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_BOOST_FILESYSTEM_FORCE) endif(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) # https://cmake.org/cmake/help/git-master/module/FindBoost.html # Implicit dependencies such as Boost::filesystem requiring Boost::system will be automatically detected and satisfied, @@ -284,7 +286,7 @@ elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) # If using Boost::thread, then Thread::Thread will also be added automatically. find_package(Boost COMPONENTS filesystem) if (Boost_FOUND) - add_definitions(-DNANA_BOOST_FILESYSTEM_AVAILABLE) + target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_BOOST_FILESYSTEM_AVAILABLE) target_link_libraries(${PROJECT_NAME} PUBLIC Boost::Boost) endif (Boost_FOUND) set(Boost_USE_STATIC_LIBS ON) @@ -294,13 +296,13 @@ endif (NANA_CMAKE_NANA_FILESYSTEM_FORCE) ######## Nana options -add_definitions(-DNANA_IGNORE_CONF) +target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_IGNORE_CONF) if(NANA_CMAKE_VERBOSE_PREPROCESSOR) - add_definitions(-DVERBOSE_PREPROCESSOR) + target_compile_definitions(${PROJECT_NAME} PUBLIC VERBOSE_PREPROCESSOR) endif(NANA_CMAKE_VERBOSE_PREPROCESSOR) if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) - add_definitions(-DNANA_AUTOMATIC_GUI_TESTING) - enable_testing () + target_compile_definitions(${PROJECT_NAME} PRIVATE NANA_AUTOMATIC_GUI_TESTING) + enable_testing () endif(NANA_CMAKE_AUTOMATIC_GUI_TESTING) From d3f55776256de89965dc9488cf4d4f1e8076ac3e Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 9 Nov 2017 23:53:55 +0000 Subject: [PATCH 07/39] These need be set *before* find_package, or it will be too late. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bac756c..d25dcb10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -284,13 +284,13 @@ elseif (NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) # 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. + set(Boost_USE_STATIC_LIBS ON) + set(Boost_USE_STATIC_RUNTIME ON) # ?? find_package(Boost COMPONENTS filesystem) if (Boost_FOUND) target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_BOOST_FILESYSTEM_AVAILABLE) target_link_libraries(${PROJECT_NAME} PUBLIC Boost::Boost) endif (Boost_FOUND) - set(Boost_USE_STATIC_LIBS ON) - set(Boost_USE_STATIC_RUNTIME ON) # ?? endif (NANA_CMAKE_NANA_FILESYSTEM_FORCE) From 309a95d32195fe6d8bba655d1189cf84b047ed1b Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 9 Nov 2017 23:54:53 +0000 Subject: [PATCH 08/39] Maybe not needed anymore? --- CMakeLists.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d25dcb10..106a0bde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,16 +55,6 @@ option(NANA_CMAKE_NANA_FILESYSTEM_FORCE "Force nana filesystem over ISO and boos 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 OLD) -endif() -if(POLICY CMP0004) # ignore leading space - # http://www.cmake.org/cmake/help/v3.0/policy/CMP0004.html - cmake_policy(SET CMP0004 OLD) -endif() - 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 From 32e6ee532c7829b01446ff817d83e631bb5efbbd Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 10 Nov 2017 00:16:50 +0000 Subject: [PATCH 09/39] Fix build after rebase. --- CMakeLists.txt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 106a0bde..7090e19a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,11 @@ foreach(subdir ${NANA_SOURCE_SUBDIRS}) # message("Subir: ${subdir}") # message("Files: ${sources}") endforeach(subdir ${NANA_SOURCE_SUBDIRS}) -add_library(${PROJECT_NAME} ${sources} ) +if(NANA_CMAKE_SHARED_LIB) + add_library(${PROJECT_NAME} SHARED ${sources} ) +else() + add_library(${PROJECT_NAME} STATIC ${sources} ) +endif(NANA_CMAKE_SHARED_LIB) ########### OS if(WIN32) @@ -196,8 +200,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AN find_package(Threads REQUIRED) target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) - if(NANA_CMAKE_SHARED_LIB) - else() + if(NOT NANA_CMAKE_SHARED_LIB) set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") endif(NANA_CMAKE_SHARED_LIB) @@ -302,12 +305,6 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") add_definitions(-fmax-errors=3) endif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") -if(NANA_CMAKE_SHARED_LIB) - add_library(${PROJECT_NAME} SHARED ${sources} ) -else() - add_library(${PROJECT_NAME} STATIC ${sources} ) -endif(NANA_CMAKE_SHARED_LIB) - target_include_directories(${PROJECT_NAME} PUBLIC ${NANA_INCLUDE_DIR}) # Headers: use INCLUDE_DIRECTORIES From b9946f262403c6218f8edf7d3f5a9ddc994a2b88 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 10 Nov 2017 00:29:07 +0000 Subject: [PATCH 10/39] Fix up some wrong parts I missed to conform with the rest of my changes. --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7090e19a..9af2d3a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,7 +227,7 @@ if(NANA_CMAKE_ENABLE_PNG) if(NANA_CMAKE_LIBPNG_FROM_OS) find_package(PNG) if (PNG_FOUND) - target_include_directories(${PROJECT_NAME} PRIVATE PNG::PNG) + target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE PNG::PNG) target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBPNG_FROM_OS) endif(PNG_FOUND) else() @@ -241,12 +241,12 @@ if(NANA_CMAKE_ENABLE_JPEG) if(NANA_CMAKE_LIBJPEG_FROM_OS) find_package(JPEG) if (JPEG_FOUND) - target_include_directories(${PROJECT_NAME PRIVATE ${JPEG_INCLUDE_DIR}) + target_include_directories(${PROJECT_NAME SYSTEM PRIVATE ${JPEG_INCLUDE_DIR}) target_link_libraries(${PROJECT_NAME} PRIVATE ${JPEG_LIBRARIES}) target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBJPEG_FROM_OS) endif(JPEG_FOUND) else() - add_definitions(-DNANA_ENABLE_JPEG) + target_compile_definitions(${PROJECT_NAME} PUBLIC NANA_ENABLE_JPEG) endif(NANA_CMAKE_LIBJPEG_FROM_OS) endif(NANA_CMAKE_ENABLE_JPEG) From 97297ae511bd7f26bcee334aad5143017eb5af05 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 10 Nov 2017 00:46:08 +0000 Subject: [PATCH 11/39] Fix cmake warning. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9af2d3a8..06b66eaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,7 +202,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # AN if(NOT NANA_CMAKE_SHARED_LIB) set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++") - endif(NANA_CMAKE_SHARED_LIB) + endif(NOT NANA_CMAKE_SHARED_LIB) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.3) # IS_GNUCXX < 5.3 From b713b01dbe8489787842a1f306b0eedb29dc2be5 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 10 Nov 2017 00:49:46 +0000 Subject: [PATCH 12/39] Fix missing closing brace. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06b66eaf..64bb1bd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,7 +241,7 @@ if(NANA_CMAKE_ENABLE_JPEG) if(NANA_CMAKE_LIBJPEG_FROM_OS) find_package(JPEG) if (JPEG_FOUND) - target_include_directories(${PROJECT_NAME SYSTEM PRIVATE ${JPEG_INCLUDE_DIR}) + target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${JPEG_INCLUDE_DIR}) target_link_libraries(${PROJECT_NAME} PRIVATE ${JPEG_LIBRARIES}) target_compile_definitions(${PROJECT_NAME} PUBLIC USE_LIBJPEG_FROM_OS) endif(JPEG_FOUND) @@ -256,7 +256,7 @@ if(NANA_CMAKE_ENABLE_AUDIO) if(UNIX) find_package(ASOUND) if (ASOUND_FOUND) - target_include_directories(${PROJECT_NAME PRIVATE ${ASOUND_INCLUDE_DIRS}) + target_include_directories(${PROJECT_NAME} PRIVATE ${ASOUND_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} PRIVATE ${ASOUND_LIBRARIES}) else(ASOUND_FOUND) message(FATAL_ERROR "libasound is not found") From 1f53aa334440b2f659ce471808aea02035bbcf55 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sat, 14 Jul 2018 02:06:10 +0200 Subject: [PATCH 13/39] nana hotfix point to nana-demo hotfix --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 42f63050..36f8353e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ matrix: - llvm-toolchain-precise before_install: - - git clone --depth=1 --branch=develop https://github.com/qPCR4vir/nana-demo.git ../nana-demo + - git clone --depth=1 --branch=hotfix 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 From 74cc3ce475b7e8b953e271ea227667d689343180 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 16 Aug 2018 08:48:32 +0200 Subject: [PATCH 14/39] VERSION --- CMakeLists.txt | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d023469..033af9ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,29 +1,33 @@ # 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) +# 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 # # 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 distributed build system +# files/projects 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 +# https://cliutils.gitlab.io/modern-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 -project(nana) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.12) +project(nana VERSION 1.6.1 + 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) @@ -302,6 +306,7 @@ else() endif() target_include_directories(${PROJECT_NAME} PUBLIC ${NANA_INCLUDE_DIR}) +target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) # target_link_libraries(${PROJECT_NAME} ${NANA_LINKS}) # Headers: use INCLUDE_DIRECTORIES From 7a2b97813a0d53ed5b68a5a410fd051343e5d486 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 16 Aug 2018 08:49:55 +0200 Subject: [PATCH 15/39] CLion install works now --- CMakeLists.txt | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 033af9ea..c18479ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,6 @@ option(NANA_CMAKE_SHARED_LIB "Compile nana as a shared library." OFF) option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." ON) 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 @@ -135,13 +134,11 @@ endif() # 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 +# 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") @@ -320,14 +317,6 @@ 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) From 95b386051c7a722e0b3dd56fb280ed77731b345b Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 16 Aug 2018 20:35:03 +0200 Subject: [PATCH 16/39] travis cmake 3.12 update ubuntu install --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 36f8353e..79e65776 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ before_install: - git clone --depth=1 --branch=hotfix 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: From 3dbbd175fab6b93d4638d07b658d67124850727e Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 16 Aug 2018 20:37:16 +0200 Subject: [PATCH 17/39] git clone nana-demo branch=cmake-dev --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 79e65776..0f761bc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ matrix: - llvm-toolchain-precise before_install: - - git clone --depth=1 --branch=hotfix https://github.com/qPCR4vir/nana-demo.git ../nana-demo + - 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.12/cmake-3.12.0-rc3-Linux-x86_64.sh || true From f789d808be25f433353a11eb1fa43d68be663b40 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 19 Aug 2018 20:49:17 +0200 Subject: [PATCH 18/39] revise --- .travis.yml | 1 - CMakeLists.txt | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0f761bc9..69624c16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,6 @@ matrix: before_install: - 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.12/cmake-3.12.0-rc3-Linux-x86_64.sh || true - chmod -R +x /tmp/tools diff --git a/CMakeLists.txt b/CMakeLists.txt index c18479ad..f65bd8d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,6 +367,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}) From 676754904252eab16e14a1fdb706e35069e7978b Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 21 Aug 2018 16:44:54 +0200 Subject: [PATCH 19/39] target centric cmake --- CMakeLists.txt | 93 ++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70310509..a31300de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,54 @@ project(nana VERSION 1.6.1 HOMEPAGE_URL http://nanapro.org LANGUAGES CXX ) + + +####################### 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_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) # +target_link_libraries(${PROJECT_NAME} ${NANA_LINKS}) + + 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) @@ -261,51 +309,6 @@ if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) endif() -####################### 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_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) # -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) From ff2444b3cba40173a0bf7b5f04e4264da57477de Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 21 Aug 2018 16:52:30 +0200 Subject: [PATCH 20/39] use BUILD_SHARED_LIBS and target_sources() --- CMakeLists.txt | 72 ++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a31300de..5f8b7b50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,18 +25,25 @@ cmake_minimum_required(VERSION 3.12) project(nana VERSION 1.6.1 - DESCRIPTION "C++ GUI library" - HOMEPAGE_URL http://nanapro.org - LANGUAGES CXX ) + DESCRIPTION "C++ GUI library" + HOMEPAGE_URL http://nanapro.org + LANGUAGES CXX ) -####################### Main setting of Nana sources, targets and install +option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF) + +####################### Main setting of Nana targets, sources and installs + + +add_library(${PROJECT_NAME} ) + 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 /. +set(NANA_SOURCE_SUBDIRS + /. /detail /filesystem /gui @@ -49,7 +56,8 @@ set(NANA_SOURCE_SUBDIRS /. /threads ) if(NANA_CMAKE_ENABLE_AUDIO) - list(APPEND NANA_SOURCE_SUBDIRS /audio + list(APPEND NANA_SOURCE_SUBDIRS + /audio /audio/detail ) endif() @@ -60,18 +68,7 @@ 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_sources(${PROJECT_NAME} PRIVATE ${SOURCES}) target_include_directories(${PROJECT_NAME} PUBLIC ${NANA_INCLUDE_DIR}) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) # target_link_libraries(${PROJECT_NAME} ${NANA_LINKS}) @@ -84,7 +81,6 @@ 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) 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) @@ -129,10 +125,10 @@ if(WIN32) 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) + 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() @@ -191,11 +187,11 @@ endif() # 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") + 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=gnu++14 -Wall") + endif() else() set(CMAKE_CXX_FLAGS "-std=c++14 -Wall") endif() @@ -224,7 +220,7 @@ endif() if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # APPLE Clang - list(APPEND NANA_LINKS -stdlib=libstdc++) + list(APPEND NANA_LINKS -stdlib=libstdc++) endif () @@ -297,20 +293,11 @@ elseif(NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) endif() -######## Nana options - -add_definitions(-DNANA_IGNORE_CONF) -if(NANA_CMAKE_VERBOSE_PREPROCESSOR) - add_definitions(-DVERBOSE_PREPROCESSOR) -endif() -if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) - add_definitions(-DNANA_AUTOMATIC_GUI_TESTING) - enable_testing() +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + add_definitions(-fmax-errors=3) endif() - - # Headers: use INCLUDE_DIRECTORIES - # Libraries: use FIND_LIBRARY and link with the result of it (try to avoid LINK_DIRECTORIES) +set(CMAKE_DEBUG_POSTFIX "_d") # 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/ @@ -352,7 +339,12 @@ endif() # Just for information: +include(CMakePrintHelpers) + message ("") +cmake_print_variables(SOURCES) + + 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}) From f24e60425b8eafea307ef4d57a41e38db9428e57 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 21 Aug 2018 16:54:56 +0200 Subject: [PATCH 21/39] use CMakePrintHelpers, move installs --- CMakeLists.txt | 97 ++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f8b7b50..f930bae4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,60 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${NANA_INCLUDE_DIR}) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) # 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) + +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() + + +######## Nana options + +add_definitions(-DNANA_IGNORE_CONF) +if(NANA_CMAKE_VERBOSE_PREPROCESSOR) + add_definitions(-DVERBOSE_PREPROCESSOR) +endif() +if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) + add_definitions(-DNANA_AUTOMATIC_GUI_TESTING) + enable_testing() +endif() + + 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) @@ -103,12 +157,6 @@ option(NANA_CMAKE_NANA_FILESYSTEM_FORCE "Force nana filesystem over ISO and boos 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) @@ -299,43 +347,6 @@ endif() set(CMAKE_DEBUG_POSTFIX "_d") -# 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) - -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() # Just for information: From d27bb0a7b32d7d627e40de8bcb26cd07afcb534f Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 23 Aug 2018 15:17:51 +0200 Subject: [PATCH 22/39] try to add headers to projects --- CMakeLists.txt | 84 ++++++++++++++++++++++++++++-------- include/nana/basic_types.hpp | 6 +-- 2 files changed, 69 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f930bae4..2986620b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,18 +30,18 @@ project(nana VERSION 1.6.1 LANGUAGES CXX ) - +# instead of option(NANA_CMAKE_SHARED_LIB "Compile nana as a shared library." OFF) ?? option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF) +set(NANA_CMAKE_SHARED_LIB ${BUILD_SHARED_LIBS}) + ####################### Main setting of Nana targets, sources and installs - add_library(${PROJECT_NAME} ) - +### collect all source sub-directories in a list to avoid duplication here 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 @@ -61,37 +61,85 @@ if(NANA_CMAKE_ENABLE_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() target_sources(${PROJECT_NAME} PRIVATE ${SOURCES}) -target_include_directories(${PROJECT_NAME} PUBLIC ${NANA_INCLUDE_DIR}) + + +### collect all headers sub-directories in a list to avoid duplication here +# 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_SOURCE_DIR}/include) +target_include_directories(${PROJECT_NAME} PRIVATE ${NANA_INCLUDE_DIR}) + +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) +endforeach() + +# Install the include directories too. +if(NANA_CMAKE_INSTALL_INCLUDES) + target_sources(${PROJECT_NAME} PRIVATE ${HEADERS}) + install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include) + foreach(subdir ${NANA_INCLUDE_SUBDIRS}) + aux_source_directory($ PUBLIC_HEADERS) + endforeach() + target_sources(${PROJECT_NAME} INTERFACE ${PUBLIC_HEADERS}) + message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include") +else() + target_sources(${PROJECT_NAME} PUBLIC ${HEADERS}) +endif() + + + target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) # 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 +message("") +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 ${PROJECT_NAME} + ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) +# test BUILD_SHARED_LIBS directly? 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") + 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}" @@ -106,8 +154,6 @@ if(NANA_CMAKE_SHARED_LIB) 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) @@ -354,6 +400,8 @@ include(CMakePrintHelpers) message ("") cmake_print_variables(SOURCES) +cmake_print_variables(HEADERS) +cmake_print_variables(PUBLIC_HEADERS) message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID}) diff --git a/include/nana/basic_types.hpp b/include/nana/basic_types.hpp index a041279b..0821c91b 100644 --- a/include/nana/basic_types.hpp +++ b/include/nana/basic_types.hpp @@ -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 From 0309e797016890b266924565051eec0623f40cc0 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 30 Aug 2018 15:05:40 +0200 Subject: [PATCH 23/39] FIX using newer Boost TODO use std::filesystem not experimental --- CMakeLists.txt | 3 +- include/nana/filesystem/filesystem.hpp | 66 ++++++++++---------------- 2 files changed, 28 insertions(+), 41 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2986620b..e8aebcd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -410,7 +410,8 @@ 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 ("") +cmake_print_variables ( NANA_LINKS ) message ( "DESTDIR = " ${DESTDIR}) message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR}) diff --git a/include/nana/filesystem/filesystem.hpp b/include/nana/filesystem/filesystem.hpp index b67a00ef..898fae3c 100644 --- a/include/nana/filesystem/filesystem.hpp +++ b/include/nana/filesystem/filesystem.hpp @@ -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 2014-07-04 +// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4100.pdf --- pdf of std draft N4100 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 header VS2015 @@ -55,36 +55,6 @@ #define NANA_USING_BOOST_FILESYSTEM 1 # include # include -// 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 From de2ec3928da7cbe9589db36f7406cd1fda7baa67 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 6 Sep 2018 10:49:54 +0200 Subject: [PATCH 24/39] modernize CMakeList and make it posible to just include nana --- CMakeLists.txt | 212 +++++++++++++------------- source/detail/mswin/platform_spec.hpp | 4 +- 2 files changed, 108 insertions(+), 108 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8aebcd2..304a446f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,30 +17,34 @@ # https://cliutils.gitlab.io/modern-cmake/ # https://cmake.org/cmake-tutorial/ -# https://cmake.org/cmake/help/v3.3/module/CMakeDependentOption.html?highlight=cmakedependentoption +# https://cmake.org/cmake/help/v3.13/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 cmake_minimum_required(VERSION 3.12) -project(nana VERSION 1.6.1 +project(nana VERSION 1.6.2 DESCRIPTION "C++ GUI library" HOMEPAGE_URL http://nanapro.org LANGUAGES CXX ) -# instead of option(NANA_CMAKE_SHARED_LIB "Compile nana as a shared library." OFF) ?? option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF) -set(NANA_CMAKE_SHARED_LIB ${BUILD_SHARED_LIBS}) - ####################### Main setting of Nana targets, sources and installs -add_library(${PROJECT_NAME} ) +add_library(nana) +target_compile_features(nana PUBLIC cxx_std_14) ### collect all source sub-directories in a list to avoid duplication here -set(NANA_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source) + +# By using CMAKE_CURRENT_LIST_DIR here you can compile and consume nana by just: +# include(path/to/nana/CMakeLists.txt) +# 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 /. @@ -64,17 +68,16 @@ endif() # collect all source files in the source-sub-dir foreach(subdir ${NANA_SOURCE_SUBDIRS}) - aux_source_directory(${NANA_SOURCE_DIR}${subdir} SOURCES) + aux_source_directory(${NANA_SOURCE_DIR}${subdir} SOURCES) # todo: use GLOB to add headers too ?? endforeach() -target_sources(${PROJECT_NAME} PRIVATE ${SOURCES}) +target_sources(nana PRIVATE ${SOURCES}) -### collect all headers sub-directories in a list to avoid duplication here +### collect all headers sub-directories in a list to avoid duplication here ?? # 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_SOURCE_DIR}/include) -target_include_directories(${PROJECT_NAME} PRIVATE ${NANA_INCLUDE_DIR}) +set(NANA_INCLUDE_DIR ${CMAKE_CURRENT_LIST_DIR}/include) set(NANA_INCLUDE_SUBDIRS /. @@ -97,79 +100,68 @@ if(NANA_CMAKE_ENABLE_AUDIO) endif() foreach(subdir ${NANA_INCLUDE_SUBDIRS}) - aux_source_directory(${NANA_INCLUDE_DIR}/nana${subdir} HEADERS) + aux_source_directory(${NANA_INCLUDE_DIR}/nana${subdir} HEADERS) # todo: use GLOB to add headers too !!!!!!! endforeach() # Install the include directories too. if(NANA_CMAKE_INSTALL_INCLUDES) - target_sources(${PROJECT_NAME} PRIVATE ${HEADERS}) - install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include) - foreach(subdir ${NANA_INCLUDE_SUBDIRS}) + target_sources(nana PRIVATE ${HEADERS}) + target_include_directories(nana PRIVATE ${NANA_INCLUDE_DIR}) + install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include) # in ${CMAKE_INSTALL_PREFIX}/include/nana + foreach(subdir ${NANA_INCLUDE_SUBDIRS}) # this works? aux_source_directory($ PUBLIC_HEADERS) - endforeach() - target_sources(${PROJECT_NAME} INTERFACE ${PUBLIC_HEADERS}) + endforeach() # todo: use GLOB to add headers too !!!!!!! + target_sources(nana INTERFACE ${PUBLIC_HEADERS}) message("The Nana include files will be installed in ${CMAKE_INSTALL_PREFIX}/include") else() - target_sources(${PROJECT_NAME} PUBLIC ${HEADERS}) + target_sources(nana PUBLIC ${HEADERS}) + target_include_directories(nana PUBLIC ${NANA_INCLUDE_DIR}) endif() -target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14) # -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) message("") 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 ${PROJECT_NAME} +install(TARGETS nana ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) -# test BUILD_SHARED_LIBS directly? -if(NANA_CMAKE_SHARED_LIB) +if(BUILD_SHARED_LIBS) # ?? 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" + 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 ${PROJECT_NAME} POST_BUILD + add_custom_command(TARGET nana 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") + COMMAND "${DLLTOOL}" --dllname "libnana.dll" + --input-def "libnana.def" + --output-lib "libnana.lib") - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.def" - "${CMAKE_CURRENT_BINARY_DIR}/lib${PROJECT_NAME}.lib" DESTINATION lib) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnana.def" + "${CMAKE_CURRENT_BINARY_DIR}/libnana.lib" DESTINATION lib) endif() endif() endif() -# 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() - - ######## Nana options -add_definitions(-DNANA_IGNORE_CONF) +target_compile_definitions(nana PRIVATE NANA_IGNORE_CONF) 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) + enable_testing() # ?? endif() @@ -204,9 +196,11 @@ option(NANA_CMAKE_STD_FILESYSTEM_FORCE "Use of STD filesystem?(a compilation err option(NANA_CMAKE_BOOST_FILESYSTEM_FORCE "Force use of Boost filesystem if available (over STD)?" OFF) ########### 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) - add_definitions(-DWIN32) + target_compile_definitions(nana PUBLIC WIN32) # todo: why not simple test for _WIN32 in code?? # 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) @@ -214,14 +208,14 @@ if(WIN32) # Change the MSVC Compiler flags if(MSVC_USE_MP) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /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_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}}") @@ -231,9 +225,9 @@ if(WIN32) 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) + if(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) # deprecated ????? + target_compile_definitions(nana PUBLIC STD_THREAD_NOT_SUPPORTED) + target_compile_definitions(nana PUBLIC NANA_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ) endif() endif() @@ -249,20 +243,20 @@ if(WIN32) endif() if(APPLE) - add_definitions(-DAPPLE) - include_directories(/opt/X11/include/) - list(APPEND NANA_LINKS -L/opt/X11/lib/ -liconv) + target_compile_definitions(nana PUBLIC APPLE) # ??? not added by compilers? use __APPLE__ ? + target_include_directories(nana PUBLIC /opt/X11/include/) + target_compile_options(nana PUBLIC -L/opt/X11/lib/ -liconv) set(ENABLE_AUDIO OFF) elseif(UNIX) - add_definitions(-Dlinux) + target_compile_definitions(nana PUBLIC linux) # todo: eliminate. Added by compilers. Also __linux posible endif() if(UNIX) - list(APPEND NANA_LINKS -lX11) + target_compile_options(nana PUBLIC -lX11) include(FindFreetype) if(FREETYPE_FOUND) - include_directories( ${FREETYPE_INCLUDE_DIRS}) - list(APPEND NANA_LINKS -lXft -lfontconfig) + target_include_directories(nana PUBLIC ${FREETYPE_INCLUDE_DIRS}) + target_compile_options(nana PUBLIC -lXft -lfontconfig) endif() endif() @@ -280,41 +274,32 @@ endif() # 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") + + target_compile_options(nana PRIVATE -Wall) 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") + target_compile_options(nana PRIVATE -I/usr/local/include) 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) + if(BUILD_SHARED_LIBS) + target_compile_options(nana PRIVATE -lgcc -lstdc++) else() + if(MINGW) - set(CMAKE_EXE_LINKER_FLAGS "-static -pthread") + target_compile_options(nana PRIVATE -static) # -static ?? cmake knows BUILD_SHARED_LIBS else() - set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -pthread") + target_compile_options(nana PRIVATE -static-libgcc -static-libstdc++) endif() - endif(NANA_CMAKE_SHARED_LIB) + endif(BUILD_SHARED_LIBS) + + target_compile_options(nana PRIVATE -pthread) - 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++) + target_compile_options(nana PRIVATE -stdlib=libstdc++) endif () @@ -325,38 +310,37 @@ 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) + target_include_directories(nana PRIVATE ${PNG_INCLUDE_DIRS}) + target_compile_options (nana PRIVATE ${PNG_LIBRARIES}) + target_compile_definitions(nana PRIVATE NANA_ENABLE_PNG USE_LIBPNG_FROM_OS) endif() else() - add_definitions(-DNANA_ENABLE_PNG) + target_compile_definitions(nana PRIVATE NANA_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) + target_include_directories(nana PRIVATE ${JPEG_INCLUDE_DIR}) + target_compile_options (nana PRIVATE ${JPEG_LIBRARY}) + target_compile_definitions(nana PRIVATE NANA_ENABLE_JPEG USE_LIBJPEG_FROM_OS) endif() else() - add_definitions(-DNANA_ENABLE_JPEG) + target_compile_definitions(nana PRIVATE NANA_ENABLE_JPEG) endif() endif() # Find ASOUND if(NANA_CMAKE_ENABLE_AUDIO) - add_definitions(-DNANA_ENABLE_AUDIO) + target_compile_definitions(nana PRIVATE NANA_ENABLE_AUDIO) if(UNIX) find_package(ASOUND) if(ASOUND_FOUND) - include_directories(${ASOUND_INCLUDE_DIRS}) - list(APPEND NANA_LINKS -lasound) + target_include_directories(nana PRIVATE ${ASOUND_INCLUDE_DIRS}) + target_compile_options(nana PRIVATE -lasound) else() message(FATAL_ERROR "libasound is not found") endif() @@ -364,37 +348,46 @@ if(NANA_CMAKE_ENABLE_AUDIO) endif() # Find/Select filesystem + + if(NANA_CMAKE_NANA_FILESYSTEM_FORCE) - add_definitions(-DNANA_FILESYSTEM_FORCE) + target_compile_definitions(nana PUBLIC NANA_FILESYSTEM_FORCE) + elseif(NANA_CMAKE_STD_FILESYSTEM_FORCE) - add_definitions(-DSTD_FILESYSTEM_FORCE) + target_compile_definitions(nana PUBLIC STD_FILESYSTEM_FORCE) + target_compile_options (nana PUBLIC -lstdc++fs) + elseif(NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) if(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) - add_definitions(-DBOOST_FILESYSTEM_FORCE) + target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_FORCE) + else() + target_compile_options (nana PUBLIC -lstdc++fs) 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}) + target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_AVAILABLE) + target_include_directories(nana PUBLIC "${Boost_INCLUDE_DIR}") # ?? SYSTEM + target_link_libraries (nana PUBLIC ${Boost_LIBRARIES}) endif() set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_RUNTIME ON) endif() + + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - add_definitions(-fmax-errors=3) + target_compile_options(nana PRIVATE -fmax-errors=3) endif() set(CMAKE_DEBUG_POSTFIX "_d") - # Just for information: include(CMakePrintHelpers) @@ -410,8 +403,15 @@ 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_print_variables ( NANA_LINKS ) + + +# 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 ( "DESTDIR = " ${DESTDIR}) message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR}) diff --git a/source/detail/mswin/platform_spec.hpp b/source/detail/mswin/platform_spec.hpp index 3505f6e3..1a44ce8b 100644 --- a/source/detail/mswin/platform_spec.hpp +++ b/source/detail/mswin/platform_spec.hpp @@ -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. From 6fab0f535479695790c71398ccb1ac2bdad893bc Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Thu, 6 Sep 2018 13:12:46 +0200 Subject: [PATCH 25/39] simplify cmake usage by nana-demo including nana --- .gitignore | 1 + .travis.yml | 7 ------- CMakeLists.txt | 8 ++++---- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 6bd33ab0..003f80b0 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,7 @@ lib/ CMakeCache.txt CMakeFiles/ cmake-build-debug/ +cmake-build-*/ .idea/ cmake_install.cmake *.DS_Store diff --git a/.travis.yml b/.travis.yml index 69624c16..09436717 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,18 +56,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 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 304a446f..6a2622c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ # https://cliutils.gitlab.io/modern-cmake/ # https://cmake.org/cmake-tutorial/ -# https://cmake.org/cmake/help/v3.13/module/CMakeDependentOption.html?highlight=cmakedependentoption +# https://cmake.org/cmake/help/v3.12/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. @@ -312,7 +312,7 @@ if(NANA_CMAKE_ENABLE_PNG) if(PNG_FOUND) target_include_directories(nana PRIVATE ${PNG_INCLUDE_DIRS}) target_compile_options (nana PRIVATE ${PNG_LIBRARIES}) - target_compile_definitions(nana PRIVATE NANA_ENABLE_PNG USE_LIBPNG_FROM_OS) + target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG USE_LIBPNG_FROM_OS) endif() else() target_compile_definitions(nana PRIVATE NANA_ENABLE_PNG) @@ -326,7 +326,7 @@ if(NANA_CMAKE_ENABLE_JPEG) if(JPEG_FOUND) target_include_directories(nana PRIVATE ${JPEG_INCLUDE_DIR}) target_compile_options (nana PRIVATE ${JPEG_LIBRARY}) - target_compile_definitions(nana PRIVATE NANA_ENABLE_JPEG USE_LIBJPEG_FROM_OS) + target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG USE_LIBJPEG_FROM_OS) endif() else() target_compile_definitions(nana PRIVATE NANA_ENABLE_JPEG) @@ -335,7 +335,7 @@ endif() # Find ASOUND if(NANA_CMAKE_ENABLE_AUDIO) - target_compile_definitions(nana PRIVATE NANA_ENABLE_AUDIO) + target_compile_definitions(nana PUBLIC NANA_ENABLE_AUDIO) if(UNIX) find_package(ASOUND) if(ASOUND_FOUND) From 88b0206016a161f6474aaffbba613ca1ebcd05ca Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 9 Sep 2018 01:25:43 +0200 Subject: [PATCH 26/39] target_include_directories INTERFACE ${CMAKE_INSTALL_PREFIX}/include)? --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a2622c3..b5803682 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,8 @@ endforeach() # Install the include directories too. if(NANA_CMAKE_INSTALL_INCLUDES) target_sources(nana PRIVATE ${HEADERS}) - target_include_directories(nana PRIVATE ${NANA_INCLUDE_DIR}) + target_include_directories(nana PRIVATE ${NANA_INCLUDE_DIR} + INTERFACE ${CMAKE_INSTALL_PREFIX}/include) install(DIRECTORY ${NANA_INCLUDE_DIR}/nana DESTINATION include) # in ${CMAKE_INSTALL_PREFIX}/include/nana foreach(subdir ${NANA_INCLUDE_SUBDIRS}) # this works? aux_source_directory($ PUBLIC_HEADERS) From ba530b83773b4b7e7ced38366e897636feec166f Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 9 Sep 2018 01:37:21 +0200 Subject: [PATCH 27/39] fixing travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 09436717..ea6f6ee9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,17 +56,17 @@ 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 - - cd ../nana_lib - mkdir bin - cd bin script: - - 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 + - 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 -DNANA_CMAKE_INSTALL_INCLUDES=OFF - make install - ls - cd .. - ls - cd .. + - mkdir nana_demo_bin - 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 From 4f11de3d606742ad5dee8958b1521e9f393d5ee5 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 9 Sep 2018 01:55:21 +0200 Subject: [PATCH 28/39] fixing travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ea6f6ee9..b1d0a290 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,8 @@ matrix: - llvm-toolchain-precise before_install: - - git clone --depth=1 --branch=cmake-dev 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" - 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 From 8e7985e0e3dbc3347b6dc6409d3ca81406f190fc Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 9 Sep 2018 02:06:06 +0200 Subject: [PATCH 29/39] fixing travis --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b1d0a290..d2e13c71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,8 +65,6 @@ script: - make install - ls - cd .. - - ls - - cd .. - mkdir nana_demo_bin - ls - cd nana_demo_bin From 8057bf95e155f9755f02bbbe7124670ddfc4bb6f Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Sun, 9 Sep 2018 11:49:30 +0200 Subject: [PATCH 30/39] use NANA_CMAKE_INSTALL --- CMakeLists.txt | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5803682..4dd04dc0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ # # Nana uses some build systems: MS-VS solution, MAKE, bakefile, codeblock, etc. manually optimized. # 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 distributed build system -# files/projects are manually writen. This current CMakeList.txt reflect this fact and that is why we don't +# 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. @@ -20,9 +20,9 @@ # https://cmake.org/cmake/help/v3.12/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 - cmake_minimum_required(VERSION 3.12) project(nana VERSION 1.6.2 DESCRIPTION "C++ GUI library" @@ -40,7 +40,7 @@ target_compile_features(nana PUBLIC cxx_std_14) ### collect all source sub-directories in a list to avoid duplication here # By using CMAKE_CURRENT_LIST_DIR here you can compile and consume nana by just: -# include(path/to/nana/CMakeLists.txt) +# add_subdirectory(../nana ../cmake-nana-build-${CONFIG} ) or simmilar # in your own CMakeLists.txt, and them : # target_link_libraries(yourApp PRIVATE nana ) @@ -104,32 +104,27 @@ foreach(subdir ${NANA_INCLUDE_SUBDIRS}) endforeach() # Install the include directories too. -if(NANA_CMAKE_INSTALL_INCLUDES) +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} - INTERFACE ${CMAKE_INSTALL_PREFIX}/include) + 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 - foreach(subdir ${NANA_INCLUDE_SUBDIRS}) # this works? - aux_source_directory($ PUBLIC_HEADERS) - endforeach() # todo: use GLOB to add headers too !!!!!!! - target_sources(nana INTERFACE ${PUBLIC_HEADERS}) 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() - - -message("") -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) - if(BUILD_SHARED_LIBS) # ?? if(WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) @@ -167,7 +162,7 @@ endif() -option(NANA_CMAKE_INSTALL_INCLUDES "Install nana includes when compile the library" ON) +option(NANA_CMAKE_INSTALL "Install nana when compile the library" OFF) 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) From 8c6b0d465332f1ac63540782825730f4d025839a Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Mon, 10 Sep 2018 14:27:56 +0200 Subject: [PATCH 31/39] simplify CMakeList with cmake scripts --- CMakeLists.txt | 168 ++++------------------------ build/cmake/enable_audio.cmake | 15 +++ build/cmake/enable_jpeg.cmake | 17 +++ build/cmake/enable_png.cmake | 17 +++ build/cmake/select_filesystem.cmake | 47 ++++++++ build/cmake/shared_libs.cmake | 30 +++++ include/nana/config.hpp | 2 +- 7 files changed, 149 insertions(+), 147 deletions(-) create mode 100644 build/cmake/enable_audio.cmake create mode 100644 build/cmake/enable_jpeg.cmake create mode 100644 build/cmake/enable_png.cmake create mode 100644 build/cmake/select_filesystem.cmake create mode 100644 build/cmake/shared_libs.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dd04dc0..8d88f0be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,14 @@ foreach(subdir ${NANA_INCLUDE_SUBDIRS}) aux_source_directory(${NANA_INCLUDE_DIR}/nana${subdir} HEADERS) # todo: use GLOB to add headers too !!!!!!! endforeach() + +option(NANA_CMAKE_INSTALL "Install nana when compile the library" OFF) +option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF) +option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." ON) +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) + + # Install the include directories too. if(NANA_CMAKE_INSTALL) # this is the prefered method to consume nana directly with some specific bulid system @@ -126,71 +134,20 @@ endif() if(BUILD_SHARED_LIBS) # ?? - if(WIN32) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - 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() + include(build/cmake/shared_libs.cmake) endif() ######## Nana options -target_compile_definitions(nana PRIVATE NANA_IGNORE_CONF) +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) - enable_testing() # ?? + # todo: enable_testing() # ?? endif() - - -option(NANA_CMAKE_INSTALL "Install nana when compile the library" OFF) -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_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." ON) -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) - -# 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 or -# 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) - ########### 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 @@ -226,16 +183,6 @@ if(WIN32) target_compile_definitions(nana PUBLIC NANA_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) @@ -274,107 +221,36 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") target_compile_options(nana PRIVATE -Wall) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") - target_compile_options(nana PRIVATE -I/usr/local/include) + target_compile_options(nana PUBLIC -I/usr/local/include) endif() endif() if(BUILD_SHARED_LIBS) - target_compile_options(nana PRIVATE -lgcc -lstdc++) + target_compile_options(nana PUBLIC -lgcc -lstdc++) else() if(MINGW) - target_compile_options(nana PRIVATE -static) # -static ?? cmake knows BUILD_SHARED_LIBS + target_compile_options(nana PUBLIC -static) # -static ?? cmake knows BUILD_SHARED_LIBS else() - target_compile_options(nana PRIVATE -static-libgcc -static-libstdc++) + target_compile_options(nana PUBLIC -static-libgcc -static-libstdc++) endif() endif(BUILD_SHARED_LIBS) - target_compile_options(nana PRIVATE -pthread) + target_compile_options(nana PUBLIC -pthread) endif() if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # APPLE Clang - target_compile_options(nana PRIVATE -stdlib=libstdc++) + target_compile_options(nana PUBLIC -stdlib=libstdc++) endif () ############# Optional libraries - -# Find PNG -if(NANA_CMAKE_ENABLE_PNG) - if(NANA_CMAKE_LIBPNG_FROM_OS) - find_package(PNG) - if(PNG_FOUND) - target_include_directories(nana PRIVATE ${PNG_INCLUDE_DIRS}) - target_compile_options (nana PRIVATE ${PNG_LIBRARIES}) - target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG USE_LIBPNG_FROM_OS) - endif() - else() - target_compile_definitions(nana PRIVATE NANA_ENABLE_PNG) - endif() -endif() - -# Find JPEG -if(NANA_CMAKE_ENABLE_JPEG) - if(NANA_CMAKE_LIBJPEG_FROM_OS) - find_package(JPEG) - if(JPEG_FOUND) - target_include_directories(nana PRIVATE ${JPEG_INCLUDE_DIR}) - target_compile_options (nana PRIVATE ${JPEG_LIBRARY}) - target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG USE_LIBJPEG_FROM_OS) - endif() - else() - target_compile_definitions(nana PRIVATE NANA_ENABLE_JPEG) - endif() -endif() - -# Find ASOUND -if(NANA_CMAKE_ENABLE_AUDIO) - target_compile_definitions(nana PUBLIC NANA_ENABLE_AUDIO) - if(UNIX) - find_package(ASOUND) - if(ASOUND_FOUND) - target_include_directories(nana PRIVATE ${ASOUND_INCLUDE_DIRS}) - target_compile_options(nana PRIVATE -lasound) - else() - message(FATAL_ERROR "libasound is not found") - endif() - endif() -endif() - -# Find/Select filesystem - - -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_compile_options (nana PUBLIC -lstdc++fs) - -elseif(NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) - if(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) - target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_FORCE) - else() - target_compile_options (nana PUBLIC -lstdc++fs) - 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) - target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_AVAILABLE) - target_include_directories(nana PUBLIC "${Boost_INCLUDE_DIR}") # ?? SYSTEM - target_link_libraries (nana PUBLIC ${Boost_LIBRARIES}) - endif() - set(Boost_USE_STATIC_LIBS ON) - set(Boost_USE_STATIC_RUNTIME ON) -endif() - - +include(build/cmake/enable_png.cmake) +include(build/cmake/enable_jpeg.cmake) +include(build/cmake/enable_audio.cmake) +include(build/cmake/select_filesystem.cmake) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") @@ -388,7 +264,7 @@ set(CMAKE_DEBUG_POSTFIX "_d") include(CMakePrintHelpers) message ("") -cmake_print_variables(SOURCES) +# cmake_print_variables(SOURCES) cmake_print_variables(HEADERS) cmake_print_variables(PUBLIC_HEADERS) diff --git a/build/cmake/enable_audio.cmake b/build/cmake/enable_audio.cmake new file mode 100644 index 00000000..ab26967f --- /dev/null +++ b/build/cmake/enable_audio.cmake @@ -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) + if(ASOUND_FOUND) + target_include_directories(nana PUBLIC ${ASOUND_INCLUDE_DIRS}) + target_compile_options(nana PUBLIC -lasound) + else() + message(FATAL_ERROR "libasound is not found") + endif() + endif() +endif() \ No newline at end of file diff --git a/build/cmake/enable_jpeg.cmake b/build/cmake/enable_jpeg.cmake new file mode 100644 index 00000000..552a252a --- /dev/null +++ b/build/cmake/enable_jpeg.cmake @@ -0,0 +1,17 @@ +option(NANA_CMAKE_ENABLE_JPEG "Enable the use of JPEG" OFF) +option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON) + +# todo: decide - PUBLIC vs PRIVATE + +if(NANA_CMAKE_ENABLE_JPEG) + if(NANA_CMAKE_LIBJPEG_FROM_OS) + find_package(JPEG) + if(JPEG_FOUND) + target_include_directories(nana PUBLIC ${JPEG_INCLUDE_DIR}) + target_compile_options (nana PUBLIC ${JPEG_LIBRARY}) + target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG USE_LIBJPEG_FROM_OS) + endif() + else() + target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG) + endif() +endif() \ No newline at end of file diff --git a/build/cmake/enable_png.cmake b/build/cmake/enable_png.cmake new file mode 100644 index 00000000..6d739782 --- /dev/null +++ b/build/cmake/enable_png.cmake @@ -0,0 +1,17 @@ +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) + if(NANA_CMAKE_LIBPNG_FROM_OS) + find_package(PNG) + if(PNG_FOUND) + target_include_directories(nana PUBLIC ${PNG_INCLUDE_DIRS}) + target_compile_options (nana PUBLIC ${PNG_LIBRARIES}) + target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG USE_LIBPNG_FROM_OS) + endif() + else() + target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG) + endif() +endif() \ No newline at end of file diff --git a/build/cmake/select_filesystem.cmake b/build/cmake/select_filesystem.cmake new file mode 100644 index 00000000..1b54f1e2 --- /dev/null +++ b/build/cmake/select_filesystem.cmake @@ -0,0 +1,47 @@ +# 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 or +# 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_compile_options (nana PUBLIC -lstdc++fs) + +elseif(NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) + if(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) + target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_FORCE) + else() + target_compile_options (nana PUBLIC -lstdc++fs) + 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) + target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_AVAILABLE) + target_include_directories(nana PUBLIC "${Boost_INCLUDE_DIR}") # ?? SYSTEM + target_link_libraries (nana PUBLIC ${Boost_LIBRARIES}) + endif() + set(Boost_USE_STATIC_LIBS ON) + set(Boost_USE_STATIC_RUNTIME ON) +endif() + + diff --git a/build/cmake/shared_libs.cmake b/build/cmake/shared_libs.cmake new file mode 100644 index 00000000..6d7d6190 --- /dev/null +++ b/build/cmake/shared_libs.cmake @@ -0,0 +1,30 @@ + 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() \ No newline at end of file diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 17c5cdc2..aac360c4 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -71,7 +71,7 @@ /////////////////// // Support of PCM playback // -#define NANA_ENABLE_AUDIO +//#define NANA_ENABLE_AUDIO /////////////////// // Support for PNG From 1821f3018e5c3d53a054e0b73eb0f3a805e42cc8 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Mon, 10 Sep 2018 14:44:42 +0200 Subject: [PATCH 32/39] travis calls nana-demo directly --- .travis.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d2e13c71..743efe3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,18 +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 bin - - cd bin + - mkdir demo-build + - cd demo-build script: - - 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 -DNANA_CMAKE_INSTALL_INCLUDES=OFF - - make install - - ls - - cd .. - - mkdir nana_demo_bin - - 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 From df1059d297efc5c33c900be3c06e5c8db7b4c03a Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 11 Sep 2018 16:32:24 +0200 Subject: [PATCH 33/39] cmake_print_variables (NANA_CMAKE_INSTALL) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d88f0be..29160e09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -267,7 +267,7 @@ message ("") # cmake_print_variables(SOURCES) cmake_print_variables(HEADERS) cmake_print_variables(PUBLIC_HEADERS) - +cmake_print_variables(NANA_CMAKE_INSTALL) message ( "CMAKE_CXX_COMPILER_ID = " ${CMAKE_CXX_COMPILER_ID}) message ( "COMPILER_IS_CLANG = " ${COMPILER_IS_CLANG}) From 8c8adb397e926abf283c3af5d7b3c42ec02d0ff8 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Mon, 1 Oct 2018 19:04:12 +0200 Subject: [PATCH 34/39] target_link_libraries --- build/cmake/enable_audio.cmake | 2 +- build/cmake/enable_jpeg.cmake | 7 ++++--- build/cmake/enable_png.cmake | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/build/cmake/enable_audio.cmake b/build/cmake/enable_audio.cmake index ab26967f..881b4c24 100644 --- a/build/cmake/enable_audio.cmake +++ b/build/cmake/enable_audio.cmake @@ -7,7 +7,7 @@ if(NANA_CMAKE_ENABLE_AUDIO) find_package(ASOUND) if(ASOUND_FOUND) target_include_directories(nana PUBLIC ${ASOUND_INCLUDE_DIRS}) - target_compile_options(nana PUBLIC -lasound) + target_link_libraries(nana PUBLIC ${ASOUND_LIBRARY}) else() message(FATAL_ERROR "libasound is not found") endif() diff --git a/build/cmake/enable_jpeg.cmake b/build/cmake/enable_jpeg.cmake index 552a252a..09fd9244 100644 --- a/build/cmake/enable_jpeg.cmake +++ b/build/cmake/enable_jpeg.cmake @@ -4,14 +4,15 @@ option(NANA_CMAKE_LIBJPEG_FROM_OS "Use libjpeg from operating system." ON) # 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_DIR}) - target_compile_options (nana PUBLIC ${JPEG_LIBRARY}) - target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG USE_LIBJPEG_FROM_OS) + target_link_libraries (nana PUBLIC ${JPEG_LIBRARY}) + target_compile_definitions(nana PUBLIC USE_LIBJPEG_FROM_OS) endif() else() - target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG) + target_compile_definitions(nana PUBLIC -ljpeg) endif() endif() \ No newline at end of file diff --git a/build/cmake/enable_png.cmake b/build/cmake/enable_png.cmake index 6d739782..e60bd02e 100644 --- a/build/cmake/enable_png.cmake +++ b/build/cmake/enable_png.cmake @@ -4,14 +4,15 @@ 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_compile_options (nana PUBLIC ${PNG_LIBRARIES}) - target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG USE_LIBPNG_FROM_OS) + target_link_libraries (nana PUBLIC ${PNG_LIBRARIES}) + target_compile_definitions(nana PUBLIC USE_LIBPNG_FROM_OS ${PNG_DEFINITIONS}) endif() else() - target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG) + target_compile_definitions(nana PUBLIC -lpng) endif() endif() \ No newline at end of file From 2e0bf06dcb41811f2c4dee1634a6148f176b88e2 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Mon, 1 Oct 2018 19:37:33 +0200 Subject: [PATCH 35/39] trying to fix a definition duplication of boolean window.h vs jpeg --- build/cmake/enable_jpeg.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build/cmake/enable_jpeg.cmake b/build/cmake/enable_jpeg.cmake index 09fd9244..8fdcb980 100644 --- a/build/cmake/enable_jpeg.cmake +++ b/build/cmake/enable_jpeg.cmake @@ -1,5 +1,6 @@ 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" ON) # todo: decide - PUBLIC vs PRIVATE @@ -15,4 +16,9 @@ if(NANA_CMAKE_ENABLE_JPEG) 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() \ No newline at end of file From 4f42041388c834b411ca0595e499d104f4910318 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Mon, 1 Oct 2018 19:55:06 +0200 Subject: [PATCH 36/39] fix definition of boolean in jpeg by default --- build/cmake/enable_jpeg.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cmake/enable_jpeg.cmake b/build/cmake/enable_jpeg.cmake index 8fdcb980..a6956f66 100644 --- a/build/cmake/enable_jpeg.cmake +++ b/build/cmake/enable_jpeg.cmake @@ -1,6 +1,6 @@ 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" ON) +option(JPEG_HAVE_BOOLEAN "Defining HAVE_BOOLEAN before including jpeglib.h" OFF) # todo: decide - PUBLIC vs PRIVATE From b430f8285504dd0be0108c93fa89bd1914fbabee Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 2 Oct 2018 18:40:27 +0200 Subject: [PATCH 37/39] delete files for deprecated Biicode --- bii/layout.bii | 12 ------------ bii/policies.bii | 11 ----------- bii/settings.bii | 2 -- biicode.conf | 49 ------------------------------------------------ 4 files changed, 74 deletions(-) delete mode 100644 bii/layout.bii delete mode 100644 bii/policies.bii delete mode 100644 bii/settings.bii delete mode 100644 biicode.conf diff --git a/bii/layout.bii b/bii/layout.bii deleted file mode 100644 index 31e284d2..00000000 --- a/bii/layout.bii +++ /dev/null @@ -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 \ No newline at end of file diff --git a/bii/policies.bii b/bii/policies.bii deleted file mode 100644 index d6d5e86e..00000000 --- a/bii/policies.bii +++ /dev/null @@ -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 - diff --git a/bii/settings.bii b/bii/settings.bii deleted file mode 100644 index fa648ede..00000000 --- a/bii/settings.bii +++ /dev/null @@ -1,2 +0,0 @@ -cmake: {generator: MinGW Makefiles} -os: {arch: 32bit, family: Windows, subfamily: '7', version: 6.1.7601} diff --git a/biicode.conf b/biicode.conf deleted file mode 100644 index 872c1375..00000000 --- a/biicode.conf +++ /dev/null @@ -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") - From 2e6a85bf893f46724abffd59aea0bab5a4b2edd0 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 2 Oct 2018 18:47:04 +0200 Subject: [PATCH 38/39] reorganize cmake in small scripts with some fix from https://github.com/cnjinhao/nana/pull/278 --- CMakeLists.txt | 235 ++++++---------------------- build/cmake/OS.cmake | 70 +++++++++ build/cmake/compilers.cmake | 48 ++++++ build/cmake/enable_audio.cmake | 4 +- build/cmake/enable_jpeg.cmake | 6 +- build/cmake/enable_png.cmake | 4 +- build/cmake/install_nana.cmake | 23 +++ build/cmake/select_filesystem.cmake | 24 +-- build/cmake/shared_libs.cmake | 25 ++- cmake/Modules/FindFontconfig.cmake | 69 -------- 10 files changed, 233 insertions(+), 275 deletions(-) create mode 100644 build/cmake/OS.cmake create mode 100644 build/cmake/compilers.cmake create mode 100644 build/cmake/install_nana.cmake delete mode 100644 cmake/Modules/FindFontconfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 89295796..2e427ee6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ # CMake configuration for Nana -# Author: Andrew Kornilov(https://github.com/ierofant) # Contributors: # Andrew Kornilov (ierofant) - original version # Jinhao @@ -8,7 +7,7 @@ # 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 +# 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. # Maybe CMake will be used in the future to generate some of them in the central nana repository. @@ -20,6 +19,7 @@ # 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 cmake_minimum_required(VERSION 3.12 FATAL_ERROR) project(nana VERSION 1.6.2 @@ -27,15 +27,27 @@ project(nana VERSION 1.6.2 HOMEPAGE_URL http://nanapro.org LANGUAGES CXX ) - -option(BUILD_SHARED_LIBS "Compile nana as a shared library." OFF) - -####################### Main setting of Nana targets, sources and installs +####################### Main setting of Nana targets, sources and installs ##################### add_library(nana) -target_compile_features(nana PUBLIC cxx_std_14) +target_compile_features(nana PUBLIC cxx_std_17) -### collect all source sub-directories in a list to avoid duplication here +# 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 @@ -71,8 +83,7 @@ endforeach() target_sources(nana PRIVATE ${SOURCES}) - -### collect all headers sub-directories in a list to avoid duplication here ?? +### 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) @@ -101,39 +112,11 @@ foreach(subdir ${NANA_INCLUDE_SUBDIRS}) aux_source_directory(${NANA_INCLUDE_DIR}/nana${subdir} HEADERS) # todo: use GLOB to add headers too !!!!!!! endforeach() - -option(NANA_CMAKE_INSTALL "Install nana when compile the library" OFF) -option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF) -option(NANA_CMAKE_VERBOSE_PREPROCESSOR "Show annoying debug messages during compilation." ON) +### 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) - - -# 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() - - -if(BUILD_SHARED_LIBS) # ?? - include(build/cmake/shared_libs.cmake) -endif() +option(NANA_CMAKE_ENABLE_MINGW_STD_THREADS_WITH_MEGANZ "replaced boost.thread with meganz's mingw-std-threads." OFF) # deprecate? ######## Nana options @@ -146,160 +129,42 @@ if(NANA_CMAKE_AUTOMATIC_GUI_TESTING) # todo: enable_testing() # ?? endif() -########### 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 +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 -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) - target_compile_definitions(nana 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) -elseif(UNIX) - target_compile_definitions(nana PUBLIC linux) # todo: eliminate. Added by compilers. Also __linux posible -endif() - -if(UNIX) - find_package(X11 REQUIRED) - 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) - 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) - - -########### 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") - - target_compile_options(nana PRIVATE -Wall) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") - target_compile_options(nana PUBLIC -I/usr/local/include) - endif() - endif() -# set(THREADS_PREFER_PTHREAD_FLAG ON) -# find_package(Threads REQUIRED) -# target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) - - 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) - # target_link_libraries(nana PRIVATE stdc++fs) # ?? - - target_compile_options(nana PUBLIC -pthread) - -endif() - - -if (APPLE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # APPLE Clang - target_compile_options(nana PUBLIC -stdlib=libstdc++) -endif () - - -############# Optional libraries +############# 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) -if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - target_compile_options(nana PRIVATE -fmax-errors=3) -endif() - - - -target_compile_features(${PROJECT_NAME} - 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 -) - -# Just for information: +### 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 ("") + #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}) @@ -307,14 +172,6 @@ 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}) - -# 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 ( "DESTDIR = " ${DESTDIR}) message ( "CMAKE_INSTALL_PREFIX = " ${CMAKE_INSTALL_PREFIX}) message ( "NANA_INCLUDE_DIR = " ${NANA_INCLUDE_DIR}) diff --git a/build/cmake/OS.cmake b/build/cmake/OS.cmake new file mode 100644 index 00000000..022e1e83 --- /dev/null +++ b/build/cmake/OS.cmake @@ -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) diff --git a/build/cmake/compilers.cmake b/build/cmake/compilers.cmake new file mode 100644 index 00000000..8cc53765 --- /dev/null +++ b/build/cmake/compilers.cmake @@ -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() + diff --git a/build/cmake/enable_audio.cmake b/build/cmake/enable_audio.cmake index 881b4c24..77ca7a4f 100644 --- a/build/cmake/enable_audio.cmake +++ b/build/cmake/enable_audio.cmake @@ -4,10 +4,10 @@ option(NANA_CMAKE_ENABLE_AUDIO "Enable class audio::play for PCM playback." OFF) if(NANA_CMAKE_ENABLE_AUDIO) target_compile_definitions(nana PUBLIC NANA_ENABLE_AUDIO) if(UNIX) - find_package(ASOUND) + 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_LIBRARY}) + target_link_libraries(nana PUBLIC ${ASOUND_LIBRARIES}) else() message(FATAL_ERROR "libasound is not found") endif() diff --git a/build/cmake/enable_jpeg.cmake b/build/cmake/enable_jpeg.cmake index a6956f66..008df7dc 100644 --- a/build/cmake/enable_jpeg.cmake +++ b/build/cmake/enable_jpeg.cmake @@ -9,9 +9,9 @@ if(NANA_CMAKE_ENABLE_JPEG) if(NANA_CMAKE_LIBJPEG_FROM_OS) find_package(JPEG) if(JPEG_FOUND) - target_include_directories(nana PUBLIC ${JPEG_INCLUDE_DIR}) - target_link_libraries (nana PUBLIC ${JPEG_LIBRARY}) - target_compile_definitions(nana PUBLIC USE_LIBJPEG_FROM_OS) + 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) diff --git a/build/cmake/enable_png.cmake b/build/cmake/enable_png.cmake index e60bd02e..7d3a5134 100644 --- a/build/cmake/enable_png.cmake +++ b/build/cmake/enable_png.cmake @@ -11,8 +11,10 @@ if(NANA_CMAKE_ENABLE_PNG) 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_compile_definitions(nana PUBLIC -lpng) + target_link_libraries(nana PUBLIC png) # provided by nana? endif() endif() \ No newline at end of file diff --git a/build/cmake/install_nana.cmake b/build/cmake/install_nana.cmake new file mode 100644 index 00000000..2b6851d6 --- /dev/null +++ b/build/cmake/install_nana.cmake @@ -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() + diff --git a/build/cmake/select_filesystem.cmake b/build/cmake/select_filesystem.cmake index 1b54f1e2..036cf050 100644 --- a/build/cmake/select_filesystem.cmake +++ b/build/cmake/select_filesystem.cmake @@ -21,27 +21,33 @@ if(NANA_CMAKE_NANA_FILESYSTEM_FORCE) elseif(NANA_CMAKE_STD_FILESYSTEM_FORCE) target_compile_definitions(nana PUBLIC STD_FILESYSTEM_FORCE) - target_compile_options (nana PUBLIC -lstdc++fs) - -elseif(NANA_CMAKE_FIND_BOOST_FILESYSTEM OR NANA_CMAKE_BOOST_FILESYSTEM_FORCE) - if(NANA_CMAKE_BOOST_FILESYSTEM_FORCE) - target_compile_definitions(nana PUBLIC BOOST_FILESYSTEM_FORCE) - else() - target_compile_options (nana PUBLIC -lstdc++fs) - endif() + 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 COMPONENTS filesystem) + 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() + + + diff --git a/build/cmake/shared_libs.cmake b/build/cmake/shared_libs.cmake index 6d7d6190..0734b47a 100644 --- a/build/cmake/shared_libs.cmake +++ b/build/cmake/shared_libs.cmake @@ -1,3 +1,8 @@ + +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) @@ -25,6 +30,22 @@ --output-lib "libnana.lib") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnana.def" - "${CMAKE_CURRENT_BINARY_DIR}/libnana.lib" DESTINATION lib) + "${CMAKE_CURRENT_BINARY_DIR}/libnana.lib" DESTINATION lib) endif() - endif() \ No newline at end of file + 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() \ No newline at end of file diff --git a/cmake/Modules/FindFontconfig.cmake b/cmake/Modules/FindFontconfig.cmake deleted file mode 100644 index e6fa81d8..00000000 --- a/cmake/Modules/FindFontconfig.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# - 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, -# -# 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) From 6355d9ac7eaa1e455a027543827d49fc47ae912e Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Tue, 2 Oct 2018 18:50:49 +0200 Subject: [PATCH 39/39] Fontconfig scripts from https://github.com/cnjinhao/nana/pull/278 --- build/cmake/Modules/FindFontconfig.cmake | 69 ++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 build/cmake/Modules/FindFontconfig.cmake diff --git a/build/cmake/Modules/FindFontconfig.cmake b/build/cmake/Modules/FindFontconfig.cmake new file mode 100644 index 00000000..e6fa81d8 --- /dev/null +++ b/build/cmake/Modules/FindFontconfig.cmake @@ -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, +# +# 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)