Skip to content

Commit

Permalink
Added Win32 support to the CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelsimo committed Dec 6, 2014
1 parent 6721ace commit 278732c
Show file tree
Hide file tree
Showing 23 changed files with 41 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
Expand All @@ -20,7 +19,6 @@
*.lai
*.la
*.a
*.lib

# Executables
*.exe
Expand Down
50 changes: 37 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4)
PROJECT(Asteroids)

if (UNIX)
# Modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Modules
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

# Ouput directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
endif (UNIX)
# Ouput directories
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)

# Move all targets to /bin (e.g. Release, Debug)
IF(WIN32)
FOREACH(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
STRING( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/bin)
ENDFOREACH(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
ENDIF(WIN32)

ADD_EXECUTABLE(
${PROJECT_NAME}
Expand All @@ -32,18 +40,17 @@ ADD_EXECUTABLE(
src/FileSystem.cpp
)


# C++11
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
IF(COMPILER_SUPPORTS_CXX11)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
ELSEIF(COMPILER_SUPPORTS_CXX0X)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
ELSE()
MESSAGE(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
ENDIF()

# OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
Expand All @@ -59,6 +66,7 @@ ENDIF(NOT OPENGL_FOUND)
#---------------------

IF(WIN32)

INCLUDE_DIRECTORIES(
${PROJECT_SOURCE_DIR}/deps/win32/devil/include
${PROJECT_SOURCE_DIR}/deps/win32/glut/include
Expand All @@ -78,9 +86,11 @@ IF(WIN32)
${PROJECT_SOURCE_DIR}/deps/win32/openal/lib/alut.lib
${PROJECT_SOURCE_DIR}/deps/win32/xercesc/lib/xerces-c_3.lib
)

ENDIF(WIN32)

if (UNIX)

# GLUT
FIND_PACKAGE(GLUT REQUIRED)
INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIRS})
Expand Down Expand Up @@ -125,6 +135,7 @@ if (UNIX)
${ALUT_LIBRARY}
${XERCESC_LIBRARY}
)

endif (UNIX)

# Copy fonts
Expand All @@ -141,6 +152,19 @@ ADD_CUSTOM_COMMAND(
${PROJECT_SOURCE_DIR}/sounds ${PROJECT_SOURCE_DIR}/bin/sounds
)

IF(WIN32)
# Gather all *.dll files
FILE(GLOB_RECURSE DLLFiles ${PROJECT_SOURCE_DIR}/deps/*.dll)

FOREACH(DLLFile ${DLLFiles})
ADD_CUSTOM_COMMAND(
TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${DLLFile} ${PROJECT_SOURCE_DIR}/bin
)
ENDFOREACH()
ENDIF(WIN32)

INSTALL (
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${PROJECT_BINARY_DIR}/bin
Expand Down
Binary file added deps/win32/devil/lib/DevIL.dll
Binary file not shown.
Binary file added deps/win32/devil/lib/DevIL.lib
Binary file not shown.
Binary file added deps/win32/devil/lib/ILU.dll
Binary file not shown.
Binary file added deps/win32/devil/lib/ILU.lib
Binary file not shown.
Binary file added deps/win32/devil/lib/ILUT.dll
Binary file not shown.
Binary file added deps/win32/devil/lib/ILUT.lib
Binary file not shown.
Binary file added deps/win32/glut/lib/freeglut.dll
Binary file not shown.
Binary file added deps/win32/glut/lib/freeglut.lib
Binary file not shown.
Binary file added deps/win32/openal/lib/OpenAL32.dll
Binary file not shown.
Binary file added deps/win32/openal/lib/OpenAL32.lib
Binary file not shown.
Binary file added deps/win32/openal/lib/alut.dll
Binary file not shown.
Binary file added deps/win32/openal/lib/alut.lib
Binary file not shown.
Binary file added deps/win32/xercesc/lib/xerces-c_3.lib
Binary file not shown.
Binary file added deps/win32/xercesc/lib/xerces-c_3D.lib
Binary file not shown.
Binary file added deps/win32/xercesc/lib/xerces-c_3_1.dll
Binary file not shown.
Binary file added deps/win32/xercesc/lib/xerces-c_static_3.lib
Binary file not shown.
Binary file added deps/win32/xercesc/lib/xerces-c_static_3D.lib
Binary file not shown.
2 changes: 1 addition & 1 deletion src/BitmapFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bool BitmapFont::LoadGlyphsFromXML(const std::string& filename)
{
try
{
std::unique_ptr<Font> font (Font_(filename,
std::auto_ptr<Font> font (Font_(filename,
xml_schema::flags::dont_validate));

m_family = static_cast<std::string>(font->family());
Expand Down
2 changes: 1 addition & 1 deletion src/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FileSystem

private:
static FileSystem* m_fileSystem;
char m_buffer[PATH_MAX];
char m_buffer[4096];
FileSystem();
};

Expand Down
5 changes: 1 addition & 4 deletions src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ namespace asteroids

void World::Update()
{

std::cout << m_asteroids.size() << std::endl;

switch (m_state)
{
case GameState::GAMEOVER:
Expand Down Expand Up @@ -683,7 +680,7 @@ namespace asteroids
void World::RenderPlayerScore()
{
int score = m_player->GetScore();
DrawText(20, 20, std::to_string(score), m_bitmapFont, 0.8);
DrawText(20, 20, std::to_string(static_cast<long long>(score)), m_bitmapFont, 0.8);
}

void World::RenderPlayerLifes()
Expand Down
3 changes: 1 addition & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ int main(int argc, char** argv)
glutInitDisplayMode(GLUT_DOUBLE);
glutInitWindowSize(SCREEN_WIDTH, SCREEN_HEIGHT);
glutCreateWindow(SCREEN_TITLE);
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,
GLUT_ACTION_CONTINUE_EXECUTION);
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_CONTINUE_EXECUTION);


if(!InitializeGL())
Expand Down

0 comments on commit 278732c

Please sign in to comment.