-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nana] Fix linux builds; install cmake targets
- Loading branch information
1 parent
cd8813f
commit ee3183c
Showing
6 changed files
with
134 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../lib/libpng16.a") | ||
set(PNG_LIBRARY_RELEASE "${CMAKE_CURRENT_LIST_DIR}/../../lib/libpng16.a" CACHE FILEPATH "") | ||
endif() | ||
_find_package(${ARGS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) | ||
project(nana VERSION 1.5.5 LANGUAGES CXX) | ||
|
||
option(NANA_ENABLE_PNG "Enable PNG support" OFF) | ||
option(NANA_ENABLE_JPEG "Enable JPEG support" OFF) | ||
option(NANA_INSTALL_HEADERS "Install headers" ON) | ||
|
||
if(APPLE) | ||
add_definitions(-DAPPLE) | ||
elseif(UNIX) | ||
add_definitions(-Dlinux) | ||
endif() | ||
|
||
file(GLOB_RECURSE headers include/*.hpp) | ||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include PREFIX "include" FILES ${headers}) | ||
|
||
file(GLOB sources source/*.hpp source/*.cpp) | ||
foreach(subdir detail filesystem gui paint system threads) | ||
file(GLOB_RECURSE sources_subdir source/${subdir}/*.hpp source/${subdir}/*.cpp) | ||
list(APPEND sources ${sources_subdir}) | ||
endforeach() | ||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/source PREFIX "source" FILES ${sources}) | ||
|
||
add_library(nana ${headers} ${sources}) | ||
target_include_directories(nana PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
|
||
target_compile_features(nana PUBLIC cxx_std_14) | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
target_link_libraries(nana PUBLIC c++experimental) | ||
endif() | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES "GCC") | ||
target_link_libraries(nana PUBLIC stdc++fs) | ||
endif() | ||
|
||
if(UNIX) | ||
find_package(Threads REQUIRED) | ||
target_link_libraries(nana PUBLIC Threads::Threads) | ||
|
||
find_package(Freetype REQUIRED) | ||
target_link_libraries(nana PUBLIC Freetype::Freetype) | ||
|
||
find_package(X11 REQUIRED) | ||
target_include_directories(nana PUBLIC ${X11_INCLUDE_DIR}) | ||
target_link_libraries(nana PUBLIC ${X11_LIBRARIES} ${X11_Xft_LIB}) | ||
|
||
find_library(FONTCONFIG_LIB NAMES fontconfig) | ||
target_link_libraries(nana PUBLIC ${FONTCONFIG_LIB}) | ||
endif() | ||
|
||
if(NANA_ENABLE_PNG) | ||
find_package(PNG REQUIRED) | ||
target_link_libraries(nana PUBLIC PNG::PNG) | ||
target_compile_definitions(nana PUBLIC NANA_ENABLE_PNG=1 USE_LIBPNG_FROM_OS=1) | ||
endif() | ||
|
||
if(NANA_ENABLE_JPEG) | ||
find_package(JPEG REQUIRED) | ||
target_include_directories(nana PUBLIC ${JPEG_INCLUDE_DIR}) | ||
target_link_libraries(nana PUBLIC $<BUILD_INTERFACE:${JPEG_LIBRARIES}>) | ||
target_compile_definitions(nana PUBLIC NANA_ENABLE_JPEG=1 USE_LIBJPEG_FROM_OS=1) | ||
endif() | ||
|
||
install(TARGETS nana EXPORT nana | ||
RUNTIME DESTINATION bin | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib) | ||
|
||
if(NANA_INSTALL_HEADERS) | ||
install(DIRECTORY include/nana DESTINATION include) | ||
endif() | ||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
configure_package_config_file(config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/unofficial-nana-config.cmake | ||
INSTALL_DESTINATION share/unofficial-nana) | ||
|
||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/unofficial-nana-config-version.cmake | ||
VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-nana-config.cmake DESTINATION share/unofficial-nana) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unofficial-nana-config-version.cmake DESTINATION share/unofficial-nana) | ||
install(EXPORT nana FILE unofficial-nana-targets.cmake NAMESPACE unofficial::nana:: DESTINATION share/unofficial-nana) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Source: nana | ||
Version: 1.5.5 | ||
Description: Cross-platform library for GUI programming in modern C++ style. | ||
Build-Depends: libpng, libjpeg-turbo | ||
Build-Depends: libpng, libjpeg-turbo, freetype (!uwp&&!windows), fontconfig (!uwp&&!windows) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@PACKAGE_INIT@ | ||
|
||
if(UNIX) | ||
find_package(Threads REQUIRED) | ||
find_package(Freetype REQUIRED) | ||
find_package(X11 REQUIRED) | ||
find_library(FONTCONFIG_LIB NAMES fontconfig) | ||
endif() | ||
|
||
if(@NANA_ENABLE_PNG@) | ||
find_package(PNG REQUIRED) | ||
endif() | ||
|
||
if(@NANA_ENABLE_JPEG@) | ||
find_package(JPEG REQUIRED) | ||
endif() | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-nana-targets.cmake") | ||
|
||
if(UNIX) | ||
target_link_libraries(unofficial::nana::nana INTERFACE ${FONTCONFIG_LIB} ${X11_LIBRARIES} ${X11_Xft_LIB}) | ||
endif() | ||
|
||
if(@NANA_ENABLE_JPEG@) | ||
target_link_libraries(unofficial::nana::nana INTERFACE ${JPEG_LIBRARIES}) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters