cmake_minimum_required(VERSION 3.0)
project(DarkRP2D_DEDICATED_SERVER)
set (CMAKE_CXX_STANDARD 11)
include(ExternalProject)

if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
    MESSAGE( "64-Bit Compiler erkannt" )
    SET( EX_PLATFORM 64 )
    SET( EX_PLATFORM_NAME "x64" )
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
    MESSAGE( "32-Bit Compiler erkannt" )
    SET( EX_PLATFORM 32 )
    SET( EX_PLATFORM_NAME "x86" )
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )

# Download automatically, you can also just copy the conan.cmake file
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
   message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
   file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.15/conan.cmake"
                 "${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)

# Launch Conan Install
conan_cmake_run(CONANFILE conanfile.txt
                BASIC_SETUP CMAKE_TARGETS
                BUILD missing 
                CONFIGURATION_TYPES "Release;Debug")

MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )
MESSAGE( STATUS "DarkRP2D_DEDICATED_SERVER_SOURCE_DIR: " ${DarkRP2D_DEDICATED_SERVER_SOURCE_DIR} )

#Libs
include(${CMAKE_BINARY_DIR}/conanbuildinfo_multi.cmake)
conan_basic_setup()

file(GLOB_RECURSE DarkRP2D_DEDICATED_SERVER_SOURCE_FILES ${DarkRP2D_DEDICATED_SERVER_SOURCE_DIR}/src/*.cpp)

add_executable(DarkRP2DDServer ${DarkRP2D_DEDICATED_SERVER_SOURCE_FILES})

MESSAGE( STATUS "Conan search Dirs: " "${CONAN_LIB_DIRS}")
MESSAGE( STATUS "Conan Libs: " "${CONAN_LIBS}")
MESSAGE( STATUS "Conan Includes: " "${CONAN_INCLUDE_DIRS}")

foreach(_LIB ${CONAN_LIBS_RELEASE})
    target_link_libraries(DarkRP2DDServer optimized ${_LIB})
endforeach()
foreach(_LIB ${CONAN_LIBS_DEBUG})
    target_link_libraries(DarkRP2DDServer debug ${_LIB})
endforeach()

#add_custom_target(CopyBinaries
#COMMAND ${CMAKE_COMMAND} -E copy ${SDL2_DLL} ${CMAKE_BINARY_DIR}
#    COMMAND ${CMAKE_COMMAND} -E copy ${SDL2_NET_DLL} ${CMAKE_BINARY_DIR}
#)

#add_dependencies(DarkRP2DDServer CopyBinaries)