
#Set up visual studio filters

# *.h
SOURCE_GROUP(KDIS FILES ${KDIS_SRC_BASE_H})
SOURCE_GROUP(KDIS\\DataTypes FILES ${KDIS_SRC_DATATYPES_H})
SOURCE_GROUP(KDIS\\DataTypes\\Enums FILES ${KDIS_SRC_ENUMS_H})
SOURCE_GROUP(KDIS\\PDU FILES ${KDIS_SRC_PDU_BASE_H})
SOURCE_GROUP(KDIS\\PDU\\Distributed_Emission_Regeneration FILES ${KDIS_SRC_PDU_DER_H})
SOURCE_GROUP(KDIS\\PDU\\Entity_Info_Interaction FILES ${KDIS_SRC_PDU_EII_H})
SOURCE_GROUP(KDIS\\PDU\\Entity_Management FILES ${KDIS_SRC_PDU_EM_H})
SOURCE_GROUP(KDIS\\PDU\\Live_Entity FILES ${KDIS_SRC_PDU_LE_H})
SOURCE_GROUP(KDIS\\PDU\\Logistics FILES ${KDIS_SRC_PDU_L_H})
SOURCE_GROUP(KDIS\\PDU\\Minefield FILES ${KDIS_SRC_PDU_M_H})
SOURCE_GROUP(KDIS\\PDU\\Radio_Communications FILES ${KDIS_SRC_PDU_R_H})
SOURCE_GROUP(KDIS\\PDU\\Simulation_Management FILES ${KDIS_SRC_PDU_SM_H})
SOURCE_GROUP(KDIS\\PDU\\Simulation_Management_With_Reliability FILES ${KDIS_SRC_PDU_SMWR_H})
SOURCE_GROUP(KDIS\\PDU\\Synthetic_Environment FILES ${KDIS_SRC_PDU_SE_H})
SOURCE_GROUP(KDIS\\PDU\\Warfare FILES ${KDIS_SRC_PDU_W_H})
SOURCE_GROUP(KDIS\\PDU\\Information_Operations FILES ${KDIS_SRC_PDU_IO_H})
SOURCE_GROUP(KDIS\\Extras FILES ${KDIS_SRC_EX_H})
SOURCE_GROUP(KDIS\\Network FILES ${KDIS_SRC_NET_H})

# *.cpp
SOURCE_GROUP(KDIS FILES ${KDIS_SRC_BASE_CPP})
SOURCE_GROUP(KDIS\\DataTypes FILES ${KDIS_SRC_DATATYPES_CPP})
SOURCE_GROUP(KDIS\\DataTypes\\Enums FILES ${KDIS_SRC_ENUMS_CPP})
SOURCE_GROUP(KDIS\\PDU FILES ${KDIS_SRC_PDU_BASE_CPP})
SOURCE_GROUP(KDIS\\PDU\\Distributed_Emission_Regeneration FILES ${KDIS_SRC_PDU_DER_CPP})
SOURCE_GROUP(KDIS\\PDU\\Entity_Info_Interaction FILES ${KDIS_SRC_PDU_EII_CPP})
SOURCE_GROUP(KDIS\\PDU\\Entity_Management FILES ${KDIS_SRC_PDU_EM_CPP})
SOURCE_GROUP(KDIS\\PDU\\Live_Entity FILES ${KDIS_SRC_PDU_LE_CPP})
SOURCE_GROUP(KDIS\\PDU\\Logistics FILES ${KDIS_SRC_PDU_L_CPP})
SOURCE_GROUP(KDIS\\PDU\\Minefield FILES ${KDIS_SRC_PDU_M_CPP})
SOURCE_GROUP(KDIS\\PDU\\Radio_Communications FILES ${KDIS_SRC_PDU_R_CPP})
SOURCE_GROUP(KDIS\\PDU\\Simulation_Management FILES ${KDIS_SRC_PDU_SM_CPP})
SOURCE_GROUP(KDIS\\PDU\\Simulation_Management_With_Reliability FILES ${KDIS_SRC_PDU_SMWR_CPP})
SOURCE_GROUP(KDIS\\PDU\\Synthetic_Environment FILES ${KDIS_SRC_PDU_SE_CPP})
SOURCE_GROUP(KDIS\\PDU\\Warfare FILES ${KDIS_SRC_PDU_W_CPP})
SOURCE_GROUP(KDIS\\PDU\\Information_Operations FILES ${KDIS_SRC_PDU_IO_CPP})
SOURCE_GROUP(KDIS\\Extras FILES ${KDIS_SRC_EX_CPP})
SOURCE_GROUP(KDIS\\Network FILES ${KDIS_SRC_NET_CPP})

