Skip to content

Commit

Permalink
Python: tighten up CMake configuration in attempt to get working cond…
Browse files Browse the repository at this point in the history
…a builds for Linux, macOS, and Windows
  • Loading branch information
selimnairb committed Sep 6, 2023
1 parent 55fa007 commit 5c242dd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# CMake 3.15+ needed for SWIG version 4.0+ support.
cmake_minimum_required(VERSION 3.15)
# CMake 3.15+ needed for SWIG version 4.0+ support. 3.18+ needed for Development.Module
# sub-component support for FindPyton.
cmake_minimum_required(VERSION 3.18)
project(OpenNavSurf-BAG LANGUAGES C CXX VERSION 2.0.1)
set(CMAKE_CXX_STANDARD 14)

Expand Down
13 changes: 6 additions & 7 deletions api/swig/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ cmake_policy(SET CMP0086 NEW)

if(Python_LOOKUP_VERSION)
set(Python_FIND_STRATEGY VERSION)
find_package(Python ${Python_LOOKUP_VERSION} COMPONENTS Interpreter Development)
find_package(Python3 ${Python_LOOKUP_VERSION} COMPONENTS Interpreter Development.Module)
else()
set(Python_FIND_STRATEGY LOCATION)
find_package(Python3 COMPONENTS Interpreter Development)
set(Python_LIBRARIES Python3::Python)
find_package(Python3 COMPONENTS Interpreter Development.Module)
endif()

# Handle where to install the resulting Python package
Expand All @@ -23,8 +22,8 @@ else()
set(BAGPY_INSTALL_PREFIX ${Python3_SITELIB})
endif()

if(DEFINED Python_INCLUDE_DIRS)
include_directories("${CMAKE_SOURCE_DIR}/api" "${Python_INCLUDE_DIRS}")
if(DEFINED Python3_INCLUDE_DIRS)
include_directories("${CMAKE_SOURCE_DIR}/api" "${Python3_INCLUDE_DIRS}")
else()
include_directories("${CMAKE_SOURCE_DIR}/api")
endif()
Expand Down Expand Up @@ -52,8 +51,8 @@ set_target_properties(bagPy
)

target_link_libraries(bagPy
${Python_LIBRARIES}
baglib
PRIVATE baglib
PRIVATE Python3::Module
)

if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
Expand Down
6 changes: 3 additions & 3 deletions docs/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This will generate an HTML coverage report in `build/ccov/all-merged/index.html`
#### Build Python wheel
After building the C++ library in the `build` directory as above,
you will be able to build a Python wheel as follows:
you will be able to build a Python wheel for installing `bagPy` as follows:
```shell
$ python -m pip wheel -w ./wheel/ ./build/api/swig/python
```
Expand Down Expand Up @@ -170,8 +170,8 @@ cmake --install build
```

#### Build Python wheels:
After building the C++ code, you can build a Python wheel of the `bagPy`
bindings as follows:
After building the C++ library in the `build` directory as above,
you will be able to build a Python wheel for installing `bagPy` as follows:
```
python -m pip wheel -w .\wheel\ .\build\api\swig\python
```
Expand Down

0 comments on commit 5c242dd

Please sign in to comment.