|
From: Lasse Kärkkäi. <tr...@us...> - 2009-07-11 09:28:32
|
Module: performous
Branch: master
Commit: bb07abcaeea4d94080334272391c45ce35d9030d
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Jul 11 12:26:50 2009 +0300
Silky Strings made part of Performous build and CMakeLists.txts rewritten.
New CMake modules for GLFW and SDL_mixer.
Make launcher execute silkystrings from path.
---
CMakeLists.txt | 5 ++
cmake/Modules/FindGLFW.cmake | 38 ++++++++++++
cmake/Modules/FindSDL_mixer.cmake | 32 ++++++++++
silkystrings/CMakeLists.txt | 32 +---------
silkystrings/src/CMakeLists.txt | 114 ++++++++++++++++-------------------
silkystrings/src/LauncherWindow.cpp | 2 +-
6 files changed, 130 insertions(+), 93 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 59e9ebc..c07a37a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -36,11 +36,16 @@ add_subdirectory(game)
add_subdirectory(docs)
option(ENABLE_TOOLS "Enable extra tools (e.g. Singstar ripper)" ON)
+option(ENABLE_SILKYSTRINGS "Enable Silky Strings (Guitar Hero clone)" ON)
if (ENABLE_TOOLS)
add_subdirectory(tools)
endif (ENABLE_TOOLS)
+if (ENABLE_SILKYSTRINGS)
+ add_subdirectory(silkystrings)
+endif (ENABLE_SILKYSTRINGS)
+
if(NOT WIN32)
if(NOT "${CMAKE_INSTALL_PREFIX}" MATCHES "^(/usr|/usr/local)$")
message(STATUS "Non-standard installation prefix. Configuring performous.sh.")
diff --git a/cmake/Modules/FindGLFW.cmake b/cmake/Modules/FindGLFW.cmake
new file mode 100644
index 0000000..f83f448
--- /dev/null
+++ b/cmake/Modules/FindGLFW.cmake
@@ -0,0 +1,38 @@
+# - Try to find GLFW
+# Once done, this will define
+#
+# GLFW_FOUND - system has OpenGL (GL and GLU)
+# GLFW_INCLUDE_DIRS - the OpenGL include directories
+# GLFW_LIBRARIES - link these to use OpenGL
+#
+# See documentation on how to write CMake scripts at
+# http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
+
+include(LibFindMacros)
+
+# Dependencies
+libfind_package(GDK OpenGL)
+
+libfind_pkg_check_modules(GLFW_PKGCONF libglfw)
+
+find_path(GLFW_INCLUDE_DIR
+ NAMES GL/glfw.h
+ PATHS ${GLFW_PKGCONF_INCLUDE_DIRS}
+)
+
+find_library(GLFW_LIBRARY
+ NAMES glfw
+ PATHS ${GLFW_PKGCONF_LIBRARY_DIRS}
+)
+
+set(GLFW_PROCESS_INCLUDES GLFW_INCLUDE_DIR OpenGL_INCLUDE_DIRS)
+set(GLFW_PROCESS_LIBS GLFW_LIBRARY OpenGL_LIBRARIES)
+
+if(UNIX)
+ find_library(X11_LIBRARY NAMES X11)
+ find_library(Xrandr_LIBRARY NAMES Xrandr)
+ set(GLFW_PROCESS_LIBS ${GLFW_PROCESS_LIBS} X11_LIBRARY Xrandr_LIBRARY)
+endif(UNIX)
+
+libfind_process(GLFW)
+
diff --git a/cmake/Modules/FindSDL_mixer.cmake b/cmake/Modules/FindSDL_mixer.cmake
new file mode 100644
index 0000000..5e369a5
--- /dev/null
+++ b/cmake/Modules/FindSDL_mixer.cmake
@@ -0,0 +1,32 @@
+# - Try to find SDL
+# Once done, this will define
+#
+# SDL_mixer_FOUND - system has SDL
+# SDL_mixer_INCLUDE_DIRS - the SDL include directories
+# SDL_mixer_LIBRARIES - link these to use SDL
+# SDL_mixer_SDL_mixer_LIBRARY - only libSDL
+# SDL_mixer_SDLmain_LIBRARY - only libSDLmain
+# SDL_mixer_SOURCES - add this in the source file list of your target (hack for OSX)
+#
+# See documentation on how to write CMake scripts at
+# http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
+
+include(LibFindMacros)
+
+libfind_pkg_check_modules(SDL_mixer_PKGCONF sdl)
+
+find_path(SDL_mixer_INCLUDE_DIR
+ NAMES SDL_mixer.h
+ PATH_SUFFIXES SDL
+ HINTS ${SDL_PKGCONF_INCLUDE_DIRS}
+)
+
+find_library(SDL_mixer_LIBRARY
+ NAMES SDL_mixer
+ HINTS ${SDL_PKGCONF_LIBRARY_DIRS}
+)
+
+set(SDL_mixer_PROCESS_INCLUDES SDL_mixer_INCLUDE_DIR)
+set(SDL_mixer_PROCESS_LIBS SDL_mixer_LIBRARY)
+libfind_process(SDL_mixer)
+
diff --git a/silkystrings/CMakeLists.txt b/silkystrings/CMakeLists.txt
index 0e29fc4..97c48df 100644
--- a/silkystrings/CMakeLists.txt
+++ b/silkystrings/CMakeLists.txt
@@ -1,31 +1,5 @@
-PROJECT(silkystrings)
+project(silkystrings)
+cmake_minimum_required(VERSION 2.4)
-INCLUDE(FindSDL)
-INCLUDE(FindSDL_mixer)
-
-SET(BOOST_SUFFIX -mt)
-
-IF (CMAKE_COMPILER_IS_GNUCXX)
- ADD_DEFINITIONS (-g)
-ENDIF (CMAKE_COMPILER_IS_GNUCXX)
-
-INCLUDE_DIRECTORIES(
- ${FREETYPE2_INCLUDE_DIR}
- ${GLFW_INCLUDE_DIR}
- ${BOOST_INCLUDE_DIR}
- ${FMODEX_INCLUDE_DIR}
- ${SDL_INCLUDE_DIR}
- ${SDLMIXER_INCLUDE_DIR}
-)
-
-LINK_DIRECTORIES(
- ${FREETYPE2_LIB_DIR}
- ${GLFW_LIB_DIR}
- ${BOOST_LIB_DIR}
- ${FMODEX_LIB_DIR}
- ${SDL_LIB_DIR}
- ${SDLMIXER_LIB_DIR}
-)
-
-SUBDIRS(src tests)
+subdirs(src tests)
diff --git a/silkystrings/src/CMakeLists.txt b/silkystrings/src/CMakeLists.txt
index 3bc1819..0bafdf0 100644
--- a/silkystrings/src/CMakeLists.txt
+++ b/silkystrings/src/CMakeLists.txt
@@ -1,77 +1,65 @@
-INCLUDE(FindOpenGL)
-INCLUDE(FindSDL)
-INCLUDE(FindSDL_mixer)
+cmake_minimum_required(VERSION 2.4)
-IF (CMAKE_COMPILER_IS_GNUCXX)
- ADD_DEFINITIONS (-g)
-ENDIF (CMAKE_COMPILER_IS_GNUCXX)
+if(COMMAND cmake_policy)
+ cmake_policy(SET CMP0003 NEW)
+endif(COMMAND cmake_policy)
-FIND_PATH(FREETYPE2_INCLUDE_DIR freetype/freetype.h
- ../include/freetype2
- /usr/local/include/freetype2
- /usr/include/freetype2
- )
+# Libraries
-ADD_LIBRARY(silkystrings-convenience
- Action.cpp
- chord.cpp
- GameView.cpp
- GLExtensionProxy.cpp
- Input.cpp
- Mesh.cpp
- MeshFactory.cpp
- midiEvent.cpp
- midiFileParser.cpp
- midiStream.cpp
- SoftwareElementDataBuffer.cpp
- SoftwareVertexDataBuffer.cpp
- Sound.cpp
- Reaction.cpp
- TextRenderer.cpp
- Texture2D.cpp
- VertexDataBufferManager.cpp
- VertexFormat.cpp
- WM.cpp
-)
+#include_directories(${CMAKE_SOURCE_DIR}/libs/libda/include)
-IF (NOT WIN32)
- SET (GLFW_EXTRA_LIBS Xxf86vm Xrandr)
-ENDIF (NOT WIN32)
+find_package(Boost 1.34 REQUIRED COMPONENTS filesystem)
+include_directories(${Boost_INCLUDE_DIRS})
+set(LIBS ${LIBS} ${Boost_LIBRARIES})
-TARGET_LINK_LIBRARIES(silkystrings-convenience
- glfw${GLFW_SUFFIX}
- ${OPENGL_LIBRARIES}
- freetype${FREETYPE_SUFFIX}
- ${GLFW_EXTRA_LIBS}
- ${SDL_LIBRARY}
- ${SDLMIXER_LIBRARY}
-)
+# Find all the libs that don't require extra parameters
+foreach(lib SDL OpenGL GLFW Freetype SDL_mixer)
+ find_package(${lib} REQUIRED)
+ include_directories(${${lib}_INCLUDE_DIRS})
+ set(LIBS ${LIBS} ${${lib}_LIBRARIES})
+ add_definitions(${${lib}_DEFINITIONS})
+endforeach(lib)
-IF (CMAKE_COMPILER_IS_GNUCXX)
- SET_TARGET_PROPERTIES(silkystrings-convenience PROPERTIES COMPILE_FLAGS "-Wall -Wextra -Wno-unused-parameter")
-ENDIF (CMAKE_COMPILER_IS_GNUCXX)
+# Set default compile flags for GCC
+if(CMAKE_COMPILER_IS_GNUCXX)
+ message(STATUS "GCC detected, enabling warnings")
+ # -pedantic cannot be used because ffmpeg headers are b0rked
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -Wall -Wextra")
+endif(CMAKE_COMPILER_IS_GNUCXX)
-INCLUDE_DIRECTORIES(
- ${CMAKE_CURRENT_BINARY_DIR}
- ${FREETYPE2_INCLUDE_DIR}
- ${GLFW_INCLUDE_DIR}
- ${BOOST_INCLUDE_DIR}
- ${FMODEX_INCLUDE_DIR}
- ${SDL_INCLUDE_DIR}
- ${SDLMIXER_INCLUDE_DIR}
+add_library(silkystrings-convenience
+ Action.cpp
+ chord.cpp
+ GameView.cpp
+ GLExtensionProxy.cpp
+ Input.cpp
+ Mesh.cpp
+ MeshFactory.cpp
+ midiEvent.cpp
+ midiFileParser.cpp
+ midiStream.cpp
+ SoftwareElementDataBuffer.cpp
+ SoftwareVertexDataBuffer.cpp
+ Sound.cpp
+ Reaction.cpp
+ TextRenderer.cpp
+ Texture2D.cpp
+ VertexDataBufferManager.cpp
+ VertexFormat.cpp
+ WM.cpp
)
-LINK_DIRECTORIES(${BOOST_LIB_DIR})
+target_link_libraries(silkystrings-convenience ${LIBS})
-INCLUDE(FindQt4)
-INCLUDE(${QT_USE_FILE})
-ADD_DEFINITIONS(${QT_DEFINITIONS})
+add_executable(silkystrings silkystrings.cpp)
+target_link_libraries(silkystrings silkystrings-convenience)
+find_package(Qt4 REQUIRED)
+include(${QT_USE_FILE})
QT4_AUTOMOC(LauncherWindow.cpp)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}) # For the MOC file
+add_executable(silkystrings-launcher LauncherWindow.cpp SongIterator.cpp)
+target_link_libraries(silkystrings-launcher ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${Boost_LIBRARIES})
-ADD_EXECUTABLE(silkystrings-launcher LauncherWindow.cpp SongIterator.cpp)
-TARGET_LINK_LIBRARIES(silkystrings-launcher ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} boost_filesystem${BOOST_SUFFIX})
-
-ADD_EXECUTABLE(silkystrings silkystrings.cpp)
-TARGET_LINK_LIBRARIES(silkystrings silkystrings-convenience)
+install(TARGETS silkystrings silkystrings-launcher DESTINATION bin)
diff --git a/silkystrings/src/LauncherWindow.cpp b/silkystrings/src/LauncherWindow.cpp
index c5769fe..e500673 100644
--- a/silkystrings/src/LauncherWindow.cpp
+++ b/silkystrings/src/LauncherWindow.cpp
@@ -222,7 +222,7 @@ void Launcher::LauncherWindow::play(){
std::cout << std::endl;
// execute silkystring and exit launcher
- execl("silkystrings",
+ execlp("silkystrings",
"silkystrings",
param[0].str().c_str(),
param[1].str().c_str(),
|