#Include directories in project settings
INCLUDE_DIRECTORIES(${KDIS_SOURCE_DIR})
INCLUDE_DIRECTORIES(${KDIS_SOURCE_DIR}/Examples)

#Create the project

SET(KDIS_FILES_H
    ${KDIS_SRC_BASE_H} 
    ${KDIS_SRC_DATATYPES_H} 
    ${KDIS_SRC_ENUMS_H}
    ${KDIS_SRC_PDU_BASE_H}
    ${KDIS_SRC_PDU_DER_H}
    ${KDIS_SRC_PDU_EII_H}
    ${KDIS_SRC_PDU_EM_H}
    ${KDIS_SRC_PDU_LE_H}
    ${KDIS_SRC_PDU_L_H}
	${KDIS_SRC_PDU_M_H}
    ${KDIS_SRC_PDU_R_H}
    ${KDIS_SRC_PDU_SM_H}
    ${KDIS_SRC_PDU_SMWR_H}
    ${KDIS_SRC_PDU_SE_H}
    ${KDIS_SRC_PDU_W_H}
	${KDIS_SRC_PDU_IO_H}
    ${KDIS_SRC_EX_H}
	${KDIS_SRC_NET_H}
    KDIS.cpp
)

SET(KDIS_FILES_CPP
    ${KDIS_SRC_BASE_CPP} 
    ${KDIS_SRC_DATATYPES_CPP}
    ${KDIS_SRC_ENUMS_CPP}
    ${KDIS_SRC_PDU_BASE_CPP}
    ${KDIS_SRC_PDU_DER_CPP}
    ${KDIS_SRC_PDU_EII_CPP}
    ${KDIS_SRC_PDU_EM_CPP}
    ${KDIS_SRC_PDU_LE_CPP}
    ${KDIS_SRC_PDU_L_CPP}
	${KDIS_SRC_PDU_M_CPP}
    ${KDIS_SRC_PDU_R_CPP}
    ${KDIS_SRC_PDU_SM_CPP}
    ${KDIS_SRC_PDU_SMWR_CPP}
    ${KDIS_SRC_PDU_SE_CPP}
    ${KDIS_SRC_PDU_W_CPP}
	${KDIS_SRC_PDU_IO_CPP}
    ${KDIS_SRC_EX_CPP}
	${KDIS_SRC_NET_CPP}
)

SET(KDIS_FILES ${KDIS_FILES_CPP} ${KDIS_FILES_H})

ADD_LIBRARY(KDIS_DLL SHARED ${KDIS_FILES})

SET_PROPERTY(TARGET KDIS_DLL PROPERTY FOLDER "Builds/")

#Lower the warning level
IF(MSVC)
    ADD_DEFINITIONS(/W1)
ENDIF(MSVC)

ADD_DEFINITIONS(-D "EXPORT_KDIS")

IF(DIS_VERSION MATCHES 6)
	ADD_DEFINITIONS(-D "DIS_VERSION=6")
ENDIF(DIS_VERSION MATCHES 6)

IF(DIS_VERSION MATCHES 5)
	ADD_DEFINITIONS(-D "DIS_VERSION=5")
ENDIF(DIS_VERSION MATCHES 5)

IF(DIS_VERSION MATCHES 7)
	ADD_DEFINITIONS(-D "DIS_VERSION=7")
ENDIF(DIS_VERSION MATCHES 7)

IF(KDIS_USE_ENUM_DESCRIPTORS)
	ADD_DEFINITIONS(-D "KDIS_USE_ENUM_DESCRIPTORS")
ENDIF(KDIS_USE_ENUM_DESCRIPTORS) 

IF(CMAKE_SYSTEM MATCHES "Linux")
    TARGET_LINK_LIBRARIES(KDIS_DLL ${RT_LIBRARY})
ENDIF(CMAKE_SYSTEM MATCHES "Linux")

IF(MINGW)
    TARGET_LINK_LIBRARIES(KDIS_DLL "ws2_32")
ENDIF(MINGW)

SET_TARGET_PROPERTIES(KDIS_DLL PROPERTIES OUTPUT_NAME "kdis" SOVERSION 0)

# INSTALL(DIRECTORY ../../../KDIS
#     DESTINATION "include"
#     FILES_MATCHING PATTERN *.h
#     PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

INSTALL(FILES ${KDIS_FILES_H} DESTINATION /usr/include/KDIS)

INSTALL(TARGETS KDIS_DLL
  ARCHIVE DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}
  LIBRARY DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}
)

