-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
131 lines (101 loc) · 4.48 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
cmake_minimum_required(VERSION 3.14)
project(VSCMG
LANGUAGES CXX C
VERSION 0.0.0)
include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Type of build (Debug, Release etc." FORCE)
if(NOT CMAKE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE "Release")
endif()
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/adcs")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_ROOT_PATH ${PROJECT_SOURCE_DIR})
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
option(BUILD_EXAMPLES "Build Example " ON)
option(BUILD_PYTHON_LIB "Build Python Wrapper " OFF)
include_directories("include" "Systems/include")
if(${BUILD_PYTHON_LIB})
add_compile_definitions(BUILD_PYTHON_LIB)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(ProjectDeps)
######################################################
# ADCS Core lib
######################################################
file(GLOB ADCS_SRC "include/ADCS/Core/*.h")
add_library(ADCS SHARED ${ADCS_SRC})
target_link_libraries (ADCS Eigen3::Eigen ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
set_target_properties(ADCS PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(ADCS PROPERTIES PUBLIC_HEADER
"include/ADCS/Core/Controllers.h;include/ADCS/Core/IBaseSystem.h;include/ADCS/Core/NumPyArrayData.h;include/ADCS/Core/kinematics.h;include/ADCS/Core/utils.h"
)
install(TARGETS ADCS
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ADCS/Core/"
)
######################################################
# ADCS System modules
######################################################
#set(CMAKE_SHARED_LIBRARY_PREFIX "")
file(GLOB SYSTEMS_MODULES "src/ADCS/Systems/*.cpp")
foreach(module_path ${SYSTEMS_MODULES})
get_filename_component(module_name ${module_path} NAME_WE)
add_library(${module_name} SHARED ${module_path} )
target_link_libraries (${module_name} ADCS Eigen3::Eigen ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${BOOST_NUMPY_LIBRARY})
set_target_properties(${module_name} PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(${module_name} PROPERTIES PUBLIC_HEADER "include/ADCS/Systems/${module_name}.h")
install(TARGETS ${module_name}
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ADCS/Systems/")
endforeach()
######################################################
# Python wrapper library
######################################################
add_library(Controller MODULE "src/ADCS/py_controller.cpp")
target_include_directories(Controller PRIVATE ${PYTHON_INCLUDE_DIRS})
target_link_libraries (Controller Eigen3::Eigen ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${BOOST_NUMPY_LIBRARY})
IF (WIN32)
set_target_properties(Controller PROPERTIES SUFFIX .pyd)
ELSE()
set_target_properties(Controller PROPERTIES SUFFIX ".so")
ENDIF()
install(TARGETS Controller
LIBRARY DESTINATION DESTINATION lib
)
#install(FILES __init__.py DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/adcs)
#file(COPY __init__.py DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
######################################################
# Executable Samples
######################################################
if(${BUILD_EXAMPLES})
add_executable (TestVSCMG examples/cpp/vscmg.cpp )
target_link_libraries (TestVSCMG VSCMG)
add_executable (TestRigidBody examples/cpp/rigid_body.cpp )
target_link_libraries (TestRigidBody RigidBody)
endif()
######################################################
# copy python samples to binary output directory
######################################################
if(${BUILD_PYTHON_LIB})
file(GLOB python_samples "examples/python/*.py")
foreach(sample ${python_samples})
file(COPY ${sample} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endforeach()
endif()
# make uninstall
add_custom_target("uninstall" COMMENT "Uninstall installed files")
add_custom_command(
TARGET "uninstall"
POST_BUILD
COMMENT "Uninstall files with install_manifest.txt"
COMMAND xargs rm -vf < install_manifest.txt || echo Nothing in
install_manifest.txt to be uninstalled!
)