From 469c25c93d5b95828b4a2ac2bfb2e5a09869b7c4 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 26 Apr 2019 04:17:29 +0100 Subject: [PATCH] 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. --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ffe7d6f..38a790aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ endif() 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 @@ endif() # 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 @@ else() 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 @@ endif() # 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})