Skip to content

Commit 589e4ff

Browse files
Enhance CMake build system and add developer readme (#75)
* Create module directory in CMake build dir * Add 'make test' support to cmake * Add developers readme Co-authored-by: Andreas Gocht <andreas.gocht@tu-dresden.de>
1 parent fddb0ce commit 589e4ff

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ find_package(Python REQUIRED COMPONENTS Interpreter Development)
1313
Python_add_library(scorep_bindings src/scorep.cpp)
1414
target_link_libraries(scorep_bindings PRIVATE Scorep::Scorep)
1515
target_compile_features(scorep_bindings PRIVATE cxx_std_11)
16+
set_target_properties(scorep_bindings PROPERTIES
17+
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/site-packages/scorep
18+
)
19+
add_custom_target(ScorepModule ALL
20+
${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/scorep $<TARGET_FILE_DIR:scorep_bindings>
21+
COMMENT "Copying module files to build tree"
22+
)
23+
24+
enable_testing()
25+
add_test(NAME ScorepPythonTests
26+
COMMAND Python::Interpreter test.py
27+
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/test
28+
)
29+
set(pythonPath ${CMAKE_CURRENT_BINARY_DIR}/site-packages)
30+
if(ENV{PYTHONPATH})
31+
string(PREPEND pythonPath "$ENV{PYTHONPATH}:")
32+
endif()
33+
set_tests_properties(ScorepPythonTests PROPERTIES ENVIRONMENT "PYTHONPATH=${pythonPath}")
1634

1735
set(INSTALL_DIR "lib/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages")
1836

DEVELOPING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Developing
2+
We appreciate any contributions to the Score-P Python Bindings.
3+
However, there are a few policies we agreed on and which are relevant for contributions.
4+
These are detailed below.
5+
6+
## Formatting / Codestyle
7+
8+
Readable and consistent code makes it easy to understand your changes.
9+
Therefore the CI system has checks using `clang-format-9` and `flake8` in place.
10+
Please make sure that these test pass, when making a Pull Request.
11+
These tests will tell you the issues and often also how to fix them.
12+
Prior to opening a Pull Request you can use the provided `.flake8` and `.clang-format` files, to check your code locally and run `clang-format-9` or `autopep8` to fix most of them automatically.
13+
14+
## Build system
15+
16+
The official way to build and install this module is using `pip`.
17+
Please make sure that all changes, you introduce, work with `pip install .`.
18+
19+
However, you might have noticed that there is a CMake-based build system in place as well.
20+
We do not support this build system, and it might be outdated or buggy.
21+
Although, we do not actively maintain the CMake build system, and will not help you fix issues related to it, Pull Requests against it might be accepted.
22+
23+
You might find this build system helpful for development, especially if you are doing C/C++ things:
24+
* Include paths for C++ are correctly searched for and set up for use by IDEs or other tools. For example Visual Studio Code works out of the box, given the appropriate extensions (C++, Python, CMake) are installed.
25+
* A folder `site-packages` is created in the build folder where the C/C++ extension module and the scorep module are copied to on each build (e.g. `make`-call). Hence it is possible to add that folder to the PYTHONPATH environment variable, build the project and start debugging or execute the tests in test/test.py.
26+
* A `test` target exists which can be run to execute all tests.
27+
28+
Please note, that changes to the Python source files are not reflected in the build folder unless a build is executed.
29+
Also, if you delete Python files, we recommended to clear and recreate the build folder.

0 commit comments

Comments
 (0)