2018-01-28 19:14:06 +08:00
|
|
|
cmake_minimum_required(VERSION 3.9)
|
|
|
|
project(libopenmpt)
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
add_compile_options(
|
2020-10-15 08:38:40 +08:00
|
|
|
/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)
|
2021-10-26 04:35:56 +08:00
|
|
|
find_package(mpg123 CONFIG REQUIRED)
|
2021-07-01 04:06:48 +08:00
|
|
|
find_package(Vorbis REQUIRED)
|
2018-01-28 19:14:06 +08:00
|
|
|
|
2023-01-24 07:56:59 +08:00
|
|
|
file(GLOB HEADERS libopenmpt/*.h libopenmpt/*.hpp src/openmpt/all/*.hpp)
|
2021-10-26 04:35:56 +08:00
|
|
|
list(FILTER HEADERS EXCLUDE REGEX "_impl\\.hpp$|_internal\\.h$")
|
2018-01-28 19:14:06 +08:00
|
|
|
|
|
|
|
include_directories(
|
|
|
|
.
|
2023-01-24 07:56:59 +08:00
|
|
|
src
|
2018-01-28 19:14:06 +08:00
|
|
|
build/svn_version
|
|
|
|
libopenmpt
|
|
|
|
common
|
|
|
|
soundbase
|
|
|
|
sounddsp
|
|
|
|
soundlib
|
|
|
|
openmpt123
|
|
|
|
)
|
|
|
|
|
2021-10-26 04:35:56 +08:00
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2021-10-26 04:35:56 +08:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2018-01-28 19:14:06 +08:00
|
|
|
|
2021-10-26 04:35:56 +08:00
|
|
|
add_library(libopenmpt ${SOURCES})
|
2023-01-24 07:50:14 +08:00
|
|
|
set_target_properties(libopenmpt PROPERTIES OUTPUT_NAME openmpt)
|
2018-01-28 19:14:06 +08:00
|
|
|
|
2021-10-26 04:35:56 +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
|
2021-10-26 04:35:56 +08:00
|
|
|
PRIVATE -DLIBOPENMPT_BUILD_DLL
|
2018-01-28 19:14:06 +08:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-10-26 04:35:56 +08:00
|
|
|
target_include_directories(
|
2018-01-28 19:14:06 +08:00
|
|
|
libopenmpt
|
2021-10-26 04:35:56 +08:00
|
|
|
PUBLIC
|
|
|
|
$<INSTALL_INTERFACE:include>
|
2018-01-28 19:14:06 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(
|
|
|
|
libopenmpt
|
2021-10-26 04:35:56 +08:00
|
|
|
PRIVATE
|
|
|
|
MPG123::libmpg123
|
|
|
|
Vorbis::vorbisfile
|
|
|
|
Vorbis::vorbis
|
|
|
|
ZLIB::ZLIB
|
2018-01-28 19:14:06 +08:00
|
|
|
)
|
|
|
|
|
2021-10-26 04:35:56 +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)
|
|
|
|
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::)
|
|
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libopenmpt-config.cmake [[
|
|
|
|
include(CMakeFindDependencyMacro)
|
|
|
|
find_dependency(ZLIB)
|
|
|
|
find_dependency(mpg123 CONFIG)
|
|
|
|
find_dependency(Vorbis)
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/libopenmpt-targets.cmake)
|
|
|
|
]])
|
|
|
|
install(FILES ${HEADERS} DESTINATION include/libopenmpt)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libopenmpt-config.cmake DESTINATION share/libopenmpt)
|