Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c72ea7aedc
Fetching contributors…

Cannot retrieve contributors at this time

file 133 lines (111 sloc) 3.631 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
# versao minima requerida
cmake_minimum_required(VERSION 2.8)

# variaveis do projeto
set(PROJECT_NAME "sfml-project")

set(
    GAME_ALL_SOURCES
    ../main.cpp
    ../sf_v8.cpp
    ../v8wrap.cpp
    ../JSCharacter.cpp
    ../Character.cpp
    ../Engine.cpp
    ../Util.cpp
)

if(APPLE)
    list(APPEND GAME_ALL_SOURCES ../ResourcePath.mm)
endif()

# define target
if(APPLE)
    set(TARGET_SYSTEM "mac")
    set(MACOSX_BUNDLE true)
elseif(WIN32)
    set(TARGET_SYSTEM "win32")
else()
    set(TARGET_SYSTEM "linux")
endif()

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build/cmake/modules")

set(RESOURCES_DIR "${CMAKE_SOURCE_DIR}/resources")
set(JS_DIR "${CMAKE_SOURCE_DIR}/js")

set(SFML_ROOT "${CMAKE_SOURCE_DIR}/library/sfml/${TARGET_SYSTEM}/lib")
set(SFML_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/library/sfml/${TARGET_SYSTEM}/include")
set(SFML_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/library/sfml/${TARGET_SYSTEM}/lib")
set(SNDFILE_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/library/sndfile/${TARGET_SYSTEM}/include")
set(SNDFILE_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/library/sndfile/${TARGET_SYSTEM}/lib")
set(V8_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/library/v8/${TARGET_SYSTEM}/include")
set(V8_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/library/v8/${TARGET_SYSTEM}/lib")

# nome do projeto
project(${PROJECT_NAME})

# icone do projeto
if(APPLE)
    set(MACOSX_BUNDLE_ICON_FILE "${RESOURCES_DIR}/icons/osx.icns")
elseif(WIN32)
    # implementar
else()
    # implementar
endif()

# biblioteca SFML
find_package(SFML COMPONENTS system window graphics network audio REQUIRED)

include_directories(
    ${SFML_INCLUDE_DIR}
)

# biblioteca SNDFILE
include_directories(
    ${SNDFILE_INCLUDE_DIR}
)

find_library(SNDFILE_LIBRARY sndfile ${SNDFILE_LIBRARY_DIR})

# biblioteca V8
include_directories(
    ${V8_INCLUDE_DIR}
)

find_library(V8_LIBRARIES v8 ${V8_LIBRARY_DIR})

# biblioteca core foundation
if(APPLE)
    set(CMAKE_EXE_LINKER_FLAGS "-framework Foundation -w")
endif()

# compila
add_executable(
    ${PROJECT_NAME}
    MACOSX_BUNDLE
    ${GAME_ALL_SOURCES}
    ${SFML_LIBRARIES}
    ${SNDFILE_LIBRARY}
    ${V8_LIBRARIES}
)

#set_target_properties(${PROJECT_NAME} PROPERTIES RESOURCE "${RESOURCES_DIR}")

# link de bibliotecas
target_link_libraries(${PROJECT_NAME} ${SFML_LIBRARIES} ${SNDFILE_LIBRARY} ${V8_LIBRARIES})

# copia arquivos
if(APPLE)
    add_custom_command(
        TARGET ${PROJECT_NAME} POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory "${SFML_LIBRARY_DIR}" "${CMAKE_SOURCE_DIR}/build/${PROJECT_NAME}.app/Contents/Frameworks"
    )
    add_custom_command(
        TARGET ${PROJECT_NAME} POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory "${SNDFILE_LIBRARY_DIR}" "${CMAKE_SOURCE_DIR}/build/${PROJECT_NAME}.app/Contents/Frameworks"
    )
    add_custom_command(
        TARGET ${PROJECT_NAME} POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_SOURCE_DIR}/build/${PROJECT_NAME}.app/Contents/Resources/js"
    )
    add_custom_command(
        TARGET ${PROJECT_NAME} POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory "${JS_DIR}" "${CMAKE_SOURCE_DIR}/build/${PROJECT_NAME}.app/Contents/Resources/js"
    )
    add_custom_command(
        TARGET ${PROJECT_NAME} POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory "${RESOURCES_DIR}" "${CMAKE_SOURCE_DIR}/build/${PROJECT_NAME}.app/Contents/Resources"
    )
elseif(WIN32)
    # implementar
else()
    # implementar
endif()

# define target mode "debug" ou "release"
set(TARGET_MODE "debug")

if(TARGET_MODE STREQUAL "debug")
    set(CMAKE_BUILD_TYPE Debug)
elseif(TARGET_MODE STREQUAL "release")
    set(CMAKE_BUILD_TYPE Release)
endif()
Something went wrong with that request. Please try again.