--- a/QTfrontend/CMakeLists.txt Tue Dec 18 20:48:37 2012 +0400
+++ b/QTfrontend/CMakeLists.txt Fri Jan 04 21:44:40 2013 +0400
@@ -11,9 +11,7 @@
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
@@ -44,24 +42,20 @@
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 bindir (on linux an absolute path is always used)
+string(SUBSTRING "${SHAREPATH}" 0 1 sharepath_start)
+if(APPLE OR WIN32 OR ${sharepath_start} MATCHES "/")
+ 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)
@@ -69,7 +63,7 @@
file(GLOB_RECURSE UIcpp ui/*.cpp)
file(GLOB UtilCpp util/*.cpp)
-set(hwfr_src
+list(APPEND hwfr_src
${ModelCpp}
${NetCpp}
${UIcpp}
@@ -90,7 +84,7 @@
#xfire integration
if(WIN32)
- set(hwfr_src ${hwfr_src} xfire.cpp ../misc/xfire/xfiregameclient.cpp)
+ list(APPEND hwfr_src xfire.cpp ../misc/xfire/xfiregameclient.cpp)
endif(WIN32)
if(MINGW)
@@ -99,9 +93,9 @@
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)
+ list(APPEND hwfr_src ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o)
else(MINGW)
- set(hwfr_src ${hwfr_src} hedgewars.rc)
+ list(APPEND hwfr_src hedgewars.rc)
endif(MINGW)
file(GLOB ModelHdr model/*.h)
@@ -138,15 +132,21 @@
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}")
+ list(APPEND HW_LINK_LIBS ${hwlibname})
+endif()
+
qt4_add_resources(hwfr_rez_src ${hwfr_rez})
qt4_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs})
-if(APPLE OR CROSSAPPLE)
+if(APPLE)
find_library(iokit_framework NAMES IOKit)
- set(HW_LINK_LIBS ${iokit_framework} ${HW_LINK_LIBS})
- set(hwfr_src ${hwfr_src} CocoaInitializer.mm
+ list(APPEND HW_LINK_LIBS ${iokit_framework})
+ list(APPEND hwfr_src CocoaInitializer.mm
InstallController.cpp
M3Panel.mm
M3InstallController.m
@@ -156,18 +156,12 @@
find_package(Sparkle)
if(SPARKLE_FOUND)
add_definitions(-DSPARKLE_ENABLED)
- set(hwfr_src ${hwfr_src} AutoUpdater.cpp SparkleAutoUpdater.mm)
- set(HW_LINK_LIBS ${SPARKLE_LIBRARY} ${HW_LINK_LIBS})
+ list(APPEND hwfr_src AutoUpdater.cpp SparkleAutoUpdater.mm)
+ list(APPEND HW_LINK_LIBS ${SPARKLE_LIBRARY})
endif()
endif()
endif()
-if(BUILD_ENGINE_LIBRARY)
- add_definitions(-DHWLIBRARY)
- set(HW_LINK_LIBS hwengine ${HW_LINK_LIBS})
- link_directories(${EXECUTABLE_OUTPUT_PATH})
-endif()
-
#when debugging, always prompt a console to see fronted messages
#TODO: check it doesn't interfere on UNIX
if(CMAKE_BUILD_TYPE MATCHES "RELEASE")
@@ -181,8 +175,11 @@
${hwfr_rez_src}
)
+if((UNIX AND NOT APPLE) AND ${BUILD_ENGINE_LIBRARY})
+ set_target_properties(hedgewars PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}")
+endif()
-set(HW_LINK_LIBS
+list(APPEND HW_LINK_LIBS
frontlib
physfs
${QT_LIBRARIES}
@@ -190,16 +187,14 @@
${SDLMIXER_LIBRARY}
${SDLNET_LIBRARY}
${FFMPEG_LIBRARIES}
- ${HW_LINK_LIBS}
)
if(WIN32 AND NOT UNIX)
if(NOT SDL_LIBRARY)
- set(HW_LINK_LIBS ${HW_LINK_LIBS} SDL)
+ list(APPEND HW_LINK_LIBS SDL)
endif()
- set(HW_LINK_LIBS
- ${HW_LINK_LIBS}
+ list(APPEND HW_LINK_LIBS
ole32
oleaut32
winspool
@@ -207,11 +202,8 @@
)
endif()
-
-if (NOT CROSSAPPLE)
- 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})