]> git.jsancho.org Git - lugaru.git/blobdiff - CMakeLists.txt
Merged FMod changes in
[lugaru.git] / CMakeLists.txt
index 700e9f49debf96fdbb681c44f12c269821405d32..360148bdc0309d71cca6d795752c0632858630f2 100644 (file)
@@ -106,19 +106,19 @@ if(WIN32)
   if(CMAKE_CROSSCOMPILING)
     ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
                                                  COMMAND i686-pc-mingw32-windres
-                                                         -I${CMAKE_CURRENT_SOURCE_DIR}/res
+                                                         -I${SRCDIR}/res
                                                          -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
-                                                         -i${CMAKE_CURRENT_SOURCE_DIR}/res/lugaru.rc
-                                             DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/res/lugaru.rc
+                                                         -i${SRCDIR}/res/Lugaru.rc
+                                             DEPENDS ${SRCDIR}/res/Lugaru.rc
                                                  )
   endif(CMAKE_CROSSCOMPILING)
   if(NOT CMAKE_CROSSCOMPILING)
     ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
                                                  COMMAND windres
-                                                         -I${CMAKE_CURRENT_SOURCE_DIR}/res
+                                                         -I${SRCDIR}/res
                                                          -o ${CMAKE_CURRENT_BINARY_DIR}/lugaru_resource.obj
-                                                         -i${CMAKE_CURRENT_SOURCE_DIR}/res/lugaru.rc
-                                             DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/res/lugaru.rc
+                                                         -i${SRCDIR}/res/Lugaru.rc
+                                             DEPENDS ${SRCDIR}/res/Lugaru.rc
                                                  )
   endif(NOT CMAKE_CROSSCOMPILING)
 
@@ -143,14 +143,17 @@ endif (APPLE)
 
 find_package(OpenGL REQUIRED)
 # force this include dir no matter what, so we get sane headers.
-set(OPENGL_INCLUDE_DIR "${DEPDIR}/OpenGL")
+include_directories("${DEPDIR}/OpenGL")
 
 find_package(OpenAL REQUIRED)  # !!! FIXME: package a .dll for Windows?
 
-find_package(SDL)
-if (NOT SDL)
+option (LUGARU_FORCE_INTERNAL_SDL "Force internal libSDL, even if there's a system version" False)
+if (NOT LUGARU_FORCE_INTERNAL_SDL)
+    find_package(SDL)
+endif (NOT LUGARU_FORCE_INTERNAL_SDL)
+if (NOT SDL_FOUND)
+    message(STATUS "Using internal copy of SDL")
     set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} SDL")
-    message(STATUS "SDL not found, using internal copy")
     set(SDLDIR "${DEPDIR}/SDL12")
     set(SDL_INCLUDE_DIR "${SDLDIR}/include")
     set(SDL_LIBRARY "")
@@ -164,21 +167,32 @@ if (NOT SDL)
 
     if (WINDOWS)
         set(LUGARU_HAS_INTERNAL_SDL True)
-        set(SDL_LIBRARY
-            ${SDLDIR}/lib/win32/SDL.lib
-            ${SDLDIR}/lib/win32/SDLmain.lib
-        )
+        if (MSVC)
+          set(SDL_LIBRARY
+              ${SDLDIR}/lib/win32/msvc/SDL.lib
+              ${SDLDIR}/lib/win32/msvc/SDLmain.lib
+          )
+        endif (MSVC)
+        if (MINGW)
+          set(SDL_LIBRARY
+              ${SDLDIR}/lib/win32/mingw/libSDL.dll.a
+              ${SDLDIR}/lib/win32/mingw/libSDLmain.a
+          )
+        endif (MINGW)
     endif (WINDOWS)
 
     if (NOT LUGARU_HAS_INTERNAL_SDL)
         message(ERROR "We don't have a prebuilt SDL for this platform.")
     endif (NOT LUGARU_HAS_INTERNAL_SDL)
-endif (NOT SDL)
-
-find_package(PNG)
-if (NOT PNG)
+endif (NOT SDL_FOUND)
+
+option (LUGARU_FORCE_INTERNAL_PNG "Force internal libPNG, even if there's a system version" False)
+if (NOT LUGARU_FORCE_INTERNAL_PNG)
+    find_package(PNG)
+endif (NOT LUGARU_FORCE_INTERNAL_PNG)
+if (NOT PNG_FOUND)
+    message(STATUS "Using internal copy of libpng")
     set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} PNG")
-    message(STATUS "libpng not found, using internal copy")
     set(PNGDIR "${DEPDIR}/libpng")
     set(PNG_INCLUDE_DIR "${PNGDIR}")
     set(PNG_LIBRARY "")
@@ -200,12 +214,15 @@ if (NOT PNG)
         ${PNGDIR}/pngwtran.c
         ${PNGDIR}/pngwutil.c
     )
