misc/libphysfs/CMakeLists.txt
branchwebgl
changeset 9236 ddd675825672
parent 9197 e4e366013e9a
parent 9224 bce8cf41d666
child 11376 5375b9168fc2
equal deleted inserted replaced
9201:bcf2f7798ebb 9236:ddd675825672
    31 endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
    31 endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
    32 
    32 
    33 include(CheckIncludeFile)
    33 include(CheckIncludeFile)
    34 include(CheckLibraryExists)
    34 include(CheckLibraryExists)
    35 include(CheckCSourceCompiles)
    35 include(CheckCSourceCompiles)
    36 
       
    37 
       
    38 # 32bit platforms won't link unless this is set
       
    39 # although Windows doesn't like it
       
    40 if(NOT WINDOWS)
       
    41     if(CMAKE_SIZEOF_VOID_P LESS 8)
       
    42         add_definitions(-DPHYSFS_NO_64BIT_SUPPORT=1)
       
    43     endif(CMAKE_SIZEOF_VOID_P LESS 8)
       
    44 endif(NOT WINDOWS)
       
    45 
    36 
    46 
    37 
    47 if(MACOSX)
    38 if(MACOSX)
    48     # 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...
    49     if(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
    40     if(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
    59     list(APPEND OTHER_LDFLAGS ${iokit_framework})
    50     list(APPEND OTHER_LDFLAGS ${iokit_framework})
    60 endif(MACOSX)
    51 endif(MACOSX)
    61 
    52 
    62 # Add some gcc-specific command lines.
    53 # Add some gcc-specific command lines.
    63 if(CMAKE_COMPILER_IS_GNUCC)
    54 if(CMAKE_COMPILER_IS_GNUCC)
    64     # Always build with debug symbols...you can strip it later.
    55     # Always build with debug symbols... you can strip it later.
    65     add_definitions(-g -fsigned-char)
    56     add_definitions(-g -fsigned-char)
    66 
       
    67     # Stupid BeOS generates warnings in the system headers.
       
    68     if(NOT BEOS)
       
    69         add_definitions(-Wall)
       
    70     endif(NOT BEOS)
       
    71 
       
    72     CHECK_C_SOURCE_COMPILES("
       
    73         #if ((defined(__GNUC__)) && (__GNUC__ >= 4))
       
    74         int main(int argc, char **argv) { int is_gcc4 = 1; return 0; }
       
    75         #else
       
    76         #error This is not gcc4.
       
    77         #endif
       
    78     " PHYSFS_IS_GCC4)
       
    79 
       
    80     if(PHYSFS_IS_GCC4)
       
    81         # Not supported on several operating systems at this time.
       
    82         if(NOT SOLARIS AND NOT WINDOWS)
       
    83             add_definitions(-fvisibility=hidden)
       
    84         endif(NOT SOLARIS AND NOT WINDOWS)
       
    85     endif(PHYSFS_IS_GCC4)
       
    86 
       
    87     # Don't use -rpath.
       
    88     set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
       
    89 endif(CMAKE_COMPILER_IS_GNUCC)
    57 endif(CMAKE_COMPILER_IS_GNUCC)
    90 
    58 
    91 if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
    59 if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
    92     add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT)
    60     add_definitions(-erroff=E_EMPTY_TRANSLATION_UNIT)
    93     add_definitions(-xldscope=hidden)
    61     add_definitions(-xldscope=hidden)
   178 endif(UNIX)
   146 endif(UNIX)
   179 
   147 
   180 if(WINDOWS)
   148 if(WINDOWS)
   181     set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
   149     set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
   182     set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
   150     set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
       
   151     list(APPEND OTHER_LDFLAGS ${SDL_LIBRARY})
   183 endif(WINDOWS)
   152 endif(WINDOWS)
   184 
   153 
   185 if(NOT PHYSFS_HAVE_CDROM_SUPPORT)
   154 if(NOT PHYSFS_HAVE_CDROM_SUPPORT)
   186     add_definitions(-DPHYSFS_NO_CDROM_SUPPORT=1)
   155     add_definitions(-DPHYSFS_NO_CDROM_SUPPORT=1)
   187     message(WARNING " ***")
   156     message(WARNING " ***")
   250 #    add_definitions(-DPHYSFS_SUPPORTS_ISO9660=1)
   219 #    add_definitions(-DPHYSFS_SUPPORTS_ISO9660=1)
   251 #    set(PHYSFS_FEATURES "${PHYSFS_FEATURES} CD-ROM")
   220 #    set(PHYSFS_FEATURES "${PHYSFS_FEATURES} CD-ROM")
   252 #endif(PHYSFS_ARCHIVE_ISO9660)
   221 #endif(PHYSFS_ARCHIVE_ISO9660)
   253 
   222 
   254 
   223 
   255 ##as needed by Hedgewars configuration
   224 ##Hedgewars modifications
   256 if(WINDOWS)
   225 add_library(physfs ${PHYSFS_SRCS})
   257     option(PHYSFS_BUILD_STATIC "Build static library" FALSE)
   226 set_target_properties(physfs PROPERTIES
   258     option(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
   227                           VERSION ${PHYSFS_VERSION}
   259     list(APPEND OTHER_LDFLAGS ${SDL_LIBRARY})
   228                           SOVERSION ${PHYSFS_SOVERSION}
   260 else(WINDOWS)
   229                           OUTPUT_NAME ${physfs_output_name})
   261     option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
   230 target_link_libraries(physfs ${optional_library_libs} ${OTHER_LDFLAGS})
   262     option(PHYSFS_BUILD_SHARED "Build shared library" FALSE)
   231 install(TARGETS physfs RUNTIME DESTINATION ${target_binary_install_dir}
   263 endif(WINDOWS)
   232                        LIBRARY DESTINATION ${target_library_install_dir}
   264 
   233                        ARCHIVE DESTINATION ${target_library_install_dir})
   265 if(PHYSFS_BUILD_STATIC)
   234 get_target_property(physfs_fullpath physfs LOCATION)
   266     add_library(physfs STATIC ${PHYSFS_SRCS})
       
   267     set_target_properties(physfs PROPERTIES OUTPUT_NAME ${physfs_output_name}) ##
       
   268     set(lib_prefix ${CMAKE_STATIC_LIBRARY_PREFIX}) ##
       
   269     set(lib_suffix ${CMAKE_STATIC_LIBRARY_SUFFIX}) ##
       
   270 endif(PHYSFS_BUILD_STATIC)
       
   271 
       
   272 if(PHYSFS_BUILD_SHARED)
       
   273     add_library(physfs SHARED ${PHYSFS_SRCS})
       
   274     set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
       
   275     set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
       
   276     set_target_properties(physfs PROPERTIES OUTPUT_NAME ${physfs_output_name}) ##
       
   277     target_link_libraries(physfs ${optional_library_libs} ${OTHER_LDFLAGS})
       
   278     install(TARGETS physfs RUNTIME DESTINATION ${target_library_install_dir}) ##
       
   279     set(lib_prefix ${CMAKE_SHARED_LIBRARY_PREFIX}) ##
       
   280     set(lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX}) ##
       
   281 endif(PHYSFS_BUILD_SHARED)
       
   282 
       
   283 if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
       
   284     message(FATAL "Both shared and static libraries are disabled!")
       
   285 endif(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
       
   286 
       
   287 # CMake FAQ says I need this...
       
   288 if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
       
   289     set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
       
   290 endif(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
       
   291 
   235 
   292 ## added standard variables emulating the FindPhysFS.cmake ones (FORCE or cmake won't pick 'em)
   236 ## added standard variables emulating the FindPhysFS.cmake ones (FORCE or cmake won't pick 'em)
   293 set(PHYSFS_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/misc/libphysfs/ CACHE STRING "" FORCE)
   237 set(PHYSFS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Physfs include dir" FORCE)
   294 set(PHYSFS_LIBRARY ${LIBRARY_OUTPUT_PATH}/${lib_prefix}${physfs_output_name}${lib_suffix} CACHE STRING "" FORCE)
   238 set(PHYSFS_LIBRARY ${physfs_fullpath} CACHE STRING "Physfs library path" FORCE)
   295 
   239 
   296 
   240 
   297 ## removed install, language bindings and test program
   241 ## removed language bindings and test program
   298 ## simplified configuration output
   242 ## simplified configuration output
       
   243 ## merged shared and static library building
   299 
   244 
   300 #message(STATUS "PhysFS will be built with ${PHYSFS_FEATURES} support")
   245 #message(STATUS "PhysFS will be built with ${PHYSFS_FEATURES} support")
   301 
   246