I tried to compile Spark on my Linux machine, had first a big error.
Reason was that in some header file "None" was defined as a preprocessor arg.
As sf::Style used "None" in an enum, it was replaced by 0L.
you know big error "expexted identifier".
simple fix (for svn/trunk (not v2)
in SPK_SFML_DEF.h add
- Code:
-
#undef None
on line 45/46 (before SFML/Window.hpp)
also I added a cmake file. it compiles fine, didn't test the libraries yet.
here's my cmake file (released unter BSL 1.0)
- Code:
-
# COPYRIGHT 2010 CKing <cking@live.de>
# Released under BSL 1.0 (Boost Software License)
# see http://www.boost.org/LICENSE_1_0.txt
# Mirror: http://www.opensource.org/licenses/bsl1.0.html
find_package(SFML REQUIRED)
find_package(OpenGL REQUIRED)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src"
${SFML_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
add_library(spark src/SPK_All.cpp)
add_library(spark-gl src/SPK_GL_All.cpp)
add_library(spark-sfml src/SPK_SFML_All.cpp)
if (BUILD_SHARED_LIBS)
target_link_libraries(spark-gl ${OPENGL_LIBRARIES})
set_target_properties(spark PROPERTIES COMPILE_DEFINITIONS
SPK_CORE_EXPORT)
set_target_properties(spark-sfml PROPERTIES COMPILE_DEFINITIONS
SPK_SFML_EXPORT;SPK_CORE_IMPORT;SPK_GL_IMPORT;SFML_DYNAMIC)
set_target_properties(spark-sfml PROPERTIES COMPILE_DEFINITIONS
SPK_GL_EXPORT;SPK_CORE_IMPORT)
else()
set_target_properties(spark PROPERTIES COMPILE_DEFINITIONS
_LIB)
endif()
target_link_libraries(spark-gl spark)
target_link_libraries(spark-sfml ${SFML_LIBRARY} spark spark-gl)
you also need a FindSFML.cmake file, for simplicity i'll post mine
- Code:
-
# Locate SFML library
# This module defines
# SFML_LIBRARY, the name of the library to link against
# - Find SFML Libraries
# Find your SFML include directory
# This file defines the following:
# - SFML_FOUND: Found SFML!
# - SFML_INCLUDE_DIR[S]: Path to SFML/[Component].hpp
# - SFML_LIBRAR[Y|IES]: Path to all (requested) Components
# - SFML_[COMPONENT]_LIBRARY: Path to the specified Component
#
# Following Components are default: System, Audio, Graphics, Network, Window
#
# Created by Nils Hasenbanck. Based on the FindSDL_*.cmake modules,
# created by Eric Wing, which were influenced by the FindSDL.cmake
# module, but with modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
# Modified by CKing <cking@live.de>, and released under BSL 1.0
# see http://www.boost.org/LICENSE_1_0.txt
# Mirror: http://www.opensource.org/licenses/bsl1.0.html
IF(NOT SFML_COMPONENTS)
SET(SFML_COMPONENTS
System
Audio
Graphics
Network
Window
)
ELSE()
LIST(APPEND SFML_COMPONENTS System)
ENDIF()
SET(SFML_INCLUDE_SEARCH_DIR
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
)
SET(SFML_LIBRARY_SEARCH_DIR
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
)
IF(SFML_STATIC)
SET(_EXT "-s")
ENDIF()
IF(SFML_DEBUG)
SET(_EXT "${_EXT}-d")
ENDIF()
FOREACH(_COMPONENT ${SFML_COMPONENTS})
STRING(TOUPPER ${_COMPONENT} _UPPERCOMPONENT)
STRING(TOLOWER ${_COMPONENT} _LOWERCOMPONENT)
FIND_LIBRARY(SFML_${_UPPERCOMPONENT}_LIBRARY
NAMES sfml-${_LOWERCOMPONENT}${_EXT}
HINTS $ENV{SFMLDIR}
PATH_SUFFIXES lib64 lib
PATHS ${SFML_LIBRARY_SEARCH_DIR}
)
FIND_PATH(SFML_${_UPPERCOMPONENT}_INCLUDE_DIR ${_COMPONENT}.hpp
HINTS $ENV{SFMLDIR}
PATH_SUFFIXES include SFML
PATHS ${SFML_INCLUDE_SEARCH_DIR}
)
IF(SFML_${_UPPERCOMPONENT}_INCLUDE_DIR AND SFML_${_UPPERCOMPONENT}_LIBRARY)
SET(SFML_${_UPPERCOMPONENT}_FOUND TRUE)
LIST(APPEND SFML_LIBRARY ${SFML_${_UPPERCOMPONENT}_LIBRARY})
LIST(APPEND SFML_INCLUDE_DIR ${SFML_${_UPPERCOMPONENT}_INCLUDE_DIR})
ENDIF()
ENDFOREACH()
IF(WIN32)
#ensure only -d as extension
STRING(REPLACE "-s" "" _EXT ${_EXT})
#Now we are looking for "sfml-main.lib".
#Because we need it if we give ADD_EXECUTABLE the WIN32 switch to creat a GUI application (that one without a cmd promt)
FIND_LIBRARY( SFML_MAIN_LIBRARY
NAMES sfml-main${_EXT}
PATH_SUFFIXES lib64 lib
PATHS ${SFML_LIBRARY_SEARCH_DIR}
)
LIST(APPEND SFML_LIBRARY ${SFML_MAIN_LIBRARY})
ENDIF(WIN32)
LIST(REMOVE_DUPLICATES SFML_LIBRARY)
LIST(REMOVE_DUPLICATES SFML_INCLUDE_DIR)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SFML DEFAULT_MSG
SFML_SYSTEM_LIBRARY SFML_LIBRARY SFML_INCLUDE_DIR)
SET(SFML_LIBRARIES ${SFML_LIBRARY})
SET(SFML_INCLUDE_DIRS ${SFML_INCLUDE_DIR})
just save the first as CMakeLists.txt and the second as FindSFML.cmake.
make sure FindSFML.cmake is in the cmake module-path.
eg, put the FindSFML.cmake in a cmake folder in the root of the sourcetree and add the following to the CMakeLists.txt of above:
- Code:
-
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
maybe this helbs someone.