-endif (NOT PNG)
-
-find_package(JPEG)
-if (NOT JPEG)
+endif (NOT PNG_FOUND)
+
+option (LUGARU_FORCE_INTERNAL_JPEG "Force internal libJPEG, even if there's a system version" False)
+if (NOT LUGARU_FORCE_INTERNAL_JPEG)
+    find_package(JPEG)
+endif (NOT LUGARU_FORCE_INTERNAL_JPEG)
+if (NOT JPEG_FOUND)
+    message(STATUS "Using internal copy of libjpeg")
     set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} JPEG")
-    message(STATUS "libjpeg not found, using internal copy")
     set(JPEGDIR "${DEPDIR}/libjpeg")
     set(JPEG_INCLUDE_DIR "${JPEGDIR}")
     set(JPEG_LIBRARY "")
@@ -257,12 +274,15 @@ if (NOT JPEG)
         ${JPEGDIR}/jdarith.c
         ${JPEGDIR}/jaricom.c
     )
-endif (NOT JPEG)
-
-find_package(ZLIB)
-if (NOT ZLIB)
+endif (NOT JPEG_FOUND)
+
+option (LUGARU_FORCE_INTERNAL_ZLIB "Force internal zlib, even if there's a system version" False)
+if (NOT LUGARU_FORCE_INTERNAL_ZLIB)
+    find_package(ZLIB)
+endif (NOT LUGARU_FORCE_INTERNAL_ZLIB)
+if (NOT ZLIB_FOUND)
+    message(STATUS "Using internal copy of zlib")
     set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} ZLIB")
-    message(STATUS "zlib not found, using internal copy")
     set(ZLIBDIR "${DEPDIR}/zlib")
     set(ZLIB_INCLUDE_DIR "${ZLIBDIR}")
     set(ZLIB_LIBRARIES "")
@@ -280,12 +300,15 @@ if (NOT ZLIB)
         ${ZLIBDIR}/uncompr.c
         ${ZLIBDIR}/zutil.c
     )
-endif (NOT ZLIB)
-
-find_package(GLU)
-if (NOT GLU)
+endif (NOT ZLIB_FOUND)
+
+option (LUGARU_FORCE_INTERNAL_GLU "Force internal libGLU, even if there's a system version" False)
+if (NOT LUGARU_FORCE_INTERNAL_GLU)
+    find_package(GLU)
+endif (NOT LUGARU_FORCE_INTERNAL_GLU)
+if (NOT GLU_FOUND)
+    message(STATUS "Using internal copy of libGLU")
     set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} GLU")
-    message(STATUS "GLU not found, using internal copy")
     set(GLUDIR "${DEPDIR}/GLU")
     set(GLU_INCLUDE_DIR "${GLUDIR}")
     set(GLU_LIBRARY "")
@@ -304,12 +327,15 @@ if (NOT GLU)
         ${GLUDIR}/tessmono.c
         ${GLUDIR}/util.c
     )
-endif (NOT GLU)
-
-find_package(OggVorbis)
-if (NOT OggVorbis)
+endif (NOT GLU_FOUND)
+
+option (LUGARU_FORCE_INTERNAL_VORBIS "Force internal Vorbis, even if there's a system version" False)
+if (NOT LUGARU_FORCE_INTERNAL_VORBIS)
+    find_package(OggVorbis)
+endif (NOT LUGARU_FORCE_INTERNAL_VORBIS)
+if (NOT OggVorbis_FOUND)
+    message(STATUS "Using internal copy of Ogg Vorbis")
     set(LUGARU_MISSING_DEPS "${LUGARU_MISSING_DEPS} OggVorbis")
-    message(STATUS "Ogg Vorbis not found, using internal copy")
     set(OGGDIR "${DEPDIR}/libogg")
     set(OGG_INCLUDE_DIR "${OGGDIR}/include")
     set(OGG_LIBRARY "")
@@ -341,7 +367,7 @@ if (NOT OggVorbis)
         ${VORBISDIR}/lib/vorbisfile.c
         ${VORBISDIR}/lib/window.c
     )
-endif (NOT OggVorbis)
+endif (NOT OggVorbis_FOUND)
 
 include_directories(
     ${OPENAL_INCLUDE_DIR}
@@ -376,6 +402,12 @@ endif(WIN32)
 # Install target
 if(WIN32)
        install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/Source/lugaru.exe DESTINATION ${CMAKE_INSTALL_PREFIX})
+       if(MSVC)
+               install(FILES ${SDLDIR}/lib/win32/msvc/SDL.dll DESTINATION ${CMAKE_INSTALL_PREFIX})
+       endif(MSVC)
+       if(MINGW)
+               install(FILES ${SDLDIR}/lib/win32/mingw/SDL.dll DESTINATION ${CMAKE_INSTALL_PREFIX})
+       endif(MINGW)
 else(WIN32)
        install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/Source/lugaru DESTINATION ${CMAKE_INSTALL_PREFIX})
 endif(WIN32)