-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
84 lines (64 loc) · 2.06 KB
/
CMakeLists.txt
File metadata and controls
84 lines (64 loc) · 2.06 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Specify the minimum version of CMake required
cmake_minimum_required(VERSION 3.27)
set(PROJECT_NAME "nadi_python_node_wrapper")
# Set C++ standard to C++23
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) # Disable compiler-specific extensions
include(FetchContent)
if(NOT TARGET nlohmann_json::nlohmann_json)
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz)
set(JSON_BuildTests OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(json)
endif()
if(NOT TARGET nadicpp::nadicpp)
add_subdirectory(nadicpp)
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.11.1 # pin a known-good release
)
FetchContent_MakeAvailable(pybind11)
if(NOT TARGET pybind11_json)
add_subdirectory(pybind11_json)
endif()
# get latest git tag
execute_process(
COMMAND git describe --tags --abbrev=0
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Fallback if no git tag exists
if (NOT GIT_VERSION)
set(GIT_VERSION "0.0.0") # standard version
endif()
# Set the version in the project
message(STATUS "Project version: ${GIT_VERSION}")
add_definitions(-DPROJECT_VERSION="${GIT_VERSION}")
project(${PROJECT_NAME} VERSION 0.0.1)
# Define the DLL target
add_library(${PROJECT_NAME} SHARED
src/main.cpp
)
# Platform-specific settings
if(WIN32)
# On Windows, ensure DLL exports symbols correctly
set_target_properties(${PROJECT_NAME} PROPERTIES
WINDOWS_EXPORT_ALL_SYMBOLS OFF # We control exports manually
)
endif()
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(${PROJECT_NAME} PRIVATE
nlohmann_json::nlohmann_json
nadi::nadi
nadicpp::nadicpp
pybind11::embed
Python3::Python
pybind11_json)