PROJECT(ccl)
SET(VERSION 3.3.3)

#============================================================================
# Please note:
#
# This should be considered an experimental build system for the CCL.
#
# Linux:
# When make installing with Linux it generates what you would typically expect
# in the install prefix.  If you want debugging symbols with your library
# you should set CMAKE_BUILD_TYPE to Debug or RelWithDebInfo before building.
#
# Windows:
# After building the Release and Debug configurations in Visual Studio and
# running the INSTALL target for both it will generate the following
# libraries:
#
# ${CMAKE_INSTALL_PREFIX}/lib:
#
# libcigicl.lib        => DLL release version
# libcigicl_debug.lib  => DLL debugged version
# libcigicl_static.lib       => Statically linked release version
# libcigicl_static_debug.lib => Statically linked debugged version
#
# ${CMAKE_INSTALL_PREFIX}/bin will include the DLLs you need at runtime if
# you're linking against the shared build of the library.
#
#============================================================================

#CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7)
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
IF(MSVC OR MINGW)
    SET(CMAKE_DEBUG_POSTFIX "_debug")
ENDIF()

SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin 
    CACHE PATH "The location where binaries go" FORCE)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib
    CACHE PATH "The location where libraries go" FORCE)
# Starting with CMake 2.6.0 this will effectively have any DLL files
# generated by CMake be placed in the specified directory.
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}) 
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}) 
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}) 

IF(CMAKE_COMPILER_IS_GNUCXX)
    CONFIGURE_FILE(cigicl.pc.in_cmake cigicl.pc)
ENDIF()

#==========================================================
# Tests
#==========================================================

INCLUDE(TestBigEndian)
TEST_BIG_ENDIAN(BIG_ENDIAN)

#==========================================================
# Global Preprocessor Definitions
#==========================================================

IF(BIG_ENDIAN)
    ADD_DEFINITIONS(-DCIGI_BIG_ENDIAN)
ELSE()
    ADD_DEFINITIONS(-DCIGI_LITTLE_ENDIAN)
ENDIF()

IF(CMAKE_COMPILER_IS_GNUCXX)
    ADD_DEFINITIONS(-Wall -fmessage-length=0)
ENDIF()

IF(MSVC80)
    ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF()

#==========================================================
# Define CIGI Class Library Source/Header files.
#==========================================================

