1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

De-duplicate list of static libraries and flags applied to all libraries

This is so flags that apply globally (i.e. to the game and all static
libraries it's compiled with), such as /MT on MSVC, can be put in a
list, and along with putting all static libraries in a list, we remove
the need for each flag to be repeated for each static library and we can
just use a foreach loop instead.

(Global compile flags of course don't apply to us meddling with
CMAKE_C_FLAGS and CMAKE_CXX_FLAGS directly, because we need to do that
in order to make sure the C and C++ standards are set properly.)
This commit is contained in:
Misa 2022-08-21 13:25:36 -07:00
parent 67d350de05
commit 712a319973

View file

@ -295,6 +295,12 @@ target_compile_definitions(lodepng-static PRIVATE
-DLODEPNG_NO_COMPILE_ENCODER
)
if(BUNDLE_DEPENDENCIES)
set(STATIC_LIBRARIES physfs-static tinyxml2-static lodepng-static faudio-static)
else()
set(STATIC_LIBRARIES lodepng-static)
endif()
if(BUNDLE_DEPENDENCIES)
add_library(tinyxml2-static STATIC ${XML2_SRC})
add_library(physfs-static STATIC ${PFS_SRC})
@ -307,27 +313,27 @@ if(BUNDLE_DEPENDENCIES)
../third_party/FAudio/include
)
target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static faudio-static)
target_link_libraries(VVVVVV ${STATIC_LIBRARIES})
else()
find_package(utf8cpp CONFIG)
target_link_libraries(VVVVVV physfs tinyxml2 utf8cpp lodepng-static FAudio)
target_link_libraries(VVVVVV ${STATIC_LIBRARIES} physfs tinyxml2 utf8cpp FAudio)
endif()
if(MSVC)
# Statically link Microsoft's runtime library so end users don't have to install it
target_compile_options(VVVVVV PRIVATE /MT)
# /MT must also be applied to every statically-linked library, else you get a linker error
if(BUNDLE_DEPENDENCIES)
target_compile_options(tinyxml2-static PRIVATE /MT)
target_compile_options(physfs-static PRIVATE /MT)
target_compile_options(faudio-static PRIVATE /MT)
endif()
target_compile_options(lodepng-static PRIVATE /MT)
list(APPEND GLOBAL_COMPILE_FLAGS /MT)
endif()
target_compile_options(VVVVVV PRIVATE ${GLOBAL_COMPILE_FLAGS})
foreach(static_library IN LISTS STATIC_LIBRARIES)
target_compile_options(${static_library} PRIVATE ${GLOBAL_COMPILE_FLAGS})
endforeach(static_library)
# SDL2 Dependency (Detection pulled from FAudio)
if(DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")