Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 168 additions & 42 deletions AdsLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,168 @@
set(SOURCES
AdsDef.cpp
AdsDevice.cpp
AdsFile.cpp
AdsLib.cpp
ECatAccess.cpp
Frame.cpp
LicenseAccess.cpp
Log.cpp
MasterDcStatAccess.cpp
RTimeAccess.cpp
RegistryAccess.cpp
RouterAccess.cpp
Sockets.cpp
SymbolAccess.cpp

bhf/ParameterList.cpp

standalone/AdsLib.cpp
standalone/AmsConnection.cpp
standalone/AmsNetId.cpp
standalone/AmsPort.cpp
standalone/AmsRouter.cpp
standalone/NotificationDispatcher.cpp
)

add_library(ads ${SOURCES})
add_library(ads::ads ALIAS ads)

target_include_directories(ads PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/ads>)

if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_link_libraries(ads PUBLIC wsock32)
endif()


if(WIN32 EQUAL 1)
target_link_libraries(ads PUBLIC ws2_32)
endif()

target_link_libraries(ads PUBLIC Threads::Threads)
set(LIB_SOURCES
AdsDef.cpp
AdsDevice.cpp
AdsFile.cpp
AdsLib.cpp
ECatAccess.cpp
Frame.cpp
LicenseAccess.cpp
Log.cpp
MasterDcStatAccess.cpp
RTimeAccess.cpp
RegistryAccess.cpp
RouterAccess.cpp
Sockets.cpp
SymbolAccess.cpp
)
set(LIB_HEADERS
AdsDef.h
AdsDevice.h
AdsException.h
AdsFile.h
AdsLib.h
AdsNotification.h
AdsNotificationOOI.h
AdsVariable.h
AmsConnection.h
AmsHeader.h
AmsPort.h
AmsRouter.h
ECatAccess.h
Frame.h
LicenseAccess.h
Log.h
MasterDcStatAccess.h
NotificationDispatcher.h
RegistryAccess.h
RingBuffer.h
Router.h
RouterAccess.h
RTimeAccess.h
Semaphore.h
Sockets.h
SymbolAccess.h
wrap_socket.h
wrap_registry.h
wrap_endian.h
)

set(BHF_SOURCES
bhf/ParameterList.cpp
)
set(BHF_HEADERS
bhf/ParameterList.h
bhf/StringToInteger.h
bhf/WindowsQuirks.h
)

set(TWINCAT_SOURCES
TwinCAT/AdsLib.cpp
)
set(TWINCAT_HEADERS
TwinCAT/AdsDef.h
TwinCAT/AdsLib.h
)

set(STANDALONE_SOURCES
standalone/AdsLib.cpp
standalone/AmsConnection.cpp
standalone/AmsNetId.cpp
standalone/AmsPort.cpp
standalone/AmsRouter.cpp
standalone/NotificationDispatcher.cpp
)
set(STANDALONE_HEADERS
standalone/AdsDef.h
standalone/AdsLib.h
)

# Create the standalone variant
add_library(AdsLib)
target_sources(AdsLib PRIVATE
${STANDALONE_SOURCES}
${LIB_SOURCES}
${BHF_SOURCES}
)
target_sources(AdsLib PUBLIC
FILE_SET HEADERS
FILES
${LIB_HEADERS}
${BHF_HEADERS}
${STANDALONE_HEADERS}
)
target_include_directories(AdsLib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/ads>
)

target_link_libraries(AdsLib
PUBLIC
Threads::Threads
)

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_link_libraries(AdsLib
PUBLIC
wsock32
ws2_32
)
endif ()

if (BUILD_SHARED_LIBS)
target_compile_definitions(TcAdsLib
PUBLIC
BHF_ADS_EXPORT_C
BHF_ADS_USE_TWINCAT_ORDER
)
endif ()

list(APPEND LIST_TARGETS_TO_INSTALL AdsLib)

