-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
45 lines (33 loc) · 1.31 KB
/
CMakeLists.txt
File metadata and controls
45 lines (33 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
cmake_minimum_required(VERSION 3.26)
function(split_version str MAJOR MINOR PATCH)
# Parse the string directly into the names provided by the arguments
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" _ ${str})
set(${MAJOR} ${CMAKE_MATCH_1})
set(${MINOR} ${CMAKE_MATCH_2})
set(${PATCH} ${CMAKE_MATCH_3})
return(PROPAGATE ${MAJOR} ${MINOR} ${PATCH})
endfunction()
if(DEFINED SKBUILD_PROJECT_VERSION)
set(HELLO_CPP_VERSION ${SKBUILD_PROJECT_VERSION})
else()
set(HELLO_CPP_VERSION "0.9.0")
endif()
split_version(${HELLO_CPP_VERSION}
HELLO_CPP_VERSION_MAJOR
HELLO_CPP_VERSION_MINOR
HELLO_CPP_VERSION_PATCH)
project(hello_cpp VERSION ${HELLO_CPP_VERSION} LANGUAGES CXX)
message(STATUS "HELLO_CPP_VERSION_MAJOR: ${HELLO_CPP_VERSION_MAJOR}")
message(STATUS "HELLO_CPP_VERSION_MINOR: ${HELLO_CPP_VERSION_MINOR}")
message(STATUS "HELLO_CPP_VERSION_PATCH: ${HELLO_CPP_VERSION_PATCH}")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(pybind11 CONFIG REQUIRED)
pybind11_add_module(hello_cpp src/hello.cpp)
target_compile_definitions(hello_cpp PUBLIC HELLO_CPP_VERSION="${HELLO_CPP_VERSION}")
install(
TARGETS hello_cpp
LIBRARY DESTINATION ${SKBUILD_PLATLIB_DIR}
RUNTIME DESTINATION ${SKBUILD_PLATLIB_DIR}
ARCHIVE DESTINATION ${SKBUILD_PLATLIB_DIR}
)