cmake_minimum_required(VERSION 3.7.0)
project( Capi62386CommunicationTestConsole )

# Example project for the CAP-I-62386 Communication Library

# Add the library's include directory
include_directories(
    ${CMAKE_BINARY_DIR}
    ${CMAKE_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/../include/
)

# Add the library's lib directory, which contains both the .lib and the .dll file
link_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/../bin/
)

# Define that you want to import the functions
add_definitions(-DCAPI62386_COMMUNICATION_DLL_IMPORT)

# Build the executable
add_executable(Capi62386CommunicationTestConsole main.cpp)

# Link the library
target_link_libraries(Capi62386CommunicationTestConsole Capi62386Communication)

# Finally, copy the DLL to the output directory, so the executable finds it on startup
add_custom_command(
    TARGET Capi62386CommunicationTestConsole
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../bin/Capi62386Communication.dll $<TARGET_FILE_DIR:Capi62386CommunicationTestConsole>/
)