###############################################################################
#
#  GenICam Build Process
#           Author:  Eric Gross
#           (c) 2009 by National Instruments
#
#       MathParser build configuration
#
#  License: This file is published under the license of the EMVA GenICam  Standard Group.
#  A text file describing the legal terms is included in  your installation as 'GenICam_license.pdf'.
#  If for some reason you are missing  this file please contact the EMVA or visit the website
#  (http:#www.genicam.org) for a full copy.
#
#  THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
#  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
#  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD  GROUP
#  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL,
#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)
#  ARISING IN ANY WAY OUT OF THE USE  OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#  POSSIBILITY OF SUCH DAMAGE.
###############################################################################

#------------------------------------------------------------------------------
#  Compiler and linker settings
#------------------------------------------------------------------------------

add_definitions(
  -DMATHPARSERDLL_EXPORTS
)

if (UNIX OR VXWORKS)
	#  Only export the necessary symbols declared with GCBASE_API
	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
	set (CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -fvisibility=hidden")
endif()

WARNING_LEVEL_4()
TREAT_WARNINGS_AS_ERRORS()

#------------------------------------------------------------------------------
#  Define source 
#------------------------------------------------------------------------------
LOCATE_HEADERS(GenApi/impl/MathParser HEADERS)
set(SOURCES ${HEADERS}
    Int64Lexer.cpp
    Int64MathParser.cpp
    Lexer.cpp
    MathParser.cpp
    StrMap.cpp
    SymTable.cpp
    StaticMathCharTypeTable.cpp
)
if (WIN32)
	set (SOURCES ${SOURCES} MathParserDll.cpp)
endif()

GENERATE_RC_VERSIONING(MathParser "GenICam Reference Implementation - MathParser Module" "MathParser.dll")

#------------------------------------------------------------------------------
# Build the library
#------------------------------------------------------------------------------
add_library (MathParser SHARED ${SOURCES} ${RC_FILE})

if(RTX_WIN64)
    add_custom_command(TARGET MathParser POST_BUILD COMMAND $ENV{RTX64Common}bin/StampTool.exe ARGS $(TargetPath) COMMENT "Signing rtdll")
endif()

if (RTX_WIN64)
    set_target_properties(MathParser PROPERTIES SUFFIX .rtdll) 
    message(STATUS "MathParser changed extension to .rtdll")
    target_link_libraries(MathParser GCBase RTmalloc StartupDllCrt optimized libcmt optimized libcpmt debug libcmtd debug libcpmtd rtx_rtss)
else()
	target_link_libraries(MathParser GCBase memcpy)
endif()

ExportTarget( MathParser )

#------------------------------------------------------------------------------
# Installation
#------------------------------------------------------------------------------

install(TARGETS MathParser
    RUNTIME DESTINATION bin/${PLATFORM_PATH_NAME}
        COMPONENT GenApiRuntime
    LIBRARY DESTINATION library/CPP/lib/${PLATFORM_PATH_NAME}
        COMPONENT GenApiRuntime
)
