Cmake fixes

This commit is contained in:
LoveEevee 2021-09-27 02:36:54 +03:00
parent fdff2728be
commit 22639565f6
5 changed files with 39 additions and 25 deletions

View File

@ -70,6 +70,9 @@ if(NOT WIN32)
set(ATRAC9_PATH CACHE PATH "Path to LibAtrac9")
set(SPEEX_PATH CACHE PATH "Path to SPEEX")
set(LIBAO_PATH CACHE PATH "Path to libao")
if(EMSCRIPTEN)
set(ZLIB_PATH CACHE PATH "Path to zlib")
endif()
endif()
# Build choices
@ -104,12 +107,14 @@ if(EMSCRIPTEN)
set(USE_JANSSON OFF)
set(BUILD_V123 OFF)
set(BUILD_AUDACIOUS OFF)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lworkerfs.js -s CASE_INSENSITIVE_FS -s ALLOW_MEMORY_GROWTH")
endif()
# Static builds will link all libraries statically
if(BUILD_STATIC)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++ -static")
# Incompatible with static builds
set(BUILD_AUDACIOUS OFF)

View File

@ -16,8 +16,12 @@ function(FetchDependency name)
set(${name}_BIN ${VGM_BINARY_DIR}/dependencies/${ARGS_DIR})
set(${name}_BIN ${${name}_BIN} PARENT_SCOPE)
if(${name}_PATH AND IS_DIRECTORY "${${name}_PATH}")
set(${name}_SOURCE "(local path)" PARENT_SCOPE)
if(${name}_PATH)
if(IS_DIRECTORY "${${name}_PATH}")
set(${name}_SOURCE "(local path)" PARENT_SCOPE)
else()
message(FATAL_ERROR "The provided path to ${ARGS_DIR} does not exist (Use ${name}_PATH)")
endif()
elseif(Git_FOUND AND ARGS_GIT_REPOSITORY OR ARGS_DOWNLOAD)
set(${name}_PATH ${VGM_SOURCE_DIR}/dependencies/${ARGS_DIR})
set(${name}_PATH ${${name}_PATH} PARENT_SCOPE)

View File

@ -178,16 +178,18 @@ if(USE_FFMPEG)
SUBDIR zlib-1.2.11
)
add_subdirectory(${ZLIB_PATH} ${ZLIB_BIN})
target_include_directories(example PRIVATE ${ZLIB_PATH})
target_include_directories(minigzip PRIVATE ${ZLIB_PATH})
target_include_directories(example64 PRIVATE ${ZLIB_PATH})
target_include_directories(minigzip64 PRIVATE ${ZLIB_PATH})
add_library(z STATIC IMPORTED)
set_target_properties(z PROPERTIES
IMPORTED_LOCATION ${ZLIB_BIN}/libz.a
)
if(ZLIB_PATH)
add_subdirectory(${ZLIB_PATH} ${ZLIB_BIN})
set_target_properties(zlib example minigzip example64 minigzip64 PROPERTIES
EXCLUDE_FROM_ALL TRUE
EXCLUDE_FROM_DEFAULT_BUILD TRUE
)
add_library(z STATIC IMPORTED)
set_target_properties(z PROPERTIES
IMPORTED_LOCATION ${ZLIB_BIN}/libz.a
)
endif()
endif()
endif()
endif()

View File

@ -13,19 +13,22 @@ if(NOT WIN32 AND USE_MPEG)
SUBDIR mpg123-1.28.2
)
set(MPEG_LINK_PATH ${MPEG_BIN}/bin/usr/local/lib/libmpg123.a)
if(NOT EXISTS ${MPEG_LINK_PATH})
add_custom_target(MPEG_MAKE ALL
COMMAND ./configure --enable-static=yes --enable-shared=no && make && make install DESTDIR="${MPEG_BIN}/bin" && make clean
WORKING_DIRECTORY ${MPEG_PATH}
if(MPEG_PATH)
set(MPEG_LINK_PATH ${MPEG_BIN}/bin/usr/local/lib/libmpg123.a)
set(MPG123_INCLUDE_DIR ${MPEG_BIN}/bin/usr/local/include)
if(NOT EXISTS ${MPEG_LINK_PATH})
add_custom_target(MPEG_MAKE ALL
COMMAND ./configure --enable-static=yes --enable-shared=no && make && make install DESTDIR="${MPEG_BIN}/bin" && make clean
WORKING_DIRECTORY ${MPEG_PATH}
)
endif()
add_library(mpg123 STATIC IMPORTED)
set_target_properties(mpg123 PROPERTIES
IMPORTED_LOCATION ${MPEG_LINK_PATH}
)
endif()
add_library(mpg123 STATIC IMPORTED)
set_target_properties(mpg123 PROPERTIES
IMPORTED_LOCATION ${MPEG_LINK_PATH}
)
endif()
endif()
if(NOT USE_MPEG)

View File

@ -38,7 +38,7 @@ macro(setup_target TARGET)
else()
target_include_directories(${TARGET} PRIVATE ${MPG123_INCLUDE_DIR})
if(LINK)
target_link_libraries(${TARGET} mpg123)
target_link_libraries(${TARGET} mpg123 m)
endif()
endif()
endif()