-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
64 lines (50 loc) · 1.98 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
cmake_minimum_required(VERSION 3.11)
include(FetchContent)
project(CanModule LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include_directories(src/include
${PROJECT_BINARY_DIR}/src/include/)
include(cmake/version.cmake)
set(SOURCES
src/main/CanFrame.cpp
src/main/CanDevice.cpp
src/main/CanVendorLoopback.cpp
src/main/CanDeviceConfiguration.cpp
src/main/CanDiagnostics.cpp
)
include(cmake/env.cmake)
set(VENDOR_SOURCES
src/main/CanVendorAnagate.cpp
)
if (UNIX)
list(APPEND VENDOR_SOURCES src/main/CanVendorSocketCan.cpp)
endif()
include(cmake/logit.cmake)
include(cmake/anagate.cmake)
add_library(CanModuleMain ${SOURCES} ${VENDOR_SOURCES})
target_include_directories(CanModuleMain PRIVATE ${logit_SOURCE_DIR}/include ${anagate_SOURCE_DIR}/include)
if (UNIX)
target_link_libraries(CanModuleMain PRIVATE
${anagate_SOURCE_DIR}/lib/libAnaGateExtStaticRelease.so
${anagate_SOURCE_DIR}/lib/libAnaGateStaticRelease.so
${anagate_SOURCE_DIR}/lib/libCANDLLStaticRelease64.so
socketcan)
file(GLOB ANAGATE_LIBRARIES_SO ${anagate_SOURCE_DIR}/lib/*.so)
file(COPY ${ANAGATE_LIBRARIES_SO} DESTINATION ${CMAKE_BINARY_DIR})
else()
target_link_libraries(CanModuleMain PRIVATE
${anagate_SOURCE_DIR}/lib/AnaGateCanDll64.lib)
file(COPY "${anagate_SOURCE_DIR}/lib/AnaGateCan64.dll" DESTINATION "${CMAKE_BINARY_DIR}/Release")
endif()
# Treat warnings as errors
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(CanModuleMain PRIVATE -Wall -Wextra -Werror)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# target_compile_options(CanModuleMain PRIVATE /W4 /WX)
# I need to disable that feature due to a macro redefinition
# in the header of Anagate software
endif()
include(cmake/pybind11.cmake)
include(cmake/gtest.cmake)