summaryrefslogblamecommitdiffstats
path: root/CMakeLists.txt
blob: aa172f42acb672ad0ad950292e95fd5a88c3ac7d (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                                   
                 
                          
                                                        
                        
 



          
                                        
                                        
 
                                                                                                                                                                                                                                                                                                                                                            
 




                         
                                                                                

                                                                                             
        



                                                            
                                                                              








                                                                 



            
                                                             




                                                                 
                                                   
                                                                         






                                                                   




                                                                                             








                                                                      




                                            

                                                           
cmake_minimum_required(VERSION 3.8)
project(AltCraft)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(externalProject)

##########
# SOURCES
##########

file(GLOB_RECURSE SOURCES "./src/*.cpp")
file(GLOB_RECURSE HEADERS "./src/*.hpp")

add_executable(AltCraft ${HEADERS} ${SOURCES} src/Utility.cpp src/Render.cpp src/Render.hpp src/RendererWorld.cpp src/RendererWorld.hpp src/Renderer.cpp src/Renderer.hpp src/Thread.cpp src/Thread.hpp src/ThreadGame.cpp src/ThreadGame.hpp src/ThreadRender.cpp src/ThreadRender.hpp src/ThreadNetwork.cpp src/ThreadNetwork.hpp src/FSM.cpp src/FSM.hpp)

################
# CONFIGURATION
################

#Configure easlylogging++
set(LOGGER_DEFINITIONS "-DELPP_THREAD_SAFE -DELPP_FEATURE_PERFORMANCE_TRACKING")
if (LINUX)
    set(LOGGER_DENITIONS "${LOGGER_DEFINITIPNS} -DELPP_FEATURE_CRASH_LOG -DELPP_STL_LOGGING")
endif ()
add_definitions(${LOGGER_DEFINITIONS})

#Set compiler's flags and setup platfrom-dependent libraries
if (CMAKE_COMPILER_IS_GNUCXX)
    #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Werror")
    #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
    #set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -O3")
    #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
    #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -p")
    set(PLATFORM_LIBRARIES "pthread" "stdc++fs")
endif ()
target_link_libraries(AltCraft ${PLATFORM_LIBRARIES})

############
# LIBRARIES
############

#Setup dependencies (GLEW, glm, nlohmann/json, easylogging++)
add_subdirectory(depedencies)
target_include_directories(AltCraft PUBLIC ./depedencies/include)
target_link_libraries(AltCraft deps)

#Setup SFML
set (SFML_ROOT "${CMAKE_SOURCE_DIR}/external/SFML")
find_package(SFML 2.3 COMPONENTS system window graphics network REQUIRED)
if (SFML_FOUND)
    target_link_libraries(AltCraft ${SFML_LIBRARIES})
    target_include_directories(AltCraft PUBLIC ${SFML_INCLUDE_DIR})
else ()
    message(FATAL_ERROR "SFML not found!")
endif ()

#Setup SFML
#add_subdirectory(external/SFML)
#target_include_directories(AltCraft PUBLIC external/SFML/include)
#target_link_libraries(AltCraft sfml-main sfml-system sfml-network sfml-window sfml-graphics)

#Setup OpenGL
find_package(OpenGL REQUIRED)
if (OPENGL_FOUND)
    target_link_libraries(AltCraft ${OPENGL_LIBRARIES})
    target_include_directories(AltCraft PUBLIC ${OPENGL_INCLUDE_DIRS})
else ()
    message(FATAL_ERROR "OpenGL not found!")
endif ()

#################
# COPY RESOURCES
#################

add_custom_command(TARGET AltCraft PRE_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${CMAKE_SOURCE_DIR}/cwd $<TARGET_FILE_DIR:AltCraft>)