From a6699df92318e0c95ae03ebee70ff1a7aed07b51 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 4 Jun 2013 13:56:33 -0500 Subject: [PATCH 01/20] Add @naraku9333's CMakeLists.txt from #41 --- CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++ Makefile | 74 ------------------------------------------- Makefile.Lowest0ne | 76 --------------------------------------------- build_clang_win.bat | 2 -- 4 files changed, 57 insertions(+), 152 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 Makefile.Lowest0ne delete mode 100644 build_clang_win.bat diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4ed793d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,57 @@ + +# ChessPlusPlus +# +# Configuration options: +# -DCMAKE_BUILD_TYPE=Release|Debug +# -DSFMLROOT=S:/F/M/L/path/only/if/not/lib/SFML +# -DSTATIC_BUILD=1|0 + +cmake_minimum_required (VERSION 2.8) + +project (CHESSPP) + +if(WIN32) +set(SFMLROOT "" CACHE STRING "Path to SFML root directory") +option(STATIC_BUILD "Link statically") +endif() + +include_directories (${CHESSPP_SOURCE_DIR}/lib/json-parser ) +include_directories (${CHESSPP_SOURCE_DIR}/lib/boost) +include_directories (${SFMLROOT}/include) + +file(GLOB_RECURSE CHESSPP_SOURCES "src/*.cpp") +file(GLOB_RECURSE CHESSPP_HEADERS "src/*.hpp") +list(APPEND CHESSPP_SOURCES "lib/json-parser/*.c") + +set (CHESSPP_INCLUDE_DIRS "") +foreach (_headerFile ${CHESSPP_HEADERS}) + get_filename_component(_dir ${_headerFile} PATH) + list (APPEND CHESSPP_INCLUDE_DIRS ${_dir}) +endforeach() +list(REMOVE_DUPLICATES CHESSPP_INCLUDE_DIRS) + +include_directories(${CHESSPP_INCLUDE_DIRS}) +link_directories(${SFMLROOT}/lib) +add_executable (chessplusplus ${CHESSPP_SOURCES}) + +set(SFMLLIBS sfml-graphics sfml-window sfml-audio sfml-network sfml-system) + +if(STATIC_BUILD) + add_definitions(-DSFML_STATIC) + foreach(_lib ${SFMLLIBS}) + set(_lib "${_lib}-s") + list(APPEND TEMPLIBS ${_lib}) + endforeach() + set(SFMLLIBS ${TEMPLIBS}) +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-DDEBUG) + foreach(_lib ${SFMLLIBS}) + set(_lib "${_lib}-d") + list(APPEND TEMPLIBS2 ${_lib}) + endforeach() + set(SFMLLIBS ${TEMPLIBS2}) +endif() + +target_link_libraries(chessplusplus ${SFMLLIBS} boost_system boost_filesystem) diff --git a/Makefile b/Makefile deleted file mode 100644 index f2a6248..0000000 --- a/Makefile +++ /dev/null @@ -1,74 +0,0 @@ -#usage -# make CFG=release - -CPP = g++ -CC = gcc -CPPFLAGS += -std=c++11 -Wall -Wextra -pedantic-errors -INCLUDE = -isystem lib/json-parser/ -Isrc - -LIB = `pkg-config --libs sfml-all` lib/json-parser/json.c -lboost_system -lboost_filesystem - -ifeq ($(CFG),) -CFG=debug -endif - -ifeq ($(CFG),debug) -CPPFLAGS += -ggdb -DDEBUG -else -CPPFLAGS += -O2 -endif -CPPFLAGS += $(INCLUDE) - - -VPATH=src:src/board/:src/config/:src/graphics/:src/log/:src/util/ -TARGET=chesscpp.bin - -SRC = \ - Queen.cpp \ - Board.cpp \ - Pawn.cpp \ - Position.cpp \ - Bishop.cpp \ - King.cpp \ - Rook.cpp \ - Knight.cpp \ - Piece.cpp \ - Main.cpp \ - Graphics.cpp \ - Application.cpp \ - AppStateGame.cpp - -OBJ = $(patsubst %.cpp, objs.$(CFG)/%.o, ${SRC}) -DEP = $(patsubst %.cpp, deps.$(CFG)/%.d, ${SRC}) - -all: ${TARGET} - -${TARGET}: ${OBJ} - mkdir -p $(dir $@) - $(CPP) $^ $(LIBDIR) $(LIB) -o $@ - -test: - echo $(OBJ) - echo $(DEP) - - -deps.$(CFG)/%.d: %.cpp - mkdir -p $(dir $@) - $(CPP) -MM -MP $(CPPFLAGS) $< | perl -pe 's#^(.*\.o)#deps.$(CFG)/$$1 objs.$(CFG)/$$1#' > $@ - -objs.$(CFG)/%.o: %.cpp - mkdir -p $(dir $@) - $(CPP) -c $(CPPFLAGS) $< -o $@ - -.PHONY: clean deps - -clean: - -rm -r objs.debug deps.debug ${TARGET} - -rm -r objs.release deps.release - - - -# Unless "make clean" is called, include the dependency files -# which are auto-generated. Don't fail if they are missing -# (-include), since they will be missing in the first invocation! --include ${DEP} diff --git a/Makefile.Lowest0ne b/Makefile.Lowest0ne deleted file mode 100644 index f1d988e..0000000 --- a/Makefile.Lowest0ne +++ /dev/null @@ -1,76 +0,0 @@ -# A MinGW Makefile -# As it uses -std=c++, g++ must be at least Version 4.7 ( $ g++ --version ) -# I ended up downloading this: http://nuwen.net/mingw.html - -CC = g++ -FLAGS = -Wall -std=c++11 -DSFML_STATIC -OFLAG = $(FLAGS) -c - -INCLUDE = -I../../include -I./lib/json-parser -I./src -LIBDIR = -L../../lib/sfml -SOURCEDIR = ./src/ - -ODIR = ./obj/ -OBJECTS = $(ODIR)Application.o $(ODIR)AppStateGame.o $(ODIR)Graphics.o\ -$(ODIR)Main.o $(ODIR)Pawn.o $(ODIR)Rook.o $(ODIR)Knight.o $(ODIR)Bishop.o\ -$(ODIR)Queen.o $(ODIR)King.o $(ODIR)Logger.o $(ODIR)Piece.o $(ODIR)Position.o\ -$(ODIR)Board.o $(ODIR)json-parser.o - -EXECUTABLE = ChessPlusPlus.exe - - -#LIBS = -lsfml-graphics -lsfml-window -lsfml-system -LIBS = -lsfml-graphics-s -lsfml-window-s -lsfml-system-s - -$(EXECUTABLE): $(OBJECTS) - $(CC) $(FLAGS) $(OBJECTS) -o $(EXECUTABLE) $(LIBDIR) $(LIBS) - -$(ODIR)Application.o: $(SOURCEDIR)Application.cpp $(SOURCEDIR)Application.hpp\ -$(SOURCEDIR)AppState.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)Application.cpp -o $(ODIR)Application.o - -$(ODIR)AppStateGame.o: $(SOURCEDIR)AppStateGame.cpp $(SOURCEDIR)graphics/Graphics.hpp\ -$(SOURCEDIR)SFML.hpp $(SOURCEDIR)TextureManager.hpp $(SOURCEDIR)board/Board.hpp\ -$(SOURCEDIR)config/Configuration.hpp $(SOURCEDIR)AppStateGame.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)AppStateGame.cpp -o $(ODIR)AppStateGame.o - -$(ODIR)Graphics.o: $(SOURCEDIR)graphics/Graphics.cpp $(SOURCEDIR)graphics/Graphics.hpp\ -$(SOURCEDIR)SFML.hpp $(SOURCEDIR)TextureManager.hpp $(SOURCEDIR)board/Piece.hpp\ -$(SOURCEDIR)config/Configuration.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)graphics/Graphics.cpp -o $(ODIR)Graphics.o - -$(ODIR)Main.o: $(SOURCEDIR)Main.cpp $(SOURCEDIR)Application.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)Main.cpp -o $(ODIR)Main.o - -$(ODIR)Pawn.o: $(SOURCEDIR)board/Pawn.cpp $(SOURCEDIR)board/Pawn.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/Pawn.cpp -o $(ODIR)Pawn.o - -$(ODIR)Rook.o: $(SOURCEDIR)board/Rook.cpp $(SOURCEDIR)board/Rook.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/Rook.cpp -o $(ODIR)Rook.o - -$(ODIR)Knight.o: $(SOURCEDIR)board/Knight.cpp $(SOURCEDIR)board/Knight.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/Knight.cpp -o $(ODIR)Knight.o - -$(ODIR)Bishop.o: $(SOURCEDIR)board/Bishop.cpp $(SOURCEDIR)board/Bishop.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/Bishop.cpp -o $(ODIR)Bishop.o - -$(ODIR)Queen.o: $(SOURCEDIR)board/Queen.cpp $(SOURCEDIR)board/Queen.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/Queen.cpp -o $(ODIR)Queen.o - -$(ODIR)King.o: $(SOURCEDIR)board/King.cpp $(SOURCEDIR)board/King.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/King.cpp -o $(ODIR)King.o - -$(ODIR)Piece.o: $(SOURCEDIR)board/Piece.cpp $(SOURCEDIR)board/Piece.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/Piece.cpp -o $(ODIR)Piece.o - -$(ODIR)Position.o: $(SOURCEDIR)board/Position.cpp $(SOURCEDIR)board/Position.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/Position.cpp -o $(ODIR)Position.o - -$(ODIR)Board.o: $(SOURCEDIR)board/Board.cpp $(SOURCEDIR)board/Board.hpp - $(CC) $(OFLAG) $(INCLUDE) $(SOURCEDIR)board/Board.cpp -o $(ODIR)Board.o - -$(ODIR)json-parser.o: ./lib/json-parser/json.c ./lib/json-parser/json.h - $(CC) $(OFLAG) ./lib/json-parser/json.c -o $(ODIR)json-parser.o - -clean: - rm $(OBJECTS) $(EXECUTABLE) \ No newline at end of file diff --git a/build_clang_win.bat b/build_clang_win.bat deleted file mode 100644 index 47e0d0c..0000000 --- a/build_clang_win.bat +++ /dev/null @@ -1,2 +0,0 @@ -clang++ -std=c++11 -o chesspp.exe -isystem lib/boost/boost/ -isystem lib/SFML/include/ -isystem lib/json-parser/ -Llib/SFML/lib/ -I src/ lib/json-parser/json.c src/*.cpp src/board/*.cpp src/graphics/*.cpp -lsfml-graphics -lsfml-window -lsfml-audio -lsfml-network -lsfml-system -pause From d654311d55e50bc0dd01af021ac5641c7376162a Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 4 Jun 2013 14:16:42 -0500 Subject: [PATCH 02/20] Fix CMakeLists.txt to have proper include paths --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ed793d..1d7b23c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ # # Configuration options: # -DCMAKE_BUILD_TYPE=Release|Debug -# -DSFMLROOT=S:/F/M/L/path/only/if/not/lib/SFML # -DSTATIC_BUILD=1|0 cmake_minimum_required (VERSION 2.8) @@ -16,8 +15,8 @@ option(STATIC_BUILD "Link statically") endif() include_directories (${CHESSPP_SOURCE_DIR}/lib/json-parser ) -include_directories (${CHESSPP_SOURCE_DIR}/lib/boost) -include_directories (${SFMLROOT}/include) +include_directories (${CHESSPP_SOURCE_DIR}/lib/boost/boost) +include_directories (${CHESSPP_SOURCE_DIR}/lib/SFML/include) file(GLOB_RECURSE CHESSPP_SOURCES "src/*.cpp") file(GLOB_RECURSE CHESSPP_HEADERS "src/*.hpp") From 13498722f76b3d99ecff2819f2378dc1ee37f188 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Wed, 5 Jun 2013 08:01:02 -0500 Subject: [PATCH 03/20] Allow overriding library paths for cmake --- CMakeLists.txt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d7b23c..3b3f273 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,3 @@ - # ChessPlusPlus # # Configuration options: @@ -14,9 +13,19 @@ set(SFMLROOT "" CACHE STRING "Path to SFML root directory") option(STATIC_BUILD "Link statically") endif() -include_directories (${CHESSPP_SOURCE_DIR}/lib/json-parser ) -include_directories (${CHESSPP_SOURCE_DIR}/lib/boost/boost) -include_directories (${CHESSPP_SOURCE_DIR}/lib/SFML/include) +if(NOT JSONLIB) + set(JSONLIB ${CHESSPP_SOURCE_DIR}/lib/json-parser) +endif() +if(NOT BOOSTLIB) + set(BOOSTLIB ${CHESSPP_SOURCE_DIR}/lib/boost) +endif() +if(NOT SFMLLIB) + set(SFMLLIB ${CHESSPP_SOURCE_DIR}/lib/SFML) +endif() + +include_directories (${JSONLIB}) +include_directories (${BOOSTLIB}/boost) +include_directories (${SFMLLIB}/include) file(GLOB_RECURSE CHESSPP_SOURCES "src/*.cpp") file(GLOB_RECURSE CHESSPP_HEADERS "src/*.hpp") From 2e4bf3e0b673fbe08fd2f9fbdf0d6b579a0638f6 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Wed, 5 Jun 2013 11:44:08 -0500 Subject: [PATCH 04/20] Fix wrong boost include path --- CMakeLists.txt | 3 ++- lib/SFML | 2 +- lib/json-parser | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b3f273..7c2abf9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ + # ChessPlusPlus # # Configuration options: @@ -24,7 +25,7 @@ if(NOT SFMLLIB) endif() include_directories (${JSONLIB}) -include_directories (${BOOSTLIB}/boost) +include_directories (${BOOSTLIB}) include_directories (${SFMLLIB}/include) file(GLOB_RECURSE CHESSPP_SOURCES "src/*.cpp") diff --git a/lib/SFML b/lib/SFML index 86897a8..7c9f9cc 160000 --- a/lib/SFML +++ b/lib/SFML @@ -1 +1 @@ -Subproject commit 86897a8347f8e6a1df56bc2a4062982539ab284f +Subproject commit 7c9f9cc41cca5afe9940eaa7f543de45b38cdc79 diff --git a/lib/json-parser b/lib/json-parser index 7a739b8..daf2065 160000 --- a/lib/json-parser +++ b/lib/json-parser @@ -1 +1 @@ -Subproject commit 7a739b89aceca165bef5c662b45a707341fcd863 +Subproject commit daf20654a22d81668625f412871ddb242d904f61 From b7f7ffa3ef16217a3b71c0f4f79d5590904b6664 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Fri, 27 Sep 2013 12:13:22 -0500 Subject: [PATCH 05/20] Remove reference to boost submodule --- CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c2abf9..15e648e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,6 @@ endif() if(NOT JSONLIB) set(JSONLIB ${CHESSPP_SOURCE_DIR}/lib/json-parser) endif() -if(NOT BOOSTLIB) - set(BOOSTLIB ${CHESSPP_SOURCE_DIR}/lib/boost) -endif() if(NOT SFMLLIB) set(SFMLLIB ${CHESSPP_SOURCE_DIR}/lib/SFML) endif() From 47966668ad2f6ba23542b78e014983e44e6ee07e Mon Sep 17 00:00:00 2001 From: Sean Vogel Date: Fri, 27 Sep 2013 22:34:28 -0500 Subject: [PATCH 06/20] Update CMakeLists.txt add FindSFML.cmake --- CMakeLists.txt | 64 ++++++----- cmake_modules/FindSFML.cmake | 209 +++++++++++++++++++++++++++++++++++ 2 files changed, 245 insertions(+), 28 deletions(-) create mode 100644 cmake_modules/FindSFML.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 15e648e..89620f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,25 +9,23 @@ cmake_minimum_required (VERSION 2.8) project (CHESSPP) +#Set options if(WIN32) -set(SFMLROOT "" CACHE STRING "Path to SFML root directory") -option(STATIC_BUILD "Link statically") + set(SFML_ROOT "" CACHE PATH "Path to SFML root directory") + set(BOOST_ROOT "" CACHE PATH "Path to Boost root directory") + set(STATIC_BUILD TRUE CACHE BOOL "Link SFML statically") #option(STATIC_BUILD "Link statically" FALSE) endif() +#Add json-parser if(NOT JSONLIB) set(JSONLIB ${CHESSPP_SOURCE_DIR}/lib/json-parser) endif() -if(NOT SFMLLIB) - set(SFMLLIB ${CHESSPP_SOURCE_DIR}/lib/SFML) -endif() - include_directories (${JSONLIB}) -include_directories (${BOOSTLIB}) -include_directories (${SFMLLIB}/include) +#Get all source files file(GLOB_RECURSE CHESSPP_SOURCES "src/*.cpp") file(GLOB_RECURSE CHESSPP_HEADERS "src/*.hpp") -list(APPEND CHESSPP_SOURCES "lib/json-parser/*.c") +list(APPEND CHESSPP_SOURCES "lib/json-parser/json.c") set (CHESSPP_INCLUDE_DIRS "") foreach (_headerFile ${CHESSPP_HEADERS}) @@ -35,29 +33,39 @@ foreach (_headerFile ${CHESSPP_HEADERS}) list (APPEND CHESSPP_INCLUDE_DIRS ${_dir}) endforeach() list(REMOVE_DUPLICATES CHESSPP_INCLUDE_DIRS) - include_directories(${CHESSPP_INCLUDE_DIRS}) -link_directories(${SFMLROOT}/lib) -add_executable (chessplusplus ${CHESSPP_SOURCES}) - -set(SFMLLIBS sfml-graphics sfml-window sfml-audio sfml-network sfml-system) +list(APPEND CMAKE_CXX_FLAGS "-std=c++11") + +# Detect and add SFML +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) if(STATIC_BUILD) - add_definitions(-DSFML_STATIC) - foreach(_lib ${SFMLLIBS}) - set(_lib "${_lib}-s") - list(APPEND TEMPLIBS ${_lib}) - endforeach() - set(SFMLLIBS ${TEMPLIBS}) + set(SFML_STATIC_LIBRARIES TRUE) +else() + set(SFML_STATIC_LIBRARIES FALSE) endif() +find_package(SFML 2 REQUIRED graphics window network system audio) +include_directories (${SFML_INCLUDE_DIR}) +link_directories(${SFML_ROOT}/lib) + +#Detect Boost +find_package(Boost 1.54.0 COMPONENTS filesystem system REQUIRED) +include_directories(${BOOST_ROOT}) +set(Boost_LIBRARYDIR ${BOOST_ROOT}/lib) +link_directories(${Boost_LIBRARY_DIR}) -if(CMAKE_BUILD_TYPE STREQUAL "Debug") - add_definitions(-DDEBUG) - foreach(_lib ${SFMLLIBS}) - set(_lib "${_lib}-d") - list(APPEND TEMPLIBS2 ${_lib}) - endforeach() - set(SFMLLIBS ${TEMPLIBS2}) +#Set static runtime for msvc +if(WIN32) + if(MSVC AND STATIC_BUILD) + foreach(flag + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}") + endif() + endforeach() + endif() endif() -target_link_libraries(chessplusplus ${SFMLLIBS} boost_system boost_filesystem) +add_executable (chesspp ${CHESSPP_SOURCES}) +target_link_libraries(chesspp ${SFML_LIBRARIES} ${Boost_LIBRARIES}) diff --git a/cmake_modules/FindSFML.cmake b/cmake_modules/FindSFML.cmake new file mode 100644 index 0000000..99cbff2 --- /dev/null +++ b/cmake_modules/FindSFML.cmake @@ -0,0 +1,209 @@ +# This script locates the SFML library +# ------------------------------------ +# +# Usage +# ----- +# +# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main). +# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing. +# example: +# find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules +# +# You can enforce a specific version, either MAJOR.MINOR or only MAJOR. +# If nothing is specified, the version won't be checked (ie. any version will be accepted). +# example: +# find_package(SFML COMPONENTS ...) // no specific version required +# find_package(SFML 2 COMPONENTS ...) // any 2.x version +# find_package(SFML 2.4 COMPONENTS ...) // version 2.4 or greater +# +# By default, the dynamic libraries of SFML will be found. To find the static ones instead, +# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...). +# In case of static linking, the SFML_STATIC macro will also be defined by this script. +# example: +# set(SFML_STATIC_LIBRARIES TRUE) +# find_package(SFML 2 COMPONENTS network system) +# +# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless +# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details. +# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which +# are available for both release and debug modes. +# +# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable +# to tell CMake where SFML is. +# +# Output +# ------ +# +# This script defines the following variables: +# - For each specified module XXX (system, window, graphics, network, audio, main): +# - SFML_XXX_LIBRARY_DEBUG: the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found) +# - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found) +# - SFML_XXX_LIBRARY: the name of the library to link to for the xxx module (includes both debug and optimized names if necessary) +# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found +# - SFML_LIBRARIES: the list of all libraries corresponding to the required modules +# - SFML_FOUND: true if all the required modules are found +# - SFML_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file) +# +# example: +# find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED) +# include_directories(${SFML_INCLUDE_DIR}) +# add_executable(myapp ...) +# target_link_libraries(myapp ${SFML_LIBRARIES}) + +# define the SFML_STATIC macro if static build was chosen +if(SFML_STATIC_LIBRARIES) + add_definitions(-DSFML_STATIC) +endif() + +# deduce the libraries suffix from the options +set(FIND_SFML_LIB_SUFFIX "") +if(SFML_STATIC_LIBRARIES) + set(FIND_SFML_LIB_SUFFIX "${FIND_SFML_LIB_SUFFIX}-s") +endif() + +# find the SFML include directory +find_path(SFML_INCLUDE_DIR SFML/Config.hpp + PATH_SUFFIXES include + PATHS + ${SFML_ROOT} + $ENV{SFML_ROOT} + ~/Library/Frameworks + /Library/Frameworks + /usr/local/ + /usr/ + /sw # Fink + /opt/local/ # DarwinPorts + /opt/csw/ # Blastwave + /opt/) + +# check the version number +set(SFML_VERSION_OK TRUE) +if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR) + # extract the major and minor version numbers from SFML/Config.hpp + # we have to handle framework a little bit differently : + if("${SFML_INCLUDE_DIR}" MATCHES "SFML.framework") + set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp") + else() + set(SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp") + endif() + FILE(READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS) + STRING(REGEX MATCH ".*#define SFML_VERSION_MAJOR ([0-9]+).*#define SFML_VERSION_MINOR ([0-9]+).*" SFML_CONFIG_HPP_CONTENTS "${SFML_CONFIG_HPP_CONTENTS}") + STRING(REGEX REPLACE ".*#define SFML_VERSION_MAJOR ([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}") + STRING(REGEX REPLACE ".*#define SFML_VERSION_MINOR ([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}") + math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10 + ${SFML_FIND_VERSION_MINOR}") + + # if we could extract them, compare with the requested version number + if (SFML_VERSION_MAJOR) + # transform version numbers to an integer + math(EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10 + ${SFML_VERSION_MINOR}") + + # compare them + if(SFML_VERSION LESS SFML_REQUESTED_VERSION) + set(SFML_VERSION_OK FALSE) + endif() + else() + # SFML version is < 2.0 + if (SFML_REQUESTED_VERSION GREATER 19) + set(SFML_VERSION_OK FALSE) + set(SFML_VERSION_MAJOR 1) + set(SFML_VERSION_MINOR x) + endif() + endif() +endif() + +# find the requested modules +set(SFML_FOUND TRUE) # will be set to false if one of the required modules is not found +set(FIND_SFML_LIB_PATHS + ${SFML_ROOT} + $ENV{SFML_ROOT} + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt) +foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS}) + string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER) + string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER) + set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER}${FIND_SFML_LIB_SUFFIX}) + + # no suffix for sfml-main, it is always a static library + if(FIND_SFML_COMPONENT_LOWER STREQUAL "main") + set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER}) + endif() + + # debug library + find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG + NAMES ${FIND_SFML_COMPONENT_NAME}-d + PATH_SUFFIXES lib64 lib + PATHS ${FIND_SFML_LIB_PATHS}) + + # release library + find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE + NAMES ${FIND_SFML_COMPONENT_NAME} + PATH_SUFFIXES lib64 lib + PATHS ${FIND_SFML_LIB_PATHS}) + + if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG OR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE) + # library found + set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND TRUE) + + # if both are found, set SFML_XXX_LIBRARY to contain both + if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY debug ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG} + optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE}) + endif() + + # if only one debug/release variant is found, set the other to be equal to the found one + if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE) + # debug and not release + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG}) + endif() + if (SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE AND NOT SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG) + # release and not debug + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE}) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE}) + endif() + else() + # library not found + set(SFML_FOUND FALSE) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_FOUND FALSE) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY "") + set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY") + endif() + + # mark as advanced + MARK_AS_ADVANCED(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY + SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE + SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG) + + # add to the global list of libraries + set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}") +endforeach() + +# handle errors +if(NOT SFML_VERSION_OK) + # SFML version not ok + set(FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR})") + set(SFML_FOUND FALSE) +elseif(NOT SFML_FOUND) + # include directory or library not found + set(FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})") +endif() +if (NOT SFML_FOUND) + if(SFML_FIND_REQUIRED) + # fatal error + message(FATAL_ERROR ${FIND_SFML_ERROR}) + elseif(NOT SFML_FIND_QUIETLY) + # error but continue + message("${FIND_SFML_ERROR}") + endif() +endif() + +# handle success +if(SFML_FOUND) + message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}") +endif() From 8d6e0fef275c9b67f75ffc579bbd5415c5485a31 Mon Sep 17 00:00:00 2001 From: Stephen Hall Date: Tue, 8 Oct 2013 13:12:00 -0400 Subject: [PATCH 07/20] Timestamps will appear as 01:02:03 instead of 1:2:3 --- src/Debug.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 0094fd6..df45079 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -79,7 +79,12 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::tm *local_time = std::localtime(&curr_time_raw); std::stringstream time; - time << "[" << local_time->tm_hour << ":" << local_time->tm_min << ":" << local_time->tm_sec << "] "; + time << "[" << (local_time->tm_hour < 10 ? "0" : "") + << local_time->tm_hour << ":" + << (local_time->tm_min < 10 ? "0" : "") + << local_time->tm_min << ":" + << (local_time->tm_sec < 10 ? "0" : "") + << local_time->tm_sec << "] "; return time.str(); } From 695c40c2cdc7e9ebae6349aed8b272b39ad2d96f Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 8 Oct 2013 12:29:36 -0500 Subject: [PATCH 08/20] Revert "Timestamps will appear as 01:02:03 instead of 1:2:3" This reverts commit 8d6e0fef275c9b67f75ffc579bbd5415c5485a31. --- src/Debug.hpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index df45079..0094fd6 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -79,12 +79,7 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::tm *local_time = std::localtime(&curr_time_raw); std::stringstream time; - time << "[" << (local_time->tm_hour < 10 ? "0" : "") - << local_time->tm_hour << ":" - << (local_time->tm_min < 10 ? "0" : "") - << local_time->tm_min << ":" - << (local_time->tm_sec < 10 ? "0" : "") - << local_time->tm_sec << "] "; + time << "[" << local_time->tm_hour << ":" << local_time->tm_min << ":" << local_time->tm_sec << "] "; return time.str(); } From 418ad93f0a554409491c7db2ba37255ac9911fa6 Mon Sep 17 00:00:00 2001 From: Valentin Tolstousov Date: Tue, 8 Oct 2013 21:42:25 +0400 Subject: [PATCH 09/20] fix timestamps and prevent variable shadowing inside constructor --- src/Debug.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 0094fd6..c25e7f2 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -2,6 +2,7 @@ #define __DebuggingLoggerUtility_HeaderPlusPlus__ #include +#include #include #include #include @@ -18,8 +19,8 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::vector buffer; public: - explicit LogUtil_buffer(std::ostream &sink, std::size_t buff_sz = 256) - : sink(sink) + explicit LogUtil_buffer(std::ostream &sink_, std::size_t buff_sz = 256) + : sink(sink_) , buffer(buff_sz + 1) { sink.clear(); @@ -79,9 +80,11 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::tm *local_time = std::localtime(&curr_time_raw); std::stringstream time; - time << "[" << local_time->tm_hour << ":" << local_time->tm_min << ":" << local_time->tm_sec << "] "; - - return time.str(); + time << std::setfill('0') << + "[" << std::setw(2) << local_time->tm_hour << + ":" << std::setw(2) << local_time->tm_min << + ":" << std::setw(2) << local_time->tm_sec << "] "; + return time.str(); } }; From f21fc6153ec47f3aa4ee970bee5953c1c3acf20d Mon Sep 17 00:00:00 2001 From: Stephen Hall Date: Tue, 8 Oct 2013 13:57:08 -0400 Subject: [PATCH 10/20] Timestamps appear as 01:02:03 instead of 1:2:3. Uses std::put_time --- src/Debug.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 0094fd6..815b265 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -2,6 +2,7 @@ #define __DebuggingLoggerUtility_HeaderPlusPlus__ #include +#include #include #include #include @@ -79,7 +80,7 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::tm *local_time = std::localtime(&curr_time_raw); std::stringstream time; - time << "[" << local_time->tm_hour << ":" << local_time->tm_min << ":" << local_time->tm_sec << "] "; + time << "[" << std::put_time(local_time, "%T") << "] "; return time.str(); } From 1b5678d8d71ca8cc4fb390c1cb003545adc058f8 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 8 Oct 2013 13:33:41 -0500 Subject: [PATCH 11/20] Fix reversed macro logic --- src/Debug.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 32e7819..70a2e94 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -80,7 +80,7 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::tm *local_time = std::localtime(&curr_time_raw); std::stringstream time; -#if !(__GNUC__ > 4 || ((__GNUC__ == 4) && __GNUC_MINOR__ > 8)) //GCC 4.8.1 does not support std::put_time +#if (__GNUC__ > 4 || ((__GNUC__ == 4) && __GNUC_MINOR__ > 8)) //GCC 4.8.1 does not support std::put_time time << "[" << std::put_time(local_time, "%T") << "] "; #else time << std::setfill('0') << From 531765f0799aee7c42437e84001f1caa460955a2 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 8 Oct 2013 13:39:23 -0500 Subject: [PATCH 12/20] Fix error when __GNUC__ is not defined --- src/Debug.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 70a2e94..8ad6506 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -80,7 +80,7 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::tm *local_time = std::localtime(&curr_time_raw); std::stringstream time; -#if (__GNUC__ > 4 || ((__GNUC__ == 4) && __GNUC_MINOR__ > 8)) //GCC 4.8.1 does not support std::put_time +#if !defined(__GNUC__) || (__GNUC__ > 4 || ((__GNUC__ == 4) && __GNUC_MINOR__ > 8)) //GCC 4.8.1 does not support std::put_time time << "[" << std::put_time(local_time, "%T") << "] "; #else time << std::setfill('0') << From 8d50698df5ebc1528e2d56652717b05922de30a6 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 8 Oct 2013 16:43:18 -0500 Subject: [PATCH 13/20] Prefer std solutuon with boost alternative --- src/Debug.hpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 8ad6506..b4fb872 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -10,6 +10,16 @@ #include #include +#if !defined(USE_STD_PUT_TIME) + //GCC 4.8.1 doesn't support std::put_time yet + #if !defined(__GNUC__) || (__GNUC__ > 4 || ((__GNUC__ == 4) && __GNUC_MINOR__ > 8)) + #define USE_STD_PUT_TIME 1 //next version of GCC probably does + #else + #define USE_STD_PUT_TIME 0 //use boost alternative + #include + #endif +#endif + class LogUtil //replaces std::clog, std::cerr, std::cout with file streams { class LogUtil_buffer : public std::streambuf @@ -77,16 +87,13 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams static std::string timestamp() { std::time_t curr_time_raw = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - std::tm *local_time = std::localtime(&curr_time_raw); + std::tm *lt = std::localtime(&curr_time_raw); std::stringstream time; -#if !defined(__GNUC__) || (__GNUC__ > 4 || ((__GNUC__ == 4) && __GNUC_MINOR__ > 8)) //GCC 4.8.1 does not support std::put_time - time << "[" << std::put_time(local_time, "%T") << "] "; +#ifdef USE_STD_PUT_TIME + time << "[" << std::put_time(lt, "%T") << "] "; #else - time << std::setfill('0') << - "[" << std::setw(2) << local_time->tm_hour << - ":" << std::setw(2) << local_time->tm_min << - ":" << std::setw(2) << local_time->tm_sec << "] "; + time << "[" << boost::posix_timeto_simple_string(time_duration(lt->tm_hour, lt->tm_min, lt->tm_sec)) << "] "; #endif return time.str(); } From 26b9de0c7e1903ec6bd6254dfd823f58e7b2a1ef Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 8 Oct 2013 16:46:38 -0500 Subject: [PATCH 14/20] Fix behavior of USE_STD_PUT_TIME macro --- src/Debug.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index b4fb872..73bf8ad 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -90,7 +90,7 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::tm *lt = std::localtime(&curr_time_raw); std::stringstream time; -#ifdef USE_STD_PUT_TIME +#if USE_STD_PUT_TIME time << "[" << std::put_time(lt, "%T") << "] "; #else time << "[" << boost::posix_timeto_simple_string(time_duration(lt->tm_hour, lt->tm_min, lt->tm_sec)) << "] "; From b8ad03bd71adf8e7105928e81593369ca4cddca8 Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 8 Oct 2013 16:48:31 -0500 Subject: [PATCH 15/20] Fix typo --- src/Debug.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 73bf8ad..066e827 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -93,7 +93,7 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams #if USE_STD_PUT_TIME time << "[" << std::put_time(lt, "%T") << "] "; #else - time << "[" << boost::posix_timeto_simple_string(time_duration(lt->tm_hour, lt->tm_min, lt->tm_sec)) << "] "; + time << "[" << boost::posix_time::to_simple_string(time_duration(lt->tm_hour, lt->tm_min, lt->tm_sec)) << "] "; #endif return time.str(); } From 640e8f78d0df49cbe1f7d93c22a3df4ecfe0288f Mon Sep 17 00:00:00 2001 From: "Nicholas \"LB\" Braden" Date: Tue, 8 Oct 2013 16:50:04 -0500 Subject: [PATCH 16/20] Qualify boost name --- src/Debug.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 066e827..714181a 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -93,7 +93,7 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams #if USE_STD_PUT_TIME time << "[" << std::put_time(lt, "%T") << "] "; #else - time << "[" << boost::posix_time::to_simple_string(time_duration(lt->tm_hour, lt->tm_min, lt->tm_sec)) << "] "; + time << "[" << boost::posix_time::to_simple_string(boost::posix_time::time_duration(lt->tm_hour, lt->tm_min, lt->tm_sec)) << "] "; #endif return time.str(); } From d0ec40fe03cc02fadcab502a49962e32b878daff Mon Sep 17 00:00:00 2001 From: Stephen Hall Date: Tue, 8 Oct 2013 21:15:09 -0400 Subject: [PATCH 17/20] CMakeLists.txt tweaks for OS x and Clang. list(append...) will not always work for CMAKE_CXX_FLAGS for reasons I don't know. Clang also requires the use of -stdlib=libc++. --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89620f4..48711db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,13 @@ endforeach() list(REMOVE_DUPLICATES CHESSPP_INCLUDE_DIRS) include_directories(${CHESSPP_INCLUDE_DIRS}) -list(APPEND CMAKE_CXX_FLAGS "-std=c++11") +# Add C++11 definitions +set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # Building with Clang (on OS x at least) requires -stdlib=libc++ flag + set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}") +endif() +#list(APPEND CMAKE_CXX_FLAGS "-std=c++11") # Detect and add SFML set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) From b29eba8debf4c0afb3c0c4dd71114daa6e653edb Mon Sep 17 00:00:00 2001 From: Stephen Hall Date: Tue, 8 Oct 2013 21:20:00 -0400 Subject: [PATCH 18/20] CMakeLists.txt comments --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48711db..4ac1c58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,13 +35,12 @@ endforeach() list(REMOVE_DUPLICATES CHESSPP_INCLUDE_DIRS) include_directories(${CHESSPP_INCLUDE_DIRS}) -# Add C++11 definitions +# Add C++11 definitions -- list(append...) will not always work. set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # Building with Clang (on OS x at least) requires -stdlib=libc++ flag set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}") endif() -#list(APPEND CMAKE_CXX_FLAGS "-std=c++11") # Detect and add SFML set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH}) From c513e1c4924a0c7321995b11d1e3b429f8396155 Mon Sep 17 00:00:00 2001 From: Stephen Hall Date: Tue, 8 Oct 2013 21:30:42 -0400 Subject: [PATCH 19/20] For some reason Clang does not support std::ostream operator bool. Workaround. --- src/Debug.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Debug.hpp b/src/Debug.hpp index 714181a..bd65726 100644 --- a/src/Debug.hpp +++ b/src/Debug.hpp @@ -61,7 +61,8 @@ class LogUtil //replaces std::clog, std::cerr, std::cout with file streams std::ptrdiff_t n = pptr() - pbase(); pbump(-n); - return (sink << out.str()); + sink << out.str(); + return (!sink.fail() && !sink.bad()); } //Overridden streambuf functions From c9ff1ac1bba9fdd53955a33c59456a175f5f4e0e Mon Sep 17 00:00:00 2001 From: Stephen Hall Date: Wed, 9 Oct 2013 00:07:15 -0400 Subject: [PATCH 20/20] Use libc++ only on apple machines. --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ac1c58..72f1dbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,10 @@ include_directories(${CHESSPP_INCLUDE_DIRS}) # Add C++11 definitions -- list(append...) will not always work. set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # Building with Clang (on OS x at least) requires -stdlib=libc++ flag - set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}") + if(APPLE) + # Building with Clang (on OS x at least) requires -stdlib=libc++ flag + set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}") + endif() endif() # Detect and add SFML