#this is just a basic CMakeLists.txt, for more information see the cmake manpage

#add definitions, compiler switches, etc.
ADD_DEFINITIONS(-Wall -O2)
#ADD_DEFINITIONS(-Wall -pg)

INCLUDE_DIRECTORIES(src/IrfPac . .. ../.. ../../.. ../../../../include )
LINK_DIRECTORIES(. .. ../.. ../../../../lib )

#build a shared library
#ADD_LIBRARY(ascfmtso SHARED SaraAscFile.cpp SaraSpacePac2Bmu.cpp)
#TARGET_LINK_LIBRARIES(ascfmtso sarapacso irfpacso linlog crypto)

#build a static library
ADD_LIBRARY(ascfmt STATIC SaraAscFile.cpp SaraSpacePac2Bmu.cpp)

IF (CMAKE_BUILD_TYPE STREQUAL "Debug")

#for testing the shared library you probably need some test app too
#you need cppunit library
# ADD_EXECUTABLE(SaraPacket_test SaraPacket_test.cpp)
# TARGET_LINK_LIBRARIES(SaraPacket_test sarapac irfpac cppunit crypto stdc++)

ADD_EXECUTABLE(AllTestAscFmt AllTestAscFmt.cpp SaraSpacePac2Bmu_test.cpp TimeFile_test.cpp)
TARGET_LINK_LIBRARIES(AllTestAscFmt ascfmt sarapac irfpac cppunit crypto stdc++)


ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug")


#for sample code, without cunit
ADD_EXECUTABLE(AscFmtReader_sample AscFmtReader_sample.cpp)
TARGET_LINK_LIBRARIES(AscFmtReader_sample ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(SaraDemultiplexor_sample SaraDemultiplexor_sample.cpp)
TARGET_LINK_LIBRARIES(SaraDemultiplexor_sample ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(SaraBufferedDemultiplexor_sample SaraBufferedDemultiplexor_sample.cpp)
TARGET_LINK_LIBRARIES(SaraBufferedDemultiplexor_sample ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(SaraBufferedDemultiplexor_sample2 SaraBufferedDemultiplexor_sample2.cpp)
TARGET_LINK_LIBRARIES(SaraBufferedDemultiplexor_sample2 ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(CenaPacketDump_sample CenaPacketDump_sample.cpp)
TARGET_LINK_LIBRARIES(CenaPacketDump_sample ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(TimeSync_sample TimeSync_sample.cpp)
TARGET_LINK_LIBRARIES(TimeSync_sample ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(SwimBmuReader_sample SwimBmuReader_sample.cpp)
TARGET_LINK_LIBRARIES(SwimBmuReader_sample ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(CenaBmuReader_sample CenaBmuReader_sample.cpp)
TARGET_LINK_LIBRARIES(CenaBmuReader_sample ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(CenaBmuReader_sample2 CenaBmuReader_sample2.cpp)
TARGET_LINK_LIBRARIES(CenaBmuReader_sample2 ascfmt sarapac irfpac linlog crypto stdc++)

# Appliations

ADD_EXECUTABLE(SaraSimpleDemulApp SaraSimpleDemulApp.cpp)
TARGET_LINK_LIBRARIES(SaraSimpleDemulApp ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(SaraDemultiplex SaraDemultiplex.cpp)
TARGET_LINK_LIBRARIES(SaraDemultiplex ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(SaraSpacePac2BmuApp SaraSpacePac2BmuApp.cpp)
TARGET_LINK_LIBRARIES(SaraSpacePac2BmuApp ascfmt sarapac irfpac crypto stdc++)

ADD_EXECUTABLE(SaraSyncCheckApp SaraSyncCheckApp.cpp)
TARGET_LINK_LIBRARIES(SaraSyncCheckApp ascfmt sarapac irfpac linlog crypto stdc++)

ADD_EXECUTABLE(TimeFileDumpApp TimeFileDumpApp.cpp)
TARGET_LINK_LIBRARIES(TimeFileDumpApp ascfmt sarapac irfpac crypto stdc++)

ADD_EXECUTABLE(CenaTimeDumpApp CenaTimeDumpApp.cpp)
TARGET_LINK_LIBRARIES(CenaTimeDumpApp ascfmt sarapac irfpac linlog crypto stdc++)


#add an install target here
#INSTALL_FILES(...)
#INSTALL_PROGRAMS(...)
#INSTALL_TARGET(...)

# ADD_SUBDIRECTORY(SaraPac)



INSTALL(TARGETS ascfmt ARCHIVE DESTINATION $ENV{HOME}/git/sara/lib)
#INSTALL(TARGETS ascfmtso LIBRARY DESTINATION $ENV{HOME}/git/sara/lib)
INSTALL(FILES ascfmt.h SaraAscFile.h SaraSpacePac2Bmu.h TimeFile.h SwimBmuReader.h CenaBmuReader.h
	DESTINATION $ENV{HOME}/git/sara/include/IrfPac/SaraPac/AscFmt)
INSTALL(PROGRAMS SaraSyncCheckApp SaraSimpleDemulApp SaraDemultiplex SaraSpacePac2BmuApp TimeFileDumpApp DESTINATION $ENV{HOME}/git/sara/bin/)