SET(CCL_PUBLIC_HDRS
  include/CigiAerosolRespV3.h
  include/CigiAllPackets.h
  include/CigiAnimationStopV3.h
  include/CigiAnimationTable.h
  include/CigiArtPartCtrlV1.h
  include/CigiArtPartCtrlV2.h
  include/CigiArtPartCtrlV3.h
  include/CigiAtmosCtrl.h
  include/CigiBaseAerosolResp.h
  include/CigiBaseAnimationStop.h
  include/CigiBaseArtPartCtrl.h
  include/CigiBaseCircleSymbolData.h
  include/CigiBaseCollDetSegDef.h
  include/CigiBaseCollDetSegResp.h
  include/CigiBaseCollDetVolDef.h
  include/CigiBaseCollDetVolResp.h
  include/CigiBaseCompCtrl.h
  include/CigiBaseConfClampEntityCtrl.h
  include/CigiBaseEarthModelDef.h
  include/CigiBaseEntityCtrl.h
  include/CigiBaseEnvCondReq.h
  include/CigiBaseEnvCtrl.h
  include/CigiBaseEnvRgnCtrl.h
  include/CigiBaseEventNotification.h
  include/CigiBaseEventProcessor.h
  include/CigiBaseHatHotReq.h
  include/CigiBaseHatHotResp.h
  include/CigiBaseIGCtrl.h
  include/CigiBaseIGMsg.h
  include/CigiBaseLosResp.h
  include/CigiBaseLosSegReq.h
  include/CigiBaseLosVectReq.h
  include/CigiBaseMaritimeSurfaceCtrl.h
  include/CigiBaseMaritimeSurfaceResp.h
  include/CigiBaseMotionTrackCtrl.h
  include/CigiBasePacket.h
  include/CigiBasePositionReq.h
  include/CigiBasePositionResp.h
  include/CigiBaseRateCtrl.h
  include/CigiBaseSOF.h
  include/CigiBaseSensorCtrl.h
  include/CigiBaseSensorResp.h
  include/CigiBaseShortArtPartCtrl.h
  include/CigiBaseShortSymbolCtrl.h
  include/CigiBaseSignalProcessing.h
  include/CigiBaseSpecEffDef.h
  include/CigiBaseSymbolCircleDef.h
  include/CigiBaseSymbolClone.h
  include/CigiBaseSymbolCtrl.h
  include/CigiBaseSymbolLineDef.h
  include/CigiBaseSymbolSurfaceDef.h
  include/CigiBaseSymbolTextDef.h
  include/CigiBaseTerrestrialSurfaceCtrl.h
  include/CigiBaseTerrestrialSurfaceResp.h
  include/CigiBaseTrajectoryDef.h
  include/CigiBaseVariableSizePckt.h
  include/CigiBaseVertexSymbolData.h
  include/CigiBaseViewCtrl.h
  include/CigiBaseViewDef.h
  include/CigiBaseWaveCtrl.h
  include/CigiBaseWeatherCondResp.h
  include/CigiBaseWeatherCtrl.h
  include/CigiCelestialCtrl.h
  include/CigiCircleSymbolDataV3_3.h
  include/CigiCnvtInfoType.h
  include/CigiCollDetSegDefV1.h
  include/CigiCollDetSegDefV2.h
  include/CigiCollDetSegDefV3.h
  include/CigiCollDetSegRespV1.h
  include/CigiCollDetSegRespV2.h
  include/CigiCollDetSegRespV3.h
  include/CigiCollDetVolDefV2.h
  include/CigiCollDetVolDefV3.h
  include/CigiCollDetVolRespV2.h
  include/CigiCollDetVolRespV3.h
  include/CigiCompCtrlV1.h
  include/CigiCompCtrlV2.h
  include/CigiCompCtrlV3.h
  include/CigiCompCtrlV3_3.h
  include/CigiConfClampEntityCtrlV3.h
  include/CigiDefaultPacket.h
  include/CigiEarthModelDefV3.h
  include/CigiEntityCtrlV1.h
  include/CigiEntityCtrlV2.h
  include/CigiEntityCtrlV3.h
  include/CigiEntityCtrlV3_3.h
  include/CigiEnvCondReqV3.h
  include/CigiEnvCtrlV1.h
  include/CigiEnvCtrlV2.h
  include/CigiEnvRgnCtrlV3.h
  include/CigiErrorCodes.h
  include/CigiEventNotificationV3.h
  include/CigiException.h
  include/CigiExceptions.h
  include/CigiHatHotReqV3.h
  include/CigiHatHotReqV3_2.h
  include/CigiHatHotRespV3.h
  include/CigiHatHotRespV3_2.h
  include/CigiHatHotXRespV3.h
  include/CigiHatHotXRespV3_2.h
  include/CigiHatReqV1.h
  include/CigiHatReqV2.h
  include/CigiHatRespV1.h
  include/CigiHatRespV2.h
  include/CigiHoldEnvCtrl.h
  include/CigiHostSession.h
  include/CigiHotReqV2.h
  include/CigiHotRespV2.h
  include/CigiIGCtrlV1.h
  include/CigiIGCtrlV2.h
  include/CigiIGCtrlV3.h
  include/CigiIGCtrlV3_2.h
  include/CigiIGCtrlV3_3.h
  include/CigiIGMsgV2.h
  include/CigiIGMsgV3.h
  include/CigiIGSession.h
  include/CigiIO.h
  include/CigiIncomingMsg.h
  include/CigiLosRespV1.h
  include/CigiLosRespV2.h
  include/CigiLosRespV3.h
  include/CigiLosRespV3_2.h
  include/CigiLosSegReqV1.h
  include/CigiLosSegReqV2.h
  include/CigiLosSegReqV3.h
  include/CigiLosSegReqV3_2.h
  include/CigiLosVectReqV1.h
  include/CigiLosVectReqV2.h
  include/CigiLosVectReqV3.h
  include/CigiLosVectReqV3_2.h
  include/CigiLosXRespV3.h
  include/CigiLosXRespV3_2.h
  include/CigiMaritimeSurfaceCtrlV3.h
  include/CigiMaritimeSurfaceRespV3.h
  include/CigiMessage.h
  include/CigiMessageBuffer.h
  include/CigiMotionTrackCtrlV3.h
  include/CigiOutgoingMsg.h
  include/CigiPositionReqV3.h
  include/CigiPositionRespV3.h
  include/CigiProcessType.h
  include/CigiRateCtrlV1.h
  include/CigiRateCtrlV2.h
  include/CigiRateCtrlV3.h
  include/CigiRateCtrlV3_2.h
  include/CigiSOFV1.h
  include/CigiSOFV2.h
  include/CigiSOFV3.h
  include/CigiSOFV3_2.h
  include/CigiSensorCtrlV1.h
  include/CigiSensorCtrlV2.h
  include/CigiSensorCtrlV3.h
  include/CigiSensorRespV1.h
  include/CigiSensorRespV2.h
  include/CigiSensorRespV3.h
  include/CigiSensorXRespV3.h
  include/CigiSession.h
  include/CigiShortArtPartCtrlV3.h
  include/CigiShortCompCtrlV3.h
  include/CigiShortCompCtrlV3_3.h
  include/CigiShortSymbolCtrlV3_3.h
  include/CigiSignalType.h
  include/CigiSpecEffDefV1.h
  include/CigiSpecEffDefV2.h
  include/CigiSwapping.h
  include/CigiSymbolCircleDefV3_3.h
  include/CigiSymbolCloneV3_3.h
  include/CigiSymbolCtrlV3_3.h
  include/CigiSymbolLineDefV3_3.h
  include/CigiSymbolSurfaceDefV3_3.h
  include/CigiSymbolTextDefV3_3.h
  include/CigiTerrestrialSurfaceCtrlV3.h
  include/CigiTerrestrialSurfaceRespV3.h
  include/CigiTrajectoryDefV1.h
  include/CigiTrajectoryDefV2.h
  include/CigiTrajectoryDefV3.h
  include/CigiTypes.h
  include/CigiTypes_Default.h
  include/CigiTypes_MSVS_Win32.h
  include/CigiVersionID.h
  include/CigiVertexSymbolDataV3_3.h
  include/CigiViewCtrlV1.h
  include/CigiViewCtrlV2.h
  include/CigiViewCtrlV3.h
  include/CigiViewDefV1.h
  include/CigiViewDefV2.h
  include/CigiViewDefV3.h
  include/CigiWaveCtrlV3.h
  include/CigiWeatherCondRespV3.h
  include/CigiWeatherCtrlV1.h
  include/CigiWeatherCtrlV2.h
  include/CigiWeatherCtrlV3.h
)

