CMakeLists.txt 3.09 KB
Newer Older
1 2
############################################################################
# CMakeLists.txt
Ronan's avatar
Ronan committed
3
# Copyright (C) 2016-2018  Belledonne Communications, Grenoble France
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 21 22
#
############################################################################

23 24
cmake_minimum_required(VERSION 3.0)

25
project(bcmatroska2
Ghislain MARY's avatar
Ghislain MARY committed
26
	VERSION 0.23
27 28 29
	LANGUAGES C
)

30 31
option(ENABLE_SHARED "Build shared library." YES)
option(ENABLE_STATIC "Build static library." YES)
32 33 34 35 36 37 38
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)
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)

39 40
include(GNUInstallDirs)

Ghislain MARY's avatar
Ghislain MARY committed
41 42 43 44 45
if(NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
	set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
	message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()

46 47
configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h)

48 49 50 51
include_directories(
	${CMAKE_BINARY_DIR}
	corec
)
52

53 54 55 56 57 58 59 60 61
set(LINK_FLAGS )
if(APPLE)
	list(APPEND LINK_FLAGS "-framework Foundation")
	if(IOS)
		list(APPEND LINK_FLAGS "-framework CoreFoundation")
	endif()
endif()
string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}")

62 63 64 65 66 67 68
if(WIN32)
	add_definitions(
		"-DEBML2_EXPORTS"
		"-DMATROSKA2_EXPORTS"
		"-DSTR_EXPORTS"
	)
endif()
69 70
add_compile_options(-w)

71 72 73 74 75
add_subdirectory(corec/corec)
add_subdirectory(libebml2)
add_subdirectory(libmatroska2)

install(FILES ${CMAKE_BINARY_DIR}/config.h
76
	DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/corec
77 78 79 80
)

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
81
	${CMAKE_BINARY_DIR}/BcMatroska2ConfigVersion.cmake
82 83 84 85
	VERSION ${MATROSKA2_VERSION}
	COMPATIBILITY AnyNewerVersion
)

86 87
export(EXPORT BcMatroska2Targets
	FILE "${CMAKE_CURRENT_BINARY_DIR}/BcMatroska2Targets.cmake"
88 89
)

90 91
configure_file(BcMatroska2Config.cmake.in
	${CMAKE_BINARY_DIR}/BcMatroska2Config.cmake
92 93 94
	@ONLY
)

Ghislain MARY's avatar
Ghislain MARY committed
95
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
96 97
install(EXPORT BcMatroska2Targets
	FILE BcMatroska2Targets.cmake
98 99
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
100
install(FILES
101 102
	${CMAKE_BINARY_DIR}/BcMatroska2ConfigVersion.cmake
	${CMAKE_BINARY_DIR}/BcMatroska2Config.cmake
103
	DESTINATION ${CONFIG_PACKAGE_LOCATION}
104
)
105

Ronan's avatar
Ronan committed
106
add_subdirectory(build)