vcpkg/ports/libopenmpt/CMakeLists.txt

98 lines
2.5 KiB
CMake
Raw Normal View History

2018-01-28 19:14:06 +08:00
cmake_minimum_required(VERSION 3.9)
project(libopenmpt)
if(MSVC)
add_compile_options(
/W3 /wd4005 /wd4267 /wd4244 /wd4996 /wd4100 /wd4018
2018-01-28 19:14:06 +08:00
-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
)
endif()
find_package(ZLIB REQUIRED)
find_package(mpg123 CONFIG REQUIRED)
2023-10-17 03:12:21 +08:00
find_package(Vorbis CONFIG REQUIRED)
2018-01-28 19:14:06 +08:00
file(GLOB HEADERS libopenmpt/*.h libopenmpt/*.hpp src/openmpt/all/*.hpp)
list(FILTER HEADERS EXCLUDE REGEX "_impl\\.hpp$|_internal\\.h$")
2018-01-28 19:14:06 +08:00
include_directories(
.
src
2018-01-28 19:14:06 +08:00
build/svn_version
libopenmpt
common
soundbase
sounddsp
soundlib
openmpt123
)
file(GLOB_RECURSE SOURCES
common/*.cpp
soundbase/*.cpp
sounddsp/*.cpp
# Because this is a GLOB_RECURSE, soundlib/plugins/*.cpp will be included
soundlib/*.cpp
2018-01-28 19:14:06 +08:00
libopenmpt/libopenmpt_c.cpp
libopenmpt/libopenmpt_cxx.cpp
libopenmpt/libopenmpt_ext_impl.cpp
libopenmpt/libopenmpt_impl.cpp
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2018-01-28 19:14:06 +08:00
add_library(libopenmpt ${SOURCES})
set_target_properties(libopenmpt PROPERTIES OUTPUT_NAME openmpt)
2018-01-28 19:14:06 +08:00
target_compile_definitions(libopenmpt PRIVATE
2018-01-28 19:14:06 +08:00
-DMPT_WITH_MPG123 -DMPT_WITH_OGG
-DMPT_WITH_VORBIS -DMPT_WITH_VORBISFILE
-DMPT_WITH_ZLIB -DMPT_BUILD_VCPKG
-DLIBOPENMPT_BUILD
)
if(BUILD_SHARED_LIBS)
target_compile_definitions(
libopenmpt
PRIVATE -DLIBOPENMPT_BUILD_DLL
2018-01-28 19:14:06 +08:00
)
endif()
target_include_directories(
2018-01-28 19:14:06 +08:00
libopenmpt
PUBLIC
$<INSTALL_INTERFACE:include>
2018-01-28 19:14:06 +08:00
)
target_link_libraries(
libopenmpt
PRIVATE
MPG123::libmpg123
Vorbis::vorbisfile
Vorbis::vorbis
ZLIB::ZLIB
2018-01-28 19:14:06 +08:00
)
set(LIBOPENMPT_REQUIRES_PRIVATE "zlib vorbis vorbisfile libmpg123")
set(LIBOPENMPT_LIBS_PRIVATE "")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix [[${prefix}]])
set(includedir [[${prefix}/include]])
set(libdir [[${prefix}/lib]])
configure_file(libopenmpt/libopenmpt.pc.in libopenmpt.pc)
2023-10-17 03:12:21 +08:00
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libopenmpt.pc" DESTINATION lib/pkgconfig)
install(TARGETS libopenmpt EXPORT libopenmpt-targets)
install(EXPORT libopenmpt-targets DESTINATION share/libopenmpt NAMESPACE libopenmpt::)
2023-10-17 03:12:21 +08:00
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libopenmpt-config.cmake" [[
include(CMakeFindDependencyMacro)
find_dependency(ZLIB)
find_dependency(mpg123 CONFIG)
2023-10-17 03:12:21 +08:00
find_dependency(Vorbis CONFIG)
include("${CMAKE_CURRENT_LIST_DIR}/libopenmpt-targets.cmake")
]])
install(FILES ${HEADERS} DESTINATION include/libopenmpt)
2023-10-17 03:12:21 +08:00
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libopenmpt-config.cmake" DESTINATION share/libopenmpt)