CMake minimum required lowered to 3.1
[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 set(SOURCES
22     metadata.cpp
23     stream_decoder.cpp
24     stream_encoder.cpp)
25
26 add_library(FLAC++-static STATIC ${SOURCES})
27 target_compile_definitions(FLAC++-static PUBLIC FLAC__NO_DLL)
28 target_include_directories(FLAC++-static INTERFACE
29     "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
30     "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
31 target_link_libraries(FLAC++-static PUBLIC FLAC-static)
32
33 add_library(FLAC++ SHARED ${SOURCES})
34 target_compile_definitions(FLAC++ PRIVATE FLACPP_API_EXPORTS FLAC__USE_VISIBILITY_ATTR)
35 target_include_directories(FLAC++ INTERFACE
36     "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
37     "$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>")
38 target_link_libraries(FLAC++ PRIVATE FLAC)
39 set_target_properties(FLAC++ PROPERTIES
40     CXX_VISIBILITY_PRESET hidden
41     VERSION 6.3.0
42     SOVERSION 6)
43
44 install(TARGETS FLAC++ FLAC++-static EXPORT targets
45     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
46     LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/"
47     RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/")
48 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/flac++.pc"
49     DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")