--- a/CMakeLists.txt Wed Jun 12 19:15:51 2013 +0200
+++ b/CMakeLists.txt Thu Jun 13 14:44:28 2013 +0200
@@ -1,7 +1,7 @@
project(hedgewars)
#initialise cmake environment
-cmake_minimum_required(VERSION 2.6.0)
+cmake_minimum_required(VERSION 2.6.4)
foreach(hwpolicy CMP0003 CMP0012 CMP0017 CMP0018)
if(POLICY ${hwpolicy})
cmake_policy(SET ${hwpolicy} NEW)
@@ -16,9 +16,17 @@
option(NOPNG "Disable screenshoot compression (off)" OFF)
option(NOVIDEOREC "Disable video recording (off)" OFF)
+#libraries are built shared unless explicitly added as a static
+option(BUILD_SHARED_LIBS "Build libraries as shared modules (on)" ON)
#set this to ON when 2.1.0 becomes more widespread (and only for linux)
option(PHYSFS_SYSTEM "Use system physfs (off)" OFF)
+if(WIN32 OR APPLE)
+ option(LUA_SYSTEM "Use system lua (off)" OFF)
+else()
+ option(LUA_SYSTEM "Use system lua (on)" ON)
+endif()
+
option(BUILD_ENGINE_LIBRARY "Enable hwengine library (off)" OFF)
option(ANDROID "Enable Android build (off)" OFF)
@@ -46,40 +54,9 @@
message(STATUS "Building ${HEDGEWARS_VERSION}-r${HEDGEWARS_REVISION} (${HEDGEWARS_HASH})")
-#where to build libs and bins
-set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
-set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
-
-#resource paths
-if(UNIX AND NOT APPLE)
- set(target_binary_install_dir "bin")
- set(target_library_install_dir "lib")
-
- string(SUBSTRING "${DATA_INSTALL_DIR}" 0 1 sharepath_start)
- if (NOT (${sharepath_start} MATCHES "/"))
- set(HEDGEWARS_DATADIR "${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/")
- else()
- set(HEDGEWARS_DATADIR "${DATA_INSTALL_DIR}/")
- endif()
- set(HEDGEWARS_FULL_DATADIR "${HEDGEWARS_DATADIR}")
-else()
- set(target_binary_install_dir "./")
-
- if(APPLE)
- set(target_library_install_dir "../Frameworks/")
- set(CMAKE_INSTALL_PREFIX "Hedgewars.app/Contents/MacOS/")
- set(HEDGEWARS_DATADIR "../Resources/")
- set(HEDGEWARS_FULL_DATADIR "/Applications/${CMAKE_INSTALL_PREFIX}/${HEDGEWARS_DATADIR}")
- elseif(WIN32)
- set(target_library_install_dir "./")
- set(HEDGEWARS_DATADIR "./")
- set(HEDGEWARS_FULL_DATADIR "${CMAKE_INSTALL_PREFIX}/")
- link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
- endif()
-endif()
-
#platform specific init code
include(${CMAKE_MODULE_PATH}/platform.cmake)
+include(${CMAKE_MODULE_PATH}/paths.cmake)
#when build type is not specified, assume Debug/Release according to build version information
@@ -101,16 +78,16 @@
if(NOT ${MINIMAL_FLAGS})
set(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_C_FLAGS_RELEASE}")
- set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g -DDEBUG ${CMAKE_C_FLAGS_DEBUG}")
- set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
- set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
- set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+ set(CMAKE_C_FLAGS_DEBUG "-Wall -O0 -g ${CMAKE_C_FLAGS_DEBUG}")
+ set(CMAKE_CXX_FLAGS "-pipe ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS_RELEASE "-w -Os -fomit-frame-pointer ${CMAKE_CXX_FLAGS_RELEASE}")
+ set(CMAKE_CXX_FLAGS_DEBUG "-Wall -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}")
else()
#CMake adds a lot of additional configuration flags, so let's clear them up
set(CMAKE_C_FLAGS_RELEASE "")
- set(CMAKE_C_FLAGS_DEBUG "-Wall -DDEBUG")
+ set(CMAKE_C_FLAGS_DEBUG "-Wall")
set(CMAKE_CXX_FLAGS_RELEASE "")
- set(CMAKE_CXX_FLAGS_DEBUG "-Wall -DDEBUG")
+ set(CMAKE_CXX_FLAGS_DEBUG "-Wall")
endif()
#parse additional parameters
@@ -164,14 +141,23 @@
include(${CMAKE_MODULE_PATH}/utils.cmake)
#lua discovery
-find_package(Lua)
-if(LUA_FOUND)
- message(STATUS "Found LUA: ${LUA_DEFAULT}")
+if (${LUA_SYSTEM})
+ if (NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
+ find_package(Lua)
+ endif()
+
+ if (LUA_LIBRARY AND LUA_INCLUDE_DIR)
+ set(LUA_FOUND TRUE)
+ else()
+ message(FATAL_ERROR "Missing Lua! Rerun cmake with -DLUA_SYSTEM=off to build the internal version")
+ endif()
else()
- message(STATUS "LUA will be provided by the bundled sources")
+ if (NOT LUA_LIBRARY OR NOT LUA_INCLUDE_DIR)
+ message(STATUS "LUA will be provided by the bundled sources")
+ endif()
+ set(lua_output_name "hwlua")
add_subdirectory(misc/liblua)
- #linking with liblua.a requires system readline
- list(APPEND pascal_flags "-k${EXECUTABLE_OUTPUT_PATH}/lib${LUA_LIBRARY}.a" "-k-lreadline")
+ list(APPEND pascal_flags "-XLAlua=${lua_output_name}" "-dLUA_INTERNAL")
endif()
@@ -201,8 +187,10 @@
message(FATAL_ERROR "Missing PhysFS! Rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version")
endif()
else()
- message(STATUS "PhysFS will be provided by the bundled sources")
- set(physfs_output_name "hw_physfs")
+ if (NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR)
+ message(STATUS "PhysFS will be provided by the bundled sources")
+ endif()
+ set(physfs_output_name "hwphysfs")
add_subdirectory(misc/libphysfs)
#-XLA is a beta fpc flag that renames libraries before passing them to the linker
#we also have to pass PHYSFS_INTERNAL to satisfy windows runtime requirements
--- a/QTfrontend/CMakeLists.txt Wed Jun 12 19:15:51 2013 +0200
+++ b/QTfrontend/CMakeLists.txt Thu Jun 13 14:44:28 2013 +0200
@@ -189,10 +189,6 @@
${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()
-
list(APPEND HW_LINK_LIBS
${PHYSFS_LIBRARY}
${PHYSLAYER_LIBRARY}
--- a/QTfrontend/campaign.cpp Wed Jun 12 19:15:51 2013 +0200
+++ b/QTfrontend/campaign.cpp Thu Jun 13 14:44:28 2013 +0200
@@ -53,11 +53,11 @@
QString getCampaignImage(QString campaign, unsigned int mNum)
{
- return getCampaignScript(campaign,mNum).replace(QString(".lua"),QString(".png"));
+ return getCampaignScript(campaign,mNum).replace(QString(".lua"),QString(".png"));
}
-QString getCampaignMissionName(QString campaign, unsigned int mNum)
+QString getCampaignMissionName(QString campaign, unsigned int mNum)
{
- return getCampaignScript(campaign,mNum).replace(QString(".lua"),QString(""));
+ return getCampaignScript(campaign,mNum).replace(QString(".lua"),QString(""));
}
--- a/QTfrontend/hwform.cpp Wed Jun 12 19:15:51 2013 +0200
+++ b/QTfrontend/hwform.cpp Thu Jun 13 14:44:28 2013 +0200
@@ -194,8 +194,8 @@
//connect (updateData, SIGNAL(activated()), &DataManager::instance(), SLOT(reload()));
#endif
- previousCampaignName = "";
- previousTeamName = "";
+ previousCampaignName = "";
+ previousTeamName = "";
UpdateTeamsLists();
InitCampaignPage();
UpdateCampaignPage(0);
@@ -1894,7 +1894,7 @@
void HWForm::UpdateCampaignPage(int index)
{
Q_UNUSED(index);
-
+
HWTeam team(ui.pageCampaign->CBTeam->currentText());
ui.pageCampaign->CBMission->clear();
@@ -1903,61 +1903,61 @@
QString tName = team.name();
unsigned int n = missionEntries.count();
unsigned int m = getCampProgress(tName, campaignName);
-
+
// if the campaign name changes update the campaignMissionDescriptions list
// this will be used later in UpdateCampaignPageMission() to update
// the mission description in the campaign page
bool updateMissionList = false;
QSettings * m_info;
- if(previousCampaignName.compare(campaignName)!=0 ||
- previousTeamName.compare(tName) != 0)
+ if(previousCampaignName.compare(campaignName)!=0 ||
+ previousTeamName.compare(tName) != 0)
{
- if (previousTeamName.compare(tName) != 0 &&
- previousTeamName.compare("") != 0)
- index = qMin(m + 1, n);
- previousCampaignName = campaignName;
- previousTeamName = tName;
- updateMissionList = true;
- // the following code was based on pagetraining.cpp
- DataManager & dataMgr = DataManager::instance();
- // get locale
- QSettings settings(dataMgr.settingsFileName(),
- QSettings::IniFormat);
- QString loc = settings.value("misc/locale", "").toString();
- if (loc.isEmpty())
- loc = QLocale::system().name();
- QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt");
- // if file is non-existant try with language only
- if (!QFile::exists(campaignDescFile))
- campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt");
+ if (previousTeamName.compare(tName) != 0 &&
+ previousTeamName.compare("") != 0)
+ index = qMin(m + 1, n);
+ previousCampaignName = campaignName;
+ previousTeamName = tName;
+ updateMissionList = true;
+ // the following code was based on pagetraining.cpp
+ DataManager & dataMgr = DataManager::instance();
+ // get locale
+ QSettings settings(dataMgr.settingsFileName(),
+ QSettings::IniFormat);
+ QString loc = settings.value("misc/locale", "").toString();
+ if (loc.isEmpty())
+ loc = QLocale::system().name();
+ QString campaignDescFile = QString("physfs://Locale/campaigns_" + loc + ".txt");
+ // if file is non-existant try with language only
+ if (!QFile::exists(campaignDescFile))
+ campaignDescFile = QString("physfs://Locale/campaigns_" + loc.remove(QRegExp("_.*$")) + ".txt");
- // fallback if file for current locale is non-existant
- if (!QFile::exists(campaignDescFile))
- campaignDescFile = QString("physfs://Locale/campaigns_en.txt");
-
- m_info = new QSettings(campaignDescFile, QSettings::IniFormat, this);
- m_info->setIniCodec("UTF-8");
- campaignMissionDescriptions.clear();
- ui.pageCampaign->CBMission->clear();
- }
-
+ // fallback if file for current locale is non-existant
+ if (!QFile::exists(campaignDescFile))
+ campaignDescFile = QString("physfs://Locale/campaigns_en.txt");
+
+ m_info = new QSettings(campaignDescFile, QSettings::IniFormat, this);
+ m_info->setIniCodec("UTF-8");
+ campaignMissionDescriptions.clear();
+ ui.pageCampaign->CBMission->clear();
+ }
+
for (unsigned int i = qMin(m + 1, n); i > 0; i--)
{
- if(updateMissionList)
+ if(updateMissionList)
{
- campaignMissionDescriptions += m_info->value(campaignName+"-"+ getCampaignMissionName(campaignName,i) + ".desc",
+ campaignMissionDescriptions += m_info->value(campaignName+"-"+ getCampaignMissionName(campaignName,i) + ".desc",
tr("No description available")).toString();
- }
- ui.pageCampaign->CBMission->addItem(QString("Mission %1: ").arg(i) + QString(missionEntries[i-1]), QString(missionEntries[i-1]));
+ }
+ ui.pageCampaign->CBMission->addItem(QString("Mission %1: ").arg(i) + QString(missionEntries[i-1]), QString(missionEntries[i-1]));
}
if(updateMissionList)
- delete m_info;
+ delete m_info;
UpdateCampaignPageMission(index);
}
-void HWForm::UpdateCampaignPageMission(int index)
-{
+void HWForm::UpdateCampaignPageMission(int index)
+{
// update thumbnail
QString campaignName = ui.pageCampaign->CBCampaign->currentText();
unsigned int mNum = ui.pageCampaign->CBMission->count() - ui.pageCampaign->CBMission->currentIndex();
@@ -1967,9 +1967,9 @@
// when campaign changes the UpdateCampaignPageMission is triggered with wrong values
// this will cause segfault. This check prevents illegal memory reads
if(index > -1 && index < campaignMissionDescriptions.count()) {
- ui.pageCampaign->lbltitle->setText("<h2>"+ui.pageCampaign->CBMission->currentText()+"</h2>");
- ui.pageCampaign->lbldescription->setText(campaignMissionDescriptions[index]);
- }
+ ui.pageCampaign->lbltitle->setText("<h2>"+ui.pageCampaign->CBMission->currentText()+"</h2>");
+ ui.pageCampaign->lbldescription->setText(campaignMissionDescriptions[index]);
+ }
}
void HWForm::UpdateCampaignPageProgress(int index)
--- a/QTfrontend/net/tcpBase.cpp Wed Jun 12 19:15:51 2013 +0200
+++ b/QTfrontend/net/tcpBase.cpp Thu Jun 13 14:44:28 2013 +0200
@@ -134,7 +134,7 @@
connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError)));
QStringList arguments=getArguments();
-#ifdef DEBUG
+#ifdef QT_DEBUG
// redirect everything written on stdout/stderr
process->setProcessChannelMode(QProcess::ForwardedChannels);
#endif
--- a/QTfrontend/ui/page/pagecampaign.cpp Wed Jun 12 19:15:51 2013 +0200
+++ b/QTfrontend/ui/page/pagecampaign.cpp Thu Jun 13 14:44:28 2013 +0200
@@ -31,7 +31,7 @@
pageLayout->setColumnStretch(2, 1);
pageLayout->setRowStretch(0, 1);
pageLayout->setRowStretch(3, 1);
-
+
QGridLayout * infoLayout = new QGridLayout();
infoLayout->setColumnStretch(0, 1);
infoLayout->setColumnStretch(1, 1);
@@ -40,27 +40,27 @@
infoLayout->setColumnStretch(4, 1);
infoLayout->setRowStretch(0, 1);
infoLayout->setRowStretch(1, 1);
-
+
// set this as default image first time page is created, this will change in hwform.cpp
btnPreview = formattedButton(":/res/campaign/A Classic Fairytale/first_blood.png", true);
- infoLayout->setAlignment(btnPreview, Qt::AlignHCenter | Qt::AlignVCenter);
-
+ infoLayout->setAlignment(btnPreview, Qt::AlignHCenter | Qt::AlignVCenter);
+
lbldescription = new QLabel();
lbldescription->setAlignment(Qt::AlignHCenter| Qt::AlignTop);
lbldescription->setWordWrap(true);
-
+
lbltitle = new QLabel();
lbltitle->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
CBTeam = new QComboBox(this);
CBMission = new QComboBox(this);
CBCampaign = new QComboBox(this);
-
- infoLayout->addWidget(btnPreview,0,1,2,1);
- infoLayout->addWidget(lbltitle,0,2,1,2);
- infoLayout->addWidget(lbldescription,1,2,1,2);
-
- pageLayout->addLayout(infoLayout, 0, 0, 2, 3);
+
+ infoLayout->addWidget(btnPreview,0,1,2,1);
+ infoLayout->addWidget(lbltitle,0,2,1,2);
+ infoLayout->addWidget(lbldescription,1,2,1,2);
+
+ pageLayout->addLayout(infoLayout, 0, 0, 2, 3);
pageLayout->addWidget(CBTeam, 2, 1);
pageLayout->addWidget(CBCampaign, 3, 1);
pageLayout->addWidget(CBMission, 4, 1);
--- a/QTfrontend/ui/page/pagecampaign.h Wed Jun 12 19:15:51 2013 +0200
+++ b/QTfrontend/ui/page/pagecampaign.h Thu Jun 13 14:44:28 2013 +0200
@@ -28,7 +28,7 @@
public:
PageCampaign(QWidget* parent = 0);
- QPushButton *btnPreview;
+ QPushButton *btnPreview;
QPushButton *BtnStartCampaign;
QLabel *lbldescription;
QLabel *lbltitle;
--- a/QTfrontend/ui/page/pagemain.cpp Wed Jun 12 19:15:51 2013 +0200
+++ b/QTfrontend/ui/page/pagemain.cpp Thu Jun 13 14:44:28 2013 +0200
@@ -133,7 +133,7 @@
setAttribute(Qt::WA_NoSystemBackground, true);
mainNote->setOpenExternalLinks(true);
-#ifdef DEBUG
+#ifdef QT_DEBUG
setDefaultDescription(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game, while some features might be broken or incomplete!"));
#else
setDefaultDescription(QLabel::tr("Tip: %1").arg(randomTip()));
--- a/QTfrontend/ui_hwform.cpp Wed Jun 12 19:15:51 2013 +0200
+++ b/QTfrontend/ui_hwform.cpp Thu Jun 13 14:44:28 2013 +0200
@@ -55,7 +55,7 @@
HWForm->resize(QSize(640, 480).expandedTo(HWForm->minimumSizeHint()));
HWForm->setMinimumSize(QSize(720, 450));
QString title = QMainWindow::tr("Hedgewars %1").arg(*cVersionString);
-#ifdef DEBUG
+#ifdef QT_DEBUG
title += QString("-r%1 (%2)").arg(*cRevisionString, *cHashString);
#endif
HWForm->setWindowTitle(title);
--- a/cmake_modules/FindLua.cmake Wed Jun 12 19:15:51 2013 +0200
+++ b/cmake_modules/FindLua.cmake Thu Jun 13 14:44:28 2013 +0200
@@ -1,37 +1,26 @@
-# Find the Lua library
-# --------------------
-# On Android/Windows/OSX this just defines the name of the library that
-# will be compiled from our bundled sources
-# On Linux it will try to load the system library and fallback to compiling
-# the bundled one when nothing is found
-
-set(LUA_FOUND false)
-set(LUA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/misc/liblua)
+# Find liblua
+#
+# Once done this will define
+# LUA_FOUND - system has Lua
+# LUA_INCLUDE_DIR - the Lua include directory
+# LUA_LIBRARY - The library needed to use Lua
+# Copyright (c) 2013, Vittorio Giovara <vittorio.giovara@gmail.com>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
-if (ANDROID)
- SET(LUA_DEFAULT "liblua5.1.so")
-else (ANDROID)
- IF(WIN32)
- SET(LUA_DEFAULT lua.dll)
- ELSE(WIN32)
- IF(APPLE)
- SET(LUA_DEFAULT lua)
- ELSE(APPLE)
- #locate the system's lua library
- FIND_LIBRARY(LUA_DEFAULT NAMES lua51 lua5.1 lua-5.1 lua PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib)
- IF(${LUA_DEFAULT} MATCHES "LUA_DEFAULT-NOTFOUND")
- set(LUA_DEFAULT lua)
- ELSE()
- set(LUA_FOUND true)
- message(STATUS "LibLua 5.1 found at ${LUA_DEFAULT}")
- find_path(LUA_INCLUDE_DIR lua.h)
- #remove the path (fpc doesn't like it - why?)
- GET_FILENAME_COMPONENT(LUA_DEFAULT ${LUA_DEFAULT} NAME)
- ENDIF()
- ENDIF(APPLE)
- ENDIF(WIN32)
-ENDIF(ANDROID)
+include(FindPackageHandleStandardArgs)
-SET(LUA_LIBRARY ${LUA_DEFAULT} CACHE STRING "Lua library to link to; file name without path only!")
+find_path(LUA_INCLUDE_DIR lua.h
+ PATHS /usr/include /usr/local/include /usr/pkg/include
+ PATH_SUFFIXES lua5.1 lua51)
+find_library(LUA_LIBRARY NAMES lua51 lua5.1 lua-5.1 lua
+ PATHS /lib /usr/lib /usr/local/lib /usr/pkg/lib)
+find_package_handle_standard_args(Lua DEFAULT_MSG LUA_LIBRARY LUA_INCLUDE_DIR)
+mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARY)
--- a/cmake_modules/compilerchecks.cmake Wed Jun 12 19:15:51 2013 +0200
+++ b/cmake_modules/compilerchecks.cmake Thu Jun 13 14:44:28 2013 +0200
@@ -17,8 +17,8 @@
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fstack-protector")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fstack-protector")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector-all -fstack-protector")
- set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector")
- set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector")
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fstack-protector-all -fstack-protector")
endif()
#symbol visibility, not supported on Windows (so we error out to avoid spam)
@@ -34,8 +34,10 @@
check_c_compiler_flag("" HAVE_NOEXECSTACK)
if(HAVE_NOEXECSTACK)
list(APPEND pascal_flags "-k-z" "-knoexecstack")
- list(APPEND haskell_flags "-optl" "-z" "-optl" "noexecstack")
+ list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
endif()
#check for full relro on ELF, Debian security
@@ -43,16 +45,20 @@
check_c_compiler_flag("" HAVE_RELROFULL)
if(HAVE_RELROFULL)
list(APPEND pascal_flags "-k-z" "-krelro" "-k-z" "-know")
- list(APPEND haskell_flags "-optl" "-z" "-optl" "relro" "-optl" "-z" "-optl" "now")
+ list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
else()
#if full relro is not available, try partial relro
set(CMAKE_REQUIRED_FLAGS "-Wl,-z,relro")
check_c_compiler_flag("" HAVE_RELROPARTIAL)
if(HAVE_RELROPARTIAL)
list(APPEND pascal_flags "-k-z" "-krelro")
- list(APPEND haskell_flags "-optl" "-z" "-optl" "relro")
+ list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
endif()
endif()
@@ -61,8 +67,10 @@
check_c_compiler_flag("" HAVE_WINASLR)
if(HAVE_WINASLR)
list(APPEND pascal_flags "-k--nxcompat")
- list(APPEND haskell_flags "-optl" "--nxcompat")
+ list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
endif()
#check for DEP on Windows XP SP2 or later, requires binutils >= 2.20
@@ -70,10 +78,22 @@
check_c_compiler_flag("" HAVE_WINDEP)
if(HAVE_WINDEP)
list(APPEND pascal_flags "-k--dynamicbase")
- list(APPEND haskell_flags "-optl" "--dynamicbase")
+ list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
endif()
+#this is actually an optimisation
+set(CMAKE_REQUIRED_FLAGS "-Wl,--as-needed")
+check_c_compiler_flag("" HAVE_ASNEEDED)
+if(HAVE_ASNEEDED)
+ list(APPEND pascal_flags "-k--as-needed")
+ list(APPEND haskell_flags "-optl" "${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} ${CMAKE_REQUIRED_FLAGS}")
+endif()
#always unset or these flags will be spread everywhere
unset(CMAKE_REQUIRED_FLAGS)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake_modules/paths.cmake Thu Jun 13 14:44:28 2013 +0200
@@ -0,0 +1,67 @@
+#where to build libs and bins
+set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+
+#resource paths
+if(UNIX AND NOT APPLE)
+ set(target_binary_install_dir "bin")
+ set(target_library_install_dir "lib")
+
+ string(SUBSTRING "${DATA_INSTALL_DIR}" 0 1 sharepath_start)
+ if (NOT (${sharepath_start} MATCHES "/"))
+ set(HEDGEWARS_DATADIR "${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/")
+ else()
+ set(HEDGEWARS_DATADIR "${DATA_INSTALL_DIR}/")
+ endif()
+ set(HEDGEWARS_FULL_DATADIR "${HEDGEWARS_DATADIR}")
+else()
+ set(target_binary_install_dir "./")
+
+ if(APPLE)
+ set(target_library_install_dir "../Frameworks/")
+ set(CMAKE_INSTALL_PREFIX "Hedgewars.app/Contents/MacOS/")
+ set(HEDGEWARS_DATADIR "../Resources/")
+ set(HEDGEWARS_FULL_DATADIR "/Applications/${CMAKE_INSTALL_PREFIX}/${HEDGEWARS_DATADIR}")
+ elseif(WIN32)
+ set(target_library_install_dir "./")
+ set(HEDGEWARS_DATADIR "./")
+ set(HEDGEWARS_FULL_DATADIR "${CMAKE_INSTALL_PREFIX}/")
+ link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
+ endif()
+endif()
+
+
+#RPATH SETTINGS
+#necessary for dynamic libraries on UNIX, ignored elsewhere
+
+#use, i.e. don't skip the full RPATH for the build tree
+set(CMAKE_SKIP_BUILD_RPATH FALSE)
+set(CMAKE_SKIP_INSTALL_RPATH FALSE)
+
+#it's safe to use our RPATH because it is relative
+set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+
+#paths where to find libraries (final slash not optional):
+# - the first is relative to the executable
+# - the second is the same directory of the executable (so it runs in bin/)
+# - the third one is the full path of the system dir
+#source http://www.cmake.org/pipermail/cmake/2008-January/019290.html
+set(CMAKE_INSTALL_RPATH "$ORIGIN/../${target_library_install_dir}/:$ORIGIN/:${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}/")
+set(CMAKE_INSTALL_RPATH_ESCAPED "$$ORIGIN/../${target_library_install_dir}/:$$ORIGIN/:${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}/")
+
+if(UNIX AND NOT APPLE)
+ list(APPEND pascal_flags "-k-rpath" "-k'${CMAKE_INSTALL_RPATH_ESCAPED}'" "-k-z" "-korigin")
+ list(APPEND haskell_flags "-optl" "-Wl,-rpath,'${CMAKE_INSTALL_RPATH_ESCAPED},-z,origin'")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,origin")
+ set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -Wl,-z,origin")
+ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -Wl,-z,origin")
+endif()
+
+#add the automatically determined parts of the RPATH
+#which point to directories outside the build tree to the install RPATH
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
+
+
+#install_name_tool magic for OS X
+set(CMAKE_INSTALL_NAME_DIR "@executable_path/../Frameworks")
+
--- a/cmake_modules/platform.cmake Wed Jun 12 19:15:51 2013 +0200
+++ b/cmake_modules/platform.cmake Thu Jun 13 14:44:28 2013 +0200
@@ -36,7 +36,8 @@
find_package(SDL_mixer REQUIRED)
set(DYLIB_SMPEG "-dylib_file @loader_path/Frameworks/smpeg.framework/Versions/A/smpeg:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/smpeg.framework/Versions/A/smpeg")
set(DYLIB_MIKMOD "-dylib_file @loader_path/Frameworks/mikmod.framework/Versions/A/mikmod:${SDLMIXER_LIBRARY}/Versions/A/Frameworks/mikmod.framework/Versions/A/mikmod")
- set(CMAKE_C_FLAGS "${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
+ set(CMAKE_CX_FLAGS "${CMAKE_CX_FLAGS} ${DYLIB_SMPEG} ${DYLIB_MIKMOD}")
list(APPEND pascal_flags "-k${DYLIB_SMPEG}" "-k${DYLIB_MIKMOD}")
endif()
@@ -73,8 +74,14 @@
endif(APPLE)
-if(WIN32)
+if(MINGW)
#this flags prevents a few dll hell problems
- set(CMAKE_C_FLAGS "-static-libgcc ${CMAKE_C_FLAGS}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc ")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc ")
+endif(MINGW)
+
+if(WIN32)
+ if(NOT ${BUILD_SHARED_LIB})
+ message(FATAL_ERROR "Static linking is not supported on Windows")
+ endif()
endif(WIN32)
-
--- a/hedgewars/CMakeLists.txt Wed Jun 12 19:15:51 2013 +0200
+++ b/hedgewars/CMakeLists.txt Thu Jun 13 14:44:28 2013 +0200
@@ -172,6 +172,16 @@
list(APPEND pascal_flags "-dPNG_SCREENSHOTS" "-Fl${PNG_LIBRARY_DIR}" "-k-L${PNG_LIBRARY_DIR}")
endif()
+if(LUA_FOUND AND LUA_SYSTEM)
+ get_filename_component(LUA_LIBRARY_DIR ${LUA_LIBRARY} PATH)
+ get_filename_component(LUA_LIBRARY_NAME ${LUA_LIBRARY} NAME)
+ #NAME_WE would strip the .1 (or .2) next to the ".so"
+ string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_PREFIX}(.*)${CMAKE_SHARED_LIBRARY_SUFFIX}" "\\1" LUA_LIBRARY_NAME "${LUA_LIBRARY_NAME}")
+ list(APPEND pascal_flags )
+ list(APPEND pascal_flags "-Fl${LUA_LIBRARY_DIR}"
+ "-k-L${LUA_LIBRARY_DIR}"
+ "-XLAlua=${LUA_LIBRARY_NAME}")
+endif()
#this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6
if(FREEPASCAL_VERSION VERSION_LESS "2.6")
@@ -186,21 +196,19 @@
if(${FFMPEG_FOUND})
+ list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING")
+
# TODO: this check is only for SDL < 2
# fpc will take care of linking but we need to have this library installed
find_package(GLUT REQUIRED)
- #TODO: convert avwrapper to .pas unit so we can skip this step
include_directories(${FFMPEG_INCLUDE_DIR})
- list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING")
- if(WIN32)
- # there are some problems with linking our avwrapper as static lib, so link it as shared
- add_library(avwrapper SHARED avwrapper.c)
- target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
- install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir})
- else()
- add_library(avwrapper STATIC avwrapper.c)
- endif()
+ add_library(avwrapper avwrapper.c)
+ #TODO: find good VERSION and SOVERSION values
+ target_link_libraries(avwrapper ${FFMPEG_LIBRARIES})
+ install(TARGETS avwrapper RUNTIME DESTINATION ${target_binary_install_dir}
+ LIBRARY DESTINATION ${target_library_install_dir}
+ ARCHIVE DESTINATION ${target_library_install_dir})
endif()
--- a/hedgewars/LuaPas.pas Wed Jun 12 19:15:51 2013 +0200
+++ b/hedgewars/LuaPas.pas Thu Jun 13 14:44:28 2013 +0200
@@ -14,6 +14,12 @@
uses uConsts;
{.$DEFINE LUA_GETHOOK}
+const LuaLibName = {$IFDEF LUA_INTERNAL}'libhwlua'{$ELSE}'liblua'{$ENDIF};
+
+{$IFNDEF WIN32}
+ {$linklib lua}
+{$ENDIF}
+
type
size_t = Cardinal;
Psize_t = ^size_t;
@@ -22,9 +28,6 @@
lua_State = record end;
Plua_State = ^lua_State;
-{$DEFINE LuaLibName:= cLuaLibrary}
-
-
(*****************************************************************************)
(* luaconfig.h *)
(*****************************************************************************)
--- a/hedgewars/avwrapper.c Wed Jun 12 19:15:51 2013 +0200
+++ b/hedgewars/avwrapper.c Thu Jun 13 14:44:28 2013 +0200
@@ -28,6 +28,14 @@
#define AVIO_FLAG_WRITE AVIO_WRONLY
#endif
+#if (defined _MSC_VER)
+#define AVWRAP_DECL __declspec(dllexport)
+#elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun))
+#define AVWRAP_DECL __attribute__((visibility("default")))
+#else
+#define AVWRAP_DECL
+#endif
+
static AVFormatContext* g_pContainer;
static AVOutputFormat* g_pFormat;
static AVStream* g_pAStream;
@@ -371,7 +379,7 @@
}
}
-void AVWrapper_WriteFrame(uint8_t* pY, uint8_t* pCb, uint8_t* pCr)
+AVWRAP_DECL void AVWrapper_WriteFrame(uint8_t* pY, uint8_t* pCb, uint8_t* pCr)
{
g_pVFrame->data[0] = pY;
g_pVFrame->data[1] = pCb;
@@ -379,7 +387,7 @@
WriteFrame(g_pVFrame);
}
-void AVWrapper_Init(
+AVWRAP_DECL void AVWrapper_Init(
void (*pAddFileLogRaw)(const char*),
const char* pFilename,
const char* pDesc,
@@ -472,7 +480,7 @@
g_pVFrame->pts = -1;
}
-void AVWrapper_Close()
+AVWRAP_DECL void AVWrapper_Close()
{
// output buffered frames
if (g_pVCodec->capabilities & CODEC_CAP_DELAY)
--- a/hedgewars/config.inc.in Wed Jun 12 19:15:51 2013 +0200
+++ b/hedgewars/config.inc.in Thu Jun 13 14:44:28 2013 +0200
@@ -25,5 +25,4 @@
cVersionString = '${HEDGEWARS_VERSION}';
cRevisionString = '${HEDGEWARS_REVISION}';
cHashString = '${HEDGEWARS_HASH}';
- cLuaLibrary = '${LUA_LIBRARY}';
cDefaultPathPrefix = '${HEDGEWARS_FULL_DATADIR}/Data';
--- a/hedgewars/uPhysFSLayer.pas Wed Jun 12 19:15:51 2013 +0200
+++ b/hedgewars/uPhysFSLayer.pas Thu Jun 13 14:44:28 2013 +0200
@@ -3,17 +3,12 @@
interface
uses SDLh, LuaPas;
-const PhysfsLibName = {$IFDEF PHYSFS_INTERNAL}'libhw_physfs'{$ELSE}'libphysfs'{$ENDIF};
+const PhysfsLibName = {$IFDEF PHYSFS_INTERNAL}'libhwphysfs'{$ELSE}'libphysfs'{$ENDIF};
const PhyslayerLibName = 'libphyslayer';
{$IFNDEF WIN32}
{$linklib physfs}
{$linklib physlayer}
-
- {statically linking physfs brings IOKit dependency on OSX}
- {$IFDEF DARWIN}
- {$linkframework IOKit}
- {$ENDIF}
{$ENDIF}
procedure initModule;
--- a/hedgewars/uScript.pas Wed Jun 12 19:15:51 2013 +0200
+++ b/hedgewars/uScript.pas Thu Jun 13 14:44:28 2013 +0200
@@ -54,6 +54,7 @@
implementation
{$IFDEF USE_LUA_SCRIPT}
+
uses LuaPas,
uConsole,
uConsts,
--- a/hedgewars/uVideoRec.pas Wed Jun 12 19:15:51 2013 +0200
+++ b/hedgewars/uVideoRec.pas Thu Jun 13 14:44:28 2013 +0200
@@ -28,9 +28,6 @@
{$ELSE}
{$IFNDEF WIN32}
- {$linklib avcodec}
- {$linklib avformat}
- {$linklib avutil}
{$linklib avwrapper}
{$ENDIF}
--- a/misc/liblua/CMakeLists.txt Wed Jun 12 19:15:51 2013 +0200
+++ b/misc/liblua/CMakeLists.txt Thu Jun 13 14:44:28 2013 +0200
@@ -4,17 +4,23 @@
if(WIN32)
add_definitions(-DLUA_BUILD_AS_DLL)
- add_library(lua SHARED ${lua_src})
-
- set(LUA_LIBRARY lua.dll)
-
- set_target_properties(lua PROPERTIES PREFIX "")
- install(TARGETS lua RUNTIME DESTINATION ${target_library_install_dir})
else(WIN32)
add_definitions(-DLUA_USE_LINUX)
- add_library(lua STATIC ${lua_src})
- set(LUA_LIBRARY lua)
+ add_definitions(-fvisibility=default) #TODO: fixme
endif(WIN32)
+add_library(lua ${lua_src})
+
+set_target_properties(lua PROPERTIES
+ VERSION "5.1.4"
+ SOVERSION 1
+ OUTPUT_NAME ${lua_output_name})
+install(TARGETS lua RUNTIME DESTINATION ${target_binary_install_dir}
+ LIBRARY DESTINATION ${target_library_install_dir}
+ ARCHIVE DESTINATION ${target_library_install_dir})
+get_target_property(lua_fullpath lua LOCATION)
+
+set(LUA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Lua include dir" FORCE)
+set(LUA_LIBRARY ${lua_fullpath} CACHE STRING "Lua library" FORCE)
--- a/misc/libphysfs/CMakeLists.txt Wed Jun 12 19:15:51 2013 +0200
+++ b/misc/libphysfs/CMakeLists.txt Thu Jun 13 14:44:28 2013 +0200
@@ -35,15 +35,6 @@
include(CheckCSourceCompiles)
-# 32bit platforms won't link unless this is set
-# although Windows doesn't like it
-if(NOT WINDOWS)
- if(CMAKE_SIZEOF_VOID_P LESS 8)
- add_definitions(-DPHYSFS_NO_64BIT_SUPPORT=1)
- endif(CMAKE_SIZEOF_VOID_P LESS 8)
-endif(NOT WINDOWS)
-
-
if(MACOSX)
# Fallback to older OS X on PowerPC to support wider range of systems...
if(CMAKE_OSX_ARCHITECTURES MATCHES ppc)
@@ -61,31 +52,8 @@
# Add some gcc-specific command lines.
if(CMAKE_COMPILER_IS_GNUCC)
- # Always build with debug symbols...you can strip it later.
+ # Always build with debug symbols... you can strip it later.
add_definitions(-g -fsigned-char)
-
- # Stupid BeOS generates warnings in the system headers.
- if(NOT BEOS)
- add_definitions(-Wall)
- endif(NOT BEOS)
-
- CHECK_C_SOURCE_COMPILES("
- #if ((defined(__GNUC__)) && (__GNUC__ >= 4))
- int main(int argc, char **argv) { int is_gcc4 = 1; return 0; }
- #else
- #error This is not gcc4.
- #endif
- " PHYSFS_IS_GCC4)
-
- if(PHYSFS_IS_GCC4)
- # Not supported on several operating systems at this time.
- if(NOT SOLARIS AND NOT WINDOWS)
- add_definitions(-fvisibility=hidden)
- endif(NOT SOLARIS AND NOT WINDOWS)
- endif(PHYSFS_IS_GCC4)
-
- # Don't use -rpath.
- set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE)
endif(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_C_COMPILER_ID STREQUAL "SunPro")
@@ -180,6 +148,7 @@
if(WINDOWS)
set(PHYSFS_HAVE_CDROM_SUPPORT TRUE)
set(PHYSFS_HAVE_THREAD_SUPPORT TRUE)
+ list(APPEND OTHER_LDFLAGS ${SDL_LIBRARY})
endif(WINDOWS)
if(NOT PHYSFS_HAVE_CDROM_SUPPORT)
@@ -252,50 +221,26 @@
#endif(PHYSFS_ARCHIVE_ISO9660)
-##as needed by Hedgewars configuration
-if(WINDOWS)
- option(PHYSFS_BUILD_STATIC "Build static library" FALSE)
- option(PHYSFS_BUILD_SHARED "Build shared library" TRUE)
- list(APPEND OTHER_LDFLAGS ${SDL_LIBRARY})
-else(WINDOWS)
- option(PHYSFS_BUILD_STATIC "Build static library" TRUE)
- option(PHYSFS_BUILD_SHARED "Build shared library" FALSE)
-endif(WINDOWS)
-
-if(PHYSFS_BUILD_STATIC)
- add_library(physfs STATIC ${PHYSFS_SRCS})
- set_target_properties(physfs PROPERTIES OUTPUT_NAME ${physfs_output_name}) ##
- set(lib_prefix ${CMAKE_STATIC_LIBRARY_PREFIX}) ##
- set(lib_suffix ${CMAKE_STATIC_LIBRARY_SUFFIX}) ##
-endif(PHYSFS_BUILD_STATIC)
-
-if(PHYSFS_BUILD_SHARED)
- add_library(physfs SHARED ${PHYSFS_SRCS})
- set_target_properties(physfs PROPERTIES VERSION ${PHYSFS_VERSION})
- set_target_properties(physfs PROPERTIES SOVERSION ${PHYSFS_SOVERSION})
- set_target_properties(physfs PROPERTIES OUTPUT_NAME ${physfs_output_name}) ##
- target_link_libraries(physfs ${optional_library_libs} ${OTHER_LDFLAGS})
- install(TARGETS physfs RUNTIME DESTINATION ${target_library_install_dir}) ##
- set(lib_prefix ${CMAKE_SHARED_LIBRARY_PREFIX}) ##
- set(lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX}) ##
-endif(PHYSFS_BUILD_SHARED)
-
-if(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
- message(FATAL "Both shared and static libraries are disabled!")
-endif(NOT PHYSFS_BUILD_SHARED AND NOT PHYSFS_BUILD_STATIC)
-
-# CMake FAQ says I need this...
-if(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
- set_target_properties(physfs PROPERTIES CLEAN_DIRECT_OUTPUT 1)
-endif(PHYSFS_BUILD_SHARED AND PHYSFS_BUILD_STATIC)
+##Hedgewars modifications
+add_library(physfs ${PHYSFS_SRCS})
+set_target_properties(physfs PROPERTIES
+ VERSION ${PHYSFS_VERSION}
+ SOVERSION ${PHYSFS_SOVERSION}
+ OUTPUT_NAME ${physfs_output_name})
+target_link_libraries(physfs ${optional_library_libs} ${OTHER_LDFLAGS})
+install(TARGETS physfs RUNTIME DESTINATION ${target_binary_install_dir}
+ LIBRARY DESTINATION ${target_library_install_dir}
+ ARCHIVE DESTINATION ${target_library_install_dir})
+get_target_property(physfs_fullpath physfs LOCATION)
## added standard variables emulating the FindPhysFS.cmake ones (FORCE or cmake won't pick 'em)
-set(PHYSFS_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/misc/libphysfs/ CACHE STRING "" FORCE)
-set(PHYSFS_LIBRARY ${LIBRARY_OUTPUT_PATH}/${lib_prefix}${physfs_output_name}${lib_suffix} CACHE STRING "" FORCE)
+set(PHYSFS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Physfs include dir" FORCE)
+set(PHYSFS_LIBRARY ${physfs_fullpath} CACHE STRING "Physfs library path" FORCE)
-## removed install, language bindings and test program
+## removed language bindings and test program
## simplified configuration output
+## merged shared and static library building
#message(STATUS "PhysFS will be built with ${PHYSFS_FEATURES} support")
--- a/misc/libphysfs/physfs_internal.h Wed Jun 12 19:15:51 2013 +0200
+++ b/misc/libphysfs/physfs_internal.h Thu Jun 13 14:44:28 2013 +0200
@@ -322,13 +322,8 @@
#define __PHYSFS_ARRAYLEN(x) ( (sizeof (x)) / (sizeof (x[0])) )
#ifdef PHYSFS_NO_64BIT_SUPPORT
-/* if a 32bit compiler sees something with this many bits: 0xFFFFFFFFFFFFFFFF
- * it doesn't know if it really means 64bit or if it's supposed to squeeze
- * it into 32 bit, so without the ULL it squeezes the number to 32 bit,
- * with it it forces it to be 64bits
- */
-#define __PHYSFS_SI64(x) ((PHYSFS_sint64) (x##LL))
-#define __PHYSFS_UI64(x) ((PHYSFS_uint64) (x##ULL))
+#define __PHYSFS_SI64(x) ((PHYSFS_sint64) (x))
+#define __PHYSFS_UI64(x) ((PHYSFS_uint64) (x))
#elif (defined __GNUC__)
#define __PHYSFS_SI64(x) x##LL
#define __PHYSFS_UI64(x) x##ULL
--- a/misc/libphyslayer/CMakeLists.txt Wed Jun 12 19:15:51 2013 +0200
+++ b/misc/libphyslayer/CMakeLists.txt Thu Jun 13 14:44:28 2013 +0200
@@ -12,25 +12,17 @@
hwpacksmounter.c
)
-set(build_type STATIC)
-set(lib_prefix ${CMAKE_STATIC_LIBRARY_PREFIX})
-set(lib_suffix ${CMAKE_STATIC_LIBRARY_SUFFIX})
+#compiles and links actual library
+add_library (physlayer ${PHYSLAYER_SRCS})
+#TODO: find good VERSION and SOVERSION values
+target_link_libraries(physlayer ${SDL_LIBRARY} ${LUA_LIBRARY} ${PHYSFS_LIBRARY})
+install(TARGETS physlayer RUNTIME DESTINATION ${target_binary_install_dir}
+ LIBRARY DESTINATION ${target_library_install_dir}
+ ARCHIVE DESTINATION ${target_library_install_dir})
+get_target_property(physlayer_fullpath physlayer LOCATION)
-if(WIN32)
- set(build_type SHARED)
- set(lib_prefix ${CMAKE_SHARED_LIBRARY_PREFIX})
- set(lib_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
-endif(WIN32)
-
-#compiles and links actual library
-add_library (physlayer ${build_type} ${PHYSLAYER_SRCS})
-
-if(WIN32)
- target_link_libraries(physlayer ${SDL_LIBRARY} ${LUA_LIBRARY} ${PHYSFS_LIBRARY})
- install(TARGETS physlayer RUNTIME DESTINATION ${target_library_install_dir})
-endif()
## added standard variables (FORCE or cmake won't pick 'em)
-set(PHYSLAYER_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/misc/libphyslayer/ CACHE STRING "" FORCE)
-set(PHYSLAYER_LIBRARY ${LIBRARY_OUTPUT_PATH}/${lib_prefix}physlayer${lib_suffix} CACHE STRING "" FORCE)
+set(PHYSLAYER_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Physlayer include dir" FORCE)
+set(PHYSLAYER_LIBRARY ${physlayer_fullpath} CACHE STRING "Physlayer library" FORCE)
--- a/project_files/hedgewars.pro Wed Jun 12 19:15:51 2013 +0200
+++ b/project_files/hedgewars.pro Thu Jun 13 14:44:28 2013 +0200
@@ -248,7 +248,7 @@
RESOURCES += ../QTfrontend/hedgewars.qrc
-LIBS += -L../bin -lhw_physfs -lphyslayer
+LIBS += -L../bin -lhwphysfs -lphyslayer
macx {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6