SET(CCL_SRCS
  source/CigiAerosolRespV3.cpp
  source/CigiAnimationStopV3.cpp
  source/CigiAnimationTable.cpp
  source/CigiArtPartCtrlV1.cpp
  source/CigiArtPartCtrlV2.cpp
  source/CigiArtPartCtrlV3.cpp
  source/CigiAtmosCtrl.cpp
  source/CigiBaseAerosolResp.cpp
  source/CigiBaseArtPartCtrl.cpp
  source/CigiBaseCircleSymbolData.cpp
  source/CigiBaseCollDetSegResp.cpp
  source/CigiBaseCollDetVolDef.cpp
  source/CigiBaseCollDetVolResp.cpp
  source/CigiBaseConfClampEntityCtrl.cpp
  source/CigiBaseEntityCtrl.cpp
  source/CigiBaseEnvCondReq.cpp
  source/CigiBaseEnvCtrl.cpp
  source/CigiBaseEnvRgnCtrl.cpp
  source/CigiBaseEventNotification.cpp
  source/CigiBaseHatHotReq.cpp
  source/CigiBaseIGCtrl.cpp
  source/CigiBaseLosResp.cpp
  source/CigiBaseLosSegReq.cpp
  source/CigiBaseLosVectReq.cpp
  source/CigiBaseMaritimeSurfaceCtrl.cpp
  source/CigiBaseMaritimeSurfaceResp.cpp
  source/CigiBaseMotionTrackCtrl.cpp
  source/CigiBasePositionReq.cpp
  source/CigiBasePositionResp.cpp
  source/CigiBaseSOF.cpp
  source/CigiBaseSensorCtrl.cpp
  source/CigiBaseSensorResp.cpp
  source/CigiBaseShortArtPartCtrl.cpp
  source/CigiBaseShortSymbolCtrl.cpp
  source/CigiBaseSpecEffDef.cpp
  source/CigiBaseSymbolCircleDef.cpp
  source/CigiBaseSymbolClone.cpp
  source/CigiBaseSymbolCtrl.cpp
  source/CigiBaseSymbolLineDef.cpp
  source/CigiBaseSymbolSurfaceDef.cpp
  source/CigiBaseSymbolTextDef.cpp
  source/CigiBaseTerrestrialSurfaceCtrl.cpp
  source/CigiBaseTrajectoryDef.cpp
  source/CigiBaseViewCtrl.cpp
  source/CigiBaseViewDef.cpp
  source/CigiBaseWaveCtrl.cpp
  source/CigiBaseWeatherCondResp.cpp
  source/CigiBaseWeatherCtrl.cpp
  source/CigiCelestialCtrl.cpp
  source/CigiCircleSymbolDataV3_3.cpp
  source/CigiCollDetSegDefV1.cpp
  source/CigiCollDetSegDefV2.cpp
  source/CigiCollDetSegDefV3.cpp
  source/CigiCollDetSegRespV1.cpp
  source/CigiCollDetSegRespV2.cpp
  source/CigiCollDetSegRespV3.cpp
  source/CigiCollDetVolDefV2.cpp
  source/CigiCollDetVolDefV3.cpp
  source/CigiCollDetVolRespV2.cpp
  source/CigiCollDetVolRespV3.cpp
  source/CigiCompCtrlV1.cpp
  source/CigiCompCtrlV2.cpp
  source/CigiCompCtrlV3.cpp
  source/CigiCompCtrlV3_3.cpp
  source/CigiConfClampEntityCtrlV3.cpp
  source/CigiDefaultPacket.cpp
  source/CigiEarthModelDefV3.cpp
  source/CigiEntityCtrlV1.cpp
  source/CigiEntityCtrlV2.cpp
  source/CigiEntityCtrlV3.cpp
  source/CigiEntityCtrlV3_3.cpp
  source/CigiEnvCondReqV3.cpp
  source/CigiEnvCtrlV1.cpp
  source/CigiEnvCtrlV2.cpp
  source/CigiEnvRgnCtrlV3.cpp
  source/CigiEventNotificationV3.cpp
  source/CigiHatHotReqV3.cpp
  source/CigiHatHotReqV3_2.cpp
  source/CigiHatHotRespV3.cpp
  source/CigiHatHotRespV3_2.cpp
  source/CigiHatHotXRespV3.cpp
  source/CigiHatHotXRespV3_2.cpp
  source/CigiHatReqV1.cpp
  source/CigiHatReqV2.cpp
  source/CigiHatRespV1.cpp
  source/CigiHatRespV2.cpp
  source/CigiHostSession.cpp
  source/CigiHotReqV2.cpp
  source/CigiHotRespV2.cpp
  source/CigiIGCtrlV1.cpp
  source/CigiIGCtrlV2.cpp
  source/CigiIGCtrlV3.cpp
  source/CigiIGCtrlV3_2.cpp
  source/CigiIGCtrlV3_3.cpp
  source/CigiIGMsgV2.cpp
  source/CigiIGMsgV3.cpp
  source/CigiIGSession.cpp
  source/CigiIO.cpp
  source/CigiIncomingMsg.cpp
  source/CigiLosRespV1.cpp
  source/CigiLosRespV2.cpp
  source/CigiLosRespV3.cpp
  source/CigiLosRespV3_2.cpp
  source/CigiLosSegReqV1.cpp
  source/CigiLosSegReqV2.cpp
  source/CigiLosSegReqV3.cpp
  source/CigiLosSegReqV3_2.cpp
  source/CigiLosVectReqV1.cpp
  source/CigiLosVectReqV2.cpp
  source/CigiLosVectReqV3.cpp
  source/CigiLosVectReqV3_2.cpp
  source/CigiLosXRespV3.cpp
  source/CigiLosXRespV3_2.cpp
  source/CigiMaritimeSurfaceCtrlV3.cpp
  source/CigiMaritimeSurfaceRespV3.cpp
  source/CigiMessage.cpp
  source/CigiMotionTrackCtrlV3.cpp
  source/CigiOutgoingMsg.cpp
  source/CigiPositionReqV3.cpp
  source/CigiPositionRespV3.cpp
  source/CigiRateCtrlV1.cpp
  source/CigiRateCtrlV2.cpp
  source/CigiRateCtrlV3.cpp
  source/CigiRateCtrlV3_2.cpp
  source/CigiSOFV1.cpp
  source/CigiSOFV2.cpp
  source/CigiSOFV3.cpp
  source/CigiSOFV3_2.cpp
  source/CigiSensorCtrlV1.cpp
  source/CigiSensorCtrlV2.cpp
  source/CigiSensorCtrlV3.cpp
  source/CigiSensorRespV1.cpp
  source/CigiSensorRespV2.cpp
  source/CigiSensorRespV3.cpp
  source/CigiSensorXRespV3.cpp
  source/CigiSession.cpp
  source/CigiShortArtPartCtrlV3.cpp
  source/CigiShortCompCtrlV3.cpp
  source/CigiShortCompCtrlV3_3.cpp
  source/CigiShortSymbolCtrlV3_3.cpp
  source/CigiSpecEffDefV1.cpp
  source/CigiSpecEffDefV2.cpp
  source/CigiSwapping.cpp
  source/CigiSymbolCircleDefV3_3.cpp
  source/CigiSymbolCloneV3_3.cpp
  source/CigiSymbolCtrlV3_3.cpp
  source/CigiSymbolLineDefV3_3.cpp
  source/CigiSymbolSurfaceDefV3_3.cpp
  source/CigiSymbolTextDefV3_3.cpp
  source/CigiTerrestrialSurfaceCtrlV3.cpp
  source/CigiTerrestrialSurfaceRespV3.cpp
  source/CigiTrajectoryDefV1.cpp
  source/CigiTrajectoryDefV2.cpp
  source/CigiTrajectoryDefV3.cpp
  source/CigiVertexSymbolDataV3_3.cpp
  source/CigiViewCtrlV1.cpp
  source/CigiViewCtrlV2.cpp
  source/CigiViewCtrlV3.cpp
  source/CigiViewDefV1.cpp
  source/CigiViewDefV2.cpp
  source/CigiViewDefV3.cpp
  source/CigiWaveCtrlV3.cpp
  source/CigiWeatherCondRespV3.cpp
  source/CigiWeatherCtrlV1.cpp
  source/CigiWeatherCtrlV2.cpp
  source/CigiWeatherCtrlV3.cpp
)

