Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ cmake_dependent_option(WITH_PYBIND "Enable PYBIND support"
cmake_dependent_option(WITH_MAGMA "Enable MAGMA features" ON "MAGMA_FOUND" OFF)
cmake_dependent_option(WITH_MNASOLVERPLUGIN "Enable MNASolver Plugins" ON "NOT WIN32" OFF)

if(WITH_PYBIND)
add_custom_target(pybind COMMENT "Build Python extension with pybind")
endif()

if(WITH_CUDA)
# BEGIN OF WORKAROUND - enable cuda dynamic linking.
# Starting with Cmake 3.17 we can use
Expand Down
1 change: 1 addition & 0 deletions dpsim-villas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if(WITH_PYBIND)
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
target_link_libraries(dpsimpyvillas PRIVATE dpsim-villas)
add_dependencies(pybind dpsimpyvillas)
endif()

add_subdirectory(src)
Expand Down
1 change: 1 addition & 0 deletions dpsim/src/pybind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ set_target_properties(dpsimpy
)
target_link_libraries(dpsimpy PRIVATE dpsim)
target_include_directories(dpsimpy PUBLIC ${DPSIMPY_INCLUDE_DIRS})
add_dependencies(pybind dpsimpy)
23 changes: 12 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shlex
import sys
import platform
import subprocess
Expand Down Expand Up @@ -43,19 +44,19 @@ def build_extension(self, ext):

env = os.environ.copy()
if env.get('CMAKE_OPTS'):
cmake_args += env.get('CMAKE_OPTS').split(' ')
cmake_args += shlex.split(env.get('CMAKE_OPTS'))

# CMakeLists.txt is in the same directory as this setup.py file
sourcedir = os.path.abspath(os.path.dirname(__file__))
print(' '.join(['cmake', sourcedir] + cmake_args))
subprocess.check_call(
['cmake', sourcedir] + cmake_args, cwd=self.build_temp, env=env
)

print(' '.join(['cmake', '--build', '.', '--target', 'dpsimpy'] + build_args))
subprocess.check_call(
['cmake', '--build', '.', '--target', 'dpsimpy'] + build_args, cwd=self.build_temp
)
source_dir = os.path.abspath(os.path.dirname(__file__))

cmake_cmd = ['cmake', source_dir] + cmake_args
build_cmd = ['cmake', '--build', '.', '--target', 'pybind'] + build_args

print(shlex.join(cmake_cmd))
subprocess.check_call(cmake_cmd, cwd=self.build_temp, env=env)

print(shlex.join(build_cmd))
subprocess.check_call(build_cmd, cwd=self.build_temp)


setup(
Expand Down
Loading