# MacPorts MySQL Connector/C++ examples CMake build
# 
# Written in 2018 by Jeffrey Dvornek
#
# To the extent possible under law, the author(s) have dedicated all 
# copyright and related and neighboring rights to this software to the 
# public domain worldwide. This software is distributed without any warranty.
# 
# You should have received a copy of the CC0 Public Domain Dedication along 
# with this software. If not, see 
# <http://creativecommons.org/publicdomain/zero/1.0/>.

cmake_minimum_required(VERSION 3.10)

SET(CMAKE_VERBOSE_MAKEFILE 0)

FIND_PACKAGE(Boost COMPONENTS system thread REQUIRED)

INCLUDE_DIRECTORIES(
  @PREFIX@/include
  @PREFIX@/include@NAME@
  @PREFIX@/include@DBPORT@
  ${Boost_INCLUDE_DIRS}
)

LINK_DIRECTORIES(
  @PREFIX@/lib/
  @PREFIX@/lib@NAME@/
  @PREFIX@/lib@DBPORT@/mysql
)

LINK_LIBRARIES(
  mysqlcppconn
  ${Boost_SYSTEM_LIBRARY}
  ${Boost_THREAD_LIBRARY}
)

FIND_LIBRARY(MYSQLCLIENT_LIB
             NAMES libmysqlclient.dylib 
             PATHS @PREFIX@/lib@NAME@ NO_DEFAULT_PATH)

ADD_DEFINITIONS(-DDYNLOAD_MYSQL_LIB="${MYSQLCLIENT_LIB}")

ADD_EXECUTABLE(connect connect.cpp)
ADD_EXECUTABLE(connection_meta_schemaobj connection_meta_schemaobj.cpp)
ADD_EXECUTABLE(debug_output debug_output.cpp)
ADD_EXECUTABLE(exceptions exceptions.cpp)
ADD_EXECUTABLE(prepared_statement prepared_statement.cpp)
ADD_EXECUTABLE(resultset resultset.cpp)
ADD_EXECUTABLE(resultset_binary resultset_binary.cpp)
ADD_EXECUTABLE(resultset_meta resultset_meta.cpp)
ADD_EXECUTABLE(resultset_types resultset_types.cpp)
ADD_EXECUTABLE(statement statement.cpp)
ADD_EXECUTABLE(dynamic_load dynamic_load.cpp)