Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add in the CMake build system from Wargus and have stargus.c use the …
…stratagus-game-launcher.h
- Loading branch information
1 parent
c3d7456
commit e612d56
Showing
5 changed files
with
323 additions
and
257 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,232 @@ | ||
# _________ __ __ | ||
# / _____// |_____________ _/ |______ ____ __ __ ______ | ||
# \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ | ||
# / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | | ||
# /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > | ||
# \/ \/ \//_____/ \/ | ||
# ______________________ ______________________ | ||
# T H E W A R B E G I N S | ||
# Stratagus - A free fantasy real time strategy game engine | ||
# | ||
# CMakeLists.txt | ||
# Copyright (C) 2011 Pali Rohár <pali.rohar@gmail.com> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
# | ||
# | ||
|
||
project(stargus) | ||
cmake_minimum_required(VERSION 2.6) | ||
set(STARGUS_VERSION 2.2.6) | ||
|
||
# Stargus sources | ||
|
||
set(scmconvert_SRCS | ||
mpq.cpp | ||
scm.cpp | ||
) | ||
|
||
set(scmconvert_HDRS | ||
mpq.h | ||
) | ||
|
||
set(startool_SRCS | ||
startool.cpp | ||
mpq.cpp | ||
scm.cpp | ||
) | ||
|
||
set(startool_HDRS | ||
mpq.h | ||
) | ||
|
||
set(stargus_SRCS | ||
stargus.c | ||
) | ||
|
||
|
||
set(starextract_SRCS | ||
starextract.c | ||
) | ||
|
||
# Additional platform checks | ||
|
||
find_package(PkgConfig QUIET REQUIRED) | ||
|
||
# Check if platform is Maemo | ||
if(UNIX AND CMAKE_SYSTEM_NAME MATCHES Linux) | ||
pkg_check_modules(MAEMO_VERSION maemo-version) | ||
if(MAEMO_VERSION_FOUND) | ||
set(MAEMO true) | ||
endif() | ||
endif() | ||
|
||
# Find all libraries | ||
|
||
option(ENABLE_STATIC "Compile Stargus binaries as static executable" OFF) | ||
|
||
if(ENABLE_STATIC) | ||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.a") | ||
endif() | ||
|
||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) | ||
|
||
find_package(Stratagus REQUIRED) | ||
find_package(PNG REQUIRED) | ||
find_package(ZLIB REQUIRED) | ||
|
||
if(WIN32) | ||
find_package(MakeNSIS) | ||
endif() | ||
|
||
if(NOT WIN32) | ||
find_package(X11 REQUIRED) | ||
find_package(GTK2 REQUIRED gtk) | ||
endif() | ||
|
||
if(MAEMO) | ||
pkg_check_modules(HILDON REQUIRED hildon-1) | ||
endif() | ||
|
||
find_package(SelfPackers) | ||
|
||
# Windows RC compiler definitions | ||
|
||
if(WIN32) | ||
enable_language(RC) | ||
include(CMakeDetermineRCCompiler) | ||
|
||
if(MINGW) | ||
set(CMAKE_RC_COMPILER_INIT windres) | ||
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>") | ||
endif() | ||
endif() | ||
|
||
# Options for compiling | ||
|
||
if(WIN32) | ||
option(ENABLE_NSIS "Create Stratagus Window NSIS Installer" OFF) | ||
endif() | ||
|
||
option(ENABLE_UPX "Compress Stratagus executable binary with UPX packer" OFF) | ||
option(ENABLE_STRIP "Strip all symbols from executables" OFF) | ||
|
||
# Stargus definitions | ||
|
||
add_definitions(${PNG_DEFINITIONS}) | ||
include_directories(${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ${STRATAGUS_INCLUDE_DIR}) | ||
set(scmconvert_LIBS ${scmconvert_LIBS} ${ZLIB_LIBRARIES}) | ||
set(startool_LIBS ${scmconvert_LIBS} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES}) | ||
|
||
# Platform definitions | ||
|
||
if(NOT WIN32) | ||
include_directories(${X11_INCLUDE_DIR} ${GTK2_INCLUDE_DIRS}) | ||
set(stargus_LIBS ${stargus_LIBS} ${X11_X11_LIB} ${GTK2_LIBRARIES}) | ||
endif() | ||
|
||
if (NOT WIN32 AND NOT MAEMO) | ||
add_definitions(-DDATA_PATH="${CMAKE_INSTALL_PREFIX}/share/games/stratagus/stargus") | ||
add_definitions(-DSCRIPTS_PATH="${CMAKE_INSTALL_PREFIX}/share/games/stratagus/stargus") | ||
add_definitions(-DSTRATAGUS_BIN="${STRATAGUS}") | ||
endif() | ||
|
||
if(MAEMO) | ||
add_definitions(-DDATA_PATH="/home/user/MyDocs/stratagus/stargus") | ||
add_definitions(-DSCRIPTS_PATH="/opt/stratagus/share/stargus") | ||
add_definitions(-DSTRATAGUS_BIN="/opt/stratagus/bin/stratagus") | ||
add_definitions(${HILDON_CFLAGS}) | ||
include_directories(${HILDON_INCLUDE_DIRS}) | ||
set(stargus_LIBS ${stargus_LIBS} ${HILDON_LIBRARIES}) | ||
endif() | ||
|
||
if(ENABLE_STRIP) | ||
set(CMAKE_EXE_LINKER_FLAGS "-s") | ||
else() | ||
set(CMAKE_EXE_LINKER_FLAGS "") | ||
endif() | ||
|
||
# Compile Stargus | ||
|
||
add_executable(scmconvert ${scmconvert_SRCS} ${scmconvert_HDRS}) | ||
target_link_libraries(scmconvert ${scmconvert_LIBS}) | ||
set_target_properties(scmconvert PROPERTIES COMPILE_DEFINITIONS "STAND_ALONE") | ||
|
||
if(MAEMO) | ||
add_executable(starextract ${starextract_SRCS} ${starextract_HDRS}) | ||
target_link_libraries(starextract ${starextract_LIBS}) | ||
endif() | ||
|
||
add_executable(stargus WIN32 ${stargus_SRCS} ${stargus_HDRS}) | ||
target_link_libraries(stargus ${stargus_LIBS}) | ||
|
||
add_executable(startool ${startool_SRCS} ${startool_HDRS}) | ||
target_link_libraries(startool ${startool_LIBS}) | ||
|
||
if(WIN32 AND MINGW AND ENABLE_STATIC) | ||
set_target_properties(scmconvert PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc") | ||
set_target_properties(stargus PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc") | ||
set_target_properties(startool PROPERTIES LINK_FLAGS "${LINK_FLAGS} -static-libgcc") | ||
endif() | ||
|
||
########### next target ############### | ||
|
||
macro(self_packer PACKER_TARGET) | ||
get_target_property(PACKER_NAME ${PACKER_TARGET} OUTPUT_NAME) | ||
if(NOT PACKER_NAME) | ||
set(PACKER_NAME ${PACKER_TARGET}) | ||
endif() | ||
add_custom_command(TARGET ${PACKER_TARGET} POST_BUILD | ||
COMMAND ${SELF_PACKER_FOR_EXECUTABLE} | ||
ARGS ${SELF_PACKER_FOR_EXECUTABLE_FLAGS} ${PACKER_NAME}${CMAKE_EXECUTABLE_SUFFIX} | ||
) | ||
endmacro() | ||
|
||
if(ENABLE_UPX AND SELF_PACKER_FOR_EXECUTABLE) | ||
self_packer(scmconvert) | ||
self_packer(stargus) | ||
self_packer(startool) | ||
endif() | ||
|
||
########### next target ############### | ||
|
||
if(WIN32 AND ENABLE_NSIS AND MAKENSIS_FOUND) | ||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/COPYING DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/COPYING-3rd DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/stargus.ico DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) | ||
add_custom_command(OUTPUT Stargus-${STARGUS_VERSION}${MAKENSIS_SUFFIX} | ||
COMMAND ${MAKENSIS} | ||
ARGS -DNO_DOWNLOAD ${MAKENSIS_FLAGS} -DCMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}" -DCMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" ${CMAKE_CURRENT_SOURCE_DIR}/stargus.nsi | ||
DEPENDS stargus.nsi scmconvert stargus startool COPYING COPYING-3rd stargus.ico | ||
COMMENT "Generating Stargus Windows NSIS Installer" VERBATIM | ||
) | ||
add_custom_target(nsis ALL DEPENDS Stargus-${STARGUS_VERSION}${MAKENSIS_SUFFIX}) | ||
endif() | ||
|
||
########### install files ############### | ||
|
||
install(TARGETS stargus DESTINATION games) | ||
install(TARGETS scmconvert startool DESTINATION bin) | ||
#install(FILES stargus.png DESTINATION share/pixmaps) | ||
install(FILES stargus.desktop DESTINATION share/applications) | ||
|
||
# Don't currently have campaigns or maps | ||
#install(DIRECTORY campaigns maps scripts DESTINATION share/games/stratagus/stargus) | ||
install(DIRECTORY scripts DESTINATION share/games/stratagus/stargus) | ||
# Not actually sure where this should go... | ||
#install(FILES contrib/fog.png DESTINATION share/games/stratagus/stargus/graphics) | ||
|
||
if(MAEMO) | ||
install(TARGETS starextract DESTINATION bin) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# - Try to find the MakeNSIS | ||
# Once done this will define | ||
# | ||
# MAKENSIS_FOUND - system has MakeNSIS | ||
# MAKENSIS - the MakeNSIS program | ||
# MAKENSIS_FLAGS - the MakeNSIS flags | ||
# MAKENSIS_SUFFIX - the MakeNSIS output file suffix | ||
|
||
# Copyright (c) 2011, Pali Rohár <pali.rohar@gmail.com> | ||
# | ||
# Redistribution and use is allowed according to the terms of the BSD license. | ||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
|
||
if(MAKENSIS) | ||
set(MAKENSIS_FOUND true) | ||
else() | ||
find_program(MAKENSIS NAMES makensis) | ||
find_package(SelfPackers) | ||
|
||
if(MAKENSIS) | ||
set(MAKENSIS_FOUND true) | ||
message(STATUS "Found MakeNSIS: ${MAKENSIS}") | ||
else() | ||
set(MAKENSIS_FOUND false) | ||
# message(FATAL_ERROR "Could not find program MakeNSIS") # TODO: This fail if REQUIRED is not used too! | ||
message(STATUS "Could not find program MakeNSIS") | ||
endif() | ||
|
||
if(NOT CMAKE_VERBOSE_MAKEFILE) | ||
set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -V2 -DQUIET) | ||
endif() | ||
|
||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -DDBG) | ||
set(MAKENSIS_SUFFIX ${MAKENSIS_SUFFIX}-debug) | ||
endif() | ||
|
||
if(CMAKE_SIZEOF_VOID_P STREQUAL 8) | ||
set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -DX86_64) | ||
set(MAKENSIS_SUFFIX ${MAKENSIS_SUFFIX}-x86_64) | ||
endif() | ||
|
||
if(ENABLE_UPX AND SELF_PACKER_FOR_EXECUTABLE) | ||
set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -DUPX=${SELF_PACKER_FOR_EXECUTABLE} -DUPX_FLAGS=${SELF_PACKER_FOR_EXECUTABLE_FLAGS}) | ||
endif() | ||
|
||
set(MAKENSIS_FLAGS ${MAKENSIS_FLAGS} -NOCD CACHE STRING "") | ||
set(MAKENSIS_SUFFIX ${MAKENSIS_SUFFIX}${CMAKE_EXECUTABLE_SUFFIX} CACHE STRING "") | ||
|
||
mark_as_advanced(MAKENSIS MAKENSIS_FLAGS MAKENSIS_SUFFIX) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# - Try to find the stratagus executable and game headers | ||
# Once done this will define | ||
# | ||
# STRATAGUS_FOUND - system has stratagus | ||
# STRATAGUS - the stratagus executable | ||
# STRATAGUS_INCLUDE_DIR - the stratagus include directory | ||
|
||
# Copyright (c) 2011, Pali Rohár <pali.rohar@gmail.com> | ||
# | ||
# Redistribution and use is allowed according to the terms of the BSD license. | ||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. | ||
|
||
if(STRATAGUS AND STRATAGUS_INCLUDE_DIR) | ||
set(STRATAGUS_FOUND true) | ||
else() | ||
find_program(STRATAGUS NAMES stratagus PATH_SUFFIXES games) | ||
find_path(STRATAGUS_INCLUDE_DIR stratagus-game-launcher.h) | ||
|
||
if(STRATAGUS AND STRATAGUS_INCLUDE_DIR) | ||
set(STRATAGUS_FOUND true) | ||
message(STATUS "Found stratagus: ${STRATAGUS}:${STRATAGUS_INCLUDE_DIR}") | ||
else() | ||
set(STRATAGUS_FOUND false) | ||
message(FATAL_ERROR "Could not find stratagus") | ||
endif() | ||
|
||
mark_as_advanced(STRATAGUS STRATAGUS_INCLUDE_DIR) | ||
endif() |
Oops, something went wrong.