#--------------------------------------------------------------------
#    Copyright 2002 - 2008, 2010, 2011 National Technology &         
#    Engineering Solutions of Sandia, LLC (NTESS). Under the terms   
#    of Contract DE-NA0003525 with NTESS, there is a                 
#    non-exclusive license for use of this work by or on behalf      
#    of the U.S. Government.  Export of this program may require     
#    a license from the United States Government.                    
#--------------------------------------------------------------------

#
# The signature for Boost.build rules is described here:
#
# http://www.boost.org/build/doc/html/bbv2/overview/targets.html
#
#function-name main-target-name
#    : sources
#    : requirements
#    : default-build
#    : usage-requirements
#    ;
#
#    * "main-target-name" is the name used to request the target
#            on command line and to use it from other main targets.
#            Main target name may contain alphanumeric characters and symbols '-' and '_';
#    * "sources" is the list of source files and other main targets that must be combined.
#    * "requirements" is the list of properties that must always be present
#            when this main target is built.
#    * "default-build" is the list of properties that will be used unless
#            some other value of the same feature is already specified.
#    * "usage-requirements" is the list of properties that will be propagated
#            to all main targets that use this one, i.e. to all dependedents.
#
#
# SECTION 1: Project definition
#

import set ;
import path ;

local stk_tools-root-inc ;
if $(RTenv-arg) = "user" {
  stk_tools-root-inc = $(stk_tools-root)/include ;
} else {
  stk_tools-root-inc = $(stk_tools-root) ;
}

project votd
  : requirements
    $(sierra-warnings)
    <define>STK_BUILT_IN_SIERRA
    <define>STK_SHOW_DEPRECATED_WARNINGS
    <define>STK_HIDE_DEPRECATED_CODE
    <define>SIERRA_MIGRATION
    <include>$(stk_tools-root-inc)
  : usage-requirements
    <define>SIERRA_MIGRATION
    <include>$(stk_tools-root-inc)
  : build-dir $(stk_tools-builddir)
  ;

# This variable should contain the applications and associated files that
# must be installed for both developers and end users. Unless they need to
# be visible to end users, unittests should not be placed here.
local installed-end-user-files = 
  stk_block_extractor
  ;
#
# This variable should contain the applications and associated files that will
# only be installed for and visible to developers.
# Note that if the --install-developer-files option is passed to bjam these will also
# be installed for end-users. (This is only intended to be used for testing.)
local installed-developer-files = 
  stk_block_extractor
  stk_tools_utest
  stk_tools_integration_tester
  stk_tools_pmesh_unit_tester
  ;

#
# SECTION 2: Development install
#

local xml-files =
  ;

explicit install-serial-targets ;
alias install-serial-targets ;

# Dependencies listed in this target are installed in the developer's project.
# This should include all executables and any other files needed for developer use.
explicit install-targets ;
alias install-targets
  : $(installed-end-user-files)
    $(installed-developer-files)
  ;

#
# SECTION 3: End-user install
#
explicit install-user-env ;
alias install-user-env : install-user-jamfile
                         install-user-include
                         install-user-lib
                         install-user-bin ;

# Dependencies listed in this target are always installed for end users.
# This should include only those executables and any other files needed by end-users.
explicit install-user-bin ;
install install-user-bin
  : $(installed-end-user-files)
    [ if-defined-val $(install-developer-files-arg) :
        # Executables listed here will only installed if the --install-developer-files option
        # is passed to bjam. This is intended for testing that requires things like 
        # unittest to be installed when they normally would not be.
        $(installed-developer-files)
    ]
  :
  # Note that all Sierra executables are installed in a common bin directory,
  # not in a product-specific bin directory.
  <location>$(install-bin-dir)
  ;

# This rule copies build-system related files for this product to the install-root.
explicit install-user-jamfile ;
install install-user-jamfile
  : [ glob $(stk_tools-root)/Jamfile ]
  : <location>$(install-root)/stk/stk_tools
    <install-source-root>$(stk_tools-root)
  ;


explicit install-user-include ;
install install-user-include
  : [ path.glob-tree $(stk_tools-root) : *.h *.hpp *.tcc ]
  : <location>$(install-root)/stk/stk_tools/include <install-source-root>$(stk_tools-root)
  ;

explicit install-user-lib ;
install install-user-lib
  : stk_tools_lib
    stk_mesh_tools_lib
    stk_transfer_utils_lib
  : <location>$(install-root)/stk/stk_tools/lib
  ;

explicit install-exe-targets ;
alias install-exe-targets : ;

#
# SECTION 4: Build configuration
#
exe stk_block_extractor
  :
    $(stk_tools-root)/stk_tools/block_extractor/main.cpp 
    stk_tools_lib
    stk_transfer_utils_lib
    /sierra/stk_util//stk_util_command_line
    /mpi//mpi
  : <tag>@sierra-exec-tag
  ;

