cmake_minimum_required(VERSION 3.10)
project(bpps)

# control where the static and shared libraries are built so that on windows
# we don't need to tinker with the path to run the executable
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}")

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

#find_package(OpenMP)
#if(OpenMP_CXX_FOUND)
#    target_link_libraries(bpps PUBLIC OpenMP::OpenMP_CXX)
#endif()

option(BUILD_SHARED_LIBS "Build using shared libraries" ON)

# the version number.
set(bpps_VERSION_MAJOR 3)
set(bpps_VERSION_MINOR 2)

if(APPLE)
  set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
elseif(UNIX)
  set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()

# configure a header file to pass the version number only
configure_file(
  "${PROJECT_SOURCE_DIR}/bppsConfig.h.in"
  "${PROJECT_BINARY_DIR}/bppsConfig.h"
  )

# Note the use of the variable EXTRA_LIBS to collect up any optional libraries
# to later be linked into the executable. The variable EXTRA_INCLUDES is used
# similarly for optional header files. 
get_filename_component(PARENT_DIR ../ ABSOLUTE)
list(APPEND EXTRA_LIBS Afn Gsq Aln Blst Tax Alex Tools Chn Pdb Hat Gsmo Vsi
	Hpt Omc Cmc Pdb Sarp Sprs Psed Hmm Rpm )
list(APPEND EXTRA_INCLUDES 
	"${PARENT_DIR}/lib/libafn"
	"${PARENT_DIR}/lib/libgsq" 
	"${PARENT_DIR}/lib/libaln" 
	"${PARENT_DIR}/lib/libblst" 
	"${PARENT_DIR}/lib/libtax" 
	"${PARENT_DIR}/lib/libalex" 
	"${PARENT_DIR}/lib/libtools" 
	"${PARENT_DIR}/lib/libpdb" 
	"${PARENT_DIR}/lib/libhpt" 
	"${PARENT_DIR}/lib/libchn" 
	"${PARENT_DIR}/lib/libgsmo" 
	"${PARENT_DIR}/lib/libhat" 
	"${PARENT_DIR}/lib/libomc" 
	"${PARENT_DIR}/lib/libcmc"
	"${PARENT_DIR}/lib/libpdb" 
	"${PARENT_DIR}/lib/libvsi" 
	"${PARENT_DIR}/lib/libsarp" 
	"${PARENT_DIR}/lib/libsprs" 
	"${PARENT_DIR}/lib/libpsed" 
	"${PARENT_DIR}/lib/librpm" 
	"${PARENT_DIR}/lib/libhmm" 
	"${PARENT_DIR}/lib/include" 
	)

# add the executable
add_executable(bpps run_bpps.cxx)
target_link_libraries(bpps ${EXTRA_LIBS} )
include_directories(${PARENT_DIR}/lib/include  ${EXTRA_INCLUDES})

add_executable(bhps cmcBPPS_main.cxx)
target_link_libraries(bhps ${EXTRA_LIBS} )

# add the binary tree to the search path for include files
# so that we will find bppsConfig.h
#target_include_directories(bpps PRIVATE "${PROJECT_BINARY_DIR}" ${EXTRA_INCLUDES} )
target_include_directories(bpps PUBLIC "${PROJECT_BINARY_DIR}" ${EXTRA_INCLUDES} )

# add the install targets
#install(TARGETS bpps DESTINATION bin)
#install(FILES "${PROJECT_BINARY_DIR}/bppsConfig.h"
#  DESTINATION include
#  )


