-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·80 lines (61 loc) · 2.67 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
cmake_policy(SET CMP0048 NEW)
project(AKDController VERSION 0.1)
cmake_minimum_required(VERSION 3.13)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/install)
endif()
option(DEBUG_MODE "Will output info on controller state" OFF)
if(DEBUG_MODE)
add_compile_definitions("AKD_ECAT_DEBUG_MODE=true")
endif()
# Check to make sure submodule was initialized.
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
option(GIT_SUBMODULE "Check submodules during build" ON)
if(GIT_SUBMODULE)
message(STATUS "Submodule update")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
endif()
endif()
endif()
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/SOEM/CMakeLists.txt")
message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.")
endif()
#Dependency
add_subdirectory(extern/SOEM)
add_library(AKD_ecat STATIC src/AKDEcatController.cpp)
#Library
#if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# add_library(AKD_ecat STATIC src/AKDEcatController.cpp)
#else()
# add_library(AKD_ecat OBJECT src/AKDEcatController.cpp)
# message(STATUS "AKD_Ecat: not creating a library archive (libAKD-ecat.a) when build as dependecy.")
#endif()
target_link_libraries(AKD_ecat PUBLIC soem pthread)
target_include_directories(AKD_ecat PUBLIC include)
#Tests
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_executable(simpleMtrCtrl tests/simpleMtrCtrl.cpp)
add_executable(simpleMtrCtrlx2 tests/simpleMtrCtrlx2.cpp)
add_executable(simpleMtrCtrlx2Flex tests/simpleMtrCtrlx2Flex.cpp)
target_link_libraries(simpleMtrCtrl PUBLIC AKD_ecat)
target_link_libraries(simpleMtrCtrlx2 PUBLIC AKD_ecat)
target_link_libraries(simpleMtrCtrlx2Flex PUBLIC AKD_ecat)
install(TARGETS simpleMtrCtrl DESTINATION tests/)
install(TARGETS simpleMtrCtrlx2 DESTINATION tests/)
install(TARGETS simpleMtrCtrlx2Flex DESTINATION tests/)
else()
message(STATUS "AKD_Ecat: not building tests when built as dependency")
endif()
message(STATUS "AKD install prefix : ${CMAKE_INSTALL_PREFIX}")
install( FILES include/AKDEcatController.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include
)
install( TARGETS AKD_ecat
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)