https://github.com/UZDoom/UZDoom/pull/1890 https://github.com/UZDoom/UZDoom/pull/1891 https://github.com/UZDoom/UZDoom/pull/1896 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(ABSL_BUILD_TESTING OFF) # don't build/run abseil tests +# UZDoom itself has no libs. Ensure bundled dependencies are statically linked. +set( BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE ) + # make all targets use LTO - want to do this early in the cmake to ensure it applies to any targets option( FORCE_NO_LTO "Turn off LTO even if it would be possible to use it." NO ) @@ -252,6 +255,11 @@ option( NO_OPENAL "Disable OpenAL sound support" OFF ) find_package( BZip2 ) find_package( VPX ) +include( FindPkgConfig ) +if( PkgConfig_FOUND ) + pkg_check_modules( WEBP IMPORTED_TARGET libwebpdecoder libwebpmux ) +endif() + if (CURL_REQUIRED) find_package( CURL ) if( MSVC AND NOT CURL_FOUND ) @@ -342,7 +350,6 @@ else() include(CheckSymbolExists) check_symbol_exists( "fts_set" "sys/types.h;sys/stat.h;fts.h" HAVE_FTS ) if ( NOT HAVE_FTS ) - include ( FindPkgConfig ) pkg_check_modules( MUSL_FTS musl-fts ) if ( MUSL_FTS_FOUND ) list(JOIN MUSL_FTS_LDFLAGS " " MUSL_FTS_LDFLAGS_JOINED) @@ -389,6 +396,7 @@ set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${DEB_C_FLAGS} -D_DEBUG" ) option(FORCE_INTERNAL_BZIP2 "Use internal bzip2") option(FORCE_INTERNAL_CPPDAP "Use internal cppdap" ON) +option(FORCE_INTERNAL_WEBP "Use internal webp" ON) if (HAVE_VULKAN) add_subdirectory( libraries/ZVulkan ) @@ -402,8 +410,6 @@ add_subdirectory( libraries/abseil ) set(ZWIDGET_BUILD_EXAMPLE OFF CACHE INTERNAL "" FORCE) add_subdirectory( libraries/ZWidget ) -add_subdirectory( libraries/webp ) - if( HAVE_VM_JIT AND UNIX ) check_symbol_exists( "backtrace" "execinfo.h" HAVE_BACKTRACE ) if( NOT HAVE_BACKTRACE ) @@ -439,15 +445,23 @@ if ( CPPDAP_FOUND AND NOT FORCE_INTERNAL_CPPDAP ) message( STATUS "Using system cppdap library, includes found at ${CPPDAP_INCLUDE_DIR}" ) else() message( STATUS "Using internal cppdap library" ) - add_subdirectory( libraries/cppdap ) + add_subdirectory( libraries/cppdap EXCLUDE_FROM_ALL ) set( CPPDAP_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries/cppdap" ) set( CPPDAP_LIBRARIES cppdap ) set( CPPDAP_LIBRARY cppdap ) set( CPPDAP_FOUND TRUE ) endif() +if ( WEBP_FOUND AND NOT FORCE_INTERNAL_WEBP ) + message( STATUS "Using system webp library, includes found at ${WEBP_libwebpdecoder_INCLUDEDIR}" ) + set( WEBP_TARGET PkgConfig::WEBP ) +else() + message( STATUS "Using internal webp library" ) + add_subdirectory( libraries/webp ) + set( WEBP_TARGET webp ) +endif() + # ZMUSIC -set( BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE ) add_subdirectory( libraries/ZMusic ) set( ZMUSIC_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zmusic" ) set( ZMUSIC_INCLUDE_DIR ${ZMUSIC_ROOT_PATH}/include ) @@ -483,12 +497,6 @@ add_subdirectory( wadsrc_lights ) add_subdirectory( wadsrc_extra ) add_subdirectory( wadsrc_widepix ) -if( ZMUSIC_SYSTEM_INSTALL ) - # Internal ZMusic library provides miniz target, miniz.h file in partuclar - # It's not the case with system-wide ZMusic installation - add_subdirectory( libraries/miniz ) -endif() - if( NOT CMAKE_CROSSCOMPILING ) export(TARGETS ${CROSS_EXPORTS} FILE "${CMAKE_BINARY_DIR}/ImportExecutables.cmake" ) endif() --- a/libraries/ZMusic/source/CMakeLists.txt +++ b/libraries/ZMusic/source/CMakeLists.txt @@ -161,7 +161,7 @@ use_fast_math(zmusiclite) # Although zmusic-obj puts the public include directory in our private include # list, we need to add it to the interface include directories for consumers. -target_include_directories(zmusic INTERFACE $ $) +target_include_directories(zmusic INTERFACE $ $ $) target_include_directories(zmusiclite INTERFACE $ $) target_link_libraries_hidden(zmusic zmusic-obj adl oplsynth opn timidity timidityplus wildmidi fluidsynth) --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,7 +12,6 @@ include( CheckCXXCompilerFlag ) include( CheckIncludeFile ) include( CheckIncludeFiles ) include( CheckLibraryExists ) -include( FindPkgConfig ) if( DEM_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) option( NO_STRIP "Do not strip Release or MinSizeRel builds" ) @@ -301,8 +300,9 @@ if (HAVE_VULKAN) list( APPEND PROJECT_LIBRARIES "zvulkan" ) endif() +list( APPEND PROJECT_LIBRARIES "zmusic" ) list( APPEND PROJECT_LIBRARIES "zwidget" ) -list( APPEND PROJECT_LIBRARIES "webp" ) +list( APPEND PROJECT_LIBRARIES "${WEBP_TARGET}" ) message("Building for target architecture: ${TARGET_ARCHITECTURE}") @@ -1211,10 +1211,6 @@ set (PCH_SOURCES utility/system_theme.cpp ) -if( ZMUSIC_SYSTEM_INSTALL OR NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) - set ( PCH_SOURCES ${PCH_SOURCES} common/utility/i_module.cpp ) -endif() - if( ${HAVE_VM_JIT} ) set( PCH_SOURCES ${PCH_SOURCES} ${VM_JIT_SOURCES} ) else() @@ -1391,7 +1387,6 @@ include_directories( launcher ../libraries/ZVulkan/include ../libraries/ZWidget/include - ../libraries/webp/include ../libraries/range_map/include ${SYSTEM_SOURCES_DIR} ) @@ -1441,8 +1436,7 @@ else() COMMAND ${CMAKE_CURRENT_BINARY_DIR}/link-make ) IF ("${INSTALL_RPATH}" STREQUAL "") set_target_properties(zdoom PROPERTIES - #allow libzmusic.so.1 library in same folder as executable at runtime - INSTALL_RPATH "\$ORIGIN:\$ORIGIN/zmusic/build/source" + INSTALL_RPATH "\$ORIGIN" BUILD_WITH_INSTALL_RPATH ON ) endif() @@ -1467,22 +1461,6 @@ add_custom_command(TARGET zdoom POST_BUILD VERBATIM ) -if ( NOT ZMUSIC_SYSTEM_INSTALL AND (NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)) - # bring zmusic in - add_custom_command(TARGET zdoom POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ $) - if ( NOT WIN32 ) - add_custom_command(TARGET zdoom POST_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink - $ $ - COMMAND ${CMAKE_COMMAND} -E create_symlink - $ $ - WORKING_DIRECTORY $) - endif() - add_dependencies(zdoom zmusic) -endif() - if (VCPKG_TOOLCHAIN) x_vcpkg_install_local_dependencies(TARGETS zdoom DESTINATION ".") endif() @@ -1552,18 +1530,6 @@ if( APPLE ) set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rpath @executable_path" ) endif() -if ( NOT ZMUSIC_SYSTEM_INSTALL ) - if ( WIN32 OR APPLE ) - # nothing to do - else() - install(TARGETS zmusic - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - COMPONENT "Game executable" - ) - endif() -endif() - if( WIN32 ) set( INSTALL_PATH . CACHE STRING "Directory where the executable will be placed during install." ) else()