]> git.tdb.fi Git - ext/vorbisfile.git/blob - lib/CMakeLists.txt
Add headers to the library component so dependencies work correctly
[ext/vorbisfile.git] / lib / CMakeLists.txt
1 set(VORBIS_PUBLIC_HEADERS
2     ../include/vorbis/codec.h
3     ../include/vorbis/vorbisenc.h
4     ../include/vorbis/vorbisfile.h
5 )
6
7 set(VORBIS_HEADERS
8     envelope.h
9     lpc.h
10     lsp.h
11     codebook.h
12     misc.h
13     psy.h
14     masking.h
15     os.h
16     mdct.h
17     smallft.h
18     highlevel.h
19     registry.h
20     scales.h
21     window.h
22     lookup.h
23     lookup_data.h
24     codec_internal.h
25     backends.h
26     bitrate.h
27 )
28
29 set(VORBIS_SOURCES
30     mdct.c
31     smallft.c
32     block.c
33     envelope.c
34     window.c
35     lsp.c
36     lpc.c
37     analysis.c
38     synthesis.c
39     psy.c
40     info.c
41     floor1.c
42     floor0.c
43     res0.c
44     mapping0.c
45     registry.c
46     codebook.c
47     sharedbook.c
48     lookup.c
49     bitrate.c
50 )
51
52 set(VORBISFILE_SOURCES
53     vorbisfile.c
54 )
55
56 set(VORBISENC_SOURCES
57     vorbisenc.c
58 )
59
60 if(WIN32)
61     list(APPEND VORBIS_SOURCES vorbisenc.c)
62 endif()
63
64 if(WIN32)
65     list(APPEND VORBIS_SOURCES ../win32/vorbis.def)
66     list(APPEND VORBISENC_SOURCES ../win32/vorbisenc.def)
67     list(APPEND VORBISFILE_SOURCES ../win32/vorbisfile.def)
68 endif()
69
70 if(MSVC)
71     add_definitions(-D_CRT_SECURE_NO_WARNINGS)
72     add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
73     add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
74 endif()
75
76 if (NOT BUILD_FRAMEWORK)
77     add_library(vorbis ${VORBIS_HEADERS} ${VORBIS_SOURCES})
78     add_library(vorbisenc ${VORBISENC_SOURCES})
79     add_library(vorbisfile ${VORBISFILE_SOURCES})
80
81     get_version_info(VORBIS_VERSION_INFO "V_LIB_CURRENT" "V_LIB_AGE" "V_LIB_REVISION")
82     set_target_properties(vorbis PROPERTIES SOVERSION ${VORBIS_VERSION_INFO})
83     get_version_info(VORBISENC_VERSION_INFO "VE_LIB_CURRENT" "VE_LIB_AGE" "VE_LIB_REVISION")
84     set_target_properties(vorbisenc PROPERTIES SOVERSION ${VORBISENC_VERSION_INFO})
85     get_version_info(VORBISFILE_VERSION_INFO "VF_LIB_CURRENT" "VF_LIB_AGE" "VF_LIB_REVISION")
86     set_target_properties(vorbisfile PROPERTIES SOVERSION ${VORBISFILE_VERSION_INFO})
87
88     target_include_directories(vorbis
89         PUBLIC
90             $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
91             $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
92        PRIVATE
93             ${CMAKE_CURRENT_SOURCE_DIR}
94     )
95     target_include_directories(vorbisenc
96         PUBLIC
97             $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
98             $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
99         PRIVATE
100             ${CMAKE_CURRENT_SOURCE_DIR}
101     )
102     target_include_directories(vorbisfile
103         PUBLIC
104             $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
105             $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
106     )
107
108     target_link_libraries(vorbis
109         PUBLIC Ogg::ogg
110         PRIVATE $<$<BOOL:${HAVE_LIBM}>:m>
111     )
112     target_link_libraries(vorbisenc PUBLIC vorbis)
113     target_link_libraries(vorbisfile PUBLIC vorbis)
114
115     install(FILES ${VORBIS_PUBLIC_HEADERS} DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/vorbis)
116
117     install(TARGETS vorbis vorbisenc vorbisfile
118         EXPORT VorbisTargets
119         RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
120         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
121         ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
122         FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}
123     )
124
125     if(INSTALL_CMAKE_PACKAGE_MODULE)
126
127     set(CMAKE_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Vorbis)
128
129         install(EXPORT VorbisTargets
130             DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
131             NAMESPACE Vorbis::
132         )
133
134
135         include(CMakePackageConfigHelpers)
136
137         configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/VorbisConfig.cmake.in ${PROJECT_BINARY_DIR}/VorbisConfig.cmake
138             INSTALL_DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
139         )
140
141         write_basic_package_version_file(${PROJECT_BINARY_DIR}/VorbisConfigVersion.cmake
142             COMPATIBILITY SameMajorVersion
143         )
144
145         install(FILES ${PROJECT_BINARY_DIR}/VorbisConfig.cmake ${PROJECT_BINARY_DIR}/VorbisConfigVersion.cmake
146             DESTINATION ${CMAKE_INSTALL_CONFIGDIR}
147         )
148
149     endif()
150 else()
151     add_library(vorbis ${VORBIS_PUBLIC_HEADERS} ${VORBIS_HEADERS} ${VORBIS_SOURCES} ${VORBISFILE_SOURCES} ${VORBISENC_SOURCES})
152     set_target_properties(vorbis PROPERTIES
153         FRAMEWORK TRUE
154         FRAMEWORK_VERSION ${PROJECT_VERSION}
155         MACOSX_FRAMEWORK_IDENTIFIER org.xiph.vorbis
156         MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PROJECT_VERSION}
157         MACOSX_FRAMEWORK_BUNDLE_VERSION ${PROJECT_VERSION}
158         XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
159         PUBLIC_HEADER "${VORBIS_PUBLIC_HEADERS}"
160         OUTPUT_NAME Vorbis
161     )
162     target_link_libraries(vorbis ${OGG_LIBRARIES})
163 endif()