##------------------------------------------------------------------------
## 1:0:0 -- 2014.06.10
##    Library name change general -> ldastoolsal
## 1:1:0 -- 2014.09.19
##    Modifications resulting in the 2.0.3 release of ldas-tools
## 2:0:0 -- 2015.05.08
##    Added elements to class CommandLineOptions
##    Added parameters to MemChecker.Append( )
##    Added method MemChecker.Info( )
##    Added method ThreadPool.Active( )
##    Added mehtod mutex_lock::baton_type::bool( )
##    Added member to mutex_lock::baton_type
## 3:0:0 - 2015.07.06
##    Added SignalHandler class
## 4:0:0 - 2016.03.03
##    Modified Directory class
## 4:1:0 - 2016.09.09
##    Added leap second for 2017.01.01
##    Addressed valgrind issue by using new instead of strdup
## 4:2:0 - 2016.09.15
##    Added functions Timeout and Interval
## 4:3:0 - 2016.09.26
##    Added optional Thread debugging
## 4:4:0 - 2016.10.10
##    Corrections to how threads handle signals.
##    Optimized registration of signal handler.
## 4:5:0 - 2016.11.14
##    Correction to internal allocation of directory buffer
## 5:0:1 - 2017.10.25 (ldas-tools-al-2.5.7)
##    Added routines needed for diskcache
## 6:0:0 - 2018.05.11 ( ldas-tools-al-2.6.0 )
##    Removed hand rolled smart pointers in favor of boost smart pointers
## 7:0:0 - ????.??.?? ( ldas-tools-al-2.6.1 )
##    Removed LDASUnexpected class
## 7:1:0 - 2019.08.14 ( ldas-tools-al-2.6.3 )
##    Minor patching
## 7:2:0 - 2021.03.09 ( ldas-tools-al-2.6.5 )
## 8:0:1 - 2024.12.16 ( ldas-tools-al-2.7.0 )
##    - Corrections for valgrind memcheck
##    - Added new logging routines based on boost::logging
##------------------------------------------------------------------------
## form: <(c)urrent>:<(r)elease>:<(a)ge
##
## 1. Update the version information only immediately before a public
##    release of your software. More frequent updates are unnecessary,
##    and only guarantee that the current interface number gets larger
##    faster.
## 2. If the library source code has changed at all since the last
##    update, then increment revision (c:r:a becomes c:r+1:a).
## 3. If any interfaces [exported functions or data] have been added,
##    removed, or changed since the last update, increment current,
##    and set revision to 0.
## 4. If any interfaces have been added since the last public
##    release, then increment age.
## 5. If any interfaces have been removed since the last public
##    release, then set age to 0.
##------------------------------------------------------------------------

set( libldastoolsal_la_CURRENT 9 )
set( libldastoolsal_la_REVISION 0 )
set( libldastoolsal_la_AGE 2 )

#lib_LTLIBRARIES = libldastoolsal.la
#
#noinst_LTLIBRARIES = libldastoolspreload.la
#
#libldastoolspreload_la_SOURCES = \
#	Unlocked.cc
#

set( libldastoolsal_la_SOURCES 
	AtExit.cc
	CommandLineOptions.cc
	ConditionalVariable.cc
	Config.cc
	DeadLockDetector.cc
	DebugLevelManager.cc
	Directory.cc
	Exec.cc
	IOLock.cc
	Log.cc
	LoggerManager.cc
	LoggerRegistry.cc
	MemChecker.cc
	MkDir.cc
	mutexlock.cc
	PatternMatcher.cc
	PSInfo.cc
	ReadWriteLock.cc
	SignalHandler.cc
	Timeout.cc
	TimerThread.cc
	base64.cc
	errors.cc
	errorinfo.cc
	ErrorLog.cc
	FileType.cc
	Fork.cc
	fstream.cc
	gpstime.cc
  LoggerOptions.cc
	Pool.cc
	regex.cc
	regexmatch.cc
	Sed.cc
	Singleton.cc
	SOLoader.cc
	streamexception.cc
  SimpleLogger.cc
	System.cc
	SystemCall.cc
	SystemCallTask.cc
	Task.cc
	TaskTimer.cc
	TaskThread.cc
	Thread.cc
	ThreadPool.cc
	UserInfoCache.cc
	util.cc
	toss.cc
	ldasexception.cc
)
#
#libldastoolsal_la_LDFLAGS = $(LDASTOOLSAL_LIBTOOL_VERSION_FLAG) $(LDFLAGS) $(BOOST_LDFLAGS)
#libldastoolsal_la_LIBADD = -ldl
#

set( HDR_DIR ldastoolsal )
set( ldastoolsalhhdir "${CMAKE_INSTALL_INCLUDEDIR}/${HDR_DIR}" )

