Fixes for compiling on MSYS

* fixed SDL_main() and putenv() issues
 * disabled desktop subdir for MSYS
 * disabled building CBot_console for now
dev-ui
Piotr Dziwinski 2013-03-22 18:19:53 +01:00
parent 1406464f0c
commit 4a30800cf1
22 changed files with 117 additions and 56 deletions

View File

@ -74,6 +74,7 @@ set(COLOBOT_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wold-style-cast ${CXX11_FLAGS}"
set(COLOBOT_CXX_FLAGS_RELEASE "-O2")
set(COLOBOT_CXX_FLAGS_DEBUG "-g -O0")
# Asserts can be enabled/disabled regardless of build type
option(ASSERTS "Enable assert()s" ON)
@ -83,6 +84,9 @@ option(TESTS "Enable tests" ON)
# CBot can also be a static library
option(CBOT_STATIC "Build CBot as static libary" OFF)
# Generate desktop files, manpage, etc.
option(DESKTOP ON)
# Doxygen docs are optional for installation
option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
@ -90,8 +94,16 @@ option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
option(OPENAL_SOUND "Build openal sound support" OFF)
# Hacks for MSYS
if (MSYS)
set(COLOBOT_CXX_FLAGS "${COLOBOT_CXX_FLAGS} -U__STRICT_ANSI__") # fixes putenv()
set(USE_SDL_MAIN 1) # fixes SDL_main
set(DESKTOP OFF) # MSYS doesn't have the necessary tools
endif()
##
# Required packages
# Searching for packages
##
find_package(OpenGL 1.4 REQUIRED)
@ -115,6 +127,10 @@ find_package(GLEW REQUIRED)
include("${colobot_SOURCE_DIR}/cmake/FindLibSndFile.cmake")
if (${OPENAL_SOUND})
find_package(OpenAL REQUIRED)
endif()
##
# Additional settings to use when cross-compiling with MXE (http://mxe.cc/)

View File

@ -16,5 +16,8 @@ if(${CBOT_STATIC})
add_library(CBot STATIC ${SOURCES})
else()
add_library(CBot SHARED ${SOURCES})
install(TARGETS CBot LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR})
install(TARGETS CBot LIBRARY
DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
endif()

View File

@ -12,22 +12,18 @@ add_subdirectory(tools)
add_subdirectory(po)
add_subdirectory(desktop)
if(${DESKTOP})
add_subdirectory(desktop)
endif()
# Optional libraries
set(OPTIONAL_LIBS "")
set(OPTIONAL_INCLUDES "")
if (${OPENAL_SOUND})
if (${PLATFORM_WINDOWS})
set(OPTIONAL_LIBS
OpenAL32
)
else()
set(OPTIONAL_LIBS
openal
)
endif()
set(OPTIONAL_LIBS ${OPENAL_LIBRARY})
set(OPTIONAL_INCLUDES ${OPENAL_INCLUDE_DIR})
endif()
# Additional libraries per platform
@ -196,8 +192,8 @@ ${OPENGL_LIBRARY}
${PNG_LIBRARIES}
${GLEW_LIBRARY}
${Boost_LIBRARIES}
${OPTIONAL_LIBS}
${LIBSNDFILE_LIBRARY}
${OPTIONAL_LIBS}
${PLATFORM_LIBS}
)
@ -217,8 +213,8 @@ ${SDLTTF_INCLUDE_DIR}
${PNG_INCLUDE_DIRS}
${GLEW_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
${OPTIONAL_INCLUDE_DIRS}
${LIBSNDFILE_INCLUDE_DIR}
${OPTIONAL_INCLUDE_DIRS}
)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/CBot)

View File

@ -33,8 +33,8 @@
#include <boost/filesystem.hpp>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include <stdlib.h>
#include <libintl.h>

View File

@ -23,6 +23,7 @@
#include "app/app.h"
#include "app/system.h"
#include "common/config.h"
#include "common/logger.h"
#include "common/misc.h"
#include "common/restext.h"
@ -70,7 +71,10 @@ The current layout is the following:
//! Entry point to the program
int main(int argc, char *argv[])
extern "C"
{
int SDL_MAIN_FUNC(int argc, char *argv[])
{
CLogger logger; // Create the logger
@ -111,3 +115,4 @@ int main(int argc, char *argv[])
return code;
}
} // extern "C"

View File

@ -22,7 +22,7 @@
#include "app/system.h"
#include <SDL/SDL.h>
#include <SDL.h>
#include <iostream>

View File

@ -7,11 +7,19 @@
#cmakedefine GLEW_STATIC
#cmakedefine OPENAL_SOUND
#cmakedefine USE_SDL_MAIN @USE_SDL_MAIN@
#ifdef USE_SDL_MAIN
#define SDL_MAIN_FUNC SDL_main
#else
#define SDL_MAIN_FUNC main
#endif
#define COLOBOT_VERSION "@COLOBOT_VERSION_FULL@"
#define COLOBOT_CODENAME "@COLOBOT_VERSION_CODENAME@"
#define COLOBOT_FULLNAME "Colobot @COLOBOT_VERSION_CODENAME@"
#define COLOBOT_DEFAULT_DATADIR "@COLOBOT_INSTALL_DATA_DIR@"
#define COLOBOT_I18N_DIR "@COLOBOT_INSTALL_I18N_DIR@"
#cmakedefine OPENAL_SOUND

View File

@ -22,8 +22,8 @@
#include <string.h>
#include <assert.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include <png.h>

View File

