mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
CMake: build static library #330
This commit is contained in:
parent
889e29731b
commit
3aa969f2a7
@ -30,26 +30,52 @@ find_library(LIBRT rt)
|
|||||||
# libnotcurses
|
# libnotcurses
|
||||||
file(GLOB NCSRCS CONFIGURE_DEPENDS src/lib/*.c)
|
file(GLOB NCSRCS CONFIGURE_DEPENDS src/lib/*.c)
|
||||||
add_library(notcurses SHARED ${NCSRCS})
|
add_library(notcurses SHARED ${NCSRCS})
|
||||||
|
add_library(notcurses-static STATIC ${NCSRCS})
|
||||||
|
set_target_properties(
|
||||||
|
notcurses-static PROPERTIES
|
||||||
|
OUTPUT_NAME notcurses
|
||||||
|
)
|
||||||
|
|
||||||
set_target_properties(notcurses PROPERTIES
|
set_target_properties(notcurses PROPERTIES
|
||||||
PUBLIC_HEADER "include/notcurses.h"
|
PUBLIC_HEADER "include/notcurses.h"
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION ${PROJECT_VERSION_MAJOR}
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||||
)
|
)
|
||||||
|
set_target_properties(notcurses-static PROPERTIES
|
||||||
|
PUBLIC_HEADER "include/notcurses.h"
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||||
|
)
|
||||||
target_include_directories(notcurses
|
target_include_directories(notcurses
|
||||||
PRIVATE
|
PRIVATE
|
||||||
include
|
include
|
||||||
"${PROJECT_BINARY_DIR}/include"
|
"${PROJECT_BINARY_DIR}/include"
|
||||||
"${TERMINFO_INCLUDE_DIRS}"
|
"${TERMINFO_INCLUDE_DIRS}"
|
||||||
)
|
)
|
||||||
|
target_include_directories(notcurses-static
|
||||||
|
PRIVATE
|
||||||
|
include
|
||||||
|
"${PROJECT_BINARY_DIR}/include"
|
||||||
|
"${TERMINFO_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
target_link_libraries(notcurses
|
target_link_libraries(notcurses
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${TERMINFO_LIBRARIES}"
|
"${TERMINFO_LIBRARIES}"
|
||||||
"${LIBRT}"
|
"${LIBRT}"
|
||||||
)
|
)
|
||||||
|
target_link_libraries(notcurses-static
|
||||||
|
PRIVATE
|
||||||
|
"${TERMINFO_LIBRARIES}"
|
||||||
|
"${LIBRT}"
|
||||||
|
)
|
||||||
target_link_directories(notcurses
|
target_link_directories(notcurses
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${TERMINFO_LIBRARY_DIRS}"
|
"${TERMINFO_LIBRARY_DIRS}"
|
||||||
)
|
)
|
||||||
|
target_link_directories(notcurses-static
|
||||||
|
PRIVATE
|
||||||
|
"${TERMINFO_LIBRARY_DIRS}"
|
||||||
|
)
|
||||||
|
|
||||||
if(NOT "${DISABLE_FFMPEG}")
|
if(NOT "${DISABLE_FFMPEG}")
|
||||||
target_include_directories(notcurses
|
target_include_directories(notcurses
|
||||||
@ -59,12 +85,28 @@ target_include_directories(notcurses
|
|||||||
"${AVUTIL_INCLUDE_DIRS}"
|
"${AVUTIL_INCLUDE_DIRS}"
|
||||||
"${SWSCALE_INCLUDE_DIRS}"
|
"${SWSCALE_INCLUDE_DIRS}"
|
||||||
)
|
)
|
||||||
|
target_include_directories(notcurses-static
|
||||||
|
PUBLIC
|
||||||
|
"${AVCODEC_INCLUDE_DIRS}"
|
||||||
|
"${AVFORMAT_INCLUDE_DIRS}"
|
||||||
|
"${AVUTIL_INCLUDE_DIRS}"
|
||||||
|
"${SWSCALE_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
target_link_libraries(notcurses
|
target_link_libraries(notcurses
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"${AVCODEC_LIBRARIES}"
|
"${AVCODEC_LIBRARIES}"
|
||||||
"${AVFORMAT_LIBRARIES}"
|
"${AVFORMAT_LIBRARIES}"
|
||||||
"${AVUTIL_LIBRARIES}"
|
"${AVUTIL_LIBRARIES}"
|
||||||
"${SWSCALE_LIBRARIES}"
|
"${SWSCALE_LIBRARIES}"
|
||||||
|
Threads::Threads
|
||||||
|
)
|
||||||
|
target_link_libraries(notcurses-static
|
||||||
|
PRIVATE
|
||||||
|
"${AVCODEC_LIBRARIES}"
|
||||||
|
"${AVFORMAT_LIBRARIES}"
|
||||||
|
"${AVUTIL_LIBRARIES}"
|
||||||
|
"${SWSCALE_LIBRARIES}"
|
||||||
|
Threads::Threads
|
||||||
)
|
)
|
||||||
target_link_directories(notcurses
|
target_link_directories(notcurses
|
||||||
PUBLIC
|
PUBLIC
|
||||||
@ -73,6 +115,13 @@ target_link_directories(notcurses
|
|||||||
"${AVUTIL_LIBRARY_DIRS}"
|
"${AVUTIL_LIBRARY_DIRS}"
|
||||||
"${SWSCALE_LIBRARY_DIRS}"
|
"${SWSCALE_LIBRARY_DIRS}"
|
||||||
)
|
)
|
||||||
|
target_link_directories(notcurses-static
|
||||||
|
PUBLIC
|
||||||
|
"${AVCODEC_LIBRARY_DIRS}"
|
||||||
|
"${AVFORMAT_LIBRARY_DIRS}"
|
||||||
|
"${AVUTIL_LIBRARY_DIRS}"
|
||||||
|
"${SWSCALE_LIBRARY_DIRS}"
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||||
@ -85,12 +134,22 @@ target_compile_options(notcurses
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
-Wall -Wextra -W -Wshadow ${DEBUG_OPTIONS}
|
-Wall -Wextra -W -Wshadow ${DEBUG_OPTIONS}
|
||||||
)
|
)
|
||||||
|
target_compile_options(notcurses-static
|
||||||
|
PRIVATE
|
||||||
|
-Wall -Wextra -W -Wshadow ${DEBUG_OPTIONS}
|
||||||
|
)
|
||||||
target_compile_definitions(notcurses
|
target_compile_definitions(notcurses
|
||||||
PUBLIC
|
PUBLIC
|
||||||
_XOPEN_SOURCE # wcwidth(3) requires _XOPEN_SOURCE, and is in our headers
|
_XOPEN_SOURCE # wcwidth(3) requires _XOPEN_SOURCE, and is in our headers
|
||||||
PRIVATE
|
PRIVATE
|
||||||
FORTIFY_SOURCE=2 _GNU_SOURCE SOURCE_DEFAULT
|
FORTIFY_SOURCE=2 _GNU_SOURCE SOURCE_DEFAULT
|
||||||
)
|
)
|
||||||
|
target_compile_definitions(notcurses-static
|
||||||
|
PUBLIC
|
||||||
|
_XOPEN_SOURCE # wcwidth(3) requires _XOPEN_SOURCE, and is in our headers
|
||||||
|
PRIVATE
|
||||||
|
FORTIFY_SOURCE=2 _GNU_SOURCE SOURCE_DEFAULT
|
||||||
|
)
|
||||||
|
|
||||||
# libnotcurses++
|
# libnotcurses++
|
||||||
set(NCPP_SOURCES
|
set(NCPP_SOURCES
|
||||||
@ -465,18 +524,22 @@ if(${BUILD_PYTHON})
|
|||||||
OUTPUT
|
OUTPUT
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/build/pytimestamp"
|
"${CMAKE_CURRENT_BINARY_DIR}/build/pytimestamp"
|
||||||
COMMAND
|
COMMAND
|
||||||
"${Python3_EXECUTABLE}" ${SETUP_PY} build_ext -R${CMAKE_INSTALL_LIBDIR} -L ${CMAKE_CURRENT_BINARY_DIR} -b ${CMAKE_CURRENT_BINARY_DIR}/python &&
|
"${Python3_EXECUTABLE}" ${SETUP_PY} build_ext -L ${CMAKE_CURRENT_BINARY_DIR} -b ${CMAKE_CURRENT_BINARY_DIR}/python -t${CMAKE_CURRENT_BINARY_DIR}/python &&
|
||||||
"${Python3_EXECUTABLE}" ${SETUP_PY} build_py &&
|
"${Python3_EXECUTABLE}" ${SETUP_PY} build_py &&
|
||||||
"${Python3_EXECUTABLE}" ${SETUP_PY} egg_info -b ${CMAKE_CURRENT_BINARY_DIR}/python
|
"${Python3_EXECUTABLE}" ${SETUP_PY} egg_info -b ${CMAKE_CURRENT_BINARY_DIR}/python
|
||||||
DEPENDS
|
DEPENDS
|
||||||
${PYSRC} ${SETUP_PY} ${SETUP_CFG} notcurses
|
${PYSRC} ${SETUP_PY} ${SETUP_CFG} notcurses
|
||||||
COMMENT "Building Python wrappers"
|
COMMENT "Building Python wrappers"
|
||||||
|
WORKING_DIRECTORY
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/python
|
||||||
)
|
)
|
||||||
# build/pytimestamp isn't actually generated, and thus this runs each time.
|
# build/pytimestamp isn't actually generated, and thus this runs each time.
|
||||||
# python does its own dep tracking, so it "works" out like recursive make.
|
# python does its own dep tracking, so it "works" out like recursive make.
|
||||||
add_custom_target(pymod
|
add_custom_target(pymod ALL
|
||||||
ALL
|
DEPENDS
|
||||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/build/pytimestamp"
|
"${CMAKE_CURRENT_BINARY_DIR}/build/pytimestamp"
|
||||||
|
WORKING_DIRECTORY
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/python
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -514,7 +577,7 @@ install(TARGETS notcurses-tester DESTINATION bin)
|
|||||||
if(NOT "${DISABLE_FFMPEG}")
|
if(NOT "${DISABLE_FFMPEG}")
|
||||||
install(TARGETS notcurses-view DESTINATION bin)
|
install(TARGETS notcurses-view DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
install(TARGETS notcurses
|
install(TARGETS notcurses notcurses-static
|
||||||
LIBRARY
|
LIBRARY
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
COMPONENT Libraries
|
COMPONENT Libraries
|
||||||
@ -527,10 +590,12 @@ if(${BUILD_PYTHON})
|
|||||||
# if DFSG_BUILD has been selected, assume we're building debs
|
# if DFSG_BUILD has been selected, assume we're building debs
|
||||||
if("${DFSG_BUILD}")
|
if("${DFSG_BUILD}")
|
||||||
install(
|
install(
|
||||||
CODE
|
CODE "execute_process(
|
||||||
"execute_process(COMMAND ${Python3_EXECUTABLE} ${SETUP_PY} install --root=${CMAKE_SOURCE_DIR}/debian/python3-notcurses --install-layout=deb --prefix=${CMAKE_INSTALL_PREFIX} --skip-build
|
COMMAND
|
||||||
WORKING_DIRECTORY
|
${Python3_EXECUTABLE} ${SETUP_PY} install --root=${CMAKE_SOURCE_DIR}/debian/tmp --install-layout=deb --prefix=/usr --skip-build
|
||||||
../python)"
|
WORKING_DIRECTORY
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/python
|
||||||
|
)"
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
install(
|
install(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user