MESSAGE("*********************************************")
MESSAGE("CMAKE VERSION: ${CMAKE_VERSION}")
MESSAGE("CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
MESSAGE("CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}")
MESSAGE("CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
MESSAGE("CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
MESSAGE("CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
MESSAGE("CMAKE_ASM_MASM_COMPILER: ${CMAKE_ASM_MASM_COMPILER}")
MESSAGE("CMAKE_ASM_COMPILER: ${CMAKE_ASM_COMPILER}")
MESSAGE("CMAKE_MAKE_PROGRAM: ${CMAKE_MAKE_PROGRAM}")
MESSAGE("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
MESSAGE("CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
MESSAGE("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE("CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
MESSAGE("CMAKE_SIZEOF_VOID_P: ${CMAKE_SIZEOF_VOID_P}")
MESSAGE("*********************************************")
MESSAGE("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
MESSAGE("CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
MESSAGE("*********************************************")

SET(CMAKE_TEMP_DIR ${CMAKE_BINARY_DIR}/solutions)

IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
    SET(TEXPACKER_ARCHITECTURE_X86 ON CACHE BOOL "TEXPACKER_ARCHITECTURE_X86" FORCE)
    SET(TEXPACKER_ARCHITECTURE_X64 OFF CACHE BOOL "TEXPACKER_ARCHITECTURE_X64" FORCE)
ELSEIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
    SET(TEXPACKER_ARCHITECTURE_X86 OFF CACHE BOOL "TEXPACKER_ARCHITECTURE_X86" FORCE)
    SET(TEXPACKER_ARCHITECTURE_X64 ON CACHE BOOL "TEXPACKER_ARCHITECTURE_X64" FORCE)
ELSE()
    message(FATAL_ERROR "unsupport CMAKE_SIZEOF_VOID_P")
ENDIF()

MESSAGE("TEXPACKER_ARCHITECTURE_X86: ${TEXPACKER_ARCHITECTURE_X86}")
MESSAGE("TEXPACKER_ARCHITECTURE_X64: ${TEXPACKER_ARCHITECTURE_X64}")

IF(TEXPACKER_ARCHITECTURE_X86)
    SET(TEXPACKER_THIRDPARTY_ARCHITECTURE_SUFFIX "x86")
ELSEIF(TEXPACKER_ARCHITECTURE_X64)
    SET(TEXPACKER_THIRDPARTY_ARCHITECTURE_SUFFIX "x64")
ELSE()
    MESSAGE(FATAL_ERROR "unsupported architecture") 
ENDIF()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

SET(TEXPACKER_REPOSITORY ${CMAKE_CURRENT_SOURCE_DIR}/../..)

IF(NOT TEXPACKER_INSTALL_PATH)
    SET(TEXPACKER_INSTALL_PATH ${TEXPACKER_REPOSITORY}/bin)
ENDIF()

MESSAGE("TEXPACKER_INSTALL_PATH: ${TEXPACKER_INSTALL_PATH}")

IF(NOT TEXPACKER_PDB_PATH)
    SET(TEXPACKER_PDB_PATH ${TEXPACKER_REPOSITORY}/pdb)
ENDIF()

MESSAGE("TEXPACKER_PDB_PATH: ${TEXPACKER_PDB_PATH}")

IF(CMAKE_GENERATOR_PLATFORM)
    SET(TEXPACKER_THIRDPARTY_LIB_OUT "${TEXPACKER_REPOSITORY}/lib/dependencies/${CMAKE_GENERATOR} ${CMAKE_GENERATOR_PLATFORM}/${TEXPACKER_THIRDPARTY_ARCHITECTURE_SUFFIX}")
    SET(TEXPACKER_THIRDPARTY_CONFIG_OUT "${TEXPACKER_REPOSITORY}/dependencies/configuration/${CMAKE_GENERATOR} ${CMAKE_GENERATOR_PLATFORM}/${TEXPACKER_THIRDPARTY_ARCHITECTURE_SUFFIX}")
ELSE()
    SET(TEXPACKER_THIRDPARTY_LIB_OUT "${TEXPACKER_REPOSITORY}/lib/dependencies/${CMAKE_GENERATOR}/${TEXPACKER_THIRDPARTY_ARCHITECTURE_SUFFIX}")
    SET(TEXPACKER_THIRDPARTY_CONFIG_OUT "${TEXPACKER_REPOSITORY}/dependencies/configuration/${CMAKE_GENERATOR}/${TEXPACKER_THIRDPARTY_ARCHITECTURE_SUFFIX}")
ENDIF()

SET(TEXPACKER_THIRDPARTY_DIR ${TEXPACKER_REPOSITORY}/dependencies)

MESSAGE("UNIX: ${UNIX}")
MESSAGE("ANDROID: ${ANDROID}")
MESSAGE("MINGW: ${MINGW}")
MESSAGE("WIN32: ${WIN32}")
MESSAGE("APPLE: ${APPLE}")
MESSAGE("IOS: ${IOS}")

if(UNIX AND NOT ANDROID AND NOT APPLE AND NOT IOS)
    # input and thirdparty paths
    SET(TEXPACKER_THIRDPARTY_LIB_OUT_SUFFIX ${CMAKE_BUILD_TYPE})
elseif(ANDROID)
    # input and thirdparty paths
    SET(TEXPACKER_THIRDPARTY_LIB_OUT_SUFFIX ${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
elseif(MINGW)
    # input and thirdparty paths
    SET(TEXPACKER_THIRDPARTY_LIB_OUT_SUFFIX ${CMAKE_BUILD_TYPE})
elseif(APPLE)
    # input and thirdparty paths
    SET(TEXPACKER_THIRDPARTY_LIB_OUT_SUFFIX ${CMAKE_BUILD_TYPE})
else()
    # input and thirdparty paths
    SET(TEXPACKER_THIRDPARTY_LIB_OUT_SUFFIX ${CMAKE_BUILD_TYPE})
endif()

SET(TEXPACKER_THIRDPARTY_LIB_DIR ${TEXPACKER_THIRDPARTY_LIB_OUT}/${TEXPACKER_THIRDPARTY_LIB_OUT_SUFFIX})
SET(TEXPACKER_THIRDPARTY_CONFIG_DIR ${TEXPACKER_THIRDPARTY_CONFIG_OUT}/${TEXPACKER_THIRDPARTY_LIB_OUT_SUFFIX})

MESSAGE("TEXPACKER_THIRDPARTY_DIR: ${TEXPACKER_THIRDPARTY_DIR}")
MESSAGE("TEXPACKER_THIRDPARTY_LIB_DIR: ${TEXPACKER_THIRDPARTY_LIB_DIR}")
MESSAGE("TEXPACKER_THIRDPARTY_CONFIG_DIR: ${TEXPACKER_THIRDPARTY_CONFIG_DIR}")

SET(TEXPACKER_CMAKE_DEPENDENCIES_DIR ${TEXPACKER_REPOSITORY}/cmake/dependencies)
SET(TEXPACKER_SOURCE_DIR ${TEXPACKER_REPOSITORY}/src)
SET(TEXPACKER_INCLUDE_DIR ${TEXPACKER_REPOSITORY}/include)
SET(TEXPACKER_DEPENDENCIES_DIR ${TEXPACKER_REPOSITORY}/dependencies)

MESSAGE("TEXPACKER_CMAKE_DEPENDENCIES_DIR: ${TEXPACKER_CMAKE_DEPENDENCIES_DIR}")
MESSAGE("TEXPACKER_SOURCE_DIR: ${TEXPACKER_SOURCE_DIR}")
MESSAGE("TEXPACKER_INCLUDE_DIR: ${TEXPACKER_INCLUDE_DIR}")
