build: streamline CMAKE_MODULE_PATH interaction + README.md xpand

This commit is contained in:
Roland Conybeare 2024-03-15 19:33:37 -04:00
commit a96142ffea
6 changed files with 30 additions and 32 deletions

9
.gitignore vendored
View file

@ -1,7 +1,6 @@
# lsp keep state here
# clangd working space (see emacs+lsp)
.cache
# typical build directories
build
ccov
# for lsp: manual symlink to chosen build directory
# typical cmake build directory (source-tree-nephew)
.build*
# symlink to builddir/compile_commands.json; should be set manually in dev sandbox
compile_commands.json

View file

@ -6,8 +6,7 @@ project(xo_pyprintjson VERSION 1.0)
enable_language(CXX)
# common XO cmake macros (see github.com:Rconybea/xo-cmake)
include(xo_macros/xo_cxx)
include(xo_macros/code-coverage)
include(cmake/xo-bootstrap-macros.cmake)
# ----------------------------------------------------------------
# unit test setup

View file

@ -23,6 +23,18 @@ $ make install
```
(also see .github/workflows/main.yml)
## Examples
```
PYTHONPATH=~/local2/lib:$PYTHONPATH python
>>> import xo_pyprintjson
>>> dir(xo_pyprintjson)
['PrintJson', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']
>>> dir(xo_pyprintjson.PrintJson)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'instance', 'print']
>>>
```
## Development
### build for unit test coverage

View file

@ -0,0 +1,12 @@
if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix"))
# default to typical install location for xo-project-macros
set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake)
endif()
message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
# needs to have been installed somewhere on CMAKE_MODULE_PATH,
# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX)
#
include(xo_macros/xo-project-macros)

1
include/README.md Normal file
View file

@ -0,0 +1 @@
placeholder for future pyprintjson #include files

View file

@ -1,25 +0,0 @@
/* @file pyprintjson.hpp
*
* automatically generated from src/pyprintjson/pyprintjson.hpp.in
* see src/pyprintjson/CMakeLists.txt
*/
/* python requires module name = library name
* example:
* PYBIND11_MODULE(PYPRINTJSON_MODULE_NAME(), m) { ... }
*/
#define PYPRINTJSON_MODULE_NAME() pyprintjson
/* example:
* py::module_::import(PYPRINTJSON_MODULE_NAME_STR)
*/
#define PYPRINTJSON_MODULE_NAME_STR "pyprintjson"
/* example:
* PYPRINTJSON_IMPORT_MODULE()
* replaces
* py::module_::import("pyprintjson")
*/
#define PYPRINTJSON_IMPORT_MODULE() py::module_::import("pyprintjson")
/* end pyprintjson.hpp */