# Create the TwinCat variant.
if (TcAdsDll_FOUND AND NOT ONLY_STANDALONE)
add_library(TcAdsLib)
target_sources(TcAdsLib PRIVATE
${TWINCAT_SOURCES}
${LIB_SOURCES}
${BHF_SOURCES}
)
target_sources(TcAdsLib PUBLIC
FILE_SET HEADERS
FILES
${LIB_HEADERS}
${BHF_HEADERS}
${TWINCAT_HEADERS}
)
target_include_directories(TcAdsLib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/ads>
)

target_link_libraries(TcAdsLib
PUBLIC
Threads::Threads
TcAdsDll::TcAdsDll
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_link_libraries(TcAdsLib
PUBLIC
wsock32
ws2_32
)
endif ()
target_compile_definitions(TcAdsLib
PUBLIC
USE_TWINCAT_ROUTER
)
if (BUILD_SHARED_LIBS)
target_compile_definitions(TcAdsLib
PUBLIC
BHF_ADS_EXPORT_C
)
endif ()
list(APPEND LIST_TARGETS_TO_INSTALL TcAdsLib)
endif ()

# Pass the created targets to the parent scope
set(LIST_TARGETS_TO_INSTALL "${LIST_TARGETS_TO_INSTALL}" PARENT_SCOPE)

6 changes: 6 additions & 0 deletions AdsLibOOITest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set(SOURCES
main.cpp
)

add_executable(AdsLibOOITest ${SOURCES})
target_link_libraries(AdsLibOOITest PRIVATE AdsLib Fructose)
11 changes: 3 additions & 8 deletions AdsLibTest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
set(SOURCES
main.cpp
main.cpp
)

add_executable(AdsLibTest.bin ${SOURCES})

target_link_libraries(AdsLibTest.bin PUBLIC ads)

target_include_directories(AdsLibTest.bin
PRIVATE ../tools/
)
add_executable(AdsLibTest ${SOURCES})
target_link_libraries(AdsLibTest PRIVATE AdsLib Fructose)
10 changes: 10 additions & 0 deletions AdsLibTestRef/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Skip this tests if no TcAdsDll
if (NOT TcAdsDll_FOUND)
return()
endif ()

set(SOURCES
main.cpp
)
add_executable(TcAdsLibTestRef ${SOURCES})
target_link_libraries(TcAdsLibTestRef PRIVATE TcAdsLib Fructose)
13 changes: 13 additions & 0 deletions AdsTest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
set(SOURCES
main.cpp
RegistryAccessTest.cpp
RegistryAccessTest.h
)

add_executable(AdsTest ${SOURCES})
target_link_libraries(AdsTest PRIVATE AdsLib)

if(TcAdsDll_FOUND AND NOT ONLY_STANDALONE)
add_executable(TcAdsTest ${SOURCES})
target_link_libraries(TcAdsTest PRIVATE TcAdsLib)
endif ()
26 changes: 24 additions & 2 deletions AdsTool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
add_executable(AdsTool main.cpp)
target_link_libraries(AdsTool PUBLIC ads::ads)

set(SOURCES
main.cpp
)
# Create the standalone variant
add_executable(AdsTool ${SOURCES})
target_link_libraries(AdsTool PRIVATE AdsLib)
set_target_properties(AdsTool PROPERTIES
OUTPUT_NAME "adstool"
)
list(APPEND LIST_TARGETS_TO_INSTALL AdsTool)

# Create the TwinCat variant
if (TcAdsDll_FOUND AND NOT ONLY_STANDALONE)
add_executable(TcAdsTool ${SOURCES})
target_link_libraries(TcAdsTool PRIVATE TcAdsLib)
set_target_properties(TcAdsTool PROPERTIES
OUTPUT_NAME "tcadstool"
)
list(APPEND LIST_TARGETS_TO_INSTALL TcAdsTool)
endif ()

# Pass the created targets to the parent scope
set(LIST_TARGETS_TO_INSTALL "${LIST_TARGETS_TO_INSTALL}" PARENT_SCOPE)
Loading