set( ldastoolsalhh_HEADERS
 	AtExit.hh
 	BackgroundTaskCounter.hh
 	CommandLineOptions.hh
 	ConditionalVariable.hh
 	Config.hh
 	DeadLockDetector.hh
	DebugLevelManager.hh
 	Deprecated.hh
 	Directory.hh
 	Exec.hh
 	InfixIterator.hh
 	IOLock.hh
 	Log.hh
  Logger.hh
  LoggerManager.hh
  LoggerOptions.hh
  LoggerRegistry.hh
 	MemChecker.hh
 	MkDir.hh
 	PatternMatcher.hh
 	PtrHash.hh
 	PSInfo.hh
 	ReadWriteLock.hh
 	ReadWriteSingleton.hh
 	Sed.hh
  SimpleLogger.hh
  SimpleLogger.inl
 	SignalHandler.hh
 	Singleton.hh
 	SingletonMacro.hh
 	Timeout.hh
 	TimerThread.hh
 	base64.hh
 	bit_vector.hh
 	compiler.h
 	errors.hh
 	errorinfo.hh
 	ErrorLog.hh
 	FileType.hh
 	Fork.hh
 	formatexception.hh
 	fstream.hh
 	gpstime.hh
 	ldasexception.hh
 	mutexlock.hh
 	objectregistry.hh
 	objectregistry.icc
 	Pool.hh
 	port.hh
 	Profile.hh
 	regex.hh
 	regexmatch.hh
 	SOLoader.hh
 	streamexception.hh
 	System.hh
 	SystemCall.hh
 	SystemCallTask.hh
 	Task.hh
 	TaskTimer.hh
 	TaskThread.hh
 	Thread.hh
 	ThreadPool.hh
 	TriStatePool.hh
 	unittest.h
 	UnitTestTS.h
 	util.hh
 	unimplemented_error.hh
 	toss.hh
 	UserInfoCache.hh
)

set( nodist_ldastoolsalhh_HEADERS
	ldas_types.h
	reverse.hh
	types.hh
	unordered_map.hh
  )

# Set default values for byte swap function detection (used in reverse.hh.in)
# These would be set by feature detection in a complete implementation
if(NOT DEFINED HAVE__OSSWAPINT16)
  set(HAVE__OSSWAPINT16 0)
endif()
if(NOT DEFINED HAVE__OSSWAPINT32)
  set(HAVE__OSSWAPINT32 0)
endif()
if(NOT DEFINED HAVE__OSSWAPINT64)
  set(HAVE__OSSWAPINT64 0)
endif()

foreach( filename ${nodist_ldastoolsalhh_HEADERS} )
  configure_file(
    ${CMAKE_CURRENT_SOURCE_DIR}/${filename}.in
    ${CMAKE_CURRENT_BINARY_DIR}/${filename}
    @ONLY
    )
endforeach( )

cx_link_headers( ${HDR_DIR} ${ldastoolsalhh_HEADERS} )
cx_link_headers( BUILT_HEADERS ${HDR_DIR} ${nodist_ldastoolsalhh_HEADERS} )

# Link stdc++fs only on Linux (not needed on macOS/BSD)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  set(STDCXXFS_LIBS "-lstdc++fs")
  set(STDCXXFS_LIB stdc++fs)
else()
  set(STDCXXFS_LIBS "")
  set(STDCXXFS_LIB "")
endif()

set( libldastoolsal_la_LIBADD
  PUBLIC
    ${BOOST_TARGETS}
    ${STDCXXFS_LIB}
    Threads::Threads
  PRIVATE
    ${CMAKE_DL_LIBS}
  )

# Build static library only if BUILD_STATIC_LIBS is ON
cx_static_libs_arg(_static_arg)

cx_target_library(
  TARGET ldastoolsal
  CURRENT ${libldastoolsal_la_CURRENT}
  REVISION ${libldastoolsal_la_REVISION}
  AGE ${libldastoolsal_la_AGE}
  ${_static_arg}
  SOURCES ${libldastoolsal_la_SOURCES}
  DEFINES
  HAVE_CONFIG_H=1
  LIBRARIES ${libldastoolsal_la_LIBADD}
  INCLUDE_DIRECTORIES BEFORE PRIVATE
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_BINARY_DIR}/include
  ${CMAKE_BINARY_DIR}
  ${BOOST_INCLUDE_DIR}
  ABI_MESSAGE "LDAS Tools Abstraction Library"
  ABI_HEADER_DIR ${HDR_DIR}
  ABI_LOCAL_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include/${HDR_DIR}
  ABI_HEADERS ${ldastoolsalhh_HEADERS}
  )

foreach(filename ${nodist_ldastoolsalhh_HEADERS})
  list(APPEND nodist_full_ldastoolsalhh_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/${filename}" )
endforeach( )
install(
  FILES ${ldastoolsalhh_HEADERS} ${nodist_full_ldastoolsalhh_HEADERS}
  DESTINATION ${ldastoolsalhhdir}
  )

cx_target_pkgconfig( ldastoolsal )