@ -22,7 +22,7 @@
#pragma once
#include "SDL/SDL_keysym.h"
#include <SDL_keysym.h>
/* Key definitions are specially defined here so that it is clear in other parts of the code
that these are used. It is to avoid having SDL-related enum values or #defines lying around

View File

@ -30,7 +30,7 @@
#include "object/robotmain.h"
#include <libintl.h>
#include <SDL/SDL_keyboard.h>
#include <SDL_keyboard.h>
const char* stringsText[RT_MAX] = { nullptr };
const char* stringsEvent[EVENT_STD_MAX] = { nullptr };

View File

@ -39,7 +39,7 @@ endif()
# Create manpage from pod-formatted file
find_program(POD2MAN pod2man)
if(POD2MAN)
if(POD2MAN AND (NOT MSYS))
set(COLOBOT_MANPAGE_SECTION 6)
macro(podman)

View File

@ -30,7 +30,7 @@
#include <sstream>
#include <SDL/SDL.h>
#include <SDL.h>
// Graphics module namespace

View File

@ -26,8 +26,8 @@
#include "math/func.h"
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#include <SDL.h>
#include <SDL_ttf.h>
// Graphics module namespace

View File

@ -27,7 +27,7 @@
// Using GLEW so only glew.h is needed
#include <GL/glew.h>
#include <SDL/SDL.h>
#include <SDL.h>
#include <cassert>

View File

@ -7,6 +7,8 @@ convert_model.cpp
include_directories(. ..)
include_directories(SYSTEM ${SDL_INCLUDE_DIR})
add_definitions(-DMODELFILE_NO_ENGINE)
add_executable(convert_model ${CONVERT_MODEL_SOURCES})

View File

@ -1,2 +1,2 @@
# CBot console interpreter
add_subdirectory(CBot_console)
#add_subdirectory(CBot_console)

View File

@ -1,5 +1,6 @@
#include "app/system.h"
#include "common/config.h"
#include "common/logger.h"
#include "common/image.h"
@ -7,8 +8,8 @@
#include "math/geometry.h"
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include <unistd.h>
#include <iostream>
@ -357,7 +358,10 @@ void MouseMove(int x, int y)
ROTATION.x = ROTATION_BASE.x + (static_cast<float> (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI;
}
int main(int argc, char *argv[])
extern "C"
{
int SDL_MAIN_FUNC(int argc, char *argv[])
{
CLogger logger;
@ -460,3 +464,5 @@ int main(int argc, char *argv[])
return 0;
}
} // extern "C"

View File

@ -1,5 +1,6 @@
#include "app/system.h"
#include "common/config.h"
#include "common/logger.h"
#include "common/image.h"
@ -8,8 +9,8 @@
#include "math/geometry.h"
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include <unistd.h>
#include <iostream>
@ -257,7 +258,10 @@ void KeyboardUp(SDLKey key)
}
}
int main(int argc, char *argv[])
extern "C"
{
int SDL_MAIN_FUNC(int argc, char *argv[])
{
CLogger logger;
@ -378,3 +382,5 @@ int main(int argc, char *argv[])
return 0;
}
} // extern "C"

View File

@ -1,3 +1,4 @@
#include "common/config.h"
#include "common/logger.h"
#include "common/image.h"
@ -5,8 +6,8 @@
#include "math/geometry.h"
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include <unistd.h>
@ -124,7 +125,10 @@ void Render(Gfx::CGLDevice *device)
device->EndScene();
}
int main()
extern "C"
{
int SDL_MAIN_FUNC(int argc, char *argv[])
{
CLogger logger;
@ -192,3 +196,5 @@ int main()
return 0;
}
} // extern "C"

View File

@ -1,5 +1,6 @@
#include "app/system.h"
#include "common/config.h"
#include "common/logger.h"
#include "common/image.h"
#include "common/iman.h"
@ -8,8 +9,8 @@
#include "math/geometry.h"
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include <unistd.h>
#include <iostream>
@ -235,7 +236,10 @@ void MouseMove(int x, int y)
ROTATION.x = ROTATION_BASE.x + (static_cast<float> (y - MOUSE_POS_BASE.y) / 600.0f) * Math::PI;
}
int main(int argc, char *argv[])
extern "C"
{
int SDL_MAIN_FUNC(int argc, char *argv[])
{
CLogger logger;
@ -338,3 +342,5 @@ int main(int argc, char *argv[])
return 0;
}
} // extern "C"

View File

@ -158,15 +158,8 @@ endif()
set(OPTIONAL_LIBS "")
if (${OPENAL_SOUND})
if (${PLATFORM_WINDOWS})
set(OPTIONAL_LIBS
OpenAL32
)
else()
set(OPTIONAL_LIBS
openal
)
endif()
set(OPTIONAL_LIBS ${OPENAL_LIBRARY})
set(OPTIONAL_INCLUDES ${OPENAL_INCLUDE_DIR})
endif()
@ -189,14 +182,28 @@ math/vector_test.cpp
${PLATFORM_TESTS}
)
# Local
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${SRC_DIR}
${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR}
.
common
math
${SRC_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
# System
include_directories(
SYSTEM
${GTEST_INCLUDE_DIR}
${GMOCK_INCLUDE_DIR}
${SDL_INCLUDE_DIR}
${SDLIMAGE_INCLUDE_DIR}
${SDLTTF_INCLUDE_DIR}
${PNG_INCLUDE_DIRS}
${GLEW_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
${OPTIONAL_INCLUDE_DIRS}
${LIBSNDFILE_INCLUDE_DIR}
)
set(LIBS

View File

@ -1,6 +1,6 @@
#include "common/image.h"
#include <SDL/SDL.h>
#include <SDL.h>
#include <stdio.h>
/* For now, just a simple test: loading a file from image