##############################################################################
#
#  $Id$
#
#  Copyright 2015 Andreas Stewering
#
#  This file is part of the canrestbus library.
#
#  The canrestbus library is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or (at your
#  option) any later version.
#
#  The canrestbus library is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
#  License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with the canrestbus library. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

if (DEBUG)
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -fstack-usage -fstack-check")
else (DEBUG)
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2")
endif (DEBUG)

INCLUDE_DIRECTORIES(
    ${PROJECT_BINARY_DIR}
    ${PROJECT_SOURCE_DIR}
    ${PROJECT_INCLUDE_DIR}
    ${LIBPCRE_INCLUDE_DIRS}
    )

  
LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/src)

ADD_EXECUTABLE(can_decoder main_decoder.c)
TARGET_LINK_LIBRARIES(can_decoder ${PROJECT_NAME} rt m ${LIBPCRE_LIBRARIES})

ADD_EXECUTABLE(can_lsa2l lsa2l.c)
TARGET_LINK_LIBRARIES(can_lsa2l ${PROJECT_NAME} rt m ${LIBPCRE_LIBRARIES})

ADD_EXECUTABLE(can_replay main_replay.c)
TARGET_LINK_LIBRARIES(can_replay ${PROJECT_NAME} rt m ${LIBPCRE_LIBRARIES})

ADD_EXECUTABLE(can_dbcls main_dbc.c)
TARGET_LINK_LIBRARIES(can_dbcls ${PROJECT_NAME})

INSTALL(TARGETS can_decoder DESTINATION bin)
INSTALL(TARGETS can_lsa2l DESTINATION bin)
INSTALL(TARGETS can_replay DESTINATION bin)
INSTALL(TARGETS can_dbcls DESTINATION bin)
