Commit 4c870ec4 authored by Ghislain MARY's avatar Ghislain MARY

Build a single library, allow building both the static and shared library and...

Build a single library, allow building both the static and shared library and set correct install directories.
parent 4195cbdf
......@@ -27,6 +27,8 @@ project(matroska2
LANGUAGES C
)
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
option(CONFIG_EBML_WRITING "Enable EBML file writing support" ON)
option(CONFIG_EBML_UNICODE "Enable Unicode support" ON)
option(CONFIG_DEBUGCHECKS "Enable internal checks" ON)
......@@ -34,6 +36,8 @@ option(CONFIG_STDIO "Use stdio.h for writing" ON)
option(CONFIG_FILEPOS_64 "Encode filepos_t on 64bits" ON)
option(CONFIG_DEBUG_LEAKS "Enable internal menory leaks checking support" OFF)
include(GNUInstallDirs)
configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
include_directories(
......@@ -52,7 +56,7 @@ add_subdirectory(libebml2)
add_subdirectory(libmatroska2)
install(FILES ${CMAKE_BINARY_DIR}/config.h
DESTINATION include/corec
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec
)
include(CMakePackageConfigHelpers)
......@@ -62,13 +66,22 @@ write_basic_package_version_file(
COMPATIBILITY AnyNewerVersion
)
export(EXPORT Matroska2Targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/Matroska2Targets.cmake"
)
configure_file(Matroska2Config.cmake.in
${CMAKE_BINARY_DIR}/Matroska2Config.cmake
@ONLY
)
set(CONFIG_PACKAGE_LOCATION "share/${PROJECT_NAME}/cmake")
install(EXPORT Matroska2Targets
FILE Matroska2Targets.cmake
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
install(FILES
${CMAKE_BINARY_DIR}/Matroska2ConfigVersion.cmake
${CMAKE_BINARY_DIR}/Matroska2Config.cmake
DESTINATION lib/cmake/Matroska2
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
......@@ -26,18 +26,16 @@
# MATROSKA2_FOUND - system has Matroska2
# MATROSKA2_INCLUDE_DIRS - the Matroska2 include directory
# MATROSKA2_LIBRARIES - The libraries needed to use Matroska2
# MATROSKA2_CPPFLAGS - The cflags needed to use Matroska2
include("${CMAKE_CURRENT_LIST_DIR}/Matroska2Targets.cmake")
get_filename_component(MATROSKA2_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
set(MATROSKA2_INCLUDE_DIRS
${MATROSKA2_CMAKE_DIR}/../../../include
${MATROSKA2_CMAKE_DIR}/../../../${CMAKE_INSTALL_INCLUDEDIR}
)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(MATROSKA2_LIBRARIES ${MATROSKA2_CMAKE_DIR}/../../matroska2.lib ${MATROSKA2_CMAKE_DIR}/../../ebml2.lib ${MATROSKA2_CMAKE_DIR}/../../corec.lib)
if(@ENABLE_SHARED@)
set(MATROSKA2_LIBRARIES matroska2)
else()
set(MATROSKA2_LIBRARIES ${MATROSKA2_CMAKE_DIR}/../../libmatroska2.a ${MATROSKA2_CMAKE_DIR}/../../libebml2.a ${MATROSKA2_CMAKE_DIR}/../../libcorec.a)
set(MATROSKA2_LIBRARIES matroska2-static)
endif()
set(MATROSKA2_CPPFLAGS)
set(MATROSKA2_FOUND 1)
......@@ -80,11 +80,7 @@ if(CONFIG_STDIO)
)
endif()
add_library(corec STATIC ${COREC_SOURCES})
install(TARGETS corec
ARCHIVE DESTINATION lib
)
add_library(corec-objects OBJECT ${COREC_SOURCES})
install(FILES
banned.h
......@@ -95,19 +91,20 @@ install(FILES
memalloc.h
memheap.h
portab.h
DESTINATION include/corec
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec
)
install(FILES array/array.h DESTINATION include/corec/array)
install(FILES helpers/charconvert/charconvert.h DESTINATION include/corec/helpers/charconvert)
install(FILES helpers/date/date.h DESTINATION include/corec/helpers/date)
install(FILES array/array.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/array)
install(FILES helpers/charconvert/charconvert.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/helpers/charconvert)
install(FILES helpers/date/date.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/helpers/date)
install(FILES
helpers/file/file.h
helpers/file/streams.h
DESTINATION include/corec/helpers/file
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/helpers/file
)
install(FILES helpers/md5/md5.h DESTINATION include/corec/helpers/md5)
install(FILES helpers/parser/buffer.h
install(FILES helpers/md5/md5.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/helpers/md5)
install(FILES
helpers/parser/buffer.h
helpers/parser/dataheap.h
helpers/parser/hotkey.h
helpers/parser/nodelookup.h
......@@ -115,15 +112,16 @@ install(FILES helpers/parser/buffer.h
helpers/parser/strtab.h
helpers/parser/strtypes.h
helpers/parser/urlpart.h
DESTINATION include/corec/helpers/parser
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/helpers/parser
)
install(FILES helpers/system/ccsystem.h DESTINATION include/corec/helpers/system)
install(FILES multithread/multithread.h DESTINATION include/corec/multithread)
install(FILES node/node.h
install(FILES helpers/system/ccsystem.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/helpers/system)
install(FILES multithread/multithread.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/multithread)
install(FILES
node/node.h
node/node_internal.h
node/nodebase.h
node/nodetools.h
node/nodetree.h
DESTINATION include/corec/node
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/node
)
install(FILES str/str.h DESTINATION include/corec/str)
install(FILES str/str.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec/str)
......@@ -20,7 +20,7 @@
#
############################################################################
add_library(ebml2 STATIC
add_library(ebml2-objects OBJECT
ebmlmain.c
ebmlelement.c
ebmlmaster.c
......@@ -32,10 +32,6 @@ add_library(ebml2 STATIC
ebmlvoid.c
)
install(TARGETS ebml2
ARCHIVE DESTINATION lib
)
install(DIRECTORY ebml
DESTINATION include
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
......@@ -20,21 +20,40 @@
#
############################################################################
add_library(matroska2 STATIC
add_library(matroska2-objects OBJECT
matroskamain.c
matroskablock.c
matroska_sem.c
)
target_include_directories(matroska2-objects PRIVATE ../libebml2 .)
target_include_directories(matroska2
PUBLIC ${CMAKE_SOURCE_DIR}/libebml2
PUBLIC ${CMAKE_SOURCE_DIR}/libmatroska2
)
if(ENABLE_STATIC)
add_library(matroska2-static STATIC $<TARGET_OBJECTS:corec-objects> $<TARGET_OBJECTS:ebml2-objects> $<TARGET_OBJECTS:matroska2-objects>)
set_target_properties(matroska2-static PROPERTIES OUTPUT_NAME matroska2)
install(TARGETS matroska2-static EXPORT Matroska2Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
if(ENABLE_SHARED)
add_library(matroska2 SHARED $<TARGET_OBJECTS:corec-objects> $<TARGET_OBJECTS:ebml2-objects> $<TARGET_OBJECTS:matroska2-objects>)
set_target_properties(matroska2 PROPERTIES VERSION 0.0.0 SOVERSION 0)
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/matroska2.pdb
DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif()
install(TARGETS matroska2 EXPORT Matroska2Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
install(DIRECTORY matroska
DESTINATION include
)
install(TARGETS matroska2
ARCHIVE DESTINATION lib
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment