VirtualBox

source: vbox/trunk/src/libs/libogg-1.3.5/CMakeLists.txt

Last change on this file was 96360, checked in by vboxsync, 2 years ago

libogg, libvorbis: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1cmake_minimum_required(VERSION 2.8.12)
2project(libogg)
3
4# Required modules
5include(GNUInstallDirs)
6include(CheckIncludeFiles)
7include(CMakePackageConfigHelpers)
8include(CTest)
9
10# Build options
11option(BUILD_SHARED_LIBS "Build shared library" OFF)
12if(APPLE)
13 option(BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF)
14endif()
15
16# Install options
17option(INSTALL_DOCS "Install documentation" ON)
18option(INSTALL_PKG_CONFIG_MODULE "Install ogg.pc file" ON)
19option(INSTALL_CMAKE_PACKAGE_MODULE "Install CMake package configuration module" ON)
20
21# Extract project version from configure.ac
22file(READ configure.ac CONFIGURE_AC_CONTENTS)
23string(REGEX MATCH "AC_INIT\\(\\[libogg\\],\\[([0-9]*).([0-9]*).([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS})
24set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})
25set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_2})
26set(PROJECT_VERSION_PATCH ${CMAKE_MATCH_3})
27set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
28
29# Extract library version from configure.ac
30string(REGEX MATCH "LIB_CURRENT=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS})
31set(LIB_CURRENT ${CMAKE_MATCH_1})
32
33string(REGEX MATCH "LIB_AGE=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS})
34set(LIB_AGE ${CMAKE_MATCH_1})
35
36string(REGEX MATCH "LIB_REVISION=([0-9]*)" DUMMY ${CONFIGURE_AC_CONTENTS})
37set(LIB_REVISION ${CMAKE_MATCH_1})
38
39math(EXPR LIB_SOVERSION "${LIB_CURRENT} - ${LIB_AGE}")
40set(LIB_VERSION "${LIB_SOVERSION}.${LIB_AGE}.${LIB_REVISION}")
41
42
43# Helper function to configure pkg-config files
44function(configure_pkg_config_file pkg_config_file_in)
45 set(prefix ${CMAKE_INSTALL_PREFIX})
46 set(exec_prefix ${CMAKE_INSTALL_FULL_BINDIR})
47 set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
48 set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
49 set(VERSION ${PROJECT_VERSION})
50 string(REPLACE ".in" "" pkg_config_file ${pkg_config_file_in})
51 configure_file(${pkg_config_file_in} ${pkg_config_file} @ONLY)
52endfunction()
53
54message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
55
56# Configure config_type.h
57check_include_files(inttypes.h INCLUDE_INTTYPES_H)
58check_include_files(stdint.h INCLUDE_STDINT_H)
59check_include_files(sys/types.h INCLUDE_SYS_TYPES_H)
60
61list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
62set(SIZE16 int16_t)
63set(USIZE16 uint16_t)
64set(SIZE32 int32_t)
65set(USIZE32 uint32_t)
66set(SIZE64 int64_t)
67set(USIZE64 uint64_t)
68
69include(CheckSizes)
70
71configure_file(include/ogg/config_types.h.in include/ogg/config_types.h @ONLY)
72
73set(OGG_HEADERS
74 ${CMAKE_CURRENT_BINARY_DIR}/include/ogg/config_types.h
75 include/ogg/ogg.h
76 include/ogg/os_types.h
77)
78
79set(OGG_SOURCES
80 src/bitwise.c
81 src/framing.c
82 src/crctable.h
83)
84
85if(WIN32 AND BUILD_SHARED_LIBS)
86 list(APPEND OGG_SOURCES win32/ogg.def)
87endif()
88
89if(BUILD_FRAMEWORK)
90 set(BUILD_SHARED_LIBS TRUE)
91endif()
92
93add_library(ogg ${OGG_HEADERS} ${OGG_SOURCES})
94add_library(Ogg::ogg ALIAS ogg)
95target_include_directories(ogg PUBLIC
96 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
97 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
98 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
99)
100
101set_target_properties(
102 ogg PROPERTIES
103 SOVERSION ${LIB_SOVERSION}
104 VERSION ${LIB_VERSION}
105 PUBLIC_HEADER "${OGG_HEADERS}"
106)
107
108if(BUILD_FRAMEWORK)
109 set_target_properties(ogg PROPERTIES
110 FRAMEWORK TRUE
111 FRAMEWORK_VERSION ${PROJECT_VERSION}
112 MACOSX_FRAMEWORK_IDENTIFIER org.xiph.ogg
113 MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION}
114 MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
115 XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
116 OUTPUT_NAME Ogg
117 )
118endif()
119
120configure_pkg_config_file(ogg.pc.in)
121
122install(TARGETS ogg
123 EXPORT OggTargets
124 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
125 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
126 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
127 FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
128 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ogg
129)
130
131export(EXPORT OggTargets NAMESPACE Ogg:: FILE OggTargets.cmake)
132
133if(INSTALL_CMAKE_PACKAGE_MODULE)
134 set(CMAKE_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Ogg)
135 install(EXPORT OggTargets
136 DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
137 NAMESPACE Ogg::
138 )
139
140 include(CMakePackageConfigHelpers)
141
142 configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/OggConfig.cmake.in ${PROJECT_BINARY_DIR}/OggConfig.cmake
143 INSTALL_DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
144 PATH_VARS CMAKE_INSTALL_FULL_INCLUDEDIR
145 )
146
147 write_basic_package_version_file(${PROJECT_BINARY_DIR}/OggConfigVersion.cmake
148 VERSION ${PROJECT_VERSION}
149 COMPATIBILITY SameMajorVersion
150 )
151
152 install(FILES ${PROJECT_BINARY_DIR}/OggConfig.cmake ${PROJECT_BINARY_DIR}/OggConfigVersion.cmake
153 DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
154 )
155endif()
156
157if(INSTALL_PKG_CONFIG_MODULE)
158 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ogg.pc
159 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
160 )
161endif()
162
163if(INSTALL_DOCS)
164 set(OGG_DOCS
165 doc/framing.html
166 doc/index.html
167 doc/oggstream.html
168 doc/ogg-multiplex.html
169 doc/fish_xiph_org.png
170 doc/multiplex1.png
171 doc/packets.png
172 doc/pages.png
173 doc/stream.png
174 doc/vorbisword2.png
175 doc/white-ogg.png
176 doc/white-xifish.png
177 doc/rfc3533.txt
178 doc/rfc5334.txt
179 doc/skeleton.html
180 )
181 install(FILES ${OGG_DOCS} DESTINATION ${CMAKE_INSTALL_DOCDIR}/html)
182 install(DIRECTORY doc/libogg DESTINATION ${CMAKE_INSTALL_DOCDIR}/html)
183endif()
184
185if(BUILD_TESTING)
186 add_executable(test_bitwise src/bitwise.c ${OGG_HEADERS})
187 target_compile_definitions(test_bitwise PRIVATE _V_SELFTEST)
188 target_include_directories(test_bitwise PRIVATE
189 include
190 ${CMAKE_CURRENT_BINARY_DIR}/include
191 )
192 add_test(NAME test_bitwise COMMAND $<TARGET_FILE:test_bitwise>)
193
194 add_executable(test_framing src/framing.c ${OGG_HEADERS})
195 target_compile_definitions(test_framing PRIVATE _V_SELFTEST)
196 target_include_directories(test_framing PRIVATE
197 include
198 ${CMAKE_CURRENT_BINARY_DIR}/include
199 )
200 add_test(NAME test_framing COMMAND $<TARGET_FILE:test_framing>)
201endif()
202
203set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
204include(CPack)
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette