forked from gazebosim/gz-sim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
96 lines (82 loc) · 3.14 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
if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
# pybind11 logic for setting up a debug build when both a debug and release
# python interpreter are present in the system seems to be pretty much broken.
# This works around the issue.
set(PYTHON_LIBRARIES "${PYTHON_DEBUG_LIBRARIES}")
endif()
if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION)
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c "if True:
from distutils import sysconfig as sc
print(sc.get_python_lib(plat_specific=True))"
OUTPUT_VARIABLE Python3_SITEARCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
# Get install variable from Python3 module
# Python3_SITEARCH is available from 3.12 on, workaround if needed:
find_package(Python3 COMPONENTS Interpreter)
endif()
if(USE_DIST_PACKAGES_FOR_PYTHON)
string(REPLACE "site-packages" "dist-packages" IGN_PYTHON_INSTALL_PATH ${Python3_SITEARCH})
endif()
else()
# If not a system installation, respect local paths
set(IGN_PYTHON_INSTALL_PATH ${IGN_LIB_INSTALL_DIR}/python)
endif()
# Set the build location and install location for a CPython extension
function(configure_build_install_location _library_name)
# Install library for actual use
install(TARGETS ${_library_name}
DESTINATION "${IGN_PYTHON_INSTALL_PATH}/ignition"
)
endfunction()
pybind11_add_module(gazebo SHARED
src/ignition/gazebo/_ignition_gazebo_pybind11.cc
src/ignition/gazebo/EntityComponentManager.cc
src/ignition/gazebo/EventManager.cc
src/ignition/gazebo/TestFixture.cc
src/ignition/gazebo/Server.cc
src/ignition/gazebo/ServerConfig.cc
src/ignition/gazebo/UpdateInfo.cc
src/ignition/gazebo/Util.cc
src/ignition/gazebo/World.cc
)
target_link_libraries(gazebo PRIVATE
${PROJECT_LIBRARY_TARGET_NAME}
sdformat${SDF_VER}::sdformat${SDF_VER}
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
)
# TODO(ahcorde): Move this module to ign-common
pybind11_add_module(common SHARED
src/ignition/common/_ignition_common_pybind11.cc
src/ignition/common/Console.cc
)
target_link_libraries(common PRIVATE
ignition-common${IGN_COMMON_VER}::ignition-common${IGN_COMMON_VER}
)
configure_build_install_location(gazebo)
configure_build_install_location(common)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Workaround for Clang and pybind11 on Focal
# https://github.com/pybind/pybind11/issues/1604
# Resolved by newer versions of pybind11
if(${pybind11_VERSION} VERSION_LESS "2.4.4")
target_compile_options(common PRIVATE -fsized-deallocation)
target_compile_options(gazebo PRIVATE -fsized-deallocation)
endif()
endif()
if (BUILD_TESTING)
set(python_tests
testFixture_TEST
)
foreach (test ${python_tests})
add_test(NAME ${test}.py COMMAND
"${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/python/test/${test}.py")
set(_env_vars)
list(APPEND _env_vars "PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/python/")
list(APPEND _env_vars "LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}:$ENV{LD_LIBRARY_PATH}")
set_tests_properties(${test}.py PROPERTIES
ENVIRONMENT "${_env_vars}")
endforeach()
endif()