exe stk_tools_utest
  :
    [ glob $(stk_tools-root)/../stk_unit_tests/stk_tools/block_extractor/*.cpp ]
    [ glob $(stk_tools-root)/../stk_unit_tests/stk_tools/mesh_clone/*.cpp ]
    [ glob $(stk_tools-root)/../stk_unit_tests/stk_tools/mesh_tools/*.cpp ]
    stk_tools_lib
    stk_mesh_tools_lib
    /sierra/stk_unit_test_utils//stk_unit_main
  : <tag>@sierra-exec-tag
  ;

exe stk_tools_integration_tester
  :
    [ glob $(stk_tools-root)/../stk_unit_tests/stk_tools/*.cpp ]
    stk_tools_lib
    /sierra/stk_unit_test_utils//stk_unit_main
  : <tag>@sierra-exec-tag
  ;

lib stk_tools_lib
  :
    [ ifdevbuild
    # Any parameters within this 'ifdevbuild' block apply to development
    # builds only and will not be present for user builds.
        [ glob $(stk_tools-root)/stk_tools/mesh_clone/*.cpp ]
        [ glob $(stk_tools-root)/stk_tools/block_extractor/*.cpp : $(stk_tools-root)/stk_tools/block_extractor/main.cpp ]
    ]
    /sierra/stk_mesh//stk_mesh_base
    /sierra/stk_io//stk_io
    stk_transfer_utils_lib
  :
    [ ifuserbuild
    # Any parameters within this 'ifuserbuild' block apply to user
    # builds only and will not be present for developer builds.
        <file>$(stk_tools-root)/lib/libstk_tools_lib.a
    ]
    [ ifdevbuild
        # Any parameters within this 'ifdevbuild' block apply to development
        # builds only and will not be present for user builds.
        <toolset>gcc:<cflags>"-Wextra -Wpedantic -Wshadow -Wno-unused-parameter"
    ]
  ;

lib stk_mesh_tools_lib
  :
    [ ifdevbuild
    # Any parameters within this 'ifdevbuild' block apply to development
    # builds only and will not be present for user builds.
        [ glob $(stk_tools-root)/stk_tools/mesh_tools/*.cpp ]
    ]
    /sierra/stk_mesh//stk_mesh_base
    /sierra/stk_search//stk_search
    /sierra/stk_io//stk_io
  :
    [ ifuserbuild
    # Any parameters within this 'ifuserbuild' block apply to user
    # builds only and will not be present for developer builds.
        <file>$(stk_tools-root)/lib/libstk_mesh_tools_lib.a
    ]
    [ ifdevbuild
        # Any parameters within this 'ifdevbuild' block apply to development
        # builds only and will not be present for user builds.
        <toolset>gcc:<cflags>"-Wextra -Wpedantic -Wshadow -Wno-unused-parameter"
    ]
  ;

lib stk_pmesh_lib
  : 
    [ ifdevbuild
        $(stk_tools-root)/stk_tools/pmesh_lib/makeparfiles.C
    ]
    /sierra/stk_io//stk_io
    /sierra/stk_io//stk_io_util
    /sierra/seacas//nemesis
  :
    [ ifuserbuild
        <file>$(stk_tools-root)/lib/libpmesh_lib.a
    ]
    [ ifdevbuild
        <include>$(stk_tools-root-inc)/stk_tools/pmesh_lib
        <toolset>gcc:<cflags>"-Wextra -Wpedantic -Wshadow -Wno-unused-parameter"
    ]
  :
  :
    <include>$(stk_tools-root-inc)/stk_tools/pmesh_lib
  ;

lib stk_transfer_utils_lib
  :
    [ ifdevbuild
        [ glob
          $(stk_tools-root)/stk_tools/transfer_utils/*.cpp ]
    ]
    /sierra/stk_mesh//stk_mesh_base
    /sierra/stk_io//stk_io
    /sierra/stk_util//stk_util_registry
    /sierra/stk_transfer//stk_transfer_impl
  :
    [ ifuserbuild
        <file>$(stk_tools-root)/lib/libstk_transfer_utils_lib.a
    ]
    [ ifdevbuild
        <toolset>gcc:<cflags>"-Wextra -Wpedantic -Wshadow -Wno-unused-parameter"
    ]
  ;

exe stk_tools_pmesh_unit_tester
  :
    [ glob
      $(stk_tools-root)/stk_tools/pmesh_lib/UnitTest/*.C
    ]
    stk_pmesh_lib
    /tpl/gtest//gtest
  :
    <tag>@sierra-exec-tag
  ;

