forked from ChazDazzle/pypoker-eval
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
114 lines (100 loc) · 5.52 KB
/
CMakeLists.txt
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
cmake_minimum_required(VERSION 3.10)
project(PyPokerEvalBinding)
# Détecter le système d'exploitation et l'architecture
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(EXISTS "$ENV{USERPROFILE}/AppData/Local/Programs/Python/Python311/python.exe")
set(Python3_EXECUTABLE "$ENV{USERPROFILE}/AppData/Local/Programs/Python/Python311/python.exe")
set(Python3_LIBRARY "$ENV{USERPROFILE}/AppData/Local/Programs/Python/Python311/libs/python311.lib")
set(Python3_INCLUDE_DIR "$ENV{USERPROFILE}/AppData/Local/Programs/Python/Python311/include")
elseif(EXISTS "$ENV{USERPROFILE}/Anaconda3/python.exe")
set(Python3_EXECUTABLE "$ENV{USERPROFILE}/Anaconda3/python.exe")
set(Python3_LIBRARY "$ENV{USERPROFILE}/Anaconda3/libs/python311.lib")
set(Python3_INCLUDE_DIR "$ENV{USERPROFILE}/Anaconda3/include")
else()
set(Python3_EXECUTABLE "C:/hostedtoolcache/windows/Python/3.11.9/x64/python.exe")
set(Python3_LIBRARY "C:/hostedtoolcache/windows/Python/3.11.9/x64/libs/python311.lib")
set(Python3_INCLUDE_DIR "C:/hostedtoolcache/windows/Python/3.11.9/x64/include")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(EXISTS "/usr/local/opt/[email protected]/libexec/bin/python3")
set(Python3_EXECUTABLE "/usr/local/opt/[email protected]/libexec/bin/python3")
set(Python3_LIBRARY "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib")
set(Python3_INCLUDE_DIR "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.11/include/python3.11")
elseif(EXISTS "$ENV{HOME}/anaconda3/bin/python3")
set(Python3_EXECUTABLE "$ENV{HOME}/anaconda3/bin/python3")
set(Python3_LIBRARY "$ENV{HOME}/anaconda3/lib/libpython3.11.dylib")
set(Python3_INCLUDE_DIR "$ENV{HOME}/anaconda3/include/python3.11")
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
if(EXISTS "/usr/bin/python3.11")
set(Python3_EXECUTABLE "/usr/bin/python3.11")
set(Python3_LIBRARY "/usr/lib/aarch64-linux-gnu/libpython3.11.so")
set(Python3_INCLUDE_DIR "/usr/include/python3.11")
elseif(EXISTS "$ENV{HOME}/anaconda3/bin/python3")
set(Python3_EXECUTABLE "$ENV{HOME}/anaconda3/bin/python3")
set(Python3_LIBRARY "$ENV{HOME}/anaconda3/lib/libpython3.11.so")
set(Python3_INCLUDE_DIR "$ENV{HOME}/anaconda3/include/python3.11")
endif()
else()
if(EXISTS "/usr/bin/python3.11")
set(Python3_EXECUTABLE "/usr/bin/python3.11")
set(Python3_LIBRARY "/usr/lib/x86_64-linux-gnu/libpython3.11.so")
set(Python3_INCLUDE_DIR "/usr/include/python3.11")
elseif(EXISTS "$ENV{HOME}/anaconda3/bin/python3")
set(Python3_EXECUTABLE "$ENV{HOME}/anaconda3/bin/python3")
set(Python3_LIBRARY "$ENV{HOME}/anaconda3/lib/libpython3.11.so")
set(Python3_INCLUDE_DIR "$ENV{HOME}/anaconda3/include/python3.11")
endif()
endif()
endif()
# Trouver Python 3.x
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
if(Python3_FOUND)
message(STATUS "Python 3.x trouvé : Version ${Python3_VERSION}")
message(STATUS "Python Interpreter : ${Python3_EXECUTABLE}")
message(STATUS "Python Libraries : ${Python3_LIBRARIES}")
message(STATUS "Python Include Dirs : ${Python3_INCLUDE_DIRS}")
include_directories(${Python3_INCLUDE_DIRS})
# Configurer les chemins pour poker-eval
set(POKER_EVAL_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/poker-eval/include")
include_directories(${POKER_EVAL_INCLUDE_DIR})
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(POKER_EVAL_LIB_PATH "${CMAKE_SOURCE_DIR}/poker-eval/build/Debug/poker_lib_static.lib")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(POKER_EVAL_LIB_PATH "${CMAKE_SOURCE_DIR}/poker-eval/build/libpoker_lib_static.a")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(POKER_EVAL_LIB_PATH "${CMAKE_SOURCE_DIR}/poker-eval/build/libpoker_lib_static.a")
endif()
# Vérifier l'existence de la bibliothèque poker-eval
if(NOT EXISTS ${POKER_EVAL_LIB_PATH})
message(FATAL_ERROR "La bibliothèque poker-eval n'a pas été trouvée à ${POKER_EVAL_LIB_PATH}. Assurez-vous de la construire d'abord.")
endif()
# Ajouter la cible pour pypokereval
add_library(pypokereval MODULE pypokereval.c)
target_link_libraries(pypokereval ${Python3_LIBRARIES} ${POKER_EVAL_LIB_PATH})
# Configurer les propriétés de la cible
set_target_properties(pypokereval PROPERTIES
PREFIX ""
SUFFIX ".so"
)
# Définir le nom de sortie en fonction du système d'exploitation
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set_target_properties(pypokereval PROPERTIES SUFFIX ".pyd")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_target_properties(pypokereval PROPERTIES SUFFIX ".so")
endif()
# Afficher des informations de débogage
message(STATUS "POKER_EVAL_INCLUDE_DIR: ${POKER_EVAL_INCLUDE_DIR}")
message(STATUS "POKER_EVAL_LIB_PATH: ${POKER_EVAL_LIB_PATH}")
# Configurer les flags de compilation
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_compile_options(pypokereval PRIVATE -fPIC)
endif()
# Définir les options de débogage si nécessaire
if(CMAKE_BUILD_TYPE MATCHES Debug)
target_compile_definitions(pypokereval PRIVATE DEBUG=1)
endif()
else()
message(FATAL_ERROR "Python 3.x n'a pas été trouvé. Le binding Python ne peut pas être construit.")
endif()