cmake_minimum_required(VERSION 3.5)

project(GoogleEarthClient VERSION 0.1 LANGUAGES CXX)

# set(CMAKE_AUTOUIC ON)
# set(CMAKE_AUTOMOC ON)
# set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# set(Qt5_DIR "D:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5")
# find_package(Qt5 REQUIRED COMPONENTS Widgets Network)

set(MAIN
    src/main/http.h
    src/main/rocktree_decoder.h
    src/main/rocktree_ex.h
    src/main/rocktree_gl.h
    src/main/rocktree_http.h
    src/main/rocktree_math.h
    src/main/rocktree_types.h
    src/main/rocktree_util.h
    src/main/stb_image.h
    src/main/threads.h
    src/main/main.cpp
)
source_group(main FILES ${MAIN})

set(CRN
    src/crn/crn.cc
    src/crn/crn.h
    src/crn/crn_decomp.h
    src/crn/crnlib.h
)
source_group(crn FILES ${CRN})
# crn设置
# add_definitions(-DPLATFORM_NACL)


#set(PROTO
#    src/proto/rocktree.pb.h
#    src/proto/rocktree.pb.cc
#)
#source_group(proto FILES ${PROTO})

# set(GLAD
#     src/gl2/include/glad/glad.h
#     src/gl2/src/glad.c
# )
# source_group(glad FILES ${GLAD})

include_directories( 
    src
    src/eigen
    src/main
    src/proto
    src/gl2/include
)

#sdl
include_directories(${CMAKE_SOURCE_DIR}/dependencies/SDL2-2.0.4/include)
link_directories(${CMAKE_SOURCE_DIR}/dependencies/SDL2-2.0.4/lib/x64)
set(SDL_LIB SDL2.lib)
# add_definitions(-DSDL_MAIN_HANDLED)
add_definitions(-DGL_ARB_debug_output)



#glew
# include_directories(${CMAKE_SOURCE_DIR}/dependencies/glew2.2.0/include)
# link_directories(${CMAKE_SOURCE_DIR}/dependencies/glew2.2.0/lib/Debug/x64)
# set(GLEW_LIB glew32sd.lib)

# 设置utf-8编码
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
# protobuffer必须定义宏，不然程序会崩溃
add_definitions(-DPROTOBUF_USE_DLLS)

# 引用protobuffer目录
include_directories(${CMAKE_SOURCE_DIR}/dependencies/protobuf-3.17.3-sdk-vs2017-x64/include)
link_directories(${CMAKE_SOURCE_DIR}/dependencies/protobuf-3.17.3-sdk-vs2017-x64/lib)
# protobuffer库
set(PROTOBUFFER_LIB
    debug libprotobufd.lib
    optimized libprotobuf.lib
)

add_executable(${PROJECT_NAME}
    ${MAIN}
    # ${UI}
    # ${PROTO}
    # ${GLAD}
    ${CRN}
)

target_link_libraries(${PROJECT_NAME} PRIVATE 
    # Qt5::Widgets Qt5::Network 
    ${PROTOBUFFER_LIB} 
    ${SDL_LIB}
)

# set_target_properties(${PROJECT_NAME} PROPERTIES
#     ${BUNDLE_ID_OPTION}
#     MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
#     MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
#     MACOSX_BUNDLE TRUE
#     WIN32_EXECUTABLE TRUE
# )

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
