misc/libphysfs/CMakeLists.txt
branchphysfslayer
changeset 8526 9f2bd885d773
parent 8522 1853628ae285
child 8540 cf808329bb6f
equal deleted inserted replaced
8524:a65e9bcf0a03 8526:9f2bd885d773
    32 
    32 
    33 include(CheckIncludeFile)
    33 include(CheckIncludeFile)
    34 include(CheckLibraryExists)
    34 include(CheckLibraryExists)
    35 include(CheckCSourceCompiles)
    35 include(CheckCSourceCompiles)
    36 
    36 
    37 ## SDL is needed by extra
       
    38 find_package(SDL REQUIRED)
       
    39 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) ##
       
    40 include_directories(${SDL_INCLUDE_DIR}) ##
       
    41 include_directories(${LUA_INCLUDE_DIR}) ##
       
    42 
    37 
    43 if(MACOSX)
    38 if(MACOSX)
    44     # Fallback to older OS X on PowerPC to support wider range of systems...
    39     # Fallback to older OS X on PowerPC to support wider range of systems...
    45     if(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
    40     if(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
    46         add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020)
    41         add_definitions(-DMAC_OS_X_VERSION_MIN_REQUIRED=1020)
    92     #  cleaned up our code, zlib, etc still use...so disable the warning.
    87     #  cleaned up our code, zlib, etc still use...so disable the warning.
    93     add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
    88     add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
    94 endif(MSVC)
    89 endif(MSVC)
    95 
    90 
    96 
    91 
    97 # Basic chunks of source code ...
       
    98 set(LZMA_SRCS
       
    99     src/lzma/C/7zCrc.c
       
   100     src/lzma/C/Archive/7z/7zBuffer.c
       
   101     src/lzma/C/Archive/7z/7zDecode.c
       
   102     src/lzma/C/Archive/7z/7zExtract.c
       
   103     src/lzma/C/Archive/7z/7zHeader.c
       
   104     src/lzma/C/Archive/7z/7zIn.c
       
   105     src/lzma/C/Archive/7z/7zItem.c
       
   106     src/lzma/C/Archive/7z/7zMethodID.c
       
   107     src/lzma/C/Compress/Branch/BranchX86.c
       
   108     src/lzma/C/Compress/Branch/BranchX86_2.c
       
   109     src/lzma/C/Compress/Lzma/LzmaDecode.c
       
   110 )
       
   111 
       
   112 if(BEOS)
    92 if(BEOS)
   113     # We add this explicitly, since we don't want CMake to think this
    93     # We add this explicitly, since we don't want CMake to think this
   114     #  is a C++ project unless we're on BeOS.
    94     #  is a C++ project unless we're on BeOS.
   115     set(PHYSFS_BEOS_SRCS src/platform_beos.cpp)
    95     set(PHYSFS_BEOS_SRCS src/platform_beos.cpp)
   116     find_library(BE_LIBRARY be)
    96     find_library(BE_LIBRARY be)
   117     find_library(ROOT_LIBRARY root)
    97     find_library(ROOT_LIBRARY root)
   118     set(optionAL_LIBRARY_LIBS ${optionAL_LIBRARY_LIBS} ${BE_LIBRARY} ${ROOT_LIBRARY})
    98     set(optional_library_libs ${optional_library_libs} ${BE_LIBRARY} ${ROOT_LIBRARY})
   119 endif(BEOS)
    99 endif(BEOS)
   120 
   100 
   121 ## extra functions needed by Hedgewars
       
   122 ## TODO: maybe it's better to have them in a separate library?
       
   123 set(PHYSFS_HEDGE_SRCS
       
   124     extras/physfsrwops.c
       
   125     extras/physfslualoader.c
       
   126     extras/hwpacksmounter.c
       
   127 )
       
   128 
   101 
   129 # Almost everything is "compiled" here, but things that don't apply to the
   102 # Almost everything is "compiled" here, but things that don't apply to the
   130 #  build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
   103 #  build are #ifdef'd out. This is to make it easy to embed PhysicsFS into
   131 #  another project or bring up a new build system: just compile all the source
   104 #  another project or bring up a new build system: just compile all the source
   132 #  code and #define the things you want.
   105 #  code and #define the things you want.
   133 set(PHYSFS_SRCS
   106 set(PHYSFS_SRCS
   134     src/physfs.c
   107     physfs.c
   135     src/physfs_byteorder.c
   108     physfs_byteorder.c
   136     src/physfs_unicode.c
   109     physfs_unicode.c
   137     src/platform_posix.c
   110     platform_posix.c
   138     src/platform_unix.c
   111     platform_unix.c
   139     src/platform_macosx.c
   112     platform_macosx.c
   140     src/platform_windows.c
   113     platform_windows.c
   141     src/archiver_dir.c
   114     archiver_dir.c
   142     src/archiver_unpacked.c
   115     archiver_unpacked.c
   143     src/archiver_grp.c
   116     archiver_grp.c
   144     src/archiver_hog.c
   117     archiver_hog.c
   145     src/archiver_lzma.c
   118     archiver_lzma.c
   146     src/archiver_mvl.c
   119     archiver_mvl.c
   147     src/archiver_qpak.c
   120     archiver_qpak.c
   148     src/archiver_wad.c
   121     archiver_wad.c
   149     src/archiver_zip.c
   122     archiver_zip.c
   150     src/archiver_iso9660.c
   123     archiver_iso9660.c
   151     ${PHYSFS_BEOS_SRCS}
   124     ${PHYSFS_BEOS_SRCS}
   152     ${PHYSFS_HEDGE_SRCS} ##
       
   153 )
   125 )
   154 
   126 
   155 
   127 
   156 # platform layers ...
   128 # platform layers ...
   157 
   129 
   230 if(PHYSFS_ARCHIVE_ZIP)
   202 if(PHYSFS_ARCHIVE_ZIP)
   231     add_definitions(-DPHYSFS_SUPPORTS_ZIP=1)
   203     add_definitions(-DPHYSFS_SUPPORTS_ZIP=1)
   232     set(PHYSFS_FEATURES "ZIP")
   204     set(PHYSFS_FEATURES "ZIP")
   233 endif(PHYSFS_ARCHIVE_ZIP)
   205 endif(PHYSFS_ARCHIVE_ZIP)
   234 
   206 
   235 option(PHYSFS_ARCHIVE_7Z "Enable 7zip support" FALSE)
       
   236 if(PHYSFS_ARCHIVE_7Z)
       
   237     add_definitions(-DPHYSFS_SUPPORTS_7Z=1)
       
   238     list(APPEND PHYSFS_SRCS ${LZMA_SRCS})
       
   239     set(PHYSFS_FEATURES "${PHYSFS_FEATURES} 7zip")
       
   240 endif(PHYSFS_ARCHIVE_7Z)
       
   241 
       
   242 option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
   207 option(PHYSFS_ARCHIVE_GRP "Enable Build Engine GRP support" TRUE)
   243 if(PHYSFS_ARCHIVE_GRP)
   208 if(PHYSFS_ARCHIVE_GRP)
   244     add_definitions(-DPHYSFS_SUPPORTS_GRP=1)
   209     add_definitions(-DPHYSFS_SUPPORTS_GRP=1)
   245     set(PHYSFS_FEATURES "${PHYSFS_FEATURES} GRP")
   210     set(PHYSFS_FEATURES "${PHYSFS_FEATURES} GRP")
   246 endif(PHYSFS_ARCHIVE_GRP)
   211 endif(PHYSFS_ARCHIVE_GRP)
   272 option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
   237 option(PHYSFS_ARCHIVE_ISO9660 "Enable ISO9660 support" TRUE)
   273 if(PHYSFS_ARCHIVE_ISO9660)
   238 if(PHYSFS_ARCHIVE_ISO9660)
   274     add_definitions(-DPHYSFS_SUPPORTS_ISO9660=1)
   239     add_definitions(-DPHYSFS_SUPPORTS_ISO9660=1)
   275     set(PHYSFS_FEATURES "${PHYSFS_FEATURES} CD-ROM")
   240     set(PHYSFS_FEATURES "${PHYSFS_FEATURES} CD-ROM")
   276 endif(PHYSFS_ARCHIVE_ISO9660)
   241 endif(PHYSFS_ARCHIVE_ISO9660)
       
   242 
   277 
   243 
   278 ##as needed by Hedgewars configuration
   244 ##as needed by Hedgewars configuration
   279 if(WINDOWS)
   245 if(WINDOWS)
   280     option(PHYSFS_BUILD_STATIC "Build static library" FALSE)
   246     option(PHYSFS_BUILD_STATIC "Build static library" FALSE)
   281     option(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
   247     option(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
   286 endif(WINDOWS)
   252 endif(WINDOWS)
   287 
   253 
   288 if(PHYSFS_BUILD_STATIC)
   254 if(PHYSFS_BUILD_STATIC)
   289     add_library(physfs STATIC ${PHYSFS_SRCS})
   255     add_library(physfs STATIC ${PHYSFS_SRCS})
   290     set_target_properties(physfs PROPERTIES OUTPUT_NAME "physfs")
   256     set_target_properties(physfs PROPERTIES OUTPUT_NAME "physfs")
       
   257     set(lib_prefix ${CMAKE_STATIC_LIBRARY_PREFIX}) ##
       
   258     set(lib_suffix ${CMAKE_STATIC_LIBRARY_SUFFIX}) ##
   291 endif(PHYSFS_BUILD_STATIC)
   259 endif(PHYSFS_BUILD_STATIC)
   292 
   260 
   293 if(PHYSFS_BUILD_SHARED)
   261 if(PHYSFS_BUILD_SHARED)
   294     add_library(physfs SHARED ${PHYSFS_SRCS})
   262     add_library(physfs SHARED ${PHYSFS_SRCS})
   295     set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
   263     set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
   296     set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
   264     set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
   297     target_link_libraries(physfs ${optionAL_LIBRARY_LIBS} ${OTHER_LDFLAGS})
   265     target_link_libraries(physfs ${optional_library_libs} ${OTHER_LDFLAGS})
   298     install(TARGETS physfs RUNTIME DESTINATION ${target_library_install_dir}) ##
   266     install(TARGETS physfs RUNTIME DESTINATION ${target_library_install_dir}) ##
       
   267     set(lib_prefix ${CMAKE_SHARED_LIBRARY_PREFIX}) ##
       
   268     set(lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX}) ##
   299 endif(PHYSFS_BUILD_SHARED)
   269 endif(PHYSFS_BUILD_SHARED)
   300 
   270 
   301 if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
   271 if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
   302     message(FATAL "Both shared and static libraries are disabled!")
   272     message(FATAL "Both shared and static libraries are disabled!")
   303 endif(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
   273 endif(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
   305 # CMake FAQ says I need this...
   275 # CMake FAQ says I need this...
   306 if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
   276 if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
   307     set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
   277     set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
   308 endif(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
   278 endif(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
   309 
   279 
       
   280 ## added standard variables emulating the FindPhysFS.cmake ones (FORCE or cmake won't pick 'em)
       
   281 set(PHYSFS_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/misc/libphysfs/ CACHE STRING "" FORCE)
       
   282 set(PHYSFS_LIBRARY ${LIBRARY_OUTPUT_PATH}/${lib_prefix}physfs${lib_suffix} CACHE STRING "" FORCE)
       
   283 
       
   284 ## this is to avoid find_package() find the just built library and shadowing it at next cmake run
       
   285 set(PHYSFS_BUNDLE TRUE CACHE STRING "" FORCE)
       
   286 
   310 
   287 
   311 ## removed install, language bindings and test program
   288 ## removed install, language bindings and test program
   312 ## simplified configuration output
   289 ## simplified configuration output
   313 
   290 
   314 message(STATUS "PhysicsFS will build with ${PHYSFS_FEATURES} support")
   291 message(STATUS "PhysFS will be built with ${PHYSFS_FEATURES} support")
   315 
   292