summaryrefslogtreecommitdiff
path: root/3rdparty/libwav/CMakeLists.txt
blob: c3faa46bdd36a4216dd7434d94739d304031b75c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
cmake_minimum_required(VERSION 3.14)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")

# Project Information
project(wav VERSION "0.1.0")

# CMake variables that affects building
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
    if(CMAKE_BUILD_TYPE STREQUAL "")
        set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
    endif()

    if(NOT DEFINED BUILD_SHARED_LIBS)
        set(BUILD_SHARED_LIBS ON CACHE BOOL "enable building of shared libraries instead of static ones" FORCE)
    endif()

    if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
        set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "enable position independent code" FORCE)
    endif()

    include(CTest)
    message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
    message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
    message(STATUS "CMAKE_POSITION_INDEPENDENT_CODE: ${CMAKE_POSITION_INDEPENDENT_CODE}")
    message(STATUS "BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}")
    message(STATUS "BUILD_TESTING: ${BUILD_TESTING}")
endif()

include(GNUInstallDirs)
include(wavTargetProperties)

add_library(${PROJECT_NAME} src/wav.c)
add_library(wav::wav ALIAS wav)
target_include_directories(${PROJECT_NAME}
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        $<INSTALL_INTERFACE:include>
    PRIVATE
        $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
    )
target_compile_features(${PROJECT_NAME} PRIVATE ${wav_compile_features})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${wav_compile_definitions})
target_compile_options(${PROJECT_NAME} PRIVATE
    ${wav_c_flags}
    $<$<CONFIG:RELEASE>:${wav_compile_options_release}>
    $<$<CONFIG:RELWITHDEBINFO>:${wav_compile_options_release}>
    )

if(BUILD_TESTING AND "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
    add_subdirectory(tests/write_f32)
endif()

export(TARGETS wav NAMESPACE wav FILE wavTargets.cmake)

install(
    TARGETS ${PROJECT_NAME}
    EXPORT wavTargets
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    )

export(PACKAGE wav)

install(DIRECTORY include DESTINATION .)

install(
    FILES README.md CHANGELOG.md LICENSE
    DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${PROJECT_NAME}
    )

install(EXPORT wavTargets
    FILE wavTargets.cmake
    NAMESPACE wav::
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
    )

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
    wavConfigVersion.cmake
    VERSION ${PACKAGE_VERSION}
    COMPATIBILITY SameMajorVersion
    )

configure_file(cmake/wavConfig.cmake.in wavConfig.cmake @ONLY)
install(
    FILES
        "${CMAKE_CURRENT_BINARY_DIR}/wavConfig.cmake"
        "${CMAKE_CURRENT_BINARY_DIR}/wavConfigVersion.cmake"
        DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
    )
  
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
    set(CPACK_PACKAGE_NAME "wav")
    set(CPACK_GENERATOR "TXZ")
    set(CPACK_SOURCE_IGNORE_FILES
        "/\\\\.git/"
        "\\\\.git.*"
        "/build/"
        "/backup/"
        "/cmake-build-.*/"
        "/\\\\.idea/"
        "/\\\\.ycm_extra_conf\\\\..*"
        "/GPATH$"
        "/GRTAGS$"
        "/GSYMS$"
        "/GTAGS$"
        "\\\\.swp$"
        "\\\\.swo$"
        ".DS_Store"
        ".ccls"
        ".ccls-cache"
        )
    set(CPACK_SOURCE_GENERATOR "TXZ")
    include(CPack)
endif()