-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
65 lines (51 loc) · 2.18 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
cmake_minimum_required(VERSION 3.0)
project(pypokerstove VERSION 0.0.0)
# Boost
find_package(Boost)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
# SWIG
find_package(SWIG REQUIRED)
include(${SWIG_USE_FILE})
set(CMAKE_SWIG_FLAGS "")
# python
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_PATH})
include_directories(pokerstove/src/lib/pokerstove/peval)
# SET(CMAKE_SWIG_FLAGS "-fPIC")
# add_definitions ("-std=c++0x")
set_source_files_properties(${PROJECT_NAME}.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties(${swig_generated_file_filename}
PROPERTIES COMPILE_FLAGS "-fPIC")
# set(CMAKE_SWIG_OUTDIR ${PROJECT_NAME})
link_directories(pokerstove/build/lib/pokerstove/peval)
find_library(libpeval REQUIRED)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_NAME})
set(CMAKE_SWIG_OUTDIR ${PROJECT_NAME})
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.8)
swig_add_library(${PROJECT_NAME}
LANGUAGE python
SOURCES ${PROJECT_NAME}.i)
else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.8)
swig_add_module(${PROJECT_NAME} PYTHON ${PROJECT_NAME}.i)
endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.8)
swig_link_libraries(${PROJECT_NAME} peval ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
# install bindings
find_program(PYTHON "python")
if (PYTHON)
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
set(INIT_PY "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py")
set(OUT_INIT_PY "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/__init__.py")
set(DEPS "${INIT_PY}")
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/timestamp")
configure_file(${SETUP_PY_IN} ${SETUP_PY})
configure_file(${INIT_PY} ${OUT_INIT_PY} COPYONLY)
add_custom_command(OUTPUT ${OUTPUT}
# COMMAND ${PYTHON} ${SETUP_PY} build
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
DEPENDS ${DEPS})
message(${DEPS})
add_custom_target(target ALL DEPENDS ${OUTPUT})
# install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)")
endif()