QTfrontend/CMakeLists.txt
branchwebgl
changeset 8330 aaefa587e277
parent 8102 20ef5bf0dc7f
parent 8323 ab0b618bdf13
child 8444 75db7bb8dce8
--- a/QTfrontend/CMakeLists.txt	Sun Dec 02 00:03:16 2012 +0100
+++ b/QTfrontend/CMakeLists.txt	Tue Dec 25 04:45:22 2012 +0100
@@ -11,15 +11,16 @@
 set(QT_USE_QTMAIN TRUE)
 
 find_package(Qt4 REQUIRED)
-if (NOT CROSSAPPLE)
-    include(${QT_USE_FILE})
-endif()
+include(${QT_USE_FILE})
 
 find_package(SDL REQUIRED)       #video in SDLInteraction
 find_package(SDL_mixer REQUIRED) #audio in SDLInteraction
 find_package(SDL_net REQUIRED)   #network frontlib
 if(NOT NOVIDEOREC)
     find_package(FFMPEG)
+    if(${FFMPEG_FOUND})
+        add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS)
+    endif()
 endif()
 
 include_directories(.)
@@ -35,30 +36,24 @@
 include_directories(${FFMPEG_INCLUDE_DIR})
 include_directories(${CMAKE_SOURCE_DIR}/misc/physfs/src)
 include_directories(${CMAKE_SOURCE_DIR}/misc/physfs/extras)
-include_directories(${CMAKE_SOURCE_DIR}/project_files/frontlib)
 if(UNIX)
     # HACK: in freebsd cannot find iconv.h included via SDL.h
     include_directories("/usr/local/include")
 endif(UNIX)
 
-
-if(WIN32 AND NOT UNIX)
-    set(HEDGEWARS_BINDIR ".")
-    set(HEDGEWARS_DATADIR "../share/")
-    add_definitions(-DUSE_XFIRE)
+#directory for resources, relative to the one above on certain platforms/configurations
+if(DEFINED DATA_INSTALL_DIR OR WIN32 OR APPLE)
+    set(HEDGEWARS_DATADIR ${SHAREPATH})
 else()
-    set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX})
-    if(DEFINED DATA_INSTALL_DIR)
-        set(HEDGEWARS_DATADIR ${DATA_INSTALL_DIR})
-    else()
-        set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/share/)
-    endif()
-    #only the cocoa version of qt supports building 64 bit apps
-    if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA))
-        message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X")
-    endif()
+    set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/${SHAREPATH}/)
 endif()
 
+#only the cocoa version of qt supports building 64 bit apps
+if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA))
+    message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X")
+endif()
+#endif()
+
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp)
 
 file(GLOB NetCpp net/*.cpp)
@@ -66,10 +61,6 @@
 file(GLOB_RECURSE UIcpp ui/*.cpp)
 file(GLOB UtilCpp util/*.cpp)
 
-if(${FFMPEG_FOUND})
-    add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS)
-endif()
-
 set(hwfr_src
     ${ModelCpp}
     ${NetCpp}
@@ -97,9 +88,9 @@
 if(MINGW)
     # resource compilation for mingw
     add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o
-    COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR}
-    -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc
-    -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
+                       COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR}
+                               -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc
+                               -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
     set(hwfr_src ${hwfr_src} ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
 else(MINGW)
     set(hwfr_src ${hwfr_src} hedgewars.rc)
@@ -138,15 +129,26 @@
 
 set(hwfr_rez hedgewars.qrc)
 
+if(${BUILD_ENGINE_LIBRARY})
+    add_definitions(-DHWLIBRARY=1)
+    set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
+    set(HW_LINK_LIBS ${hwlibname} ${HW_LINK_LIBS})
+endif()
+
 qt4_add_resources(hwfr_rez_src ${hwfr_rez})
 
 qt4_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs})
 
 
-if(APPLE OR CROSSAPPLE)
-    set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m)
-    set(HW_LINK_LIBS IOKit ${HW_LINK_LIBS})
-
+if(APPLE)
+    find_library(iokit_framework NAMES IOKit)
+    set(HW_LINK_LIBS ${iokit_framework} ${HW_LINK_LIBS})
+    set(hwfr_src ${hwfr_src} CocoaInitializer.mm
+                             InstallController.cpp
+                             M3Panel.mm
+                             M3InstallController.m
+                             NSWorkspace_RBAdditions.m
+                             )
     if(NOT NOAUTOUPDATE)
         find_package(Sparkle)
         if(SPARKLE_FOUND)
@@ -157,28 +159,33 @@
     endif()
 endif()
 
-if(LIBENGINE)
+#when debugging, always prompt a console to see fronted messages
+#TODO: check it doesn't interfere on UNIX
+if(CMAKE_BUILD_TYPE MATCHES "RELEASE")
+    set(console_access "WIN32")
+endif(CMAKE_BUILD_TYPE MATCHES "RELEASE")
+if(${LIBENGINE})
     add_definitions(-DHWLIBRARY)
     set(HW_LINK_LIBS hwengine ${HW_LINK_LIBS})
     link_directories(${EXECUTABLE_OUTPUT_PATH})
 endif()
 
-
-add_executable(hedgewars WIN32
+add_executable(hedgewars ${console_access}
     ${hwfr_src}
     ${hwfr_moc_srcs}
     ${hwfr_hdrs}
     ${hwfr_rez_src}
     )
 
+if((UNIX AND NOT APPLE) AND ${LIBENGINE})
+    set_target_properties(hedgewars PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}")
+endif()
 
 set(HW_LINK_LIBS
     physfs
-    frontlib
     ${QT_LIBRARIES}
     ${SDL_LIBRARY}
     ${SDLMIXER_LIBRARY}
-    ${SDLNET_LIBRARY}
     ${FFMPEG_LIBRARIES}
     ${HW_LINK_LIBS}
     )
@@ -197,13 +204,8 @@
         )
 endif()
 
-
-if (CROSSAPPLE)
-
-else()
-    target_link_libraries(hedgewars ${HW_LINK_LIBS})
-endif()
+target_link_libraries(hedgewars ${HW_LINK_LIBS})
 
 
-install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_dir})
+install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hedgewars${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_binary_install_dir})