summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt18
-rw-r--r--src/CBot/CMakeLists.txt5
-rw-r--r--src/CMakeLists.txt20
-rw-r--r--src/app/app.cpp4
-rw-r--r--src/app/main.cpp7
-rw-r--r--src/app/system_other.h2
-rw-r--r--src/common/config.h.cmake12
-rw-r--r--src/common/image.cpp4
-rw-r--r--src/common/key.h2
-rw-r--r--src/common/restext.cpp2
-rw-r--r--src/desktop/CMakeLists.txt2
-rw-r--r--src/graphics/engine/terrain.cpp2
-rw-r--r--src/graphics/engine/text.cpp4
-rw-r--r--src/graphics/opengl/gldevice.cpp2
-rw-r--r--src/tools/CMakeLists.txt2
-rw-r--r--test/cbot/CMakeLists.txt2
-rw-r--r--test/envs/opengl/light_test.cpp12
-rw-r--r--test/envs/opengl/model_test.cpp12
-rw-r--r--test/envs/opengl/texture_test.cpp12
-rw-r--r--test/envs/opengl/transform_test.cpp12
-rw-r--r--test/unit/CMakeLists.txt33
-rw-r--r--test/unit/common/image_test.cpp2
22 files changed, 117 insertions, 56 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e25826..60839be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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/)
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index daf08c6..fecd18e 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -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()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index cc181f2..3d6908d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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)
diff --git a/src/app/app.cpp b/src/app/app.cpp
index cb1ac34..e84091b 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -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>
diff --git a/src/app/main.cpp b/src/app/main.cpp
index e621065..0622370 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -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"
diff --git a/src/app/system_other.h b/src/app/system_other.h
index 6fb4b86..aee3536 100644
--- a/src/app/system_other.h
+++ b/src/app/system_other.h
@@ -22,7 +22,7 @@
#include "app/system.h"
-#include <SDL/SDL.h>
+#include <SDL.h>
#include <iostream>
diff --git a/src/common/config.h.cmake b/src/common/config.h.cmake
index 1595e09..d5a03b4 100644
--- a/src/common/config.h.cmake
+++ b/src/common/config.h.cmake
@@ -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
diff --git a/src/common/image.cpp b/src/common/image.cpp
index be5711d..db14797 100644
--- a/src/common/image.cpp
+++ b/src/common/image.cpp
@@ -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>
diff --git a/src/common/key.h b/src/common/key.h
index 196f66d..84ee618 100644
--- a/src/common/key.h
+++ b/src/common/key.h
@@ -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
diff --git a/src/common/restext.cpp b/src/common/restext.cpp
index 4768aed..a6c33a3 100644
--- a/src/common/restext.cpp
+++ b/src/common/restext.cpp
@@ -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 };
diff --git a/src/desktop/CMakeLists.txt b/src/desktop/CMakeLists.txt
index ce4f48d..9a00dd4 100644
--- a/src/desktop/CMakeLists.txt
+++ b/src/desktop/CMakeLists.txt
@@ -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)
diff --git a/src/graphics/engine/terrain.cpp b/src/graphics/engine/terrain.cpp
index 8f7ad26..c2a7855 100644
--- a/src/graphics/engine/terrain.cpp
+++ b/src/graphics/engine/terrain.cpp
@@ -30,7 +30,7 @@
#include <sstream>
-#include <SDL/SDL.h>
+#include <SDL.h>
// Graphics module namespace
diff --git a/src/graphics/engine/text.cpp b/src/graphics/engine/text.cpp
index 9dea129..308c813 100644
--- a/src/graphics/engine/text.cpp
+++ b/src/graphics/engine/text.cpp
@@ -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
diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp
index beeb85e..df64e34 100644
--- a/src/graphics/opengl/gldevice.cpp
+++ b/src/graphics/opengl/gldevice.cpp
@@ -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>
diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index 3653357..0be2bd5 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -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})
diff --git a/test/cbot/CMakeLists.txt b/test/cbot/CMakeLists.txt
index e864ed5..e087ea5 100644
--- a/test/cbot/CMakeLists.txt
+++ b/test/cbot/CMakeLists.txt
@@ -1,2 +1,2 @@
# CBot console interpreter
-add_subdirectory(CBot_console)
+#add_subdirectory(CBot_console)
diff --git a/test/envs/opengl/light_test.cpp b/test/envs/opengl/light_test.cpp
index b1e0151..d4635cc 100644
--- a/test/envs/opengl/light_test.cpp
+++ b/test/envs/opengl/light_test.cpp
@@ -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"
diff --git a/test/envs/opengl/model_test.cpp b/test/envs/opengl/model_test.cpp
index 882b785..168eb32 100644
--- a/test/envs/opengl/model_test.cpp
+++ b/test/envs/opengl/model_test.cpp
@@ -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"
diff --git a/test/envs/opengl/texture_test.cpp b/test/envs/opengl/texture_test.cpp
index b1f352c..5c27b43 100644
--- a/test/envs/opengl/texture_test.cpp
+++ b/test/envs/opengl/texture_test.cpp
@@ -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"
diff --git a/test/envs/opengl/transform_test.cpp b/test/envs/opengl/transform_test.cpp
index 04c73f7..02f9d83 100644
--- a/test/envs/opengl/transform_test.cpp
+++ b/test/envs/opengl/transform_test.cpp
@@ -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"
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt
index 34027b8..f3be01d 100644
--- a/test/unit/CMakeLists.txt
+++ b/test/unit/CMakeLists.txt
@@ -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
diff --git a/test/unit/common/image_test.cpp b/test/unit/common/image_test.cpp
index 2a8d5e4..2b20a17 100644
--- a/test/unit/common/image_test.cpp
+++ b/test/unit/common/image_test.cpp
@@ -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