2019-11-17 10:04:41 +00:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2019-12-25 16:55:07 +00:00
|
|
|
project(notcurses VERSION 0.9.3
|
2019-12-02 11:02:03 +00:00
|
|
|
DESCRIPTION "UI for modern terminal emulators"
|
2019-11-17 10:04:41 +00:00
|
|
|
HOMEPAGE_URL "https://nick-black.com/dankwiki/index.php/notcurses"
|
|
|
|
LANGUAGES C CXX)
|
2019-12-03 18:31:04 +00:00
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
2019-11-17 10:04:41 +00:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2019-11-27 06:02:05 +00:00
|
|
|
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
2019-11-25 03:24:41 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
2019-11-27 06:02:05 +00:00
|
|
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
2019-11-17 10:04:41 +00:00
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2019-12-25 07:00:53 +00:00
|
|
|
option(DISABLE_FFMPEG "Disable FFmpeg image/video support" OFF)
|
|
|
|
|
|
|
|
configure_file(tools/version.h.in include/version.h)
|
|
|
|
|
2019-11-17 17:55:12 +00:00
|
|
|
find_package(PkgConfig REQUIRED)
|
2019-12-01 22:48:38 +00:00
|
|
|
find_package(Threads REQUIRED)
|
2019-11-17 17:55:12 +00:00
|
|
|
pkg_check_modules(TERMINFO REQUIRED tinfo>=6.1)
|
2019-12-25 07:00:53 +00:00
|
|
|
if(NOT "${DISABLE_FFMPEG}")
|
2019-11-28 16:15:29 +00:00
|
|
|
pkg_check_modules(AVUTIL REQUIRED libavutil>=56.0)
|
|
|
|
pkg_check_modules(AVFORMAT REQUIRED libavformat>=57.0)
|
|
|
|
pkg_check_modules(SWSCALE REQUIRED libswscale>=5.0)
|
2019-12-25 07:00:53 +00:00
|
|
|
endif()
|
2019-11-23 14:05:32 +00:00
|
|
|
find_library(LIBRT rt)
|
2019-11-17 17:55:12 +00:00
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# libnotcurses
|
2019-11-17 10:04:41 +00:00
|
|
|
file(GLOB LIBSRCS CONFIGURE_DEPENDS src/lib/*.c)
|
|
|
|
add_library(notcurses SHARED ${LIBSRCS})
|
2019-12-25 07:00:53 +00:00
|
|
|
set_target_properties(notcurses PROPERTIES
|
|
|
|
PUBLIC_HEADER "include/notcurses.h"
|
|
|
|
VERSION ${PROJECT_VERSION}
|
|
|
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
|
|
)
|
2019-11-17 10:04:41 +00:00
|
|
|
target_include_directories(notcurses
|
|
|
|
PRIVATE
|
|
|
|
include
|
|
|
|
"${PROJECT_BINARY_DIR}/include"
|
2019-12-27 10:27:51 +00:00
|
|
|
"${TERMINFO_INCLUDE_DIRS}"
|
2019-12-25 07:00:53 +00:00
|
|
|
)
|
|
|
|
target_link_libraries(notcurses
|
|
|
|
PRIVATE
|
|
|
|
"${TERMINFO_LIBRARIES}"
|
|
|
|
"${LIBRT}"
|
|
|
|
)
|
|
|
|
target_link_directories(notcurses
|
|
|
|
PRIVATE
|
|
|
|
"${TERMINFO_LIBRARY_DIRS}"
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT "${DISABLE_FFMPEG}")
|
|
|
|
target_include_directories(notcurses
|
|
|
|
PRIVATE
|
2019-12-27 10:27:51 +00:00
|
|
|
"${AVFORMAT_INCLUDE_DIRS}"
|
|
|
|
"${SWSCALE_INCLUDE_DIRS}"
|
2019-11-17 17:55:12 +00:00
|
|
|
)
|
|
|
|
target_link_libraries(notcurses
|
2019-11-23 14:05:32 +00:00
|
|
|
PRIVATE
|
2019-11-25 03:22:18 +00:00
|
|
|
"${AVFORMAT_LIBRARIES}"
|
2019-11-27 22:22:35 +00:00
|
|
|
"${SWSCALE_LIBRARIES}"
|
2019-11-17 10:04:41 +00:00
|
|
|
)
|
2019-12-01 17:42:18 +00:00
|
|
|
target_link_directories(notcurses
|
|
|
|
PRIVATE
|
|
|
|
"${AVFORMAT_LIBRARY_DIRS}"
|
|
|
|
"${SWSCALE_LIBRARY_DIRS}"
|
|
|
|
)
|
2019-12-25 07:00:53 +00:00
|
|
|
endif()
|
2019-11-17 10:04:41 +00:00
|
|
|
|
|
|
|
target_compile_options(notcurses
|
|
|
|
PRIVATE
|
2019-11-21 11:38:07 +00:00
|
|
|
-Wall -Wextra -W -Wshadow
|
2019-11-17 10:04:41 +00:00
|
|
|
)
|
2019-11-18 03:02:43 +00:00
|
|
|
target_compile_definitions(notcurses
|
2019-11-26 06:42:04 +00:00
|
|
|
PUBLIC
|
2019-12-27 06:41:14 +00:00
|
|
|
_XOPEN_SOURCE # wcwidth(3) requires _XOPEN_SOURCE, and is in our headers
|
2019-12-03 18:26:49 +00:00
|
|
|
PRIVATE
|
|
|
|
FORTIFY_SOURCE=2 _GNU_SOURCE SOURCE_DEFAULT
|
2019-11-18 03:02:43 +00:00
|
|
|
)
|
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# notcurses-demo
|
2019-11-27 20:22:54 +00:00
|
|
|
file(GLOB DEMOSRCS CONFIGURE_DEPENDS src/demo/*.c)
|
|
|
|
add_executable(notcurses-demo ${DEMOSRCS})
|
2019-11-17 10:04:41 +00:00
|
|
|
target_include_directories(notcurses-demo PRIVATE include)
|
|
|
|
target_link_libraries(notcurses-demo
|
|
|
|
PRIVATE
|
|
|
|
notcurses
|
2019-12-01 22:48:38 +00:00
|
|
|
Threads::Threads
|
2019-11-17 10:04:41 +00:00
|
|
|
)
|
2019-11-26 06:42:04 +00:00
|
|
|
target_compile_options(notcurses-demo
|
|
|
|
PRIVATE
|
|
|
|
-Wall -Wextra -W -Wshadow
|
2019-11-17 10:04:41 +00:00
|
|
|
)
|
2019-12-03 18:26:49 +00:00
|
|
|
target_compile_definitions(notcurses-demo
|
|
|
|
PRIVATE
|
2019-12-14 01:25:48 +00:00
|
|
|
FORTIFY_SOURCE=2 _GNU_SOURCE
|
2019-12-03 18:26:49 +00:00
|
|
|
)
|
2019-11-17 10:04:41 +00:00
|
|
|
|
2019-12-12 09:52:59 +00:00
|
|
|
# tiny proofs of concept, one binary per source file
|
2019-12-17 05:33:51 +00:00
|
|
|
file(GLOB POCSRCS CONFIGURE_DEPENDS src/poc/*.c src/poc/*.cpp)
|
2019-12-12 09:52:59 +00:00
|
|
|
foreach(f ${POCSRCS})
|
|
|
|
get_filename_component(fe "${f}" NAME_WE)
|
|
|
|
add_executable(${fe} ${f})
|
|
|
|
target_include_directories(${fe}
|
2019-12-27 10:27:51 +00:00
|
|
|
PRIVATE include "${TERMINFO_INCLUDE_DIRS}"
|
2019-12-12 09:52:59 +00:00
|
|
|
)
|
|
|
|
target_link_libraries(${fe}
|
2019-12-12 12:59:48 +00:00
|
|
|
PRIVATE notcurses "${TERMINFO_LIBRARIES}"
|
2019-12-12 09:52:59 +00:00
|
|
|
)
|
|
|
|
target_link_directories(${fe}
|
|
|
|
PRIVATE "${TERMINFO_LIBRARY_DIRS}"
|
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# Documentation
|
|
|
|
file(GLOB MANSOURCE3 CONFIGURE_DEPENDS doc/man/man3/*.ronn)
|
|
|
|
FIND_PROGRAM(RONN ronn)
|
|
|
|
iF(NOT RONN)
|
|
|
|
message(WARNING "ronn not found, won't regenerate man pages")
|
|
|
|
else()
|
2019-12-27 13:01:15 +00:00
|
|
|
foreach(m ${MANSOURCE3})
|
|
|
|
get_filename_component(me ${m} NAME_WLE)
|
2019-12-27 12:36:42 +00:00
|
|
|
add_custom_command(
|
2019-12-27 13:01:15 +00:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${me}
|
2019-12-27 12:36:42 +00:00
|
|
|
DEPENDS ${m}
|
|
|
|
COMMAND ${RONN}
|
2019-12-27 13:01:15 +00:00
|
|
|
ARGS -r --pipe ${m} > ${CMAKE_CURRENT_BINARY_DIR}/${me}
|
|
|
|
COMMENT "Building man page ${me}"
|
2019-12-27 12:36:42 +00:00
|
|
|
)
|
|
|
|
add_custom_target(docs
|
|
|
|
ALL
|
2019-12-27 13:01:15 +00:00
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${me}
|
2019-12-27 12:36:42 +00:00
|
|
|
)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# notcurses-input
|
2019-11-29 05:20:30 +00:00
|
|
|
file(GLOB INPUTSRCS CONFIGURE_DEPENDS src/input/*.cpp)
|
|
|
|
add_executable(notcurses-input ${INPUTSRCS})
|
|
|
|
target_include_directories(notcurses-input
|
|
|
|
PRIVATE
|
|
|
|
include
|
|
|
|
"${PROJECT_BINARY_DIR}/include"
|
|
|
|
)
|
|
|
|
target_link_libraries(notcurses-input
|
|
|
|
PRIVATE
|
|
|
|
notcurses
|
|
|
|
)
|
|
|
|
target_compile_options(notcurses-input
|
|
|
|
PRIVATE
|
|
|
|
-Wall -Wextra -W -Wshadow
|
|
|
|
)
|
2019-12-03 18:26:49 +00:00
|
|
|
target_compile_definitions(notcurses-input
|
|
|
|
PRIVATE
|
|
|
|
FORTIFY_SOURCE=2
|
|
|
|
)
|
2019-11-29 05:20:30 +00:00
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# notcurses-planereel
|
2019-12-21 01:38:13 +00:00
|
|
|
file(GLOB PLANEREELSRCS CONFIGURE_DEPENDS src/planereel/*.cpp)
|
|
|
|
add_executable(notcurses-planereel ${PLANEREELSRCS})
|
|
|
|
target_include_directories(notcurses-planereel
|
|
|
|
PRIVATE
|
|
|
|
include
|
|
|
|
"${PROJECT_BINARY_DIR}/include"
|
|
|
|
)
|
|
|
|
target_link_libraries(notcurses-planereel
|
|
|
|
PRIVATE
|
|
|
|
notcurses
|
|
|
|
)
|
|
|
|
target_compile_options(notcurses-planereel
|
|
|
|
PRIVATE
|
|
|
|
-Wall -Wextra -W -Wshadow
|
|
|
|
)
|
|
|
|
target_compile_definitions(notcurses-planereel
|
|
|
|
PRIVATE
|
|
|
|
FORTIFY_SOURCE=2
|
|
|
|
)
|
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# notcurses-view
|
2019-11-27 20:22:54 +00:00
|
|
|
file(GLOB VIEWSRCS CONFIGURE_DEPENDS src/view/*.cpp)
|
2019-12-25 07:00:53 +00:00
|
|
|
if(NOT "${DISABLE_FFMPEG}")
|
2019-11-27 20:22:54 +00:00
|
|
|
add_executable(notcurses-view ${VIEWSRCS})
|
2019-11-27 21:22:50 +00:00
|
|
|
target_include_directories(notcurses-view
|
|
|
|
PRIVATE
|
|
|
|
include
|
|
|
|
"${PROJECT_BINARY_DIR}/include"
|
2019-12-27 10:27:51 +00:00
|
|
|
"${AVUTIL_INCLUDE_DIRS}"
|
2019-11-27 21:22:50 +00:00
|
|
|
)
|
|
|
|
target_link_directories(notcurses-view
|
|
|
|
PRIVATE
|
|
|
|
"${AVUTIL_LIBRARY_DIRS}"
|
|
|
|
)
|
2019-11-27 20:22:54 +00:00
|
|
|
target_link_libraries(notcurses-view
|
|
|
|
PRIVATE
|
|
|
|
notcurses
|
2019-11-27 21:22:50 +00:00
|
|
|
PRIVATE
|
|
|
|
"${AVUTIL_LIBRARIES}"
|
2019-12-25 07:00:53 +00:00
|
|
|
"${AVFORMAT_LIBRARIES}"
|
|
|
|
"${SWSCALE_LIBRARIES}"
|
2019-11-27 20:22:54 +00:00
|
|
|
)
|
|
|
|
target_compile_options(notcurses-view
|
|
|
|
PRIVATE
|
|
|
|
-Wall -Wextra -W -Wshadow
|
|
|
|
)
|
2019-12-03 18:26:49 +00:00
|
|
|
target_compile_definitions(notcurses-view
|
|
|
|
PRIVATE
|
|
|
|
FORTIFY_SOURCE=2
|
|
|
|
)
|
2019-12-27 06:29:45 +00:00
|
|
|
endif()
|
2019-11-27 20:22:54 +00:00
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# Testing
|
2019-11-17 10:04:41 +00:00
|
|
|
file(GLOB TESTSRCS CONFIGURE_DEPENDS tests/*.cpp)
|
|
|
|
add_executable(notcurses-tester ${TESTSRCS})
|
|
|
|
find_package(GTest 1.9 REQUIRED)
|
2019-11-24 17:36:46 +00:00
|
|
|
target_include_directories(notcurses-tester
|
|
|
|
PRIVATE
|
|
|
|
include
|
2019-12-25 07:00:53 +00:00
|
|
|
"${PROJECT_BINARY_DIR}/include"
|
2019-11-24 17:36:46 +00:00
|
|
|
src/lib
|
|
|
|
)
|
2019-11-17 10:04:41 +00:00
|
|
|
target_link_libraries(notcurses-tester
|
|
|
|
GTest::GTest
|
|
|
|
notcurses
|
|
|
|
)
|
|
|
|
target_compile_options(notcurses-tester PRIVATE
|
2019-11-21 11:38:07 +00:00
|
|
|
-Wall -Wextra -W -Wshadow
|
2019-11-17 10:04:41 +00:00
|
|
|
)
|
2019-12-03 18:26:49 +00:00
|
|
|
target_compile_definitions(notcurses-tester
|
|
|
|
PRIVATE
|
|
|
|
FORTIFY_SOURCE=2
|
|
|
|
)
|
2019-11-17 10:04:41 +00:00
|
|
|
|
|
|
|
gtest_discover_tests(notcurses-tester)
|
|
|
|
enable_testing()
|
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# pkg-config support
|
2019-11-17 10:04:41 +00:00
|
|
|
configure_file(tools/notcurses.pc.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/notcurses.pc
|
|
|
|
@ONLY
|
|
|
|
)
|
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# CMake support
|
2019-11-17 10:04:41 +00:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
configure_package_config_file(tools/notcursesConfig.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/notcursesConfig.cmake
|
|
|
|
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/notcurses/cmake
|
|
|
|
)
|
|
|
|
|
|
|
|
write_basic_package_version_file(
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/notcursesConfigVersion.cmake
|
|
|
|
COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
|
2019-12-27 12:36:42 +00:00
|
|
|
# Installation
|
2019-11-17 10:04:41 +00:00
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/notcursesConfig.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/notcursesConfigVersion.cmake
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/notcurses
|
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/notcurses.pc
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
|
|
|
)
|
|
|
|
|
2019-12-24 00:16:49 +00:00
|
|
|
file(GLOB TESTDATA CONFIGURE_DEPENDS data/*)
|
2019-12-01 20:27:17 +00:00
|
|
|
install(FILES
|
|
|
|
${TESTDATA}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/notcurses
|
|
|
|
)
|
|
|
|
|
2019-12-27 13:01:15 +00:00
|
|
|
file(GLOB MANPAGES1 CONFIGURE_DEPENDS doc/man/man1/*.1)
|
|
|
|
# FIXME -- these won't exist until we've run through once, ack
|
2019-12-27 12:36:42 +00:00
|
|
|
file(GLOB MANPAGES3 CONFIGURE_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/*.3notcurses)
|
2019-12-05 15:12:47 +00:00
|
|
|
install(FILES
|
|
|
|
${MANPAGES1}
|
2019-12-18 11:49:30 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man1
|
2019-12-05 15:12:47 +00:00
|
|
|
)
|
2019-12-12 12:38:04 +00:00
|
|
|
install(FILES
|
|
|
|
${MANPAGES3}
|
2019-12-18 11:49:30 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man3
|
2019-12-12 12:38:04 +00:00
|
|
|
)
|
2019-12-05 15:12:47 +00:00
|
|
|
|
2019-11-17 10:04:41 +00:00
|
|
|
install(TARGETS notcurses-demo DESTINATION bin)
|
2019-12-25 07:00:53 +00:00
|
|
|
if(NOT "${DISABLE_FFMPEG}")
|
2019-11-27 20:22:54 +00:00
|
|
|
install(TARGETS notcurses-view DESTINATION bin)
|
2019-12-25 07:00:53 +00:00
|
|
|
endif()
|
2019-11-29 05:20:30 +00:00
|
|
|
install(TARGETS notcurses-input DESTINATION bin)
|
2019-12-21 01:38:13 +00:00
|
|
|
install(TARGETS notcurses-planereel DESTINATION bin)
|
2019-11-17 10:04:41 +00:00
|
|
|
install(TARGETS notcurses
|
|
|
|
LIBRARY
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
COMPONENT Libraries
|
|
|
|
NAMELINK_COMPONENT Development
|
|
|
|
PUBLIC_HEADER
|
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
COMPONENT Development
|
|
|
|
)
|