Skip to content

Commit 14dcce4

Browse files
committed
fixes for systec build in cmake
1 parent 5868298 commit 14dcce4

2 files changed

Lines changed: 39 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@ if (UNIX)
7171
else()
7272
target_link_libraries(CanModuleMain PUBLIC
7373
${anagate_SOURCE_DIR}/Win64/AnaGateCanDll64.lib
74+
${systec_SOURCE_DIR}/lib/USBCAN64.lib
7475
)
76+
target_include_directories(CanModuleMain PUBLIC ${systec_SOURCE_DIR}/Include)
7577
file(COPY "${anagate_SOURCE_DIR}/Win64/AnaGateCan64.dll"
7678
DESTINATION "${CMAKE_BINARY_DIR}/Release")
79+
file(COPY "${systec_SOURCE_DIR}/lib/USBCAN64.dll"
80+
DESTINATION "${CMAKE_BINARY_DIR}/Release")
7781
endif()
7882

7983
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")

cmake/systec.cmake

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1-
#-----
2-
#SYSTEC USB-CANmodul Utility Disk
3-
#-----
4-
if( NOT DEFINED ENV{SYSTEC_PATH_HEADERS} OR NOT DEFINED ENV{SYSTEC_PATH_LIBS} )
5-
message( FATAL_ERROR "unable to determine SYSTEC USB-CANmodule Utility Disk headers and library paths from environment variables SYSTEC_PATH_HEADERS [$ENV{SYSTEC_PATH_HEADERS}] SYSTEC_PATH_LIBS [$ENV{SYSTEC_PATH_LIBS}]")
1+
include(FetchContent)
2+
3+
if(NOT DEFINED SYSTEC_LIBRARY)
4+
message(FATAL_ERROR "Could not find systec library locally")
5+
# set(SYTEC_LIBRARY "TODO zip path goes here")
6+
endif()
7+
8+
set(SYSTEC_FETCHCONTENT_ARGS
9+
URL "${SYSTEC_LIBRARY}"
10+
DOWNLOAD_EXTRACT_TIMESTAMP True
11+
)
12+
13+
if(EXISTS "${SYSTEC_LIBRARY}")
14+
message(STATUS "Using local Systec archive: ${SYSTEC_LIBRARY}")
15+
elseif(SYSTEC_LIBRARY MATCHES "^https?://")
16+
if(DEFINED ENV{ICS_REPO_DEPS_TOKEN} AND NOT "$ENV{ICS_REPO_DEPS_TOKEN}" STREQUAL "")
17+
message(STATUS "Downloading Systec archive with authentication: ${SYSTEC_LIBRARY}")
18+
list(APPEND SYSTEC_FETCHCONTENT_ARGS
19+
HTTP_HEADER "PRIVATE-TOKEN: $ENV{ICS_REPO_DEPS_TOKEN}"
20+
)
21+
else()
22+
message(STATUS "Downloading Systec archive without authentication: ${SYSTEC_LIBRARY}")
23+
endif()
624
else()
7-
message( STATUS "using SYSTEC USB-CANmodule Utility Disk headers and library paths from environment variables SYSTEC_PATH_HEADERS [$ENV{SYSTEC_PATH_HEADERS}] SYSTEC_PATH_LIBS [$ENV{SYSTEC_PATH_LIBS}]")
25+
message(FATAL_ERROR "SYSTEC_LIBRARY must be an existing local archive or an http(s) URL. Got: ${SYSTEC_LIBRARY}")
26+
endif()
27+
28+
FetchContent_Declare(
29+
Systec
30+
${SYSTEC_FETCHCONTENT_ARGS}
31+
)
32+
33+
FetchContent_MakeAvailable(Systec)
34+
35+
if (WIN32)
36+
add_compile_definitions(WIN32)
837
endif()
9-
include_directories($ENV{SYSTEC_PATH_HEADERS})
10-
set(SYSTEC_LIB_PATH $ENV{SYSTEC_PATH_LIBS})
11-
if(NOT TARGET libusbcan64)
12-
add_library(libusbcan64 SHARED IMPORTED)
13-
set_property(TARGET libusbcan64 PROPERTY IMPORTED_LOCATION $ENV{SYSTEC_PATH_LIBS}/USBCAN64.lib)
14-
endif()

0 commit comments

Comments
 (0)