Merge remote-tracking branch 'KingDuckZ/develop' into merge-KingDuckZ
# Conflicts: # CMakeLists.txt
This commit is contained in:
commit
dc666a893f
@ -1,8 +1,10 @@
|
||||
# CMake configuration for Nana
|
||||
# Author: Andrew Kornilov(https://github.com/ierofant)
|
||||
# Contributors:
|
||||
# Andrew Kornilov (ierofant) - original version
|
||||
# Jinhao
|
||||
# Ariel Vina-Rodriguez (qPCR4vir)
|
||||
# (King_DuckZ)
|
||||
# Robert Hauck - Enable support for PNG/Freetype
|
||||
# Pavel O. - fix compilation with boost::filesystem (#281)
|
||||
# Frostbane - Add option for compiling a shared library (#263,#265)
|
||||
@ -18,12 +20,8 @@
|
||||
# https://cliutils.gitlab.io/modern-cmake/
|
||||
# https://cmake.org/cmake-tutorial/
|
||||
# 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)
|
||||
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
|
||||
project(nana VERSION 1.6.2
|
||||
DESCRIPTION "C++ GUI library"
|
||||
HOMEPAGE_URL http://nanapro.org
|
||||
@ -154,6 +152,7 @@ endif()
|
||||
|
||||
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)
|
||||
@ -188,20 +187,35 @@ endif()
|
||||
if(APPLE)
|
||||
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)
|
||||
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)
|
||||
target_compile_options(nana PUBLIC -lX11)
|
||||
include(FindFreetype)
|
||||
if(FREETYPE_FOUND)
|
||||
target_include_directories(nana PUBLIC ${FREETYPE_INCLUDE_DIRS})
|
||||
target_compile_options(nana PUBLIC -lXft -lfontconfig)
|
||||
endif()
|
||||
endif()
|
||||
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
|
||||
@ -224,6 +238,9 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
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++)
|
||||
@ -235,6 +252,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
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)
|
||||
|
||||
@ -257,9 +275,22 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
target_compile_options(nana PRIVATE -fmax-errors=3)
|
||||
endif()
|
||||
|
||||
set(CMAKE_DEBUG_POSTFIX "_d")
|
||||
|
||||
|
||||
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:
|
||||
include(CMakePrintHelpers)
|
||||
|
||||
|
||||
69
cmake/Modules/FindFontconfig.cmake
Normal file
69
cmake/Modules/FindFontconfig.cmake
Normal file
@ -0,0 +1,69 @@
|
||||
# - Try to find the Fontconfig
|
||||
# Once done this will define
|
||||
#
|
||||
# FONTCONFIG_FOUND - system has Fontconfig
|
||||
# FONTCONFIG_INCLUDE_DIR - The include directory to use for the fontconfig headers
|
||||
# FONTCONFIG_LIBRARIES - Link these to use FONTCONFIG
|
||||
# FONTCONFIG_DEFINITIONS - Compiler switches required for using FONTCONFIG
|
||||
|
||||
# Copyright (c) 2006,2007 Laurent Montel, <montel@kde.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. The name of the author may not be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
if (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
|
||||
|
||||
# in cache already
|
||||
set(FONTCONFIG_FOUND TRUE)
|
||||
|
||||
else (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
|
||||
|
||||
if (NOT WIN32)
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(PC_FONTCONFIG fontconfig)
|
||||
|
||||
set(FONTCONFIG_DEFINITIONS ${PC_FONTCONFIG_CFLAGS_OTHER})
|
||||
endif (NOT WIN32)
|
||||
|
||||
find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h
|
||||
PATHS
|
||||
${PC_FONTCONFIG_INCLUDEDIR}
|
||||
${PC_FONTCONFIG_INCLUDE_DIRS}
|
||||
/usr/X11/include
|
||||
)
|
||||
|
||||
find_library(FONTCONFIG_LIBRARIES NAMES fontconfig
|
||||
PATHS
|
||||
${PC_FONTCONFIG_LIBDIR}
|
||||
${PC_FONTCONFIG_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Fontconfig DEFAULT_MSG FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR )
|
||||
|
||||
mark_as_advanced(FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR)
|
||||
|
||||
endif (FONTCONFIG_LIBRARIES AND FONTCONFIG_INCLUDE_DIR)
|
||||
Loading…
x
Reference in New Issue
Block a user