e73ffcb183ec213c5e1afa00727adb6c1ba1e11f
[flac.git] / src / libFLAC++ / CMakeLists.txt
1 set(prefix "${CMAKE_INSTALL_PREFIX}")
2 set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
3 set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
4 set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
5 configure_file(flac++.pc.in flac++.pc @ONLY)
6
7 check_cxx_source_compiles("
8     #ifdef __STDC_NO_VLA__
9     syntax error;
10     #else
11     int fvla (int m, int * c)
12     {
13       int D[m];
14       return D[0] == c[0];
15     }
16
17     int main(int, char * []) { return 0; }
18     #endif"
19     HAVE_CXX_VARARRAYS)
20
21 add_compile_definitions($<$<BOOL:${HAVE_CXX_VARARRAYS}>:HAVE_CXX_VARARRAYS>)
22
23 set(SOURCES
24     metadata.cpp
25     stream_decoder.cpp
26     stream_encoder.cpp)
27
28 add_library(FLAC++-static STATIC ${SOURCES})
29 target_compile_definitions(FLAC++-static PUBLIC FLAC__NO_DLL)
30 target_include_directories(FLAC++-static INTERFACE
31     "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
32     "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
33 target_link_libraries(FLAC++-static PUBLIC FLAC-static)
34
35 add_library(FLAC++ SHARED ${SOURCES})
36 target_compile_definitions(FLAC++ PRIVATE FLACPP_API_EXPORTS FLAC__USE_VISIBILITY_ATTR)
37 target_include_directories(FLAC++ INTERFACE
38     "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
39     "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
40 target_link_libraries(FLAC++ PRIVATE FLAC)
41 set_target_properties(FLAC++ PROPERTIES
42     CXX_VISIBILITY_PRESET hidden
43     VERSION 6.3.0
44     SOVERSION 6)
45
46 install(TARGETS FLAC++ FLAC++-static EXPORT targets
47     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
48     LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
49     RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
50 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac++.pc"
51     DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")