#==========================================================
# Library Targets
#==========================================================

INCLUDE_DIRECTORIES(include)

#
# Compiling the CCL as a shared library
#
ADD_LIBRARY(cigicl-shared SHARED ${CCL_PUBLIC_HDRS} ${CCL_SRCS})

IF(MSVC OR MINGW)
    # Both the CCL_DLL and _CCL_EXPORTS_ defines are needed to export DLLs.
    SET_TARGET_PROPERTIES(cigicl-shared PROPERTIES
        COMPILE_FLAGS -DCCL_DLL
        DEFINE_SYMBOL _CCL_EXPORTS_
        )
ENDIF()

SET_TARGET_PROPERTIES(cigicl-shared PROPERTIES 
    OUTPUT_NAME cigicl
    CLEAN_DIRECT_OUTPUT 1
    VERSION ${VERSION}
    SOVERSION 1
)

#
# Compiling the CCL as a static library
#
IF(MSVC OR MINGW)
    ADD_LIBRARY(cigicl-static STATIC ${CCL_PUBLIC_HDRS} ${CCL_SRCS})
    SET_TARGET_PROPERTIES(cigicl-static PROPERTIES OUTPUT_NAME cigicl_static)
ELSE()
    ADD_LIBRARY(cigicl-static STATIC ${CCL_PUBLIC_HDRS} ${CCL_SRCS})
    SET_TARGET_PROPERTIES(cigicl-static PROPERTIES OUTPUT_NAME cigicl)
ENDIF()
SET_TARGET_PROPERTIES(cigicl-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)

#==========================================================
# Install
#==========================================================

INSTALL(TARGETS cigicl-static cigicl-shared
        RUNTIME DESTINATION bin
        LIBRARY DESTINATION lib
        ARCHIVE DESTINATION lib)
INSTALL(FILES ${CCL_PUBLIC_HDRS} DESTINATION include/cigicl)
INSTALL(FILES
    COPYING
    ChangeLog
    license.html
    README
    ReleaseNotes.txt
    DESTINATION share/cigicl)

IF(CMAKE_COMPILER_IS_GNUCXX)
    INSTALL(FILES ${CMAKE_BINARY_DIR}/cigicl.pc DESTINATION lib/pkgconfig)
ENDIF()
