Improved cmake script of libmt32emu wrt. packaging

The advanced option libmt32emu_PACKAGE_TYPE is now possible to select
regardless whether a static or shared library is built. For static builds,
values Complete and Devel are identical but for Runtime, documentation
files are only added to the package.

This permits somewhat better build experience when using the top-level
CMakeLists.txt script. Specifically, it is now easy to omit development
files and build both components mt32emu_qt and mt32emu_smf2wav statically
linked with the library with just a single cmake command like

  cmake -Dlibmt32emu_PACKAGE_TYPE=Runtime .
This commit is contained in:
sergm
2021-01-26 21:15:18 +02:00
parent 7a941bdc32
commit 2caba8b87c

View File

@@ -36,19 +36,16 @@ endif(${libmt32emu_SHARED} AND NOT ${munt_WITH_MT32EMU_QT})
set(LIB_INSTALL_DIR lib CACHE PATH "Relative installation path to libraries")
set(libmt32emu_PACKAGE_TYPE Complete CACHE STRING "Selects output binary package type: Complete, Runtime or Devel")
mark_as_advanced(libmt32emu_PACKAGE_TYPE)
set_property(CACHE libmt32emu_PACKAGE_TYPE PROPERTY STRINGS Complete Runtime Devel)
if(libmt32emu_SHARED)
set(libmt32emu_PACKAGE_TYPE Complete CACHE STRING "Selects output binary package type: Complete, Runtime or Devel")
mark_as_advanced(libmt32emu_PACKAGE_TYPE)
set_property(CACHE libmt32emu_PACKAGE_TYPE
PROPERTY STRINGS Complete Runtime Devel
)
option(libmt32emu_INSTALL_DEFAULT_LOCALE "Install user-preferred system locale as C locale when initialising shared library.\
This is generally not necessary, although may be required in some cases\
(for instance, when builing shared library with old versions of MS VC with the C runtime statically linked)\
to open ROM files with localised pathnames successfully." FALSE)
mark_as_advanced(libmt32emu_INSTALL_DEFAULT_LOCALE)
else()
set(libmt32emu_PACKAGE_TYPE Complete)
endif()
set(libmt32emu_SOURCES
@@ -235,10 +232,12 @@ if(libmt32emu_SHARED AND CMAKE_SYSTEM_NAME STREQUAL Windows)
endif()
if(libmt32emu_PACKAGE_TYPE STREQUAL "Runtime")
install(TARGETS mt32emu
LIBRARY DESTINATION ${LIB_INSTALL_DIR} NAMELINK_SKIP
RUNTIME DESTINATION bin
)
if(libmt32emu_SHARED)
install(TARGETS mt32emu
LIBRARY DESTINATION ${LIB_INSTALL_DIR} NAMELINK_SKIP
RUNTIME DESTINATION bin
)
endif()
elseif(libmt32emu_PACKAGE_TYPE STREQUAL "Devel")
if(WIN32 OR CYGWIN)
install(TARGETS mt32emu ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
@@ -253,14 +252,14 @@ else()
)
endif()
if(NOT libmt32emu_PACKAGE_TYPE STREQUAL "Runtime" OR libmt32emu_PACKAGE_TYPE STREQUAL "Devel")
if(NOT libmt32emu_PACKAGE_TYPE STREQUAL "Runtime")
install(DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/include/mt32emu"
DESTINATION include
)
endif()
if(libmt32emu_PACKAGE_TYPE STREQUAL "Runtime" OR NOT libmt32emu_PACKAGE_TYPE STREQUAL "Devel")
if(NOT(libmt32emu_SHARED AND libmt32emu_PACKAGE_TYPE STREQUAL "Devel"))
install(FILES
AUTHORS.txt COPYING.txt COPYING.LESSER.txt NEWS.txt README.md TODO.txt
DESTINATION share/doc/munt/libmt32emu