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.
This commit is contained in:
parent
164030202c
commit
f142367a8a
1 changed files with 18 additions and 3 deletions
|
@ -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}
|
||||
|
@ -28,7 +41,7 @@ include_directories(
|
|||
src/movers
|
||||
include
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
lib/physfs-2.0.3
|
||||
${PHYSFS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
configure_file(
|
||||
|
@ -36,7 +49,9 @@ configure_file(
|
|||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h"
|
||||
)
|
||||
|
||||
if (NOT PHYSFS_FOUND)
|
||||
add_subdirectory(lib/physfs-2.0.3)
|
||||
endif(NOT PHYSFS_FOUND)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
src/main.cpp
|
||||
|
@ -70,6 +85,6 @@ add_executable(${PROJECT_NAME}
|
|||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
${SDL2_LIBRARIES}
|
||||
physfs
|
||||
${PHYSFS_LIBRARY}
|
||||
${PNG_LIBRARIES}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue