#-------------------------------------------------------------------
# This file is part of the CMake build system for Hydrax
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------

#######################################################################
# This file takes care of configuring Hydrax to build with the settings
# given in CMake. It creates the necessary config.h file and will 
# also prepare package files for pkg-config and CMake.
#######################################################################

# dynamic or static build
if (HYDRAX_STATIC)
  set(HYDRAX_LIB_TYPE STATIC)
else ()
  set(HYDRAX_LIB_TYPE SHARED)
endif ()

# Create the pkg-config package files on Unix systems
if (UNIX)
  set(HYDRAX_LIB_SUFFIX "")
  set(HYDRAX_PLUGIN_PREFIX "")
  set(HYDRAX_PLUGIN_EXT ".so")
  if (HYDRAX_STATIC)
    set(HYDRAX_LIB_SUFFIX "${HYDRAX_LIB_SUFFIX}Static")
    set(HYDRAX_PLUGIN_PREFIX "lib")
    set(HYDRAX_PLUGIN_EXT ".a")
  endif ()
  string(TOLOWER "${CMAKE_BUILD_TYPE}" HYDRAX_BUILD_TYPE)
  if (HYDRAX_BUILD_TYPE STREQUAL "debug")
    set(HYDRAX_LIB_SUFFIX "${HYDRAX_LIB_SUFFIX}_d")
  endif ()

  set(HYDRAX_ADDITIONAL_LIBS "")
  set(HYDRAX_CFLAGS "")
  set(HYDRAX_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
  configure_file(${HYDRAX_TEMPLATES_DIR}/hydrax.pc.in ${HYDRAX_BINARY_DIR}/pkgconfig/hydrax${HYDRAX_LIB_SUFFIX}.pc @ONLY)

  install(FILES ${HYDRAX_BINARY_DIR}/pkgconfig/hydrax${HYDRAX_LIB_SUFFIX}.pc DESTINATION lib/pkgconfig)
endif ()

if (MSVC)
  # Enable intrinsics on MSVC in debug mode
  add_definitions(/Oi)
endif (MSVC)