Skip to content

Commit c659941

Browse files
author
peng.li24
committed
Auto-detect version from pip shapely (1.8.4); fail if shapely not installed
1 parent f89226c commit c659941

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
cmake_minimum_required(VERSION 3.16)
2-
project(shapelycpp VERSION 0.1.0 LANGUAGES CXX)
2+
3+
# -- Auto-detect version from pip's shapely -----------------------------------
4+
execute_process(
5+
COMMAND python3 -c "import shapely; print(shapely.__version__)"
6+
OUTPUT_VARIABLE SHAPELY_PIP_VERSION
7+
OUTPUT_STRIP_TRAILING_WHITESPACE
8+
ERROR_QUIET
9+
RESULT_VARIABLE _pip_rc
10+
)
11+
if(NOT _pip_rc EQUAL 0 OR SHAPELY_PIP_VERSION STREQUAL "")
12+
message(FATAL_ERROR "Cannot detect shapely version from pip. Install shapely first: pip install shapely")
13+
endif()
14+
15+
project(shapelycpp VERSION ${SHAPELY_PIP_VERSION} LANGUAGES CXX)
316

417
# C++17
518
set(CMAKE_CXX_STANDARD 17)

0 commit comments

Comments
 (0)