cmake
naraku9333 opened this issue · 1 comments
naraku9333 commented
I hacked together a CMakeLists.txt file that works for me in windows using g++. It needs testing on other OS and compilers. Configuration options are
CMAKE_BUILD_TYPE [Release|Debug]
SFMLROOT Path to SFML root directory
STATIC_BUILD Link statically if checked.
#ChessPlusPlus
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)