From f28dc743d653df245fb074ecfaf3befa54859dc4 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Mon, 4 Aug 2014 18:57:14 +0200 Subject: [PATCH] Use the system's PhysFS if present. Also add an option to allow the user to override this and force the use of the supplied library. Pass -DWITH_BUILTIN_PHYSFS=on to cmake to force using the supplied library. --- CMakeLists.txt | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7aa40b..6509b17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,11 +5,24 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -pedantic -Wcon set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11 -Wall -Wextra -pedantic -Wconversion") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++11 -Wall -Wextra -pedantic -Wconversion") +option(WITH_BUILTIN_PHYSFS "Force using the version of PhysFS accompanying the code even if a system library is available" OFF) + include(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) find_package(PNG REQUIRED) find_package(Boost 1.55.0 REQUIRED) +if (NOT WITH_BUILTIN_PHYSFS) + find_package(PhysFS 2.0.3) +endif() + +if (PHYSFS_FOUND) + message(STATUS "Using system's PhysFS, set WITH_BUILTIN_PHYSFS to on to override this") +else(PHYSFS_FOUND) + message(STATUS "Using internal PhysFS") + set(PHYSFS_INCLUDE_DIR "lib/physfs-2.0.3") + set(PHYSFS_LIBRARY "physfs") +endif(PHYSFS_FOUND) add_definitions( ${PNG_DEFINITIONS} @@ -27,7 +40,7 @@ include_directories( src/movers include "${PROJECT_BINARY_DIR}" - lib/physfs-2.0.3 + ${PHYSFS_INCLUDE_DIR} ) configure_file( @@ -35,7 +48,9 @@ configure_file( "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h" ) -add_subdirectory(lib/physfs-2.0.3) +if (NOT PHYSFS_FOUND) + add_subdirectory(lib/physfs-2.0.3) +endif(NOT PHYSFS_FOUND) add_executable(${PROJECT_NAME} src/main.cpp @@ -69,6 +84,6 @@ add_executable(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES} - physfs + ${PHYSFS_LIBRARY} ${PNG_LIBRARIES} )