ref: 469c25c93d5b95828b4a2ac2bfb2e5a09869b7c4
parent: 6209661c76ce2d345ed891d7353f4d38615c0ce4
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Apr 26 00:17:29 EDT 2019
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.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@
option(JAPANESE "Enable the Japanese-language build" 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(FORCE_LOCAL_LIBS "Ignore system libraries, and compile the statically-linked local copies instead" OFF)
# Default to Release build
if(NOT CMAKE_BUILD_TYPE)
@@ -292,11 +293,11 @@
# Find dependencies
find_package(SDL2)
-if(TARGET SDL2::SDL2)
+if(TARGET SDL2::SDL2 AND NOT FORCE_LOCAL_LIBS)
# CMake-generated config (Arch, vcpkg, Raspbian)
message(STATUS "Using system SDL2")
target_link_libraries(CSE2 SDL2::SDL2 SDL2::SDL2main)
-elseif(SDL2_FOUND)
+elseif(SDL2_FOUND AND NOT FORCE_LOCAL_LIBS)
# Autotools-generated config (MSYS2)
message(STATUS "Using system SDL2")
target_include_directories(CSE2 PRIVATE ${SDL2_INCLUDE_DIRS})
@@ -310,7 +311,7 @@
endif()
find_package(Freetype)
-if(FREETYPE_FOUND)
+if(FREETYPE_FOUND AND NOT FORCE_LOCAL_LIBS)
message(STATUS "Using system FreeType")
target_include_directories(CSE2 PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_link_libraries(CSE2 ${FREETYPE_LIBRARIES})
@@ -348,7 +349,7 @@
# Find FLTK
find_package(FLTK)
-if(FLTK_FOUND)
+if(FLTK_FOUND AND NOT FORCE_LOCAL_LIBS)
message(STATUS "Using system FLTK")
target_include_directories(DoConfig PRIVATE ${FLTK_INCLUDE_DIR})
target_link_libraries(DoConfig ${FLTK_LIBRARIES})