Added FORCE_LOCAL_LIBS option

This forces CMake to use the local libraries, even if system libs
are readily available. This is useful for MSYS2, since find_package
would link dynamic libraries, but local libraries are static.
This commit is contained in:
Clownacy 2019-04-26 04:17:29 +01:00
parent 6209661c76
commit 469c25c93d

View file

@ -7,6 +7,7 @@ endif()
option(JAPANESE "Enable the Japanese-language build" OFF) option(JAPANESE "Enable the Japanese-language build" OFF)
option(FIX_BUGS "Fix certain bugs (see src/Bug Fixes.txt)" OFF) option(FIX_BUGS "Fix certain bugs (see src/Bug Fixes.txt)" OFF)
option(NONPORTABLE "Enable bits of code that aren't portable, but are what the original game used" OFF) option(NONPORTABLE "Enable bits of code that aren't portable, but are what the original game used" OFF)
option(FORCE_LOCAL_LIBS "Ignore system libraries, and compile the statically-linked local copies instead" OFF)
# Default to Release build # Default to Release build
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)
@ -292,11 +293,11 @@ endif()
# Find dependencies # Find dependencies
find_package(SDL2) find_package(SDL2)
if(TARGET SDL2::SDL2) if(TARGET SDL2::SDL2 AND NOT FORCE_LOCAL_LIBS)
# CMake-generated config (Arch, vcpkg, Raspbian) # CMake-generated config (Arch, vcpkg, Raspbian)
message(STATUS "Using system SDL2") message(STATUS "Using system SDL2")
target_link_libraries(CSE2 SDL2::SDL2 SDL2::SDL2main) target_link_libraries(CSE2 SDL2::SDL2 SDL2::SDL2main)
elseif(SDL2_FOUND) elseif(SDL2_FOUND AND NOT FORCE_LOCAL_LIBS)
# Autotools-generated config (MSYS2) # Autotools-generated config (MSYS2)
message(STATUS "Using system SDL2") message(STATUS "Using system SDL2")
target_include_directories(CSE2 PRIVATE ${SDL2_INCLUDE_DIRS}) target_include_directories(CSE2 PRIVATE ${SDL2_INCLUDE_DIRS})
@ -310,7 +311,7 @@ else()
endif() endif()
find_package(Freetype) find_package(Freetype)
if(FREETYPE_FOUND) if(FREETYPE_FOUND AND NOT FORCE_LOCAL_LIBS)
message(STATUS "Using system FreeType") message(STATUS "Using system FreeType")
target_include_directories(CSE2 PRIVATE ${FREETYPE_INCLUDE_DIRS}) target_include_directories(CSE2 PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(CSE2 ${FREETYPE_LIBRARIES}) target_link_libraries(CSE2 ${FREETYPE_LIBRARIES})
@ -348,7 +349,7 @@ endif()
# Find FLTK # Find FLTK
find_package(FLTK) find_package(FLTK)
if(FLTK_FOUND) if(FLTK_FOUND AND NOT FORCE_LOCAL_LIBS)
message(STATUS "Using system FLTK") message(STATUS "Using system FLTK")
target_include_directories(DoConfig PRIVATE ${FLTK_INCLUDE_DIR}) target_include_directories(DoConfig PRIVATE ${FLTK_INCLUDE_DIR})
target_link_libraries(DoConfig ${FLTK_LIBRARIES}) target_link_libraries(DoConfig ${FLTK_LIBRARIES})