build: streamline CMAKE_MODULE_PATH interaction
This commit is contained in:
parent
ccccf26f59
commit
fd279f0e38
4 changed files with 38 additions and 16 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,6 +1,6 @@
|
|||
# lsp keeps state here
|
||||
.cache
|
||||
# typical build directory
|
||||
build
|
||||
.build*
|
||||
# lsp: symlink to file in build directory (established manually)
|
||||
compile_commands.json
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ cmake_minimum_required(VERSION 3.10)
|
|||
project(xo_pyreflect VERSION 0.1)
|
||||
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
|
||||
|
|
|
|||
36
README.md
36
README.md
|
|
@ -1,4 +1,4 @@
|
|||
# python bindings for c++ reflection library (xo-reflect)
|
||||
# python bindings for c++ reflection library (xo-pyreflect)
|
||||
|
||||
## Getting Started
|
||||
|
||||
|
|
@ -22,6 +22,22 @@ $ make install
|
|||
```
|
||||
(also see .github/workflows/main.yml)
|
||||
|
||||
## Examples
|
||||
|
||||
Assumes `xo-pyreflect` installed to `~/local2/lib`
|
||||
|
||||
```
|
||||
PYTHONPATH=~/local2/lib python
|
||||
>>> import xo_pyreflect
|
||||
>>> dir(xo_pyreflect)
|
||||
['SelfTagging', 'TaggedRcptr', 'TypeDescr', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']
|
||||
>>> xo_pyreflect.TypeDescr.print_reflected_types()
|
||||
<type_table_v[0]:>
|
||||
```
|
||||
(Not _immediately_ interesting: no reflected types in `pyreflect` itself)
|
||||
|
||||
## Development
|
||||
|
||||
### build for unit test coverage
|
||||
```
|
||||
$ cd xo-pyreflect
|
||||
|
|
@ -37,24 +53,20 @@ $ cmake \
|
|||
### LSP (language server) support
|
||||
|
||||
LSP looks for compile commands in the root of the source tree;
|
||||
while Cmake creates them in the root of its build directory.
|
||||
while `cmake` creates them in the root of its build directory.
|
||||
|
||||
```
|
||||
$ cd xo-pyreflect
|
||||
$ ln -s build/compile_commands.json # supply compile commands to LSP
|
||||
```
|
||||
|
||||
## Examples
|
||||
### display cmake variables
|
||||
|
||||
Assumes `xo-pyreflect` installed to `~/local2/lib`
|
||||
- `-L` list variables
|
||||
- `-A` include 'advanced' variables
|
||||
- `-H` include help text
|
||||
|
||||
```
|
||||
PYTHONPATH=~/local2/lib python
|
||||
>>> import pyreflect
|
||||
>>> dir(pyreflect)
|
||||
['SelfTagging', 'TaggedRcptr', 'TypeDescr', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__']
|
||||
>>> pyreflect.TypeDescr.print_reflected_types()
|
||||
<type_table_v[0]:>
|
||||
$ cd xo-pyprintjson/build
|
||||
$ cmake -LAH
|
||||
```
|
||||
|
||||
Not _immediately_ interesting: no reflected types in `pyreflect` itself
|
||||
|
|
|
|||
12
cmake/xo-bootstrap-macros.cmake
Normal file
12
cmake/xo-bootstrap-macros